'N' AND T_RefDeliveryOrderDetailIsConfirm = 'N' AND T_RefDeliveryOrderDetailIsActive = 'Y' JOIN t_orderheader ON T_OrderHeaderID = T_RefDeliveryOrderDetailT_OrderHeaderID JOIN t_test ON T_TestID = T_RefDeliveryOrderDetailT_TestID JOIN t_worklist_ref_confirmdetail ON T_WorklistRefConfirmDetailID = T_RefDeliveryOrderDetailT_WorklistRefConfirmDetailID AND T_WorklistRefConfirmDetailIsDeliveryOrder <> 'X' AND T_WorklistRefConfirmDetailIsActive = 'Y' JOIN t_worklist ON T_WorklistID = T_WorklistRefConfirmDetailT_WorklistID WHERE T_RefDeliveryOrderCreated > '2024-12-01'"; $qry = $this->db->query($sql); $rows = $qry->result_array(); if (count($rows) == 0) { $result = array( "total" => count($rows) , "message" => "No Data" ); } else { foreach ($rows as $k => $v) { $sql = "UPDATE t_worklist_ref_confirmdetail SET T_WorklistRefConfirmDetailIsDeliveryOrder = 'X' WHERE T_WorklistRefConfirmDetailID = {$v["T_WorklistRefConfirmDetailID"]}"; $qry = $this->db->query($sql); if (!$qry) { $this->sys_error_db("Error update t_worklist_ref_confirmdetail"); exit; } } $result = array( "total" => count($rows) , "message" => "Data Fix" ); } $this->sys_ok($result); exit; } }