165 lines
6.0 KiB
PHP
165 lines
6.0 KiB
PHP
<?php
|
|
|
|
class Futureorderfix extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "CONTROL API";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
function lookuptransaction()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$search = $prm['search'];
|
|
$all = $prm['all'];
|
|
$sdate = $prm['sdate'];
|
|
$limit = '';
|
|
if ($all == 'N') {
|
|
$limit = ' LIMIT 10';
|
|
}
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
|
$sql = "select COUNT(*) as total
|
|
from future_order
|
|
LEFT JOIN future_map ON FutureMapFutureOrderID = FutureOrderID AND FutureMapIsActive = 'Y'
|
|
LEFT JOIN t_orderheader ON T_OrderHeaderID = FutureMapT_OrderHeaderID
|
|
where
|
|
FutureOrderIsActive = 'Y' AND
|
|
(FutureOrderNumber LIKE CONCAT('%','{$search}','%') OR
|
|
T_OrderHeaderLabNumber LIKE CONCAT('%','{$search}','%')) AND
|
|
T_OrderHeaderID IS NULL";
|
|
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
|
$query = $this->db_onedev->query($sql);
|
|
//echo $this->db_onedev->last_query();
|
|
$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("future_order count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select FutureOrderID as id,
|
|
DATE_FORMAT(FutureOrderDateBooking,'%d-%m-%Y') as tanggal,
|
|
future_order.*,
|
|
T_OrderHeaderLabNumber,
|
|
IF(FutureOrderDateBooking <= date(now()) , 'N','Y') as ishide,
|
|
JSON_UNQUOTE(JSON_EXTRACT(fn_get_patient_atribute(FutureOrderM_PatientID), '$.patient_fullname')) as M_PatientName
|
|
from future_order
|
|
LEFT JOIN future_map ON FutureMapFutureOrderID = FutureOrderID AND FutureMapIsActive = 'Y'
|
|
LEFT JOIN t_orderheader ON T_OrderHeaderID = FutureMapT_OrderHeaderID
|
|
where
|
|
FutureOrderIsActive = 'Y' AND
|
|
(FutureOrderNumber LIKE CONCAT('%','{$search}','%') OR
|
|
T_OrderHeaderLabNumber LIKE CONCAT('%','{$search}','%')) AND
|
|
T_OrderHeaderID IS NULL
|
|
GROUP BY FutureOrderID
|
|
ORDER BY FutureOrderDateBooking ASC
|
|
limit $number_limit offset $number_offset";
|
|
$sql_param = array($search);
|
|
$query = $this->db_onedev->query($sql);
|
|
//echo $this->db_onedev->last_query();
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
} else {
|
|
$this->sys_error_db("future_order select");
|
|
exit;
|
|
}
|
|
|
|
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
|
|
public function fix()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$id = $prm['id'];
|
|
$nomor = md5($prm['nomor']);
|
|
$sql = $this->db_onedev->query("SELECT M_BranchIPAddress as branch_ip_address FROM m_branch WHERE M_BranchIsDefault = 'Y'")->row();
|
|
$branch_ip_address = $sql->branch_ip_address;
|
|
$param = array(
|
|
"id" => $id,
|
|
"nomor" => $nomor
|
|
);
|
|
$j_param = json_encode($param);
|
|
$url = "http://$branch_ip_address/one-api-lab/fix/fix_future/do_fix/" . $id . "/" . $nomor . "/" . $userid;
|
|
$post_rst = $this->post($url);
|
|
// echo "to $url \nresponse : $post_rst\n";
|
|
$j_rst = json_decode($post_rst, true);
|
|
$xstatus = $j_rst["status"];
|
|
$xpesan = $j_rst["message"];
|
|
|
|
$result = array("total" => 1, "records" => array("xid" => 0), "pesan" => $post_rst);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
function post($url)
|
|
{
|
|
//$data = $data;
|
|
$ch = curl_init($url);
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
$result = curl_exec($ch);
|
|
//echo "RST : $result ";
|
|
return $result;
|
|
}
|
|
function postold($url, $data)
|
|
{
|
|
$ch = curl_init($url);
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 12);
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
|
curl_setopt(
|
|
$ch,
|
|
CURLOPT_HTTPHEADER,
|
|
array(
|
|
'Content-Type: application/json',
|
|
'Content-Length: ' . strlen($data)
|
|
)
|
|
);
|
|
$result = curl_exec($ch);
|
|
if (curl_errno($ch)) {
|
|
return json_encode(array(
|
|
"status" => "ERR",
|
|
"message" => curl_error($ch)
|
|
));
|
|
}
|
|
curl_close($ch);
|
|
return $result;
|
|
}
|
|
}
|