Initial import
This commit is contained in:
71
application/controllers/tools/Fix_resample.php
Normal file
71
application/controllers/tools/Fix_resample.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
class Fix_resample extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
function check($date = "") {
|
||||
if ($date == "" ) $date = date("Y-m-d");
|
||||
$sql = "select T_OrderHeaderLabNumber, T_TestName, T_OrderHeaderID,
|
||||
T_TestT_SampleTypeID, group_concat(T_OrderDetailAddOnID) xids
|
||||
from t_orderdetail
|
||||
join t_orderheader on T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
and date(T_OrderHeaderDate) = ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join t_orderdetailaddon on T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
where T_OrderDetailAddOnReSample = 'Y'
|
||||
and T_OrderDetailAddOnReSampleStatus = 'R'
|
||||
group by T_OrderHeaderID,T_TestT_SampleTypeID";
|
||||
$qry = $this->db_onedev->query($sql, array($date) );
|
||||
if (!$qry) {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$sql = "select T_OrderSampleBarcode, T_OrderSampleSampling
|
||||
from t_ordersample
|
||||
where T_OrderSampleT_OrderHeaderID = ? and T_OrderSampleT_SampleTypeID = ?
|
||||
and T_OrderSampleIsActive = 'Y'";
|
||||
foreach($rows as $r ) {
|
||||
//check if all already sampling
|
||||
echo $r["T_OrderHeaderLabNumber"] . ", " . $r["T_TestName"] . " :\n";
|
||||
$headerID = $r["T_OrderHeaderID"];
|
||||
$sampleID = $r["T_TestT_SampleTypeID"];
|
||||
$addonIDS = $r["xids"];
|
||||
$qry = $this->db->query($sql, array($headerID,$sampleID));
|
||||
|
||||
if ($qry) {
|
||||
$d_rows = $qry->result_array();
|
||||
$all_is_sampling = true;
|
||||
foreach($d_rows as $d_r) {
|
||||
echo $d_r["T_OrderSampleBarcode"] . " is sampling " . $d_r["T_OrderSampleSampling"] . "\n";
|
||||
if ($d_r["T_OrderSampleSampling"] == "N" ) $all_is_sampling = false;
|
||||
}
|
||||
echo "All : $all_is_sampling\n ";
|
||||
if ($all_is_sampling ) {
|
||||
echo "ids : $addonIDS \n";
|
||||
if ($addonIDS != "" ) {
|
||||
$sql_u = "update t_orderdetailaddon set T_OrderDetailAddOnReSampleStatus = 'W'
|
||||
where T_OrderDetailAddOnID in ($addonIDS ) ";
|
||||
$this->db->query($sql_u);
|
||||
echo "Fixed Resample\n";
|
||||
}
|
||||
} else {
|
||||
echo "Belum semua barcode di sampling\n";
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user