db_onedev = $this->load->database("onedev", true); } function searchcompany(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $max_rst = 12; $tot_count =0; $q = [ 'search' => '%' ]; if ($prm['search'] != '') { $q['search'] = "%{$prm['search']}%"; } // QUERY TOTAL $sql = "SELECT count(*) as total FROM m_company WHERE M_CompanyName like ? AND M_CompanyIsActive = 'Y'"; $query = $this->db_onedev->query($sql,$q['search']); //echo $query; if ($query) { $tot_count = $query->result_array()[0]["total"]; } else { $this->sys_error_db("m_city count",$this->db_onedev); exit; } $sql = " SELECT M_CompanyID as id, M_CompanyName as name FROM m_company WHERE M_CompanyName like ? AND M_CompanyIsActive = 'Y' ORDER BY M_CompanyName DESC "; $query = $this->db_onedev->query($sql, array($q['search'])); if ($query) { $rows = $query->result_array(); //echo $this->db_onedev->last_query(); $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows)); $this->sys_ok($result); } else { $this->sys_error_db("m_company rows",$this->db_onedev); exit; } } function getsampletypes(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $orderid = $prm['orderid']; $stationid = $prm['stationid']; $statusid = $prm['statusid']; $sql = "SELECT T_OrderDetailID, T_OrderDetailT_TestCode, T_OrderDetailT_TestName, T_SampleTypeID, T_SampleTypeName, T_BahanName, IF(ISNULL(T_SamplingSoID),'N',T_SamplingSoFlag) as status, IF(ISNULL(T_SamplingSoID),DATE_FORMAT(CURDATE(),'%d-%m-%Y'),DATE_FORMAT(T_SamplingSoProcessDate,'%d-%m-%Y')) as process_date, IF(ISNULL(T_SamplingSoID),DATE_FORMAT(CURTIME(),'%H:%i'),DATE_FORMAT(T_SamplingSoProcessTime,'%H:%i')) as process_time, IF(ISNULL(T_SamplingSoID) OR T_SamplingSoFlag = 'P',DATE_FORMAT(CURDATE(),'%d-%m-%Y'),DATE_FORMAT(T_SamplingSoDoneDate,'%d-%m-%Y')) as done_date, IF(ISNULL(T_SamplingSoID) OR T_SamplingSoFlag = 'P',DATE_FORMAT(CURTIME(),'%H:%i'),DATE_FORMAT(T_SamplingSoDoneTime,'%H:%i')) as done_time FROM t_orderheader JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y' JOIN t_test ON T_OrderDetailT_TestID = T_TestID JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid} LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND T_SamplingSoIsActive = 'Y' WHERE T_OrderHeaderID = {$orderid} AND T_OrderHeaderIsActive = 'Y' GROUP BY T_SampleTypeID"; //echo $sql; $rows = $this->db_onedev->query($sql)->result_array(); $result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_onedev->last_query()); $this->sys_ok($result); exit; } public function search() { $prm = $this->sys_input; if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $filter_company_id = $prm["filter_company"]["id"]; // echo $norm; $sql_where = ""; if($filter_company_id != 0 || $filter_company_id != '0') $sql_where = " AND Mcu_AgreementCustomerM_CompanyID = {$filter_company_id}"; //$sql_param = array(); $sql = " SELECT COUNT(*) as total FROM mcu_agreement LEFT JOIN mcu_agreement_customer ON Mcu_AgreementCustomerMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_facility ON Mcu_AgreementFacilityMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_implementation ON Mcu_AgreementImplementationMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_marketing ON Mcu_AgreementMarketingMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_notes ON Mcu_AgreementNotesMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_price ON Mcu_AgreementPriceMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_scopework ON Mcu_AgreementScopeWorkMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_send_result ON Mcu_AgreementSendResultMcu_AgreementID = Mcu_AgreementID LEFT JOIN m_company ON Mcu_AgreementCustomerM_CompanyID = M_CompanyID LEFT JOIN m_mou ON Mcu_AgreementCustomerM_MouID = M_MouID WHERE Mcu_AgreementIsActive = 'Y' $sql_where "; //echo $sql; $query = $this->db_onedev->query($sql); $tot_count = 0; //$tot_page = 0; if ($query) { $tot_count = $query->result_array()[0]["total"]; //$tot_page = ceil($tot_count/$number_limit); } else { $this->sys_error_db("m_doctor count", $this->db_onedev); exit; } $sql = "SELECT Mcu_AgreementID as trx_id, DATE_FORMAT(Mcu_AgreementDate,'%d-%m-%Y') as trx_date, Mcu_AgreementNumbering as trx_numbering, mcu_agreement.*, mcu_agreement_customer.*, mcu_agreement_facility.*, mcu_agreement_implementation.*, mcu_agreement_marketing.*, mcu_agreement_notes.*, mcu_agreement_price.*, mcu_agreement_scopework.*, mcu_agreement_send_result.*, mcu_agreement_promise.*, M_CompanyName, M_MouName, Mcu_AgreementTypeName, '' as mou, time_format(Mcu_AgreementPromiseAtTime,'%H:%i') as promise_time FROM mcu_agreement LEFT JOIN mcu_agreement_customer ON Mcu_AgreementCustomerMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_facility ON Mcu_AgreementFacilityMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_implementation ON Mcu_AgreementImplementationMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_marketing ON Mcu_AgreementMarketingMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_notes ON Mcu_AgreementNotesMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_price ON Mcu_AgreementPriceMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_scopework ON Mcu_AgreementScopeWorkMcu_AgreementID = Mcu_AgreementID LEFT JOIN mcu_agreement_send_result ON Mcu_AgreementSendResultMcu_AgreementID = Mcu_AgreementID LEFT JOIN m_company ON Mcu_AgreementCustomerM_CompanyID = M_CompanyID LEFT JOIN m_mou ON Mcu_AgreementCustomerM_MouID = M_MouID LEFT JOIN mcu_agreementtype ON Mcu_AgreementScopeWorkMcu_AgreementTypeID = Mcu_AgreementTypeID LEFT JOIN mcu_agreement_promise ON Mcu_AgreementPromiseMcu_AgreementID = Mcu_AgreementID WHERE Mcu_AgreementIsActive = 'Y' $sql_where limit 0,20"; //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){ $companyid = $v['Mcu_AgreementCustomerM_CompanyID']; $query =" SELECT M_MouID as id, M_MouName as name FROM m_mou WHERE M_MouM_CompanyID = $companyid AND M_MouIsActive = 'Y' "; //echo $query; $rows[$k]['mou'] = $this->db_onedev->query($query)->result_array(); } } //$this->_add_address($rows); $result = array("total" => $tot_count, "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 = []; $query =" SELECT T_SampleStationID as id, T_SampleStationName as name FROM t_samplestation WHERE T_SampleStationIsActive = 'Y' "; //echo $query; $rows['stations'] = $this->db_onedev->query($query)->result_array(); $rows['statuses'] = array(array('id'=>0,'name'=>'New')); $query =" SELECT T_SamplingQueueStatusID as id, T_SamplingQueueStatusName as name FROM t_sampling_queue_status WHERE T_SamplingCallStatusIsActive = 'Y' "; //echo $query; $statuses = $this->db_onedev->query($query)->result_array(); //print_r($statuses); foreach($statuses as $k=>$v){ array_push($rows['statuses'],$v); } $result = array( "total" => count($rows) , "records" => $rows, ); $this->sys_ok($result); exit; } function getagreementtype(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $rows = []; $query =" SELECT Mcu_AgreementTypeID as id, Mcu_AgreementTypeName as name FROM mcu_agreementtype WHERE Mcu_AgreementTypeIsActive = 'Y' "; //echo $query; $rows = $this->db_onedev->query($query)->result_array(); $result = array( "total" => count($rows) , "records" => $rows, ); $this->sys_ok($result); exit; } function getmou(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $companyid = $prm['company']['id']; $query =" SELECT M_MouID as id, M_MouName as name FROM m_mou WHERE M_MouM_CompanyID = $companyid AND M_MouIsActive = 'Y' "; //echo $query; $rows = $this->db_onedev->query($query)->result_array(); $result = array( "total" => count($rows), "records" => $rows, ); $this->sys_ok($result); exit; } function saveagreement(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $userid = $this->sys_user["M_UserID"]; $header_id = $prm['trx_id']; $numbering = ''; if($header_id == '0' || $header_id == 0){ $numbering = $this->db_onedev->query("SELECT fn_numbering('AG') as numbering")->row()->numbering; $query = "INSERT INTO mcu_agreement( Mcu_AgreementNumbering, Mcu_AgreementDate, Mcu_AgreementCreatedBy, Mcu_AgreementUserID, Mcu_AgreementCreated ) VALUES( '{$numbering}', CURDATE(), '{$userid}', '{$userid}', NOW() )"; $r = $this->db_onedev->query($query); $header_id = $this->db_onedev->insert_id(); } else{ $numbering = $this->db_onedev->query("SELECT Mcu_AgreementNumbering as numbering FROM mcu_agreement WHERE Mcu_AgreementID = '{$header_id}'")->row()->numbering; } $query = "INSERT INTO mcu_agreement_customer( Mcu_AgreementCustomerMcu_AgreementID, Mcu_AgreementCustomerM_CompanyID, Mcu_AgreementCustomerM_MouID, Mcu_AgreementCustomerCpName, Mcu_AgreementCustomerCpHp, Mcu_AgreementCustomerCreated, Mcu_AgreementCustomerUserID ) VALUES( '{$header_id}', '{$prm['company']['id']}', '{$prm['mou']['id']}', '{$prm['company_cpname']}', '{$prm['company_cphp']}', CURDATE(), {$userid} ) ON DUPLICATE KEY UPDATE Mcu_AgreementCustomerM_CompanyID = '{$prm['company']['id']}', Mcu_AgreementCustomerM_MouID = '{$prm['mou']['id']}', Mcu_AgreementCustomerCpName = '{$prm['company_cpname']}', Mcu_AgreementCustomerCpHp = '{$prm['company_cphp']}', Mcu_AgreementCustomerUserID = {$userid}, Mcu_AgreementCustomerIsActive = 'Y' "; //echo $query; $xr = $this->db_onedev->query($query); //echo $this->db_onedev->last_query(); $query = "INSERT INTO mcu_agreement_scopework( Mcu_AgreementScopeWorkMcu_AgreementID, Mcu_AgreementScopeWorkMcu_AgreementTypeID, Mcu_AgreementScopeWorkParticipants, Mcu_AgreementScopeWorkResultTypeReport, Mcu_AgreementScopeWorkSpecialRequirements, Mcu_AgreementScopeWorkUserID, Mcu_AgreementScopeWorkCreated ) VALUES( '{$header_id}', '{$prm['agreement_type']['id']}', '{$prm['participants']}', '{$prm['resulttype_report']}', '{$prm['special_requirement']}', {$userid}, CURDATE() ) ON DUPLICATE KEY UPDATE Mcu_AgreementScopeWorkMcu_AgreementTypeID = '{$prm['agreement_type']['id']}', Mcu_AgreementScopeWorkParticipants = '{$prm['participants']}', Mcu_AgreementScopeWorkResultTypeReport = '{$prm['company_cpname']}', Mcu_AgreementScopeWorkSpecialRequirements = '{$prm['resulttype_report']}', Mcu_AgreementScopeWorkUserID = {$userid}, Mcu_AgreementScopeWorkIsActive = 'Y' "; $xs = $this->db_onedev->query($query); $query = "INSERT INTO mcu_agreement_implementation( Mcu_AgreementImplementationMcu_AgreementID, Mcu_AgreementImplementationDate, Mcu_AgreementImplementationTime, Mcu_AgreementImplementationPlace, Mcu_AgreementImplementationSetupInstumentTime, Mcu_AgreementImplementationUserID, Mcu_AgreementImplementationCreated ) VALUES( '{$header_id}', '{$prm['implementation_date']}', '{$prm['implementation_time']}', '{$prm['implementation_place']}', '{$prm['setupinstrument_time']}', {$userid}, CURDATE() ) ON DUPLICATE KEY UPDATE Mcu_AgreementImplementationDate = '{$prm['implementation_date']}', Mcu_AgreementImplementationTime = '{$prm['implementation_time']}', Mcu_AgreementImplementationPlace = '{$prm['implementation_place']}', Mcu_AgreementImplementationSetupInstumentTime = '{$prm['setupinstrument_time']}', Mcu_AgreementImplementationUserID = {$userid}, Mcu_AgreementImplementationIsActive = 'Y' "; $xt = $this->db_onedev->query($query); $query = "INSERT INTO mcu_agreement_price( Mcu_AgreementPriceMcu_AgreementID, Mcu_AgreementPriceNormalPrice, Mcu_AgreementPriceAgreementPrice, Mcu_AgreementPriceDiscount, Mcu_AgreementPriceBillingSystem, Mcu_AgreementPriceDueDate, Mcu_AgreementPriceUserID, Mcu_AgreementPriceCreated ) VALUES( '{$header_id}', '{$prm['normal_price']}', '{$prm['agreement_price']}', '{$prm['discount_price']}', '{$prm['billing_system']}', '{$prm['duedate']}', {$userid}, CURDATE() ) ON DUPLICATE KEY UPDATE Mcu_AgreementPriceNormalPrice = '{$prm['normal_price']}', Mcu_AgreementPriceAgreementPrice = '{$prm['agreement_price']}', Mcu_AgreementPriceDiscount = '{$prm['discount_price']}', Mcu_AgreementPriceBillingSystem = '{$prm['billing_system']}', Mcu_AgreementPriceDueDate = '{$prm['duedate']}', Mcu_AgreementPriceUserID = {$userid}, Mcu_AgreementPriceIsActive = 'Y' "; $xu = $this->db_onedev->query($query); $query = "INSERT INTO mcu_agreement_facility( Mcu_AgreementFacilityMcu_AgreementID, Mcu_AgreementFacilityFood, Mcu_AgreementFacilityUserID, Mcu_AgreementFacilityCreated ) VALUES( '{$header_id}', '{$prm['foods']}', {$userid}, CURDATE() )ON DUPLICATE KEY UPDATE Mcu_AgreementFacilityFood = '{$prm['foods']}', Mcu_AgreementFacilityUserID = {$userid}, Mcu_AgreementFacilityIsActive = 'Y' "; $xv = $this->db_onedev->query($query); $query = "INSERT INTO mcu_agreement_send_result( Mcu_AgreementSendResultMcu_AgreementID, Mcu_AgreementSendResultDate, Mcu_AgreementSendResultPlace, Mcu_AgreementSendResultCPName, Mcu_AgreementSendResultCPHP, Mcu_AgreementSendResultUserID, Mcu_AgreementSendResultCreated ) VALUES( '{$header_id}', '{$prm['sendresult_date']}', '{$prm['sendresult_place']}', '{$prm['sendresult_cpname']}', '{$prm['sendresult_cphp']}', {$userid}, CURDATE() ) ON DUPLICATE KEY UPDATE Mcu_AgreementSendResultDate = '{$prm['sendresult_date']}', Mcu_AgreementSendResultPlace = '{$prm['sendresult_place']}', Mcu_AgreementSendResultCPName = '{$prm['sendresult_cpname']}', Mcu_AgreementSendResultCPHP = '{$prm['sendresult_cphp']}', Mcu_AgreementSendResultUserID = {$userid}, Mcu_AgreementSendResultIsActive = 'Y' "; //echo $query; $xw = $this->db_onedev->query($query); $query = "INSERT INTO mcu_agreement_marketing( Mcu_AgreementMarketingMcu_AgreementID, Mcu_AgreementMarketingName, Mcu_AgreementMarketingUserID, Mcu_AgreementMarketingCreated ) VALUES( '{$header_id}', '{$prm['marketing_staff']}', {$userid}, CURDATE() )ON DUPLICATE KEY UPDATE Mcu_AgreementMarketingName = '{$prm['marketing_staff']}', Mcu_AgreementMarketingUserID = {$userid}, Mcu_AgreementMarketingIsActive = 'Y' "; $xx = $this->db_onedev->query($query); $query = "INSERT INTO mcu_agreement_notes( Mcu_AgreementNotesMcu_AgreementID, Mcu_AgrrementNotesValue, Mcu_AgrrementNotesUserID, Mcu_AgrrementNotesCreated ) VALUES( '{$header_id}', '{$prm['notes']}', {$userid}, CURDATE() )ON DUPLICATE KEY UPDATE Mcu_AgrrementNotesValue = '{$prm['notes']}', Mcu_AgrrementNotesUserID = {$userid}, Mcu_AgrrementNotesIsActive = 'Y' "; $xz = $this->db_onedev->query($query); $query = "INSERT INTO mcu_agreement_promise( Mcu_AgreementPromiseMcu_AgreementID, Mcu_AgreementPromiseStartDate, Mcu_AgreementPromiseEndDate, Mcu_AgreementPromiseMonth, Mcu_AgreementPromiseWeek, Mcu_AgreementPromiseDay, Mcu_AgreementPromiseFlagAtTime, Mcu_AgreementPromiseAtTime, Mcu_AgreementPromiseUserID, Mcu_AgreementPromiseCreated ) VALUES( '{$header_id}', '{$prm['startdate']}', '{$prm['enddate']}', '{$prm['xmonth']}', '{$prm['xweek']}', '{$prm['xday']}', '{$prm['flagattime']}', '{$prm['attime']}', {$userid}, CURDATE() )ON DUPLICATE KEY UPDATE Mcu_AgreementPromiseStartDate = '{$prm['startdate']}', Mcu_AgreementPromiseEndDate = '{$prm['enddate']}', Mcu_AgreementPromiseMonth = '{$prm['xmonth']}', Mcu_AgreementPromiseWeek = '{$prm['xweek']}', Mcu_AgreementPromiseDay = '{$prm['xday']}', Mcu_AgreementPromiseFlagAtTime = '{$prm['flagattime']}', Mcu_AgreementPromiseAtTime = '{$prm['attime']}', Mcu_AgreementPromiseUserID = {$userid}, Mcu_AgreementPromiseIsActive = 'Y' "; $xz = $this->db_onedev->query($query); $rows['numbering'] = $numbering; $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"]; $next_status = $prm['statusnextid']; if($prm['act'] == 'samplingprocess'){ $sql = "INSERT INTO t_samplingso ( T_SamplingSoT_OrderHeaderID, T_SamplingSoT_SampleTypeID, T_SamplingSoProcessDate, T_SamplingSoProcessTime, T_SamplingSoProcessUserID, T_SamplingSoCreated, T_SamplingSoUserID ) VALUES( {$prm['id']}, {$prm['sample']['T_SampleTypeID']}, CURDATE(), CURTIME(), {$userid}, NOW(), {$userid} ) ON DUPLICATE KEY UPDATE T_SamplingSoProcessDate = CURDATE(), T_SamplingSoProcessTime = CURTIME(), T_SamplingSoFlag = 'P', T_SamplingSoIsActive = 'Y', T_SamplingSoProcessUserID = {$userid}, T_SamplingSoUserID = {$userid}"; $this->db_onedev->query($sql); } if($prm['act'] == 'samplingdone'){ $sql = "INSERT INTO t_samplingso ( T_SamplingSoT_OrderHeaderID, T_SamplingSoT_SampleTypeID, T_SamplingSoDoneDate, T_SamplingSoDoneTime, T_SamplingSoDoneUserID, T_SamplingSoCreated, T_SamplingSoUserID ) VALUES( {$prm['id']}, {$prm['sample']['T_SampleTypeID']}, CURDATE(), CURTIME(), {$userid}, NOW(), {$userid} ) ON DUPLICATE KEY UPDATE T_SamplingSoDoneDate = CURDATE(), T_SamplingSoDoneTime = CURTIME(), T_SamplingSoFlag = 'D', T_SamplingSoIsActive = 'Y', T_SamplingSoDoneUserID = {$userid}, T_SamplingSoUserID = {$userid}"; $this->db_onedev->query($sql); $sql = "SELECT count(*) as xcount FROM (SELECT * FROM t_orderheader JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y' JOIN t_test ON T_OrderDetailT_TestID = T_TestID JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND T_SamplingSoIsActive = 'Y' WHERE T_OrderHeaderID = {$prm['id']} AND T_SamplingSoT_SampleTypeID <> {$prm['sample']['T_SampleTypeID']} AND (ISNULL(T_SamplingSoID) OR T_SamplingSoFlag = 'P') AND T_OrderHeaderIsActive = 'Y' GROUP BY T_SampleTypeID ) xx"; //echo $sql; $xcount = $this->db_onedev->query($sql)->row()->xcount; if($xcount == 0){ $next_status = 5; } } if($prm['act'] !== 'samplingprocess'){ $dt_json = json_encode(array('T_SampleStationID'=>$prm['stationid'],'T_OrderHeaderID'=>$prm['id'],'T_SamplingQueueStatusID'=>$next_status)); $query = "INSERT INTO one_log.log_sampling_queue (Log_SamplingQueueDate,Log_SamplingQueueJSON,Log_SamplingQueueUserID) VALUES(NOW(),'{$dt_json}',{$userid})"; //echo $query; $rows = $this->db_onedev->query($query); $sql = "SELECT * FROM t_sampling_queue_last_status WHERE T_SamplingQueueLastStatusT_SampleStationID = {$prm['stationid']} AND T_SamplingQueueLastStatusT_OrderHeaderID = {$prm['id']} AND T_SamplingQueueLastStatusIsActive = 'Y'"; $data_last = $this->db_onedev->query($sql)->row(); $query = "INSERT INTO t_sampling_queue_last_status ( T_SamplingQueueLastStatusT_SampleStationID, T_SamplingQueueLastStatusT_OrderHeaderID, T_SamplingQueueLastStatusT_SamplingQueueStatusID, T_SamplingQueueLastStatusUserID) VALUES( {$prm['stationid']}, {$prm['id']}, {$next_status}, {$userid}) ON DUPLICATE KEY UPDATE T_SamplingQueueLastStatusT_SamplingQueueStatusID = {$next_status}"; //echo $query; $rows = $this->db_onedev->query($query); } $result = array( "total" => 1 , "records" => array('status'=>'OK') ); $this->sys_ok($result); exit; } }