102 lines
4.0 KiB
PHP
102 lines
4.0 KiB
PHP
<?php
|
|
class Fixreffbarcode extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Fix Reff Barcode API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
public function fix($labno = "")
|
|
{
|
|
if ($labno == "") {
|
|
$sql = "SELECT
|
|
T_RefDeliveryOrderID,
|
|
T_RefDeliveryOrderDetailT_WorklistRefConfirmDetailID,
|
|
T_RefDeliveryOrderDate,
|
|
T_RefDeliveryOrderDetailID,
|
|
T_RefDeliveryOrderDetailT_OrderHeaderID,
|
|
T_RefDeliveryOrderDetailT_OrderDetailID,
|
|
T_RefDeliveryOrderDetailT_TestID,
|
|
T_RefDeliveryOrderDetailT_BarcodeLabBarcode,
|
|
T_BarcodeLabBarcode
|
|
|
|
FROM
|
|
t_ref_deliveryorder_detail
|
|
JOIN t_ref_deliveryorder ON T_RefDeliveryOrderID = T_RefDeliveryOrderDetailT_RefDeliveryOrderID AND T_RefDeliveryOrderIsActive = 'Y' AND T_RefDeliveryOrderIsConfirm = 'N'
|
|
JOIN t_test ON T_TestID = T_RefDeliveryOrderDetailT_TestID
|
|
JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_RefDeliveryOrderDetailT_OrderHeaderID
|
|
AND T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID
|
|
AND T_BarcodeLabIsActive = 'Y'
|
|
WHERE T_RefDeliveryOrderDetailIsActive = 'Y' AND
|
|
T_RefDeliveryOrderDetailT_BarcodeLabBarcode <> T_BarcodeLabBarcode";
|
|
|
|
$qry = $this->db_onedev->query($sql);
|
|
|
|
|
|
if (!$qry) {
|
|
$this->resp["message"] = "Err select barcode | " . $this->db_onedev->error()["message"] . "|"
|
|
. $this->db_onedev->last_query();
|
|
}
|
|
$rows = $qry->result_array();
|
|
|
|
}else{
|
|
$sql = "SELECT
|
|
T_RefDeliveryOrderID,
|
|
T_RefDeliveryOrderDetailT_WorklistRefConfirmDetailID,
|
|
T_RefDeliveryOrderDate,
|
|
T_RefDeliveryOrderDetailID,
|
|
T_RefDeliveryOrderDetailT_OrderHeaderID,
|
|
T_RefDeliveryOrderDetailT_OrderDetailID,
|
|
T_RefDeliveryOrderDetailT_TestID,
|
|
T_RefDeliveryOrderDetailT_BarcodeLabBarcode,
|
|
T_BarcodeLabBarcode
|
|
|
|
FROM t_orderheader
|
|
JOIN t_ref_deliveryorder_detail ON T_RefDeliveryOrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_RefDeliveryOrderDetailIsActive = 'Y'
|
|
JOIN t_ref_deliveryorder ON T_RefDeliveryOrderID = T_RefDeliveryOrderDetailT_RefDeliveryOrderID AND T_RefDeliveryOrderIsActive = 'Y' AND T_RefDeliveryOrderIsConfirm = 'N'
|
|
JOIN t_test ON T_TestID = T_RefDeliveryOrderDetailT_TestID
|
|
JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_RefDeliveryOrderDetailT_OrderHeaderID
|
|
AND T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID
|
|
AND T_BarcodeLabIsActive = 'Y'
|
|
WHERE (T_OrderHeaderLabNumber = '{$labno}' OR T_OrderHeaderLabNumberExt = '{$labno}') AND
|
|
T_RefDeliveryOrderDetailT_BarcodeLabBarcode <> T_BarcodeLabBarcode";
|
|
|
|
$qry = $this->db_onedev->query($sql);
|
|
|
|
|
|
if (!$qry) {
|
|
$this->resp["message"] = "Err select barcode | " . $this->db_onedev->error()["message"] . "|"
|
|
. $this->db_onedev->last_query();
|
|
}
|
|
$rows = $qry->result_array();
|
|
|
|
}
|
|
|
|
if (count($rows) == 0) {
|
|
$result = array("records" => "Tidak ada data","total" => 0);
|
|
$this->sys_ok($result);
|
|
}else{
|
|
$result = [];
|
|
foreach ($rows as $k => $v) {
|
|
$sql = "UPDATE t_ref_deliveryorder_detail
|
|
SET T_RefDeliveryOrderDetailT_BarcodeLabBarcode = '{$v['T_BarcodeLabBarcode']}'
|
|
WHERE T_RefDeliveryOrderDetailID = {$v['T_RefDeliveryOrderDetailID']}";
|
|
$qry = $this->db_onedev->query($sql);
|
|
|
|
$sql = "UPDATE t_worklist_ref_confirmdetail
|
|
SET T_WorklistRefConfirmDetailT_BarcodeLabBarcode = '{$v['T_BarcodeLabBarcode']}'
|
|
WHERE T_WorklistRefConfirmDetailID = {$v['T_RefDeliveryOrderDetailT_WorklistRefConfirmDetailID']}";
|
|
$qry = $this->db_onedev->query($sql);
|
|
}
|
|
$result = array("records" => $rows,"total" => count($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
}
|
|
|
|
} |