1326 lines
56 KiB
PHP
1326 lines
56 KiB
PHP
<?php
|
|
class List 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_TransactionIsActive = 'Y'";
|
|
}else{
|
|
$sql_where = "WHERE T_TransactionIsActive = 'Y' AND HS_DeliveryOrderStatus = '{$status}'";
|
|
}
|
|
$sql_param = array();
|
|
if ($nama != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " GROUP_CONCAT(DISTINCT M_PatientName SEPARATOR ',') like ? ";
|
|
$sql_param[] = "%$nama%";
|
|
}
|
|
if ($norm != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " concat(T_TransactionNumbering) like ? ";
|
|
$sql_param[] = "%$norm%";
|
|
}
|
|
|
|
|
|
$sql = " SELECT count(*) as total
|
|
FROM one_hs.t_transaction
|
|
JOIN one_hs.t_transactionHS ON t_transactionHST_TransactionID = T_TransactionID AND t_transactionHSIsActive = 'Y'
|
|
JOIN one_hs.t_order ON T_OrderT_TransactionID = T_TransactionID
|
|
LEFT JOIN one_hs.hs_deliveryorderdetail ON HS_DeliveryOrderDetailT_TransactionID = T_TransactionID AND HS_DeliveryOrderDetailIsActive = 'Y'
|
|
LEFT JOIN one_hs.hs_deliveryorder ON HS_DeliveryOrderID = HS_DeliveryOrderDetailHS_DeliveryOrderID AND HS_DeliveryOrderIsActive = 'Y'
|
|
left join m_user ON M_UserID = HS_DeliveryOrderM_UserID
|
|
$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_hs.hs_deliveryorder count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT
|
|
HS_DeliveryOrderID,
|
|
HS_DeliveryOrderNumber,
|
|
HS_DeliveryOrderDate,
|
|
HS_DeliveryOrderDateHS,
|
|
CONCAT(DATE_FORMAT(T_OrderDate,'%d-%m-%Y'), ' ',T_OrderTime) as hsdate,
|
|
HS_DeliveryOrderTotal,
|
|
HS_DeliveryOrderStatus,
|
|
HS_DeliveryOrderUserID,
|
|
M_UserID,
|
|
M_StaffID,
|
|
CONCAT(M_StaffName, ' [',M_UserUsername,']') as M_StaffName,
|
|
CASE
|
|
WHEN HS_DeliveryOrderStatus = 'N' THEN 'Baru'
|
|
WHEN HS_DeliveryOrderStatus = 'G' THEN 'Berangkat'
|
|
WHEN HS_DeliveryOrderStatus = 'P' THEN 'Proses'
|
|
WHEN HS_DeliveryOrderStatus = 'D' THEN 'Selesai'
|
|
ELSE ''
|
|
END as status,
|
|
HS_DeliveryOrderDetailID,
|
|
HS_DeliveryOrderDetailHS_DeliveryOrderID,
|
|
HS_DeliveryOrderDetailT_TransactionID,
|
|
HS_DeliveryOrderDetailTotal,
|
|
HS_DeliveryOrderDetailIsPaid,
|
|
T_TransactionNumbering,
|
|
T_OrderDate,
|
|
T_OrderTime,
|
|
HS_DeliveryOrderDetailTotal as total,
|
|
HS_AddressAddress as address,
|
|
GROUP_CONCAT(DISTINCT M_PatientName SEPARATOR ',') as pasienname
|
|
|
|
FROM
|
|
one_hs.t_transaction
|
|
JOIN one_hs.t_transactionHS ON t_transactionHST_TransactionID = T_TransactionID AND t_transactionHSIsActive = 'Y'
|
|
JOIN one_hs.t_order ON T_OrderT_TransactionID = T_TransactionID
|
|
LEFT JOIN one_hs.hs_deliveryorderdetail ON HS_DeliveryOrderDetailT_TransactionID = T_TransactionID AND HS_DeliveryOrderDetailIsActive = 'Y'
|
|
LEFT JOIN one_hs.hs_deliveryorder ON HS_DeliveryOrderID = HS_DeliveryOrderDetailHS_DeliveryOrderID AND HS_DeliveryOrderIsActive = 'Y'
|
|
left join m_user ON M_UserID = HS_DeliveryOrderM_UserID
|
|
left join m_staff ON M_StaffID = M_UserM_StaffID
|
|
$sql_where
|
|
AND ( T_OrderDate BETWEEN '{$startdate} 00:00:00' AND '{$enddate} 23:59:59' )
|
|
ORDER BY T_TransactionID DESC
|
|
limit 0,$tot_count ";
|
|
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$rows = $query->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
$x = $this->db_onedev->query("
|
|
select count(*) as tot
|
|
FROM one_hs.hs_deliveryorderdetail
|
|
WHERE HS_DeliveryOrderDetailHS_DeliveryOrderID = '{$v['HS_DeliveryOrderID']}'")->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
|
|
JOIN m_user ON M_UserM_StaffID = M_StaffID AND M_UserIsActive = 'Y'
|
|
WHERE
|
|
CONCAT(M_StaffName, ' [',M_UserUsername,']') like ?
|
|
AND M_StaffIsActive = '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_staff count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT M_UserID as M_StaffID, CONCAT(M_StaffName, ' [',M_UserUsername,']') as M_StaffName
|
|
FROM m_staff
|
|
JOIN m_user ON M_UserM_StaffID = M_StaffID AND M_UserIsActive = 'Y'
|
|
WHERE
|
|
CONCAT(M_StaffName, ' [',M_UserUsername,']') like ?
|
|
AND M_StaffIsActive = 'Y'
|
|
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_PatientDOB']));
|
|
$query ="UPDATE m_patient SET
|
|
M_PatientM_TitleID = '{$prm['M_PatientM_TitleID']}',
|
|
M_PatientName = '{$prm['M_PatientName']}',
|
|
M_PatientDOB = '{$pdob}',
|
|
M_PatientM_SexID = '{$prm['M_PatientM_SexID']}',
|
|
M_PatientM_ReligionID = '{$prm['M_PatientM_ReligionID']}',
|
|
M_PatientEmail = '{$prm['M_PatientEmail']}',
|
|
M_PatientHP = '{$prm['M_PatientHP']}',
|
|
M_PatientPhone = '{$prm['M_PatientPhone']}',
|
|
M_PatientM_IdTypeID = '{$prm['M_PatientM_IdTypeID']}',
|
|
M_PatientIDNumber = '{$prm['M_PatientIDNumber']}',
|
|
M_PatientNote = '{$prm['M_PatientNote']}'
|
|
WHERE
|
|
M_PatientID = '{$prm['M_PatientID']}'
|
|
";
|
|
//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_hs.hs_deliveryorder (
|
|
HS_DeliveryOrderNumber,
|
|
HS_DeliveryOrderDate,
|
|
HS_DeliveryOrderDateHS,
|
|
HS_DeliveryOrderM_UserID,
|
|
HS_DeliveryOrderNote,
|
|
HS_DeliveryOrderUserID,
|
|
HS_DeliveryOrderCreated,
|
|
HS_DeliveryOrderLastUpdated
|
|
)
|
|
VALUES(
|
|
`fn_numbering`('HSDO'),
|
|
date(now()),
|
|
'{$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_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 HS_DeliveryOrderNumber as billNo from one_hs.hs_deliveryorder
|
|
where HS_DeliveryOrderID = $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_hs.hs_deliveryorder_confirm_issue SET HS_DeliveryOrderConfirmIssueImg = '{$filename}',
|
|
HS_DeliveryOrderConfirmIssueIsReceive = 'Y',
|
|
HS_DeliveryOrderConfirmIssueReceiveDate = '{$tanggal}',
|
|
HS_DeliveryOrderConfirmIssueReceiveUserID = {$userid}
|
|
WHERE HS_DeliveryOrderConfirmIssueID = {$idconfirm}";
|
|
//echo $sql;
|
|
$save = $this->db_onedev->query($sql);
|
|
|
|
$sqlbill = "UPDATE one_hs.hs_deliveryorder SET HS_DeliveryOrderDueDate = '{$sdate}'
|
|
WHERE HS_DeliveryOrderID = {$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_hs.hs_deliveryorder_confirm_issue SET
|
|
HS_DeliveryOrderConfirmIssueM_BankAccountID = '{$prm['bankid']}',
|
|
HS_DeliveryOrderConfirmIssueUserID = '{$userid}'
|
|
WHERE HS_DeliveryOrderConfirmIssueHS_DeliveryOrderID = '{$prm['id']}'
|
|
";
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $prm['id'];
|
|
$query ="UPDATE one_hs.hs_deliveryorder SET
|
|
HS_DeliveryOrderNumberte = '{$prm['note']}',
|
|
HS_DeliveryOrderUserID = '{$userid}'
|
|
WHERE HS_DeliveryOrderID = '{$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_hs.hs_deliveryorderdetail(HS_DeliveryOrderDetailHS_DeliveryOrderID, HS_DeliveryOrderDetailT_TransactionID,
|
|
HS_DeliveryOrderDetailTotal, HS_DeliveryOrderDetailUnpaid) values(?,?,?,?)";
|
|
$billID = $prm["billID"];
|
|
// print_r($prm);
|
|
exit;
|
|
foreach($prm["patients"] as $p) {
|
|
$orderID = $p["T_TransactionID"];
|
|
$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_DeliveryOrderID'];
|
|
if($status == 'Y' && $id == '0'){
|
|
|
|
$sql = "insert into one_hs.temp_delivery_order(
|
|
Temp_DeliveryOrderHS_DeliveryOrderID,
|
|
Temp_DeliveryOrderM_UserID,
|
|
Temp_DeliveryOrderT_TransactionID,
|
|
Temp_DeliveryOrderUserID,
|
|
Temp_DeliveryOrderTotal,
|
|
Temp_DeliveryOrderCreated,
|
|
Temp_DeliveryOrderLastUpdated)
|
|
values(?,?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array($billid,
|
|
$v['M_UserID'],
|
|
$v['T_TransactionID'],
|
|
$userid,
|
|
$v['total'],)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("temp_delivery_order insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
}elseif($status == 'N' && $id != '0'){
|
|
$sql = "UPDATE one_hs.temp_delivery_order SET
|
|
Temp_DeliveryOrderIsActive = 'N',
|
|
Temp_DeliveryOrderUserID = ?
|
|
WHERE Temp_DeliveryOrderID = ?";
|
|
$query = $this->db_onedev->query($sql,
|
|
array($userid,
|
|
$id
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("temp_delivery_order update",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
$sqlsum = "select format(sum(IFNULL(Temp_DeliveryOrderTotal,0)),0) sumtot, count(Temp_DeliveryOrderID) as ctot from one_hs.temp_delivery_order
|
|
LEFT JOIN one_hs.hs_deliveryorderdetail ON HS_DeliveryOrderDetailT_TransactionID = Temp_DeliveryOrderT_TransactionID AND HS_DeliveryOrderDetailIsActive = 'Y'
|
|
LEFT JOIN one_hs.hs_deliveryorder ON HS_DeliveryOrderID=HS_DeliveryOrderDetailHS_DeliveryOrderID AND HS_DeliveryOrderIsActive = 'Y'
|
|
where Temp_DeliveryOrderHS_DeliveryOrderID=? AND Temp_DeliveryOrderIsActive = 'Y' AND HS_DeliveryOrderDetailID 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'];
|
|
$mouid = $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_hs.temp_delivery_order(
|
|
Temp_DeliveryOrderHS_DeliveryOrderID,
|
|
Temp_DeliveryOrderM_UserID,
|
|
Temp_DeliveryOrderT_TransactionID,
|
|
Temp_DeliveryOrderUserID,
|
|
Temp_DeliveryOrderTotal,
|
|
Temp_DeliveryOrderCreated,
|
|
Temp_DeliveryOrderLastUpdated)
|
|
values(?,?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array($billid,
|
|
$mouid,
|
|
$headerid,
|
|
$userid,
|
|
$total)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("temp_delivery_order insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$last_id = $this->db_onedev->insert_id();
|
|
$sqlsum = "select format(sum(IFNULL(Temp_DeliveryOrderTotal,0)),0) sumtot, count(Temp_DeliveryOrderID) as ctot from one_hs.temp_delivery_order
|
|
LEFT JOIN one_hs.hs_deliveryorderdetail ON HS_DeliveryOrderDetailT_TransactionID = Temp_DeliveryOrderT_TransactionID AND HS_DeliveryOrderDetailIsActive = 'Y'
|
|
LEFT JOIN one_hs.hs_deliveryorder ON HS_DeliveryOrderID=HS_DeliveryOrderDetailHS_DeliveryOrderID AND HS_DeliveryOrderIsActive = 'Y'
|
|
where Temp_DeliveryOrderHS_DeliveryOrderID=? AND Temp_DeliveryOrderIsActive = 'Y' AND HS_DeliveryOrderDetailID 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);
|
|
|
|
}elseif($status == 'N' && $id != '0'){
|
|
$sql = "UPDATE one_hs.temp_delivery_order SET
|
|
Temp_DeliveryOrderIsActive = 'N',
|
|
Temp_DeliveryOrderUserID = ?
|
|
WHERE Temp_DeliveryOrderID = ?";
|
|
$query = $this->db_onedev->query($sql,
|
|
array($userid,
|
|
$id
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("temp_delivery_order update",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$last_id = $this->db_onedev->insert_id();
|
|
$sqlsum = "select format(sum(IFNULL(Temp_DeliveryOrderTotal,0)),0) sumtot, count(Temp_DeliveryOrderID) as ctot from one_hs.temp_delivery_order
|
|
LEFT JOIN one_hs.hs_deliveryorderdetail ON HS_DeliveryOrderDetailT_TransactionID = Temp_DeliveryOrderT_TransactionID AND HS_DeliveryOrderDetailIsActive = 'Y'
|
|
LEFT JOIN one_hs.hs_deliveryorder ON HS_DeliveryOrderID=HS_DeliveryOrderDetailHS_DeliveryOrderID AND HS_DeliveryOrderIsActive = 'Y'
|
|
where Temp_DeliveryOrderHS_DeliveryOrderID=? AND Temp_DeliveryOrderIsActive = 'Y' AND HS_DeliveryOrderDetailID is null";
|
|
$rstsum = $this->db_onedev->query($sqlsum,array($billid))->row();
|
|
$sumtotal = $rstsum->sumtot;
|
|
$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_hs.hs_deliveryorderdetail where HS_DeliveryOrderDetailHS_DeliveryOrderID=?";
|
|
$rst = $this->db_onedev->query($sql,array($billID))->row();
|
|
//echo $this->db_onedev->last_query();
|
|
|
|
|
|
if ($rst->tot > 0 ) {
|
|
$sql = "select
|
|
HS_DeliveryOrderDetailID,
|
|
HS_DeliveryOrderDetailHS_DeliveryOrderID,
|
|
HS_DeliveryOrderDetailT_TransactionID,
|
|
HS_DeliveryOrderDetailTotal,
|
|
HS_DeliveryOrderDetailIsPaid,
|
|
T_TransactionNumbering,
|
|
T_OrderDate,
|
|
T_OrderTime,
|
|
HS_DeliveryOrderDetailTotal as total,
|
|
HS_AddressAddress as address,
|
|
GROUP_CONCAT(DISTINCT M_PatientName SEPARATOR ',') as pasienname,
|
|
'' as tes,
|
|
'xxx' as tests,
|
|
'' as action
|
|
FROM one_hs.hs_deliveryorderdetail
|
|
join one_hs.t_transaction ON T_TransactionID = HS_DeliveryOrderDetailT_TransactionID
|
|
join one_hs.t_order ON T_OrderT_TransactionID = T_TransactionID AND T_OrderIsActive = 'Y'
|
|
left join one_hs.t_transactionHS ON t_transactionHST_TransactionID = T_TransactionID
|
|
left join one_hs.hs_address ON t_transactionHSHS_AddressID = t_transactionHSHS_AddressID
|
|
left join one_hs.m_patient ON M_PatientID = T_OrderM_PatientID
|
|
WHERE
|
|
HS_DeliveryOrderDetailIsActive = 'Y' and HS_DeliveryOrderDetailHS_DeliveryOrderID = '{$billID}'
|
|
GROUP BY HS_DeliveryOrderDetailID
|
|
ORDER BY T_TransactionID ASC";
|
|
} else {
|
|
$sql = "SELECT *, IF(HS_DeliveryOrderNumber IS NULL ,'N','Y') as isbill,
|
|
HS_DeliveryOrderNumber,
|
|
IF(Temp_DeliveryOrderID = 0 OR HS_DeliveryOrderNumber IS NOT NULL,'N','Y') as checx,
|
|
IF(Temp_DeliveryOrderID = 0 OR HS_DeliveryOrderNumber IS NOT NULL,'false','true') as chex
|
|
FROM (select
|
|
T_TransactionID,
|
|
T_TransactionNumbering,
|
|
T_OrderDate,
|
|
T_OrderTime,
|
|
(T_TransactionTotal + T_TransactionFee) - T_TransactionDiscount as total,
|
|
HS_AddressAddress as address,
|
|
GROUP_CONCAT(DISTINCT M_PatientName SEPARATOR ',') as pasienname,
|
|
'' as tes,
|
|
'xxx' as tests,
|
|
'' as action,
|
|
IFNULL(Temp_DeliveryOrderID,0) as Temp_DeliveryOrderID,
|
|
HS_DeliveryOrderID as doid,
|
|
HS_DeliveryOrderM_UserID as M_UserID,
|
|
HS_DeliveryOrderDateHS as hsdate
|
|
FROM one_hs.t_transaction
|
|
join one_hs.t_order ON T_OrderT_TransactionID = T_TransactionID AND T_OrderIsActive = 'Y'
|
|
join one_hs.hs_deliveryorder on HS_DeliveryOrderID = '{$billID}'
|
|
LEFT JOIN one_hs.hs_deliveryorderdetail ON T_TransactionID = HS_DeliveryOrderDetailT_TransactionID AND HS_DeliveryOrderDetailIsActive = 'Y'
|
|
left join one_hs.temp_delivery_order ON Temp_DeliveryOrderHS_DeliveryOrderID = HS_DeliveryOrderID AND Temp_DeliveryOrderM_UserID = HS_DeliveryOrderM_UserID AND Temp_DeliveryOrderT_TransactionID = T_TransactionID AND Temp_DeliveryOrderIsActive = 'Y'
|
|
join one_hs.t_transactionHS ON t_transactionHST_TransactionID = T_TransactionID
|
|
left join one_hs.hs_address ON t_transactionHSHS_AddressID = t_transactionHSHS_AddressID
|
|
left join one_hs.m_patient ON M_PatientID = T_OrderM_PatientID
|
|
WHERE
|
|
T_TransactionIsActive = 'Y' AND
|
|
T_TransactionIsDeliveryOrder = 'N'
|
|
AND ( date(T_OrderDate) = '{$startdate}')
|
|
AND (T_TransactionNumbering like concat('%','{$search}','%'))
|
|
GROUP BY T_TransactionID
|
|
ORDER BY T_TransactionID ASC) a
|
|
LEFT JOIN one_hs.hs_deliveryorderdetail ON T_TransactionID = HS_DeliveryOrderDetailT_TransactionID AND HS_DeliveryOrderDetailIsActive = 'Y'
|
|
left join one_hs.hs_deliveryorder on HS_DeliveryOrderID = HS_DeliveryOrderDetailHS_DeliveryOrderID
|
|
";
|
|
|
|
}
|
|
//echo $sql;
|
|
$qry = $this->db_onedev->query($sql);
|
|
//echo $this->db_onedev->last_query();
|
|
$rows = array();
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
}
|
|
$sqlsum = "select format(sum(IFNULL(Temp_DeliveryOrderTotal,0)),0) sumtot, count(Temp_DeliveryOrderID) as ctot from one_hs.temp_delivery_order
|
|
LEFT JOIN one_hs.hs_deliveryorderdetail ON HS_DeliveryOrderDetailT_TransactionID = Temp_DeliveryOrderT_TransactionID AND HS_DeliveryOrderDetailIsActive = 'Y'
|
|
LEFT JOIN one_hs.hs_deliveryorder ON HS_DeliveryOrderID=HS_DeliveryOrderDetailHS_DeliveryOrderID AND HS_DeliveryOrderIsActive = 'Y'
|
|
where Temp_DeliveryOrderHS_DeliveryOrderID=? AND Temp_DeliveryOrderIsActive = 'Y' AND HS_DeliveryOrderDetailID is null";
|
|
$rstsum = $this->db_onedev->query($sqlsum,array($billID))->row();
|
|
$sumtotal = $rstsum->sumtot;
|
|
$ctotal = $rstsum->ctot;
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
"sumtotal" => $sumtotal,
|
|
"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_hs.hs_deliveryorderdetail
|
|
(HS_DeliveryOrderDetailHS_DeliveryOrderID,
|
|
HS_DeliveryOrderDetailT_TransactionID,
|
|
HS_DeliveryOrderDetailTotal,
|
|
HS_DeliveryOrderDetailUserID,
|
|
HS_DeliveryOrderDetailCreated,
|
|
HS_DeliveryOrderDetailLastUpdated)
|
|
VALUE(
|
|
?,?,?,?,now(),now()
|
|
)";
|
|
$insert_new_test = $this->db_onedev->query($query,array(
|
|
$billID,
|
|
$v['T_TransactionID'],
|
|
$v['total'],
|
|
$userid
|
|
));
|
|
|
|
$sqltransaction = "UPDATE one_hs.t_transaction SET T_TransactionIsDeliveryOrder = 'Y'
|
|
WHERE T_TransactionID = {$v['T_TransactionID']}";
|
|
$updatetransaction = $this->db_onedev->query($sqltransaction);
|
|
|
|
$sqltemp = "UPDATE one_hs.temp_delivery_order SET Temp_DeliveryOrderIsActive = 'N'
|
|
WHERE Temp_DeliveryOrderT_TransactionID = {$v['T_TransactionID']} AND Temp_DeliveryOrderHS_DeliveryOrderID <> $billID";
|
|
$updatetemp = $this->db_onedev->query($sqltemp);
|
|
|
|
}
|
|
$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_hs.hs_deliveryorder_confirm_mou
|
|
(HS_DeliveryOrderConfirmMouHS_DeliveryOrderID,
|
|
HS_DeliveryOrderConfirmMouM_UserID,
|
|
HS_DeliveryOrderConfirmMouUserID,
|
|
HS_DeliveryOrderConfirmMouCreated,
|
|
HS_DeliveryOrderConfirmMouLastUpdated)
|
|
VALUE(
|
|
?,?,?,?,?,now(),now()
|
|
)";
|
|
$insert_new_test = $this->db_onedev->query($query,array(
|
|
$billID,
|
|
$v['M_UserID'],
|
|
$userid
|
|
));
|
|
|
|
}
|
|
$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_hs.hs_deliveryorder SET
|
|
HS_DeliveryOrderIsActive = 'N',
|
|
HS_DeliveryOrderUserID = '{$userid}'
|
|
WHERE
|
|
HS_DeliveryOrderID = '{$prm['id']}'";
|
|
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$query ="UPDATE one_hs.hs_deliveryorderdetail SET
|
|
HS_DeliveryOrderDetailIsActive = 'N',
|
|
HS_DeliveryOrderDetailUserID = '{$userid}'
|
|
WHERE
|
|
HS_DeliveryOrderDetailHS_DeliveryOrderID = '{$prm['id']}'";
|
|
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$query ="UPDATE one_hs.hs_deliveryorder_confirm_issue SET
|
|
HS_DeliveryOrderConfirmIssueIsActive = 'N',
|
|
HS_DeliveryOrderConfirmIssueUserID = '{$userid}'
|
|
WHERE
|
|
HS_DeliveryOrderConfirmIssueHS_DeliveryOrderID = '{$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_hs.hs_deliveryorder_confirm_issue SET
|
|
HS_DeliveryOrderConfirmIssueIsConfirm = 'Y',
|
|
HS_DeliveryOrderConfirmIssueConfirmUserID = '{$userid}',
|
|
HS_DeliveryOrderConfirmIssueConfirmDate = now()
|
|
WHERE
|
|
HS_DeliveryOrderConfirmIssueHS_DeliveryOrderID = '{$prm['id']}'";
|
|
|
|
// 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_hs.hs_deliveryorderdetail SET
|
|
HS_DeliveryOrderDetailIsActive = 'N',
|
|
HS_DeliveryOrderDetailUserID = '{$userid}'
|
|
WHERE
|
|
HS_DeliveryOrderDetailID = '{$prm['HS_DeliveryOrderDetailID']}'
|
|
";
|
|
//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_hs.hs_deliveryorder_confirm_issue SET HS_DeliveryOrderConfirmIssueImg = '{$filename}',
|
|
HS_DeliveryOrderConfirmIssueIsReceive = 'Y',
|
|
HS_DeliveryOrderConfirmIssueReceiveDate = '{$inp['rtanggal']}',
|
|
HS_DeliveryOrderConfirmIssueReceiveUserID = {$userid}
|
|
WHERE HS_DeliveryOrderConfirmIssueID = {$inp['idx']}";
|
|
//echo $sql;
|
|
$save = $this->db_onedev->query($sql);
|
|
|
|
$sqlbill = "UPDATE one_hs.hs_deliveryorder SET HS_DeliveryOrderDueDate = '{$inp['sdate']}'
|
|
WHERE HS_DeliveryOrderID = {$inp['idbill']}";
|
|
//echo $sqlbill;
|
|
$savebill = $this->db_onedev->query($sqlbill);
|
|
|
|
$sqllog = "INSERT INTO one_hs.hs_deliveryorder_receive_log (HS_DeliveryOrderReceiveLogHS_DeliveryOrderConfirmIssueID,
|
|
HS_DeliveryOrderReceiveLogDate,
|
|
HS_DeliveryOrderReceiveLogImg,
|
|
HS_DeliveryOrderReceiveLogUserID,
|
|
HS_DeliveryOrderReceiveLogCreated,
|
|
HS_DeliveryOrderReceiveLogLastUpdated)
|
|
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_hs.hs_deliveryorder_confirm_issue SET HS_DeliveryOrderConfirmIssueImgSend = '{$filename}',
|
|
HS_DeliveryOrderConfirmIssueSendUserID = {$userid}
|
|
WHERE HS_DeliveryOrderConfirmIssueID = {$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;
|
|
}
|
|
|
|
}
|