622 lines
25 KiB
PHP
622 lines
25 KiB
PHP
<?php
|
|
|
|
|
|
class Rv_validation extends MY_Controller
|
|
{
|
|
var $db_smartone;
|
|
|
|
public function index()
|
|
{
|
|
echo "Result Validation API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_smartone = $this->load->database("onedev", true);
|
|
}
|
|
|
|
|
|
public function mr_state()
|
|
{
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm["order_id"];
|
|
|
|
$data = [
|
|
"image" => "http://blog.aylien.com/wp-content/uploads/2016/07/Screen-Shot-2016-07-21-at-18.46.42.png",
|
|
"note" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
|
"title" => "Multi Rule"
|
|
];
|
|
$this->sys_ok($data);
|
|
}
|
|
|
|
public function confirm()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$data = json_decode($prm["data"]);
|
|
|
|
if (sizeof($data) < 1) {
|
|
$this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
|
exit;
|
|
} else {
|
|
$ids = [];
|
|
foreach ($data as $k => $v) {
|
|
$mr_state = "X";
|
|
if (isset($v->mr_state[0])) $mr_state = $v->mr_state[0];
|
|
$qry = $this->db_smartone->set('T_OrderDetailValMRState', $mr_state)
|
|
->set('T_OrderDetailValidation', $v->validation)
|
|
->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
|
->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
|
->set('T_OrderDetailValidation1', $v->validation)
|
|
->set('T_OrderDetailValidation1Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
|
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
|
->set('T_OrderDetailValidation2', $v->validation)
|
|
->set('T_OrderDetailValidation2Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
|
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
|
->where('T_OrderDetailID', $v->id)
|
|
->update('t_orderdetail');
|
|
if (!$qry) {
|
|
print_r($this->db_smartone->error());
|
|
}
|
|
$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();
|
|
|
|
$sql_order = "SELECT
|
|
T_OrderDetailT_OrderHeaderID
|
|
FROM t_orderdetail
|
|
WHERE T_OrderDetailID = ? and T_OrderDetailIsActive = 'Y'";
|
|
$qry_order = $this->db_smartone->query($sql_order, [$data[0]->id]);
|
|
// echo $this->db_smartone->last_query();
|
|
if ($qry_order) {
|
|
$row = $qry_order->row_array();
|
|
} else {
|
|
$this->sys_error_db("select orderheader", $this->db_smartone);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select
|
|
T_OrderHeaderID,T_OrderHeaderLabNumber,
|
|
T_TestName, T_OrderDetailID, T_OrderDetailResult, T_OrderDetailNat_MethodeID,
|
|
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,
|
|
T_OrderDetailMinValue, T_OrderDetailMaxValue, T_OrderDetailMinValueInclusive,
|
|
T_OrderDetailMaxValueInclusive,
|
|
Mcu_SummaryLabID,
|
|
Mcu_SummaryLabValue,
|
|
Mcu_SummaryLabNat_MethodeID,
|
|
Mcu_SummaryLabWithMethode,
|
|
Mcu_SummaryLabType,
|
|
Mcu_SummaryLabIsNormalValue,
|
|
Mcu_KelainanID, Mcu_KelainanName, Mcu_KelainanClasification,
|
|
Nat_TestID,
|
|
Nat_TestCode,
|
|
mcu_kelainangroup.*
|
|
from t_orderdetail
|
|
join t_orderheader on T_OrderHeaderID = ?
|
|
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
|
and T_OrderDetailIsActive = 'Y'
|
|
join t_test
|
|
on T_OrderDetailT_TestID = T_TestID
|
|
join nat_test ON T_TestNat_TestID = Nat_TestID
|
|
join mcu_summarylab on T_TestNat_TestID = Mcu_SummaryLabNat_TestID AND Mcu_SummaryLabIsActive = 'Y'
|
|
join mcu_kelainan on Mcu_SummaryLabMcu_KelainanID = Mcu_KelainanID
|
|
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID";
|
|
$qry = $this->db_smartone->query($sql, array($row["T_OrderDetailT_OrderHeaderID"]));
|
|
if (!$qry) {
|
|
echo json_encode([
|
|
"status" => "ERR",
|
|
"message" => "Error get order | " . $this->db_smartone->error()["message"]
|
|
]);
|
|
exit;
|
|
}
|
|
|
|
$rows = $qry->result_array();
|
|
$results = [];
|
|
|
|
$sql_upd = "UPDATE t_kelainan_lab
|
|
SET T_KelainanLabIsActive = 'N',
|
|
T_KelainanLabCreatedUserID = {$this->sys_user['M_UserID']}
|
|
WHERE T_KelainanLabT_OrderHeaderID = {$rows[0]['T_OrderHeaderID']}";
|
|
$qry_upd = $this->db_smartone->query($sql_upd);
|
|
if (!$qry_upd) {
|
|
$this->db_smartone->trans_rollback();
|
|
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
|
exit;
|
|
}
|
|
|
|
foreach ($rows as $r) {
|
|
$result_value = $r['T_OrderDetailResult'];
|
|
|
|
$value_comparison = 0;
|
|
//echo $r['Mcu_SummaryLabIsNormalValue'];
|
|
$kelainan = [];
|
|
$notavailable = [];
|
|
if (trim($result_value) == 'NA') {
|
|
$notavailable = $r;
|
|
} elseif ($r['Mcu_SummaryLabIsNormalValue'] == 'Y') {
|
|
if ($r['Mcu_SummaryLabType'] == '<' || $r['Mcu_SummaryLabType'] == '<=') {
|
|
$value_comparison = $r['T_OrderDetailMinValue'];
|
|
}
|
|
if ($r['Mcu_SummaryLabType'] == '>' || $r['Mcu_SummaryLabType'] == '>=') {
|
|
$value_comparison = $r['T_OrderDetailMaxValue'];
|
|
}
|
|
//echo "Y";
|
|
if ($r['Mcu_SummaryLabWithMethode'] == 'N' && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
|
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
} else {
|
|
$value_comparison = $r['Mcu_SummaryLabValue'];
|
|
if ($r['Mcu_SummaryLabType'] == '!=' || $r['Mcu_SummaryLabType'] == '==') {
|
|
if ($this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
|
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
} else {
|
|
if (is_numeric($result_value) && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
|
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (count($results) > 0) {
|
|
|
|
foreach ($results as $v_result) {
|
|
$sql_kel_lab = "SELECT *
|
|
FROM t_kelainan_lab
|
|
WHERE T_KelainanLabIsActive = 'Y'
|
|
AND T_KelainanLabT_OrderDetailID = ?";
|
|
$qry_kel_lab = $this->db_smartone->query($sql_kel_lab, array($v_result['orderdetailID']));
|
|
if ($qry_kel_lab) {
|
|
$rows_kel = $qry_kel_lab->result_array();
|
|
} else {
|
|
$this->sys_error_db("select kelainan lab", $this->db_smartone);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows_kel) > 0) {
|
|
|
|
// print_r($v_result['orderdetailID']);
|
|
// exit;
|
|
|
|
$sql_update_kel = "UPDATE t_kelainan_lab
|
|
SET T_KelainanLabT_OrderDetailID = ?,
|
|
T_KelainanLabT_OrderHeaderID = ?,
|
|
T_KelainanLabNat_TestID = ?,
|
|
T_KelainanLabMcu_SummaryLabID = ?,
|
|
T_KelainanLabCreatedUserID = ?,
|
|
T_KelainanLabCreated = NOW()
|
|
WHERE T_KelainanLabID = ?";
|
|
$qry_update_kel = $this->db_smartone->query($sql_update_kel, array(
|
|
$v_result['orderdetailID'],
|
|
$v_result['orderheaderID'],
|
|
$v_result['nat_testID'],
|
|
$v_result['mcu_summarylabID'],
|
|
$this->sys_user['M_UserID'],
|
|
$rows_kel[0]['T_KelainanLabID']
|
|
));
|
|
if (!$qry_update_kel) {
|
|
$this->db_smartone->trans_rollback();
|
|
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
|
exit;
|
|
}
|
|
} else {
|
|
// print_r('insert');
|
|
// exit;
|
|
$sql_insert_lab = "INSERT INTO t_kelainan_lab(
|
|
T_KelainanLabT_OrderDetailID,
|
|
T_KelainanLabT_OrderHeaderID,
|
|
T_KelainanLabNat_TestID,
|
|
T_KelainanLabMcu_SummaryLabID,
|
|
T_KelainanLabCreatedUserID,
|
|
T_KelainanLabCreated) VALUES(
|
|
{$v_result['orderdetailID']},
|
|
{$v_result['orderheaderID']},
|
|
{$v_result['nat_testID']},
|
|
{$v_result['mcu_summarylabID']},
|
|
{$this->sys_user['M_UserID']},
|
|
NOW())";
|
|
$qry_insert_lab = $this->db_smartone->query($sql_insert_lab);
|
|
|
|
if (!$qry_insert_lab) {
|
|
$this->db_smartone->trans_rollback();
|
|
$this->sys_error_db('error', 'Error insert kelainan lab: ' . $this->db_smartone);
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// END OF Log Process
|
|
//update validation multi
|
|
//$this->load->library("Txbranchstatus");
|
|
// $this->txbranchstatus->update_multi("VALIDATION",$ids,$this->sys_user['M_StaffName']);
|
|
$this->sys_ok($ids);
|
|
}
|
|
}
|
|
|
|
function dynamic_comparison($varleft, $op, $varright)
|
|
{
|
|
|
|
switch ($op) {
|
|
case "=":
|
|
return $varleft == $varright;
|
|
case "!=":
|
|
return $varleft != $varright;
|
|
case ">=":
|
|
return $varleft >= $varright;
|
|
case "<=":
|
|
return $varleft <= $varright;
|
|
case ">":
|
|
return $varleft > $varright;
|
|
case "<":
|
|
return $varleft < $varright;
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// public function validate()
|
|
// {
|
|
// $prm = $this->sys_input;
|
|
// $data = json_decode($prm["data"]);
|
|
|
|
// if (sizeof($data) < 1)
|
|
// {
|
|
// $this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
|
// exit;
|
|
// }
|
|
// else
|
|
// {
|
|
// $ids = [];
|
|
// foreach ($data as $k => $v)
|
|
// {
|
|
// $this->db_smartone->set('T_OrderDetailValMRState', $v->mr_state)
|
|
// ->set('T_OrderDetailValidation', $v->validation)
|
|
// ->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
|
// ->set('T_OrderDetailValUserID', $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.Validation')
|
|
// ->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);
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
function print_count()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$this->firstprint();
|
|
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = T_OrderDetailPrintCount + 1
|
|
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailValidation = 'Y'
|
|
AND T_OrderDetailIsActive = 'Y'";
|
|
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
|
if ($query) {
|
|
$this->sys_ok($this->db_smartone->last_query());
|
|
} else
|
|
$this->sys_error_db("Print Count", $this->db_smartone);
|
|
}
|
|
|
|
public function reject()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$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 VALIDATION", $this->db_smartone);
|
|
}
|
|
}
|
|
|
|
public function unvalidate()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$order_id = $prm["order_id"];
|
|
|
|
$this->db_smartone->set('T_OrderDetailValidation', "N")
|
|
->set('T_OrderDetailValDate', null)
|
|
->set('T_OrderDetailValUserID', 0)
|
|
->set('T_OrderDetailValidation1', "N")
|
|
->set('T_OrderDetailValidation1Time', null)
|
|
->set('T_OrderDetailValidation1UserID', 0)
|
|
->set('T_OrderDetailValidation2', "N")
|
|
->set('T_OrderDetailValidation2Time', null)
|
|
->set('T_OrderDetailValidation1UserID', 0)
|
|
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
|
->where('T_OrderDetailIsActive', 'Y')
|
|
->where('T_OrderDetailValidation', 'Y')
|
|
->update('t_orderdetail');
|
|
|
|
$q = $this->db_smartone->last_query();
|
|
|
|
// 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_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
|
->get('t_orderdetail')
|
|
->row();
|
|
|
|
/* $dblog = $this->load->database("onelog", true);
|
|
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Unvalidation')
|
|
->set('Log_ProcessOrderID', $order->id)
|
|
->set('Log_ProcessOrderNumber', $order->lab_number)
|
|
->set('Log_ProcessJson', '{}')
|
|
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
|
->insert('log_process');
|
|
// END OF Log Process
|
|
*/
|
|
$this->sys_ok($q);
|
|
}
|
|
|
|
// Copas Fajri
|
|
function firstprint()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm['T_OrderHeaderID'] = $prm['order_id'];
|
|
$datarows = [];
|
|
$query = " SELECT T_OrderDetailID,T_TestName
|
|
FROM t_orderdetail
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
|
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
|
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID AND DocumentationGroupName = 'lab'
|
|
WHERE
|
|
T_OrderDetailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
|
T_OrderDetailValidation = 'Y' AND
|
|
T_OrderDetailPrintCount = 0 AND
|
|
T_OrderDetailT_OrderPromiseID <> 0 AND
|
|
( T_OrderDetailResult <> '' OR T_OrderDetailResult IS NOT NULL ) AND
|
|
T_OrderDetailIsActive = 'Y'
|
|
GROUP BY T_OrderDetailID";
|
|
//echo $query;
|
|
$datarows = $this->db_smartone->query($query)->result_array();
|
|
$ids = array();
|
|
$testname = array();
|
|
if ($datarows) {
|
|
foreach ($datarows as $k => $v) {
|
|
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = 1 WHERE T_OrderDetailID = {$v['T_OrderDetailID']}";
|
|
$this->db_smartone->query($sql);
|
|
array_push($ids, $v['T_OrderDetailID']);
|
|
array_push($testname, $v['T_TestName']);
|
|
}
|
|
}
|
|
$join_ids = "[" . join(",", $ids) . "]";
|
|
$join_testname = "[" . join(",", $testname) . "]";
|
|
|
|
$sql = "SELECT t_orderdelivery.*, M_DeliveryTypeCode as code
|
|
FROM t_orderdelivery
|
|
JOIN m_deliverytype ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
|
WHERE
|
|
T_OrderDeliveryT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
|
T_OrderDeliveryIsActive = 'Y'
|
|
GROUP BY T_OrderDeliveryID
|
|
";
|
|
//echo $sql;
|
|
$result_delivery = $this->db_smartone->query($sql)->result_array();
|
|
$arr_deliveryid = array();
|
|
foreach ($result_delivery as $i => $j) {
|
|
array_push($arr_deliveryid, $j["T_OrderDeliveryM_DeliveryID"]);
|
|
}
|
|
|
|
foreach ($result_delivery as $k => $v) {
|
|
|
|
if ($v['code'] == 'PICKUP') {
|
|
$sql = "INSERT INTO result_frontoffice(
|
|
Result_FrontOfficeT_OrderHeaderID,
|
|
Result_FrontOfficeIds,
|
|
Result_FrontOfficeStatus,
|
|
Result_FrontOfficeType,
|
|
Result_FrontOfficeTestName,
|
|
Result_FrontOfficeCreated,
|
|
Result_FrontOfficeUserID
|
|
)
|
|
VALUES(
|
|
{$prm['T_OrderHeaderID']},
|
|
'{$join_ids}',
|
|
'P',
|
|
'lab',
|
|
'Pemeriksaan Laboratorium',
|
|
NOW(),
|
|
{$userid}
|
|
) ON DUPLICATE KEY UPDATE
|
|
Result_FrontOfficeStatus = 'P',
|
|
Result_FrontOfficeUserID = {$userid}
|
|
";
|
|
|
|
$this->db_smartone->query($sql);
|
|
|
|
$sql = "SELECT * FROM result_frontoffice
|
|
WHERE Result_FrontOfficeT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
|
Result_FrontOfficeIds = '{$join_ids}' AND
|
|
Result_FrontOfficeType = 'lab'";
|
|
$rst_log = $this->db_smartone->query($sql)->result_array();
|
|
$dt_log = json_encode($rst_log);
|
|
$sql = "INSERT INTO one_log.log_result_front_office(
|
|
Log_ResultFrontOfficeDateTime,
|
|
Log_ResultFrontOfficeJson,
|
|
Log_ResultFrontOfficeUserID
|
|
)
|
|
VALUES(
|
|
NOW(),
|
|
'{$dt_log}',
|
|
{$userid}
|
|
)";
|
|
$this->db_smartone->query($sql);
|
|
}
|
|
|
|
if ($v['code'] == 'EMAIL') {
|
|
$type = "MANUAL";
|
|
if (in_array(1, $arr_deliveryid) && (in_array(3, $arr_deliveryid) || in_array(5, $arr_deliveryid) || in_array(11, $arr_deliveryid))) {
|
|
$type = "FO";
|
|
}
|
|
$sql = "INSERT INTO result_sendemail(
|
|
Result_SendEmailT_OrderHeaderID,
|
|
Result_SendEmailActionBy,
|
|
Result_SendEmailIds,
|
|
Result_SendEmailT_OrderDeliveryID,
|
|
Result_SendEmailStatus,
|
|
Result_SendEmailType,
|
|
Result_SendEmailT_TestName,
|
|
Result_SendEmailCreated,
|
|
Result_SendEmailUserID
|
|
)
|
|
VALUES(
|
|
{$prm['T_OrderHeaderID']},
|
|
'{$type}',
|
|
'{$join_ids}',
|
|
{$v['T_OrderDeliveryID']},
|
|
'P',
|
|
'lab',
|
|
'Pemeriksaan Laboratorium',
|
|
NOW(),
|
|
{$userid}
|
|
) ON DUPLICATE KEY UPDATE
|
|
Result_SendEmailStatus = 'P',
|
|
Result_SendEmailUserID = {$userid}
|
|
";
|
|
$this->db_smartone->query($sql);
|
|
|
|
$sql = "SELECT * FROM result_sendemail
|
|
WHERE
|
|
Result_SendEmailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
|
Result_SendEmailIds = '{$join_ids}' AND
|
|
Result_SendEmailT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
|
Result_SendEmailType = 'lab' LIMIT 1";
|
|
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
|
$sql = "INSERT INTO one_log.log_resultsendemail (
|
|
Log_ResultSendEmailDatetime,
|
|
Log_ResultSendEmailJson,
|
|
Log_ResultSendEmailUserID
|
|
)
|
|
VALUES(
|
|
NOW(),
|
|
'{$dt_log}',
|
|
{$userid}
|
|
)";
|
|
$this->db_smartone->query($sql);
|
|
}
|
|
|
|
if ($v['code'] == 'ADDRESS') {
|
|
$sql = "INSERT INTO result_sendcourier(
|
|
Result_SendCourierT_OrderHeaderID,
|
|
Result_SendCourierIds,
|
|
Result_SendCourierT_OrderDeliveryID,
|
|
Result_SendCourierStatus,
|
|
Result_SendCourierType,
|
|
Result_SendCourierT_TestName,
|
|
Result_SendCourierCreated,
|
|
Result_SendCourierUserID
|
|
)
|
|
VALUES(
|
|
{$prm['T_OrderHeaderID']},
|
|
'{$join_ids}',
|
|
{$v['T_OrderDeliveryID']},
|
|
'P',
|
|
'lab',
|
|
'Pemeriksaan Laboratorium',
|
|
NOW(),
|
|
{$userid}
|
|
) ON DUPLICATE KEY UPDATE
|
|
Result_SendCourierStatus = 'P',
|
|
Result_SendCourierUserID = {$userid}
|
|
";
|
|
$this->db_smartone->query($sql);
|
|
|
|
$sql = "SELECT * FROM result_sendcourier
|
|
WHERE
|
|
Result_SendCourierT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
|
Result_SendCourierIds = '{$join_ids}' AND
|
|
Result_SendCourierT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
|
Result_SendCourierType = 'lab' LIMIT 1";
|
|
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
|
$sql = "INSERT INTO one_log.log_resultsendcourier (
|
|
Log_ResultSendCourierDateTime,
|
|
Log_ResultSendCourierJson,
|
|
Log_ResultSendCourierUserID
|
|
)
|
|
VALUES(
|
|
NOW(),
|
|
'{$dt_log}',
|
|
{$userid}
|
|
)";
|
|
$this->db_smartone->query($sql);
|
|
}
|
|
|
|
|
|
//echo $sql;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
// $result = array(
|
|
// "total" => count($datarows) ,
|
|
// "records" => $datarows,
|
|
// );
|
|
// $this->sys_ok($result);
|
|
// exit;
|
|
}
|
|
}
|