db_onedev = $this->load->database("onedev", true); $this->load->helper(array('form', 'url')); } public function search() { $prm = $this->sys_input; if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $name = $prm["name"]; $nolab = $prm["nolab"]; $branchid = $prm["branchid"]; $typeid = $prm["typeid"]; $filter_branch = ''; if(intval($branchid) > 0) $filter_branch = " AND M_BranchID = {$branchid}"; $sql = "SELECT tx_mou.*, TxMouID as id, 'Mou Verifikasi' as tipe, M_BranchName as branchname, CONCAT(DATE_FORMAT(M_MouStartDate,'%d-%m-%Y'),' - ', DATE_FORMAT(M_MouEndDate,'%d-%m-%Y')) as moudate, M_MouID as mouid, M_MouName as mouname, T_TestName as testname, IF(TxMouStatus = 'N','Pending','Terkirim') as status, TxMouRetry as pengulangan, '' as staffname 'N' as chex FROM tx_mou JOIN t_branch ON TxMouM_BranchCode = M_BranchCode $filter_branch WHERE TxMouT_TestID = 0 $filter_search GROUP BY TxMouID UNION SELECT tx_mou.*, TxMouID as id, 'Mou Verifikasi' as tipe, M_BranchName as branchname, CONCAT(DATE_FORMAT(M_MouStartDate,'%d-%m-%Y'),' - ', DATE_FORMAT(M_MouEndDate,'%d-%m-%Y')) as moudate, M_MouID as mouid, M_MouName as mouname, T_TestName as testname, IF(TxMouStatus = 'N','Pending','Terkirim') as status, TxMouRetry as pengulangan, '' as staffname 'N' as chex FROM tx_mou JOIN t_branch ON TxMouM_BranchCode = M_BranchCode $filter_branch WHERE TxMouT_TestID > 0 $filter_search GROUP BY TxMouID ORDER BY TxMouID ASC "; //echo $sql; $query = $this->db_onedev->query($sql); //echo $this->db_onedev->last_query(); $rows = $query->result_array(); if($rows){ foreach($rows as $k => $v){ if($v['chex'] == 'N'){ $rows[$k]['chex'] = false; }else{ $rows[$k]['chex'] = true; } } } //$this->_add_address($rows); $result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_onedev->last_query()); $this->sys_ok($result); exit; } function getstationstatus(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $rows = []; $rows['types'] = array(array('id'=>0,'name'=>'Semua'),array('id'=>1,'name'=>'Mou Verifikasi'),array('id'=>2,'name'=>'Edit Price')); $sql = "SELECT M_BranchID as id, M_BranchName as name FROM m_branch WHERE M_BranchIsActive = 'Y' GROUP BY M_BranchID"; $rows['branchs'] = $this->db_onedev->query($sql)->result_array(); array_push($rows['branchs'],array('id'=> 0,'name'=> 'Semua')); $result = array( "total" => count($rows) , "records" => $rows, ); $this->sys_ok($result); exit; } function doaction(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $userid = $this->sys_user["M_UserID"]; $samples = $prm['sample']; if($prm['act'] == 'send'){ foreach($samples as $k=>$v){ $sql = "UPDATE t_ordersample SET T_OrderSampleSendHandling = 'Y', T_OrderSampleSendHandlingDate = CURDATE(), T_OrderSampleSendHandlingTime = CURTIME(), T_OrderSampleSendHandlingUserID = {$userid}, T_OrderSampleUserID = {$userid} WHERE T_OrderSampleID = {$v['T_OrderSampleID']}"; $this->db_onedev->query($sql); $sql = "INSERT INTO sample_by_step( SampleByStepM_StatusSampleCode, SampleByStepT_OrderHeaderID, SampleByStepT_BarcodeLabID, SampleByStepRequirementStatus, SampleByStepRequirements, SampleByStepUserID, SampleByStepDateTime ) VALUES( 'SAMPLING.Verification.To.Handling', {$v['T_OrderHeaderID']}, {$v['T_BarcodeLabID']}, 'Y', '[]', {$userid}, NOW() )"; $this->db_onedev->query($sql); } } //sipe $this->broadcast("specimen-verification-send"); $result = array( "total" => 1 , "broadcast" => "specimen-verification-send", "records" => array('status'=>'OK') ); $this->sys_ok($result); exit; } }