1387 lines
58 KiB
PHP
1387 lines
58 KiB
PHP
<?php
|
|
class Deliveryorder extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Register 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;
|
|
}
|
|
$norm = $prm["snorm"];
|
|
$nama = $prm["nama"];
|
|
$status = $prm["status"];
|
|
$startdate = $prm["startdate"];
|
|
$enddate = $prm["enddate"];
|
|
|
|
if($status = "A"){
|
|
$sql_where = "WHERE T_DeliveryCourierIsActive = 'Y'";
|
|
}else{
|
|
$sql_where = "WHERE T_DeliveryCourierIsActive = 'Y' AND T_DeliveryCourierStatus = '{$status}'";
|
|
}
|
|
$sql_param = array();
|
|
if ($nama != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= "M_StaffName like ? ";
|
|
$sql_param[] = "%$nama%";
|
|
}
|
|
if ($norm != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " concat(T_DeliveryCourierNumber) like ? ";
|
|
$sql_param[] = "%$norm%";
|
|
}
|
|
|
|
|
|
$sql = " SELECT count(*) as total
|
|
FROM one_rujukan_eksternal.t_deliverycourier
|
|
left join m_staff ON M_StaffID = T_DeliveryCourierM_StaffID
|
|
$sql_where
|
|
";
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
|
|
$tot_count = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
} else {
|
|
$this->sys_error_db("one_rujukan_eksternal.t_deliverycourier count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT
|
|
T_DeliveryCourierID,
|
|
T_DeliveryCourierNumber,
|
|
T_DeliveryCourierDate,
|
|
DATE_FORMAT(T_DeliveryCourierDate,'%d-%m-%Y') as sjdate,
|
|
T_DeliveryCourierStatus,
|
|
M_StaffID,
|
|
M_StaffName,
|
|
CASE
|
|
WHEN T_DeliveryCourierStatus = 'N' THEN 'Baru'
|
|
WHEN T_DeliveryCourierStatus = 'C' THEN 'Konfirmasi'
|
|
WHEN T_DeliveryCourierStatus = 'P' THEN 'Proses'
|
|
WHEN T_DeliveryCourierStatus = 'D' THEN 'Selesai'
|
|
ELSE ''
|
|
END as status,
|
|
'' as statuss,
|
|
0 as totalsend,
|
|
0 as totalall
|
|
|
|
FROM one_rujukan_eksternal.t_deliverycourier
|
|
left join m_staff ON M_StaffID = T_DeliveryCourierM_StaffID
|
|
$sql_where
|
|
AND ( T_DeliveryCourierDate BETWEEN '{$startdate} 00:00:00' AND '{$enddate} 23:59:59' )
|
|
ORDER BY T_DeliveryCourierID DESC
|
|
limit 0,$tot_count ";
|
|
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
//echo $this->db_onedev->last_query();
|
|
$rows = $query->result_array();
|
|
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
|
|
|
|
$x = $this->db_onedev->query("
|
|
select count(*) as tot
|
|
FROM one_rujukan_eksternal.t_deliverycourierdetail
|
|
WHERE T_DeliveryCourierDetailT_DeliveryCourierID = '{$v['T_DeliveryCourierID']}' AND T_DeliveryCourierDetailIsActive = 'Y'")->row();
|
|
if($x->tot == 0 ) {
|
|
$rows[$k]['haveDetail'] = "N";
|
|
} else {
|
|
$rows[$k]['haveDetail'] = "Y";
|
|
}
|
|
|
|
}
|
|
}
|
|
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
exit;
|
|
|
|
|
|
}
|
|
function searchbank(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_bank_account
|
|
join nat_bank on Nat_BankID = M_BankAccountNat_BankID
|
|
WHERE
|
|
CONCAT(Nat_BankName, ' [ ',M_BankAccountNo,' | ',IFNULL(M_BankAccountName,''),' ]') like ?
|
|
AND M_BankAccountIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_bank_account count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *, CONCAT(Nat_BankName, ' [ ',M_BankAccountNo,' | ',IFNULL(M_BankAccountName,''),' ]') as M_BankAccountName
|
|
FROM m_bank_account
|
|
join nat_bank on Nat_BankID = M_BankAccountNat_BankID
|
|
WHERE
|
|
CONCAT(Nat_BankName, ' [ ',M_BankAccountNo,' | ',IFNULL(M_BankAccountName,''),' ]') like ?
|
|
AND M_BankAccountIsActive = 'Y'
|
|
ORDER BY M_BankAccountIsDefault desc, Nat_BankName asc
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_bank_account rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchstaff(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_staff
|
|
WHERE
|
|
M_StaffName like ?
|
|
AND M_StaffIsActive = 'Y'
|
|
AND NOT EXISTS (SELECT T_DeliveryCourierM_StaffID FROM one_rujukan_eksternal.t_deliverycourier WHERE T_DeliveryCourierM_StaffID = M_StaffID AND T_DeliveryCourierIsActive = 'Y' AND T_DeliveryCourierStatus = 'N')";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_staff count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT M_StaffID, M_StaffName
|
|
FROM m_staff
|
|
WHERE
|
|
M_StaffName like ?
|
|
AND M_StaffIsActive = 'Y'
|
|
AND NOT EXISTS (SELECT T_DeliveryCourierM_StaffID FROM one_rujukan_eksternal.t_deliverycourier WHERE T_DeliveryCourierM_StaffID = M_StaffID AND T_DeliveryCourierIsActive = 'Y' AND T_DeliveryCourierStatus IN ('N','S','A','P'))
|
|
ORDER BY M_StaffName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_staff rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function getmou(){
|
|
$prm = $this->sys_input;
|
|
$bquery = "SELECT M_BranchS_RegionalID as regionalid FROM m_branch WHERE M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'";
|
|
$regionalid = $this->db_onedev->query($bquery)->row()->regionalid;
|
|
$query ="SELECT M_UserID,
|
|
M_UserName,
|
|
CONCAT(M_UserName, ' | Cabang: ', M_BranchName) as M_UserDesc,
|
|
M_UserAgingDay,
|
|
M_UserPicBillName,
|
|
M_UserPicBillHandphone,
|
|
M_UserPicBillEmail,
|
|
CONCAT(M_UserPicBillName,' , ', M_UserFinanceName) as M_UserFinanceName,
|
|
CONCAT(M_UserPicBillHandphone,' , ', M_UserFinanceHandphone) as M_UserFinanceHandphone,
|
|
CONCAT(M_UserPicBillEmail,' , ', M_UserFinanceEmail) as M_UserFinanceEmail,
|
|
M_BranchID,
|
|
M_BranchCode,
|
|
M_BranchName,
|
|
Concat(M_BranchCode,' - ',M_BranchName) as cabang
|
|
FROM m_mou
|
|
JOIN m_branch ON M_BranchID = M_UserM_BranchBillID AND M_BranchS_RegionalID = $regionalid
|
|
WHERE
|
|
M_UserIsActive <> 'N' AND M_UserM_StaffID = ?
|
|
AND M_UserIsAgingOnHold = 'Y' AND M_UserAgingDay > 0
|
|
AND M_UserM_BillTypeID = 2
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function listmou(){
|
|
$prm = $this->sys_input;
|
|
$bquery = "SELECT M_BranchS_RegionalID as regionalid FROM m_branch WHERE M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'";
|
|
$regionalid = $this->db_onedev->query($bquery)->row()->regionalid;
|
|
$query ="SELECT M_UserID,
|
|
M_UserName,
|
|
CONCAT(M_UserName, ' | Cabang: ', M_BranchName) as M_UserDesc,
|
|
M_UserAgingDay,
|
|
M_UserPicBillName,
|
|
M_UserPicBillHandphone,
|
|
M_UserPicBillEmail,
|
|
CONCAT(M_UserPicBillName,' , ', M_UserFinanceName) as M_UserFinanceName,
|
|
CONCAT(M_UserPicBillHandphone,' , ', M_UserFinanceHandphone) as M_UserFinanceHandphone,
|
|
CONCAT(M_UserPicBillEmail,' , ', M_UserFinanceEmail) as M_UserFinanceEmail,
|
|
DATE_FORMAT(DATE_ADD(date(now()), INTERVAL M_UserAgingDay DAY),'%d-%m-%Y') as duedateina,
|
|
DATE_FORMAT(DATE_ADD(date(now()), INTERVAL M_UserAgingDay DAY),'%Y-%m-%d') as duedate,
|
|
M_BranchID,
|
|
M_BranchCode,
|
|
M_BranchName,
|
|
Concat(M_BranchCode,' - ',M_BranchName) as cabang
|
|
FROM m_mou
|
|
JOIN m_branch ON M_BranchID = M_UserM_BranchBillID AND M_BranchS_RegionalID = $regionalid
|
|
WHERE
|
|
M_UserIsActive <> 'N' AND M_UserM_StaffID = ?
|
|
AND M_UserIsAgingOnHold = 'Y' AND M_UserAgingDay > 0
|
|
AND M_UserM_BillTypeID = 2
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getnomor(){
|
|
$prm = $this->sys_input;
|
|
$query ="SELECT M_No_FormRev
|
|
FROM m_no_form
|
|
WHERE
|
|
M_No_FormIsActive = 'Y' AND M_No_FormName = 'BILL'";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array()[0]["M_No_FormRev"];
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getsexreg(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_sex
|
|
WHERE
|
|
M_SexIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT *, CONCAT(R_ReportCode,' | ',R_ReportName) as rname
|
|
FROM r_report
|
|
WHERE
|
|
R_ReportCode IN('KEU09','KEU10','KEU11','KEU12','KEU13','KEU14','KEU15','KEU16','KEU17') AND `R_ReportIsActive` = 'Y'
|
|
ORDER BY R_ReportCode ASC
|
|
";
|
|
//echo $query;
|
|
$rows['reports'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query ="SELECT '/birt/run?__report=report/one/fo/rpt_t_009.rptdesign' as t_url, 'PENAGIHAN' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_bill_confirm_inv.rptdesign' as t_url, 'LAMPIRAN TAGIHAN (PERIODE BULAN)' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_bill_confirm_inv_tanggal.rptdesign' as t_url, 'LAMPIRAN TAGIHAN (PERIODE TANGGAL)' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_bill_confirm_kwitansi.rptdesign' as t_url, 'KWITANSI (PERIODE BULAN)' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_bill_confirm_kwitansi_tanggal.rptdesign' as t_url, 'KWITANSI (PERIODE TANGGAL)' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_bill_confirm_tandaterima.rptdesign' as t_url, 'TANDA TERIMA (PERIODE BULAN)' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_bill_confirm_tandaterima_tanggal.rptdesign' as t_url, 'TANDA TERIMA (PERIODE TANGGAL)' as t_name
|
|
";
|
|
//echo $query;
|
|
$rows['cetaks'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function save(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$pdob = date('Y-m-d',strtotime($prm['M_CompanyDOB']));
|
|
$query ="UPDATE m_company SET
|
|
M_CompanyM_TitleID = '{$prm['M_CompanyM_TitleID']}',
|
|
M_CompanyName = '{$prm['M_CompanyName']}',
|
|
M_CompanyDOB = '{$pdob}',
|
|
M_CompanyM_SexID = '{$prm['M_CompanyM_SexID']}',
|
|
M_CompanyM_ReligionID = '{$prm['M_CompanyM_ReligionID']}',
|
|
M_CompanyEmail = '{$prm['M_CompanyEmail']}',
|
|
M_CompanyHP = '{$prm['M_CompanyHP']}',
|
|
M_CompanyPhone = '{$prm['M_CompanyPhone']}',
|
|
M_CompanyM_IdTypeID = '{$prm['M_CompanyM_IdTypeID']}',
|
|
M_CompanyIDNumber = '{$prm['M_CompanyIDNumber']}',
|
|
M_CompanyNote = '{$prm['M_CompanyNote']}'
|
|
WHERE
|
|
M_CompanyID = '{$prm['M_CompanyID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function newreceivereference(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="INSERT INTO one_rujukan_eksternal.t_deliverycourier (
|
|
T_DeliveryCourierNumber,
|
|
T_DeliveryCourierDate,
|
|
T_DeliveryCourierM_StaffID,
|
|
T_DeliveryCourierNote,
|
|
T_DeliveryCourierUserID,
|
|
T_DeliveryCourierCreated,
|
|
T_DeliveryCourierLastUpdated
|
|
)
|
|
VALUES(
|
|
`fn_numbering`('RE'),
|
|
'{$prm['sdate']}',
|
|
'{$prm['staffid']}',
|
|
'{$prm['note']}',
|
|
'{$userid}',
|
|
now(),
|
|
NOW()
|
|
)
|
|
";
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
|
|
$querylog ="INSERT INTO one_rujukan_eksternal.t_deliverycourierstatuslog(
|
|
T_DeliveryCourierStatusLogName,
|
|
T_DeliveryCourierStatusLogDate,
|
|
T_DeliveryCourierStatusLogT_DeliveryCourierID,
|
|
T_DeliveryCourierStatusLogT_DeliveryCourierDetailID,
|
|
T_DeliveryCourierStatusLogT_OrderDeliveryID,
|
|
T_DeliveryCourierStatusLogStatus,
|
|
T_DeliveryCourierStatusLogStatusName,
|
|
T_DeliveryCourierStatusLogUserID,
|
|
T_DeliveryCourierStatusLogCreated,
|
|
T_DeliveryCourierStatusLogLastUpdated)
|
|
VALUES(
|
|
'DELIVERY ORDER',
|
|
date(now()),
|
|
$last_id,
|
|
0,
|
|
0,
|
|
'N',
|
|
'Baru',
|
|
$userid,
|
|
NOW(),
|
|
NOW()
|
|
)";
|
|
// echo $querylog;
|
|
$insert_new_log = $this->db_onedev->query($querylog);
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
"id" => $last_id
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
|
|
}
|
|
public function uploadnew($img,$tanggal,$idbill,$idconfirm,$sdate)
|
|
{
|
|
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$home_dir = "/home/one/project/one/";
|
|
$target_dir = $home_dir . "one-media/one-photo/";
|
|
|
|
$sqlsum = "select T_DeliveryCourierNumber as billNo from one_rujukan_eksternal.t_deliverycourier
|
|
where T_DeliveryCourierID = $idbill";
|
|
$billNo = $this->db_onedev->query($sqlsum)->row()->billNo;
|
|
|
|
if (!file_exists($target_dir)) {
|
|
mkdir($target_dir, 0755, true);
|
|
}
|
|
$filename = date("YmdHis")."_".$billNo . ".jpg";
|
|
$target_path = $target_dir . $filename;
|
|
$this->base64_to_jpeg($img, $target_path);
|
|
$sql = "UPDATE one_rujukan_eksternal.t_deliverycourier_confirm_issue SET T_DeliveryCourierConfirmIssueImg = '{$filename}',
|
|
T_DeliveryCourierConfirmIssueIsReceive = 'Y',
|
|
T_DeliveryCourierConfirmIssueReceiveDate = '{$tanggal}',
|
|
T_DeliveryCourierConfirmIssueReceiveUserID = {$userid}
|
|
WHERE T_DeliveryCourierConfirmIssueID = {$idconfirm}";
|
|
//echo $sql;
|
|
$save = $this->db_onedev->query($sql);
|
|
|
|
$sqlbill = "UPDATE one_rujukan_eksternal.t_deliverycourier SET T_DeliveryCourierDueDate = '{$sdate}'
|
|
WHERE T_DeliveryCourierID = {$idbill}";
|
|
//echo $sqlbill;
|
|
$savebill = $this->db_onedev->query($sqlbill);
|
|
|
|
$result = array("url" => "http://" . $_SERVER['SERVER_NAME'] . "/one-media/one-photo/" . $filename. "?d=" . date("YmdHis"));
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function editbill(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$pdate = date('Y-m-d',strtotime($prm['sdate']));
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE one_rujukan_eksternal.t_deliverycourier_confirm_issue SET
|
|
T_DeliveryCourierConfirmIssueM_BankAccountID = '{$prm['bankid']}',
|
|
T_DeliveryCourierConfirmIssueUserID = '{$userid}'
|
|
WHERE T_DeliveryCourierConfirmIssueT_DeliveryCourierID = '{$prm['id']}'
|
|
";
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $prm['id'];
|
|
$query ="UPDATE one_rujukan_eksternal.t_deliverycourier SET
|
|
T_DeliveryCourierNumberte = '{$prm['note']}',
|
|
T_DeliveryCourierUserID = '{$userid}'
|
|
WHERE T_DeliveryCourierID = '{$prm['id']}'
|
|
";
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$querylog ="
|
|
|
|
";
|
|
$insert_new_log = $this->db_onedev->query($querylog);
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
"id" => $last_id
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function sendorder(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$query ="UPDATE t_receivereferenceheader SET
|
|
T_ReceiveReferenceHeaderIsSent = 'Y',
|
|
T_ReceiveReferenceHeaderSentDate = now(),
|
|
T_ReceiveReferenceHeaderUserID = '{$userid}'
|
|
WHERE
|
|
T_ReceiveReferenceHeaderID = '{$prm['T_ReceiveReferenceHeaderID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
|
G_ReceiveReferenceHeaderStatusLogDate,
|
|
G_ReceiveReferenceHeaderStatusLogT_ReceiveReferenceHeaderID,
|
|
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
|
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
|
G_ReceiveReferenceHeaderStatusLogUserID,
|
|
G_ReceiveReferenceHeaderStatusLogCreated,
|
|
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
|
)
|
|
VALUES(
|
|
NOW(),
|
|
'{$prm['T_ReceiveReferenceHeaderID']}',
|
|
'2',
|
|
'{$userid}',
|
|
'{$userid}',
|
|
NOW(),
|
|
NOW()
|
|
)";
|
|
//echo $querylog;
|
|
$insert_new_log = $this->db_onedev->query($querylog);
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function save_patient() {
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$sql = "insert into one_rujukan_eksternal.t_deliverycourierdetail(T_DeliveryCourierDetailT_DeliveryCourierID, T_DeliveryCourierDetailT_OrderDeliveryID,
|
|
) values(?,?,?,?)";
|
|
$billID = $prm["billID"];
|
|
// print_r($prm);
|
|
exit;
|
|
foreach($prm["patients"] as $p) {
|
|
$orderID = $p["T_OrderDeliveryID"];
|
|
$total = $p["total"];
|
|
$this->db_onedev->query($sql,array($billID, $orderID, $total, $total));
|
|
}
|
|
$result = "Pasien saved";
|
|
$this->sys_ok($result);
|
|
}
|
|
function saveall_tempbill(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$billid = $prm['billID'];
|
|
$status = $prm['status'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach($prm['patients'] as $k=>$v){
|
|
$id = $v['Temp_DeliveryCourierID'];
|
|
if($status == 'Y' && $id == '0'){
|
|
|
|
$sql = "insert into one_rujukan_eksternal.temp_deliverycourier(
|
|
Temp_DeliveryCourierT_DeliveryCourierID,
|
|
Temp_DeliveryCourierM_StaffID,
|
|
Temp_DeliveryCourierT_OrderDeliveryID,
|
|
Temp_DeliveryCourierUserID,
|
|
Temp_DeliveryCourierCreated,
|
|
Temp_DeliveryCourierLastUpdated)
|
|
values(?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array($billid,
|
|
$v['M_UserID'],
|
|
$v['T_OrderDeliveryID'],
|
|
$userid)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("temp_deliverycourier insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
}elseif($status == 'N' && $id != '0'){
|
|
$sql = "UPDATE one_rujukan_eksternal.temp_deliverycourier SET
|
|
Temp_DeliveryCourierIsActive = 'N',
|
|
Temp_DeliveryCourierUserID = ?
|
|
WHERE Temp_DeliveryCourierID = ?";
|
|
$query = $this->db_onedev->query($sql,
|
|
array($userid,
|
|
$id
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("temp_deliverycourier update",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
$sqlsum = "select count(Temp_DeliveryCourierID) as ctot from one_rujukan_eksternal.temp_deliverycourier
|
|
LEFT JOIN one_rujukan_eksternal.t_deliverycourierdetail ON T_DeliveryCourierDetailT_OrderDeliveryID = Temp_DeliveryCourierT_OrderDeliveryID AND T_DeliveryCourierDetailIsActive <> 'N'
|
|
LEFT JOIN one_rujukan_eksternal.t_deliverycourier ON T_DeliveryCourierID=T_DeliveryCourierDetailT_DeliveryCourierID AND T_DeliveryCourierIsActive = 'Y'
|
|
where Temp_DeliveryCourierT_DeliveryCourierID=? AND Temp_DeliveryCourierIsActive = 'Y' AND T_DeliveryCourierDetailID is null";
|
|
$rstsum = $this->db_onedev->query($sqlsum,array($billid))->row();
|
|
$sumtotal = $rstsum->sumtot;
|
|
$ctotal = $rstsum->ctot;
|
|
|
|
$result = array ("total" => 1, "ctotal" => $ctotal,"sumtotal" => $sumtotal,"records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}
|
|
|
|
function save_tempbill(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$staffid = $prm['M_UserID'];
|
|
$billid = $prm['billid'];
|
|
$headerid = $prm['headerid'];
|
|
$status = $prm['checx'];
|
|
$total = $prm['total'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
|
|
if($status == 'Y' && $id == '0'){
|
|
$sql = "insert into one_rujukan_eksternal.temp_deliverycourier(
|
|
Temp_DeliveryCourierT_DeliveryCourierID,
|
|
Temp_DeliveryCourierM_StaffID,
|
|
Temp_DeliveryCourierT_OrderDeliveryID,
|
|
Temp_DeliveryCourierUserID,
|
|
Temp_DeliveryCourierCreated,
|
|
Temp_DeliveryCourierLastUpdated)
|
|
values(?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array($billid,
|
|
$staffid,
|
|
$headerid,
|
|
$userid)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("temp_deliverycourier insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$last_id = $this->db_onedev->insert_id();
|
|
$sqlsum = "select count(Temp_DeliveryCourierID) as ctot from one_rujukan_eksternal.temp_deliverycourier
|
|
LEFT JOIN one_rujukan_eksternal.t_deliverycourierdetail ON T_DeliveryCourierDetailT_OrderDeliveryID = Temp_DeliveryCourierT_OrderDeliveryID AND T_DeliveryCourierDetailIsActive <> 'N'
|
|
LEFT JOIN one_rujukan_eksternal.t_deliverycourier ON T_DeliveryCourierID=T_DeliveryCourierDetailT_DeliveryCourierID AND T_DeliveryCourierIsActive = 'Y'
|
|
where Temp_DeliveryCourierT_DeliveryCourierID=? AND Temp_DeliveryCourierIsActive = 'Y' AND T_DeliveryCourierDetailID is null";
|
|
$rstsum = $this->db_onedev->query($sqlsum,array($billid))->row();
|
|
$ctotal = $rstsum->ctot;
|
|
|
|
$result = array ("total" => 1, "ctotal" => $ctotal,"records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
}elseif($status == 'N' && $id != '0'){
|
|
$sql = "UPDATE one_rujukan_eksternal.temp_deliverycourier SET
|
|
Temp_DeliveryCourierIsActive = 'N',
|
|
Temp_DeliveryCourierUserID = ?
|
|
WHERE Temp_DeliveryCourierID = ?";
|
|
$query = $this->db_onedev->query($sql,
|
|
array($userid,
|
|
$id
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("temp_deliverycourier update",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$last_id = $this->db_onedev->insert_id();
|
|
$sqlsum = "select count(Temp_DeliveryCourierID) as ctot from one_rujukan_eksternal.temp_deliverycourier
|
|
LEFT JOIN one_rujukan_eksternal.t_deliverycourierdetail ON T_DeliveryCourierDetailT_OrderDeliveryID = Temp_DeliveryCourierT_OrderDeliveryID AND T_DeliveryCourierDetailIsActive <> 'N'
|
|
LEFT JOIN one_rujukan_eksternal.t_deliverycourier ON T_DeliveryCourierID=T_DeliveryCourierDetailT_DeliveryCourierID AND T_DeliveryCourierIsActive = 'Y'
|
|
where Temp_DeliveryCourierT_DeliveryCourierID=? AND Temp_DeliveryCourierIsActive = 'Y' AND T_DeliveryCourierDetailID is null";
|
|
$rstsum = $this->db_onedev->query($sqlsum,array($billid))->row();
|
|
$ctotal = $rstsum->ctot;
|
|
|
|
$result = array ("total" => 1, "ctotal" => $ctotal,"records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}
|
|
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
function getpatient(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$billID = $prm["id"];
|
|
$mouID = $prm["userid"];
|
|
$branchid = $prm["branchid"];
|
|
$startdate = $prm["startdate"];
|
|
$enddate = $prm["enddate"];
|
|
$search = $prm["search"];
|
|
$sql = "select count(*) tot from one_rujukan_eksternal.t_deliverycourierdetail where T_DeliveryCourierDetailT_DeliveryCourierID=?";
|
|
$rst = $this->db_onedev->query($sql,array($billID))->row();
|
|
//echo $this->db_onedev->last_query();
|
|
|
|
|
|
if ($rst->tot > 0 ) {
|
|
$sql = "select T_DeliveryCourierDetailID,
|
|
T_DeliveryCourierDetailT_DeliveryCourierID,
|
|
T_DeliveryCourierDetailT_OrderDeliveryID,
|
|
T_OrderDeliveryNumber,
|
|
DATE_FORMAT(T_OrderDeliveryDate,'%d-%m-%Y') as sdate,
|
|
T_OrderDeliveryDate,
|
|
M_CompanyAddress as address,
|
|
M_CompanyName as pasienname,
|
|
'' as tes,
|
|
'xxx' as tests,
|
|
'' as action,
|
|
T_DeliveryCourierDetailT_DeliveryCourierID as doid,
|
|
CONCAT(T_OrderDeliveryStaffUsername , ' | ', T_OrderDeliveryStaffHp) as pic,
|
|
T_OrderDeliveryNote,
|
|
'' as tes,
|
|
'xxx' as tests,
|
|
'' as action,
|
|
'' as issend,
|
|
'' as isoperadd,
|
|
'' as isnew,
|
|
'' as isopermin,
|
|
IFNULL(T_WhatsAppIsSent,'N') as T_WhatsAppIsSent
|
|
FROM one_rujukan_eksternal.t_deliverycourierdetail
|
|
join one_rujukan_eksternal.t_orderdelivery ON T_OrderDeliveryID = T_DeliveryCourierDetailT_OrderDeliveryID
|
|
left join m_company ON M_CompanyID = T_OrderDeliveryM_CompanyID
|
|
left join one_rujukan_eksternal.t_whatsapp ON T_WhatsAppT_OrderDeliveryID = T_OrderDeliveryID AND T_WhatsAppIsActive = 'Y'
|
|
WHERE
|
|
T_DeliveryCourierDetailIsActive <> 'N' and T_DeliveryCourierDetailT_DeliveryCourierID = '{$billID}'
|
|
GROUP BY T_OrderDeliveryID
|
|
ORDER BY T_OrderDeliveryID ASC";
|
|
|
|
|
|
} else {
|
|
$sql = "SELECT *, IF(T_DeliveryCourierDetailID IS NULL,'N','Y') as isbill,
|
|
T_DeliveryCourierNumber,
|
|
IF(Temp_DeliveryCourierID = 0 ,'N','Y') as checx,
|
|
IF(Temp_DeliveryCourierID = 0,'false','true') as chex
|
|
FROM (select
|
|
T_OrderDeliveryID,
|
|
T_OrderDeliveryNumber,
|
|
T_DeliveryCourierDetailID,
|
|
DATE_FORMAT(T_OrderDeliveryDate,'%d-%m-%Y') as sdate,
|
|
T_OrderDeliveryDate,
|
|
M_CompanyAddress as address,
|
|
M_CompanyName as pasienname,
|
|
'' as tes,
|
|
'xxx' as tests,
|
|
'' as action,
|
|
IFNULL(Temp_DeliveryCourierID,0) as Temp_DeliveryCourierID,
|
|
T_DeliveryCourierID as doid,
|
|
T_DeliveryCourierM_StaffID as M_UserID,
|
|
T_DeliveryCourierDate as sjdate,
|
|
T_DeliveryCourierNumber,
|
|
CONCAT(T_OrderDeliveryStaffUsername , ' | ', T_OrderDeliveryStaffHp) as pic,
|
|
T_OrderDeliveryNote
|
|
FROM one_rujukan_eksternal.t_orderdelivery
|
|
join one_rujukan_eksternal.t_deliverycourier on T_DeliveryCourierID = '{$billID}'
|
|
LEFT JOIN one_rujukan_eksternal.t_deliverycourierdetail ON T_OrderDeliveryID = T_DeliveryCourierDetailT_OrderDeliveryID AND T_DeliveryCourierDetailIsActive <> 'N'
|
|
left join one_rujukan_eksternal.temp_deliverycourier ON Temp_DeliveryCourierT_DeliveryCourierID = T_DeliveryCourierID AND Temp_DeliveryCourierM_StaffID = T_DeliveryCourierM_StaffID AND Temp_DeliveryCourierT_OrderDeliveryID = T_OrderDeliveryID AND Temp_DeliveryCourierIsActive = 'Y'
|
|
left join m_company ON M_CompanyID = T_OrderDeliveryM_CompanyID
|
|
WHERE
|
|
T_OrderDeliveryIsActive = 'Y' AND
|
|
T_OrderDeliveryT_DeliverytypeID = 1 AND
|
|
T_DeliveryCourierDetailID IS NULL
|
|
AND (T_OrderDeliveryNumber like concat('%','{$search}','%'))
|
|
GROUP BY T_OrderDeliveryID
|
|
ORDER BY T_OrderDeliveryID ASC) a
|
|
GROUP BY T_OrderDeliveryID
|
|
";
|
|
|
|
}
|
|
//echo $sql;
|
|
$qry = $this->db_onedev->query($sql);
|
|
//echo $this->db_onedev->last_query();
|
|
$rows = array();
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
}
|
|
$sqlsum = "select count(Temp_DeliveryCourierID) as ctot from one_rujukan_eksternal.temp_deliverycourier
|
|
LEFT JOIN one_rujukan_eksternal.t_deliverycourierdetail ON T_DeliveryCourierDetailT_OrderDeliveryID = Temp_DeliveryCourierT_OrderDeliveryID AND T_DeliveryCourierDetailIsActive <> 'N'
|
|
LEFT JOIN one_rujukan_eksternal.t_deliverycourier ON T_DeliveryCourierID=T_DeliveryCourierDetailT_DeliveryCourierID AND T_DeliveryCourierIsActive = 'Y'
|
|
where Temp_DeliveryCourierT_DeliveryCourierID=? AND Temp_DeliveryCourierIsActive = 'Y' AND T_DeliveryCourierDetailID is null";
|
|
$rstsum = $this->db_onedev->query($sqlsum,array($billID))->row();
|
|
$sumtotal = $rstsum->sumtot;
|
|
$ctotal = $rstsum->ctot;
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
"ctotal" => $ctotal
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function add_test($orderid){
|
|
$query =" SELECT t_receivereferencetest.*, t_test.*,'Y' as editable, T_ReceiveReferenceTestT_TestID as xid,
|
|
T_ReceiveReferenceTestT_TestPrice as T_PriceAmount,
|
|
T_ReceiveReferenceTestT_TestDisc as T_PriceDisc,
|
|
T_ReceiveReferenceTestT_TestDiscRp as T_PriceDiscRp,
|
|
T_ReceiveReferenceTestT_TestTotal as total
|
|
FROM t_receivereferencetest
|
|
JOIN t_receivereferencepatient ON T_ReceiveReferenceTestT_ReceiveReferencePatientID = T_ReceiveReferencePatientID
|
|
JOIN t_receivereferenceheader ON T_ReceiveReferencePatientT_ReceiveReferenceHeaderID = T_ReceiveReferenceHeaderID
|
|
JOIN t_test ON T_ReceiveReferenceTestT_TestID = T_TestID
|
|
WHERE
|
|
T_ReceiveReferenceTestT_ReceiveReferencePatientID = {$orderid} AND T_ReceiveReferenceTestIsActive = 'Y'
|
|
GROUP BY T_ReceiveReferenceTestID";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
if(!$rows)
|
|
$rows = array();
|
|
return $rows;
|
|
}
|
|
|
|
function savenewpatient(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$billID = $prm['billID'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach($prm['patients'] as $k=>$v){
|
|
$query = "INSERT INTO one_rujukan_eksternal.t_deliverycourierdetail
|
|
(T_DeliveryCourierDetailT_DeliveryCourierID,
|
|
T_DeliveryCourierDetailT_OrderDeliveryID,
|
|
T_DeliveryCourierDetailUserID,
|
|
T_DeliveryCourierDetailCreated,
|
|
T_DeliveryCourierDetailLastUpdated)
|
|
VALUE(
|
|
?,?,?,now(),now()
|
|
)";
|
|
$insert_new_test = $this->db_onedev->query($query,array(
|
|
$billID,
|
|
$v['T_OrderDeliveryID'],
|
|
$userid
|
|
));
|
|
$last_id = $this->db_onedev->insert_id();
|
|
|
|
$sqltemp = "UPDATE one_rujukan_eksternal.temp_deliverycourier SET Temp_DeliveryCourierIsActive = 'N'
|
|
WHERE Temp_DeliveryCourierT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND Temp_DeliveryCourierT_DeliveryCourierID <> $billID";
|
|
$updatetemp = $this->db_onedev->query($sqltemp);
|
|
$t_id = $v['T_OrderDeliveryID'];
|
|
|
|
|
|
}
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function savebillmou(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$billID = $prm['billID'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach($prm['patients'] as $k=>$v){
|
|
$query = "INSERT INTO one_rujukan_eksternal.t_deliverycourier_confirm_mou
|
|
(T_DeliveryCourierConfirmMouT_DeliveryCourierID,
|
|
T_DeliveryCourierConfirmMouM_UserID,
|
|
T_DeliveryCourierConfirmMouUserID,
|
|
T_DeliveryCourierConfirmMouCreated,
|
|
T_DeliveryCourierConfirmMouLastUpdated)
|
|
VALUE(
|
|
?,?,?,?,?,now(),now()
|
|
)";
|
|
$insert_new_test = $this->db_onedev->query($query,array(
|
|
$billID,
|
|
$v['M_UserID'],
|
|
$userid
|
|
));
|
|
$last_id = $this->db_onedev->insert_id();
|
|
$querylog ="INSERT INTO one_rujukan_eksternal.t_deliverycourierstatuslog(
|
|
T_DeliveryCourierStatusLogName,
|
|
T_DeliveryCourierStatusLogDate,
|
|
T_DeliveryCourierStatusLogT_DeliveryCourierID,
|
|
T_DeliveryCourierStatusLogT_DeliveryCourierDetailID,
|
|
T_DeliveryCourierStatusLogT_OrderDeliveryID,
|
|
T_DeliveryCourierStatusLogStatus,
|
|
T_DeliveryCourierStatusLogStatusName,
|
|
T_DeliveryCourierStatusLogUserID,
|
|
T_DeliveryCourierStatusLogCreated,
|
|
T_DeliveryCourierStatusLogLastUpdated)
|
|
VALUES(
|
|
'DELIVERY ORDER',
|
|
date(now()),
|
|
$last_id,
|
|
0,
|
|
0,
|
|
'N',
|
|
'Baru',
|
|
$userid,
|
|
NOW(),
|
|
NOW()
|
|
)";
|
|
// echo $querylog;
|
|
$insert_new_log = $this->db_onedev->query($querylog);
|
|
|
|
}
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function saveeditpatient(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$order_id = $prm['T_ReceiveReferencePatientID'];
|
|
$pdob = date('Y-m-d',strtotime($prm['T_ReceiveReferencePatientDOB']));
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE t_receivereferencepatient SET
|
|
T_ReceiveReferencePatientT_ReceiveReferenceHeaderID = '{$prm['T_ReceiveReferencePatientT_ReceiveReferenceHeaderID']}',
|
|
T_ReceiveReferencePatientNoRef = '{$prm['T_ReceiveReferencePatientNoRef']}',
|
|
T_ReceiveReferencePatientName = '{$prm['T_ReceiveReferencePatientName']}',
|
|
T_ReceiveReferencePatientDOB = '{$pdob}',
|
|
T_ReceiveReferencePatientM_SexID = '{$prm['T_ReceiveReferencePatientM_SexID']}',
|
|
T_ReceiveReferencePatientTotal = '{$prm['T_ReceiveReferencePatientTotal']}',
|
|
T_ReceiveReferencePatientDPPercent = '{$prm['T_ReceiveReferencePatientDPPercent']}',
|
|
T_ReceiveReferencePatientDPAmount = '{$prm['T_ReceiveReferencePatientDPAmount']}',
|
|
T_ReceiveReferencePatientUserID = '{$userid}'
|
|
WHERE
|
|
T_ReceiveReferencePatientID = '{$prm['T_ReceiveReferencePatientID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
foreach($prm['ordertests'] as $k=>$v){
|
|
if($v['xid'] == 0 || $v['xid'] == '0'){
|
|
$query = "INSERT INTO t_receivereferencetest (
|
|
T_ReceiveReferenceTestT_ReceiveReferencePatientID,
|
|
T_ReceiveReferenceTestT_TestID,
|
|
T_ReceiveReferenceTestT_TestCode,
|
|
T_ReceiveReferenceTestT_TestName,
|
|
T_ReceiveReferenceTestT_TestPrice,
|
|
T_ReceiveReferenceTestUserID,
|
|
T_ReceiveReferenceTestCreated,
|
|
T_ReceiveReferenceTestLastUpdated
|
|
)
|
|
VALUE(
|
|
?,?,?,?,?,?,now(),now()
|
|
)";
|
|
$insert_new_test = $this->db_onedev->query($query,array(
|
|
$order_id,
|
|
$v['T_TestID'],
|
|
$v['T_TestCode'],
|
|
$v['T_TestName'],
|
|
$v['total'],
|
|
$userid
|
|
));
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($prm['deleted_ordertests'])){
|
|
foreach($prm['deleted_ordertests'] as $i=>$del){
|
|
|
|
$query = "UPDATE t_receivereferencetest SET
|
|
T_ReceiveReferenceTestIsActive = 'N',
|
|
T_ReceiveReferenceTestUserID = '{$userid}',
|
|
T_ReceiveReferenceTestLastUpdated = now()
|
|
WHERE
|
|
T_ReceiveReferenceTestID = ?
|
|
";
|
|
$delete_exist_test = $this->db_onedev->query($query,array($del['T_ReceiveReferenceTestID'],));
|
|
}
|
|
}
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function deletebill(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE one_rujukan_eksternal.t_deliverycourier SET
|
|
T_DeliveryCourierIsActive = 'N',
|
|
T_DeliveryCourierUserID = '{$userid}'
|
|
WHERE
|
|
T_DeliveryCourierID = '{$prm['id']}'";
|
|
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$query ="UPDATE one_rujukan_eksternal.t_deliverycourierdetail SET
|
|
T_DeliveryCourierDetailIsActive = 'N',
|
|
T_DeliveryCourierDetailUserID = '{$userid}'
|
|
WHERE
|
|
T_DeliveryCourierDetailT_DeliveryCourierID = '{$prm['id']}'";
|
|
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function notifbill(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE one_rujukan_eksternal.t_deliverycourier SET
|
|
T_DeliveryCourierStatus = 'C',
|
|
T_DeliveryCourierUserID = '{$userid}',
|
|
T_DeliveryCourierLastUpdated = now()
|
|
WHERE
|
|
T_DeliveryCourierID = '{$prm['id']}'";
|
|
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$querydo ="UPDATE one_rujukan_eksternal.t_orderdelivery
|
|
JOIN one_rujukan_eksternal.t_deliverycourierdetail ON T_DeliveryCourierDetailT_OrderDeliveryID = T_OrderDeliveryID
|
|
AND T_DeliveryCourierDetailT_DeliveryCourierID = '{$prm['id']}'
|
|
AND T_DeliveryCourierDetailIsActive = 'Y'
|
|
SET T_OrderDeliveryStatus = 'U'
|
|
WHERE T_OrderDeliveryIsActive = 'Y'";
|
|
|
|
//echo $query;
|
|
$rowsdo = $this->db_onedev->query($querydo);
|
|
|
|
$querydetail ="UPDATE one_rujukan_eksternal.t_deliverycourierdetail SET
|
|
T_DeliveryCourierDetailStatus = 'C',
|
|
T_DeliveryCourierDetailUserID = '{$userid}',
|
|
T_DeliveryCourierDetailLastUpdated = now()
|
|
WHERE
|
|
T_DeliveryCourierDetailT_DeliveryCourierID = '{$prm['id']}'";
|
|
|
|
// echo $query;
|
|
$rowsdetail = $this->db_onedev->query($querydetail);
|
|
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function renotifbill(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE one_rujukan_eksternal.t_whatsapp SET
|
|
T_WhatsAppIsSent = 'R',
|
|
T_WhatsAppUserID = '{$userid}',
|
|
T_WhatsAppLastUpdated = now()
|
|
WHERE
|
|
T_WhatsAppT_OrderDeliveryID = '{$prm['id']}'
|
|
AND
|
|
T_WhatsAppT_DeliveryCourierID = '{$prm['doid']}'
|
|
AND
|
|
T_WhatsAppIsActive = 'Y'";
|
|
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function sendbill() {
|
|
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']);
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$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/keu/titip_tagihan/upload/".$id."/".$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 deletepatient(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE one_rujukan_eksternal.t_deliverycourierdetail SET
|
|
T_DeliveryCourierDetailIsActive = 'N',
|
|
T_DeliveryCourierDetailUserID = '{$userid}'
|
|
WHERE
|
|
T_DeliveryCourierDetailID = '{$prm['T_DeliveryCourierDetailID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function searchtest(){
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count = 0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
$mou_id = $prm['mouid'];
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM t_test
|
|
JOIN t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_UserID = '{$mou_id}'
|
|
WHERE
|
|
T_TestName like ? AND
|
|
T_TestIsActive = 'Y'
|
|
ORDER BY T_TestName ASC";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("test count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT 'Y' as editable,
|
|
0 as xid,
|
|
T_TestID,
|
|
T_TestCode,
|
|
T_TestName, T_PriceAmount, T_PriceDisc, T_PriceDiscRp, T_PriceAmount - ((T_PriceDisc/100) * T_PriceAmount) - T_PriceDiscRp as total,
|
|
M_StaffID,'N' as M_StaffIsBill, 0 as M_StaffMinDP
|
|
FROM one.t_test
|
|
JOIN one.t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_UserID = '{$mou_id}'
|
|
JOIN one.m_mou ON M_UserID = '{$mou_id}'
|
|
JOIN one.m_staff ON M_UserM_StaffID = M_StaffID
|
|
WHERE
|
|
T_TestName like ? AND
|
|
T_TestIsActive = 'Y'
|
|
ORDER BY T_TestName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("test rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
public function upload()
|
|
{
|
|
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$inp = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$receive_date = date('Y-m-d H:i:s',strtotime($prm['rdate']));
|
|
$home_dir = "/home/one/project/one/";
|
|
$target_dir = $home_dir . "one-media/one-photo/";
|
|
|
|
if (!file_exists($target_dir)) {
|
|
mkdir($target_dir, 0755, true);
|
|
}
|
|
$filename = date("YmdHis")."_".$inp['billNo'] . ".jpg";
|
|
$target_path = $target_dir . $filename;
|
|
$this->base64_to_jpeg($inp['img'], $target_path);
|
|
$sql = "UPDATE one_rujukan_eksternal.t_deliverycourier_confirm_issue SET T_DeliveryCourierConfirmIssueImg = '{$filename}',
|
|
T_DeliveryCourierConfirmIssueIsReceive = 'Y',
|
|
T_DeliveryCourierConfirmIssueReceiveDate = '{$inp['rtanggal']}',
|
|
T_DeliveryCourierConfirmIssueReceiveUserID = {$userid}
|
|
WHERE T_DeliveryCourierConfirmIssueID = {$inp['idx']}";
|
|
//echo $sql;
|
|
$save = $this->db_onedev->query($sql);
|
|
|
|
$sqlbill = "UPDATE one_rujukan_eksternal.t_deliverycourier SET T_DeliveryCourierDueDate = '{$inp['sdate']}'
|
|
WHERE T_DeliveryCourierID = {$inp['idbill']}";
|
|
//echo $sqlbill;
|
|
$savebill = $this->db_onedev->query($sqlbill);
|
|
|
|
$sqllog = "INSERT INTO one_rujukan_eksternal.t_deliverycourier_receive_log (T_DeliveryCourierReceiveLogT_DeliveryCourierConfirmIssueID,
|
|
T_DeliveryCourierReceiveLogDate,
|
|
T_DeliveryCourierReceiveLogImg,
|
|
T_DeliveryCourierReceiveLogUserID,
|
|
T_DeliveryCourierReceiveLogCreated,
|
|
T_DeliveryCourierReceiveLogLastUpdated)
|
|
VALUES
|
|
({$inp['idx']},
|
|
'{$inp['rtanggal']}',
|
|
'{$filename}',
|
|
{$userid},
|
|
now(),
|
|
now())";
|
|
//echo $sqllog;
|
|
$savelog = $this->db_onedev->query($sqllog);
|
|
|
|
$result = array("url" => "http://" . $_SERVER['SERVER_NAME'] . "/one-media/one-photo/" . $filename. "?d=" . date("YmdHis"));
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
public function uploadsend()
|
|
{
|
|
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$inp = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$receive_date = date('Y-m-d H:i:s',strtotime($prm['rdate']));
|
|
$home_dir = "/home/one/project/one/";
|
|
$target_dir = $home_dir . "one-media/one-photo/";
|
|
|
|
if (!file_exists($target_dir)) {
|
|
mkdir($target_dir, 0755, true);
|
|
}
|
|
$filename = date("YmdHis")."_".$inp['billNo'] . "_send.jpg";
|
|
$target_path = $target_dir . $filename;
|
|
$this->base64_to_jpeg($inp['img'], $target_path);
|
|
$sql = "UPDATE one_rujukan_eksternal.t_deliverycourier_confirm_issue SET T_DeliveryCourierConfirmIssueImgSend = '{$filename}',
|
|
T_DeliveryCourierConfirmIssueSendUserID = {$userid}
|
|
WHERE T_DeliveryCourierConfirmIssueID = {$inp['idx']}";
|
|
//echo $sql;
|
|
$save = $this->db_onedev->query($sql);
|
|
|
|
$result = array("url" => "http://" . $_SERVER['SERVER_NAME'] . "/one-media/one-photo/" . $filename. "?d=" . date("YmdHis"));
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function base64_to_jpeg($base64_string, $output_file) {
|
|
// open the output file for writing
|
|
$ifp = fopen( $output_file, 'wb' );
|
|
|
|
// split the string on commas
|
|
// $data[ 0 ] == "data:image/png;base64"
|
|
// $data[ 1 ] == <actual base64 string>
|
|
$data = explode( ',', $base64_string );
|
|
|
|
// we could add validation here with ensuring count( $data ) > 1
|
|
fwrite( $ifp, base64_decode( $data[ 1 ] ) );
|
|
|
|
// clean up the file resource
|
|
fclose( $ifp );
|
|
|
|
return $output_file;
|
|
}
|
|
|
|
}
|