205 lines
5.9 KiB
PHP
205 lines
5.9 KiB
PHP
<?php
|
|
class Done extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "SampleStorage API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$spk = $prm['spk'];
|
|
|
|
|
|
|
|
$sql = "SELECT Result_CourierSPKDetailID as id,T_OrderHeaderID,
|
|
T_OrderDeliveryID ,T_OrderPromiseID,
|
|
DATE_FORMAT(T_OrderPromiseDateTime,'%d-%m-%Y %H:%i') as date_promise,
|
|
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
|
M_CompanyName,
|
|
T_OrderHeaderLabNumberExt as no_reg,
|
|
courier_staff.M_StaffName as staff_name,
|
|
IFNULL(spv_staff.M_StaffName,'Belum dikonfirmasi') as spv_name,
|
|
Result_CourierSPKDetailStatus as status
|
|
FROM result_courierspk_detail
|
|
JOIN result_courierspk ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
|
JOIN t_orderpromise ON Result_CourierSPKDetailT_OrderPromiseID = T_OrderPromiseID
|
|
JOIN t_orderdelivery ON Result_CourierSPKDetailT_OrderDeliveryID = T_OrderDeliveryID
|
|
JOIN t_orderheader ON T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
|
JOIN m_courier ON Result_CourierSPKM_CourierID = M_CourierID
|
|
JOIN m_staff courier_staff ON M_CourierM_StaffID = courier_staff.M_StaffID
|
|
LEFT JOIN m_user ON Result_CourierSPKDetailConfirmedBy = M_UserID
|
|
LEFT JOIN m_staff spv_staff ON M_UserM_StaffID = spv_staff.M_StaffID
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
WHERE
|
|
Result_CourierSPKDetailResult_CourierSPKID = {$spk} AND
|
|
Result_CourierSPKDetailIsActive = 'Y'
|
|
ORDER BY T_OrderPromiseDateTime ASC, T_OrderHeaderID ASC ";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
$rows[$k]['chex'] = false;
|
|
}
|
|
}
|
|
|
|
$result = array("total" => $tot_page, "records" => $rows, "sql"=> '');
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
function getkerajaan(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//$rst = array(array('id'=>0,'name'=>'Semua'));
|
|
|
|
$sql = "SELECT 0 as id, 'Semua' as name UNION SELECT Nat_GroupID as id, Nat_GroupName as name FROM nat_group WHERE Nat_GroupIsActive = 'Y'";
|
|
$rst_db = $this->db_onedev->query($sql)->result_array();
|
|
//$c = array_combine($rst,$rst_db);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => $rst_db
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function dosend(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
$selected = $prm['selected'];
|
|
|
|
foreach($selected as $k => $v){
|
|
$sql = "UPDATE result_frontoffice SET Result_FrontOfficeStatus = 'R' WHERE Result_FrontOfficeID = {$v['xid']}";
|
|
$this->db_onedev->query($sql);
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
public function getspk()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT Result_CourierSPKID as id,
|
|
CONCAT(Result_CourierSPKNumbering,' ',M_StaffName) as name
|
|
FROM result_courierspk
|
|
JOIN m_courier ON Result_CourierSPKM_CourierID = M_CourierID
|
|
JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
|
WHERE
|
|
Result_CourierSPKDate = '{$prm['startdate']}' AND
|
|
Result_CourierSPKIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql);
|
|
$rows = $query->result_array();
|
|
|
|
$result = array("total" => count($rows), "records" => $rows, "sql"=> '');
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function sendemail(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
$rows = array();
|
|
$ids = "(".$prm['ids'].")";
|
|
$sql = "UPDATE result_sendemail SET Result_SendEmailStatus = 'S', Result_SendEmailUserID = {$userid} WHERE Result_SendEmailID IN {$ids}";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
$sql = "SELECT * FROM result_sendemail WHERE Result_SendEmailID IN {$ids}";
|
|
$dt_rst = $this->db_onedev->query($sql)->result_array();
|
|
foreach($dt_rst as $k => $v){
|
|
$dt_log = json_encode($v);
|
|
$sql = "INSERT INTO one_log.log_resultsendemail (
|
|
Log_ResultSendEmailDatetime,
|
|
Log_ResultSendEmailJson,
|
|
Log_ResultSendEmailUserID
|
|
)
|
|
VALUES(
|
|
NOW(),
|
|
'{$dt_log}',
|
|
{$userid}
|
|
)";
|
|
$this->db_onedev->query($sql);
|
|
}
|
|
|
|
$result = array ("total" => 0, "records" => $rows);
|
|
$this->sys_ok($result);
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function updateemail(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
$rows = array();
|
|
$id = $prm['id'];
|
|
$sql = "UPDATE t_orderdelivery SET T_OrderDeliveryDestination = '{$prm['edited_email']}', T_OrderDeliveryUserID = {$userid} WHERE T_OrderDeliveryID = {$id}";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
|
|
$result = array ("total" => 0, "records" => array());
|
|
$this->sys_ok($result);
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
} |