db_smartone = $this->load->database("onedev", true); $this->db_one= $this->load->database("onedev", true); } function requirement($id) { $sql = "call sp_result_verify_requirement(?)"; $query = $this->db_one->query($sql, array($id)); $this->clean_mysqli_connection($this->db_one); $rows = $query->result_array() ; $result = array(); foreach( $rows as $r ) { $jdata = json_decode( $r["jdata"] ); $a_pos = array(); foreach($jdata as $req ) { $xreq = json_decode($req,true); foreach($xreq as $position => $req) { $a_req = explode("^",$req); $a_pos[$position] = $a_req; } } $result = $a_pos; } return $this->req_html($result); } function req_html($result) { $a_pos = $result; if (count($a_pos) == 0 ) return ""; $html = "\n"; $html .= "\n"; foreach($a_pos as $pos => $reqs) { $html .= "\n"; $html .= ""; $html .= ""; $html .= ""; } $html .= "
Position Requirements
$pos"; foreach($reqs as $r) { $html .= "$r
"; } $html .= "
"; return $html; } public function trend_analysis() { $prm = $this->sys_input; $id = $prm["order_id"]; $image = ""; $note = ""; try { $sql = "select fn_process_re_trendanalysis(?) ta"; $qry = $this->db_one->query($sql,array($id)); if ($qry) { $row = $qry->row(); $j_tmp = json_decode($row->ta); if ($j_tmp->image != "") { $image = $j_tmp->image . "&ts=" . date("Ymdhnis"); } $note = $j_tmp->note; } } catch(Exception $e) { } $req_note =$this->requirement($id); if ($req_note != "" ) { $note = $req_note; $image = ""; } $data = ["image"=>$image, "note"=> $note, "title"=>"Trend Analisis"]; $this->sys_ok($data); } public function delta_check() { $prm = $this->sys_input; $id = $prm["order_id"]; $note = ""; try { $sql = "select fn_process_re_deltacheck(?) ta"; $qry = $this->db_one->query($sql,array($id)); if ($qry) { $row = $qry->row(); $j_tmp = json_decode($row->ta); $note = $j_tmp->note; } } catch(Exception $e) { } $req_note =$this->requirement($id); if ($req_note != "" ) { $note = $req_note; $image = ""; } $data = [ "note"=> $note, "image" => "", "title"=>"Delta Check"]; $this->sys_ok($data); } public function confirm() { $prm = $this->sys_input; $data = json_decode($prm["data"]); if (sizeof($data) < 1) { $this->sys_error_db("RE Verification Confirmation", $this->db_smartone); exit; } else { $ids = []; foreach ($data as $k => $v) { $this->db_smartone->set('T_OrderDetailVerDeltaCheck', $v->delta) ->set('T_OrderDetailVerTrendAnalysis', $v->trend) ->set('T_OrderDetailVerification', $v->verification) ->set('T_OrderDetailVerDate', $v->verification == "Y" ? date('Y-m-d H:i:s') : null) ->set('T_OrderDetailVerUserID', $this->sys_user['M_UserID']) ->where('T_OrderDetailID', $v->id) ->update('t_orderdetail'); $ids[] = $v->id; } // LOG Process $order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false) ->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID') ->where('T_OrderDetailID', $data[0]->id) ->get('t_orderdetail') ->row(); $dblog = $this->load->database("onelog", true); $dblog->set('Log_ProcessCode', 'PROCESS.Result.Verification') ->set('Log_ProcessOrderID', $order->id) ->set('Log_ProcessOrderNumber', $order->lab_number) ->set('Log_ProcessJson', json_encode($data)) ->set('Log_ProcessUserID', $this->sys_user['M_UserID']) ->insert('log_process'); // END OF Log Process //sipe : verifikasi Y t_orderdetail IsParent Y T_OrderDetailVerification X IsResult N // Heri, 2020-01-02 $tcode = $this->db_smartone->where('T_OrderDetailID', $v->id) ->get('t_orderdetail') ->row(); $sql = "update t_orderdetail,t_test set T_OrderDetailVerification='Y', T_OrderDetailVerDate = now(), T_OrderDetailVerUserID = ? where T_OrderDetailT_OrderHeaderID = ? and T_OrderDetailT_TestID = T_TestID and T_TestIsParent = 'Y' and T_TestIsResult = 'N' and T_OrderDetailVerification='X' and ? LIKE CONCAT(T_OrderDetailT_TestSasCode, '%')"; $this->db_smartone->query($sql,array($this->sys_user['M_UserID'],$order->id, $tcode->T_OrderDetailT_TestSasCode)); file_put_contents("/xtmp/pe-debug.sql",$this->db_smartone->last_query()); $this->sys_ok($ids); } } public function reject() { $prm = $this->sys_input; // QUERY TOTAL $sql = "CALL sp_process_result_validation_reject(?, ?)"; $query = $this->db_smartone->query($sql, [$prm['id'], $prm['action']]); if ($query) { $row = $query->row(); $this->sys_ok($row); } else { $this->sys_error_db("REJECT VERIFICATION", $this->db_smartone); } } }