146 lines
4.7 KiB
PHP
146 lines
4.7 KiB
PHP
<?php
|
|
|
|
|
|
class Rv_verification extends MY_Controller
|
|
{
|
|
var $db_smartone;
|
|
|
|
public function index()
|
|
{
|
|
echo "RV Px API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->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 = "<table >\n";
|
|
$html .= "<tr><th style='text-align:left;padding:5px;'>Position</th>
|
|
<th style='text-align:left;padding:5px;' >Requirements</th></tr>\n";
|
|
foreach($a_pos as $pos => $reqs) {
|
|
$html .= "<tr valign='top' >\n";
|
|
$html .= "<td style='text-align:left;padding:5px;'>$pos</td>";
|
|
$html .= "<td style='text-align:left;padding:5px;'>";
|
|
foreach($reqs as $r) {
|
|
$html .= "$r<br/>";
|
|
}
|
|
$html .= "</td>";
|
|
$html .= "</tr>";
|
|
}
|
|
$html .= "</table>";
|
|
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"];
|
|
|
|
$data = ["image"=>"https://www.sec.gov/files/trendChart-2018.jpg",
|
|
"note"=>$this->requirement($id),
|
|
"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
|
|
|
|
$this->sys_ok($ids);
|
|
}
|
|
}
|
|
}
|
|
|