169 lines
6.7 KiB
PHP
169 lines
6.7 KiB
PHP
<?php
|
|
|
|
class Generateorder 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 t_onlinetx
|
|
LEFT JOIN t_onlineorder ON T_OnlineOrderT_OnlineTxID = T_OnlineTxID AND T_OnlineOrderIsActive = 'Y'
|
|
LEFT JOIN t_orderheader ON T_OrderHeaderID = T_OnlineOrderT_OrderHeaderID
|
|
where
|
|
T_OnlineTxIsActive = 'Y' AND T_OnlineTxIsProcess <> 'Y' AND
|
|
(T_OnlineTxNumbering LIKE CONCAT('%','{$search}','%') OR
|
|
T_OrderHeaderLabNumber LIKE CONCAT('%','{$search}','%') OR
|
|
T_OnlineTxBookingQrCode LIKE CONCAT('%','{$search}','%')) AND
|
|
T_OrderHeaderID IS NULL AND DATE_FORMAT(STR_TO_DATE(LEFT(T_OnlineTxBookingDate , 10), '%d-%m-%Y'), '%Y-%m-%d') >= '2021-12-13' AND
|
|
date(T_OnlineTxDate) >= '2021-12-13'";
|
|
// $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("t_onlinetx count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select T_OnlineTxID as id,
|
|
T_OnlineTxNumbering,
|
|
T_OrderHeaderLabNumber,
|
|
LEFT(T_OnlineTxBookingDate , 16) as tanggal,
|
|
DATE_FORMAT(STR_TO_DATE(LEFT(T_OnlineTxBookingDate , 10), '%d-%m-%Y'), '%Y-%m-%d') as xdate,
|
|
IF(DATE_FORMAT(STR_TO_DATE(LEFT(T_OnlineTxBookingDate, 10), '%d-%m-%Y'), '%Y-%m-%d') <= date(now()) , 'N','Y') as ishide,
|
|
T_OnlineTxBookingDate,
|
|
T_OnlineTxBookingQrCode,
|
|
T_OnlineTxBookingName as M_PatientName
|
|
from t_onlinetx
|
|
LEFT JOIN t_onlineorder ON T_OnlineOrderT_OnlineTxID = T_OnlineTxID AND T_OnlineOrderIsActive = 'Y'
|
|
LEFT JOIN t_orderheader ON T_OrderHeaderID = T_OnlineOrderT_OrderHeaderID
|
|
where
|
|
T_OnlineTxIsActive = 'Y' AND T_OnlineTxIsProcess <> 'Y' AND
|
|
(T_OnlineTxNumbering LIKE CONCAT('%','{$search}','%') OR
|
|
T_OrderHeaderLabNumber LIKE CONCAT('%','{$search}','%') OR
|
|
T_OnlineTxBookingQrCode LIKE CONCAT('%','{$search}','%')) AND
|
|
T_OrderHeaderID IS NULL AND
|
|
DATE_FORMAT(STR_TO_DATE(LEFT(T_OnlineTxBookingDate , 10), '%d-%m-%Y'), '%Y-%m-%d') >= '2021-12-13' AND
|
|
date(T_OnlineTxDate) >= '2021-12-13'
|
|
GROUP BY T_OnlineTxID
|
|
ORDER BY T_OnlineTxBookingDate 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("t_onlinetx 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;
|
|
$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/fix/pramitalabku/generate_order/".$id;
|
|
$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;
|
|
}
|
|
|
|
|
|
}
|