FHM28052603SAS - commit remaining changes

This commit is contained in:
sas.fajri
2026-05-28 14:35:21 +07:00
parent 512f649616
commit ee7689654b
10 changed files with 8397 additions and 362 deletions

View File

@@ -0,0 +1,13 @@
{
"permissions": {
"allow": [
"Bash(ssh devcpone *)",
"Bash(git -C /Users/fajrihardhitamurti/REPO_CPONE/BE_CPONE ls-tree -r origin/master --name-only)",
"Bash(git *)",
"Bash(ssh *)",
"Bash(curl -s https://devcpone.aplikasi.web.id/one-api/mockup/resultentrysoelectromedis-v9-cpone/resultentry/search -H 'Accept: application/json, text/plain, */*' -H 'Content-Type: application/json;charset=UTF-8' -b 'cpone_project_mcu_id=1583; token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyVXNlcm5hbWUiOiJqb2tvQGdtYWlsLmNvbSIsIk1fVXNlckdyb3VwRGFzaGJvYXJkIjoib25lLXVpXC90ZXN0XC92dWV4XC9vbmUtbWN1LW9mZmxpbmUtcHJlcmVnaXN0ZXItYXBwLWNwb25ldjhcLyIsIk1fVXNlckRlZmF1bHRUX1NhbXBsZVN0YXRpb25JRCI6IjEiLCJNX1N0YWZmTmFtZSI6IkFkbWluIENQT05FIiwiaXNfY291cmllciI6Ik4iLCJNX0JyYW5jaElEIjoiMTAiLCJNX0JyYW5jaE5hbWUiOiJMYWJvcmF0b3JpdW0gTWFrYXNzYXIiLCJ0aW1lX2F1dG9sb2dvdXQiOiIxNSIsImlwIjoiMTI4LjE5OS44Ni43IiwiYWdlbnQiOiJHby1odHRwLWNsaWVudFwvMS4xIiwidmVyc2lvbiI6InYyIiwibGFzdC1sb2dpbiI6IjIwMjYtMDUtMTEgMTM6NTg6MjIifQ.HL_TvRA5GaaL2X5NnJHDMQkRqWlbHE-fssgarBYWZSY' --data-raw '{\"startdate\":\"2026-05-11\",\"companyid\":0,\"switch_exclude\":false,\"search\":\"\",\"stationid\":\"1675\",\"groupid\":2,\"subgroupid\":0,\"current_page\":1,\"lastid\":-1,\"token\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyVXNlcm5hbWUiOiJqb2tvQGdtYWlsLmNvbSIsIk1fVXNlckdyb3VwRGFzaGJvYXJkIjoib25lLXVpXC90ZXN0XC92dWV4XC9vbmUtbWN1LW9mZmxpbmUtcHJlcmVnaXN0ZXItYXBwLWNwb25ldjhcLyIsIk1fVXNlckRlZmF1bHRUX1NhbXBsZVN0YXRpb25JRCI6IjEiLCJNX1N0YWZmTmFtZSI6IkFkbWluIENQT05FIiwiaXNfY291cmllciI6Ik4iLCJNX0JyYW5jaElEIjoiMTAiLCJNX0JyYW5jaE5hbWUiOiJMYWJvcmF0b3JpdW0gTWFrYXNzYXIiLCJ0aW1lX2F1dG9sb2dvdXQiOiIxNSIsImlwIjoiMTI4LjE5OS44Ni43IiwiYWdlbnQiOiJHby1odHRwLWNsaWVudFwvMS4xIiwidmVyc2lvbiI6InYyIiwibGFzdC1sb2dpbiI6IjIwMjYtMDUtMTEgMTM6NTg6MjIifQ.HL_TvRA5GaaL2X5NnJHDMQkRqWlbHE-fssgarBYWZSY\"}')",
"Bash(python3 -m json.tool)",
"Bash(scp *)"
]
}
}

View File

@@ -30,6 +30,7 @@ while read -r local_ref local_sha remote_ref remote_sha; do
repo_root=$(git rev-parse --show-toplevel)
if ! "$repo_root/scripts/devcpone_sync.sh" "$branch"; then
printf '%s\n' "devcpone sync skipped/failed; push kept intact" >&2
printf '%s\n' "devcpone sync failed; blocking push" >&2
exit 1
fi
done < "$tmpdir/pushes"

View File

@@ -578,6 +578,7 @@ class Transactionv2 extends MY_Controller
when Nat_GroupID = 4 then '1303'
when Nat_GroupID = 5 then '1321'
when Nat_GroupID = 6 then '1600'
when Nat_GroupID = 7 then '1500'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
@@ -1117,6 +1118,7 @@ class Transactionv2 extends MY_Controller
when Nat_GroupID = 4 then '1303'
when Nat_GroupID = 5 then '1321'
when Nat_GroupID = 6 then '1600'
when Nat_GroupID = 7 then '1500'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
@@ -1913,6 +1915,7 @@ class Transactionv2 extends MY_Controller
when Nat_GroupID = 4 then '1303'
when Nat_GroupID = 5 then '1321'
when Nat_GroupID = 6 then '1600'
when Nat_GroupID = 7 then '1500'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
@@ -2412,6 +2415,7 @@ class Transactionv2 extends MY_Controller
when Nat_GroupID = 4 then '1303'
when Nat_GroupID = 5 then '1321'
when Nat_GroupID = 6 then '1600'
when Nat_GroupID = 7 then '1500'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
@@ -2857,6 +2861,7 @@ class Transactionv2 extends MY_Controller
when Nat_GroupID = 4 then '1303'
when Nat_GroupID = 5 then '1321'
when Nat_GroupID = 6 then '1600'
when Nat_GroupID = 7 then '1500'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
@@ -2904,7 +2909,15 @@ class Transactionv2 extends MY_Controller
T_OrderDetailIsActive = 'Y'
UNION
SELECT T_OrderDetailID as TrxLayananID,
Nat_GroupID as ProfitCostCenterCode,
case
when Nat_GroupID = 1 then '1100'
when Nat_GroupID = 2 then '1200'
when Nat_GroupID = 3 then '1200'
when Nat_GroupID = 4 then '1303'
when Nat_GroupID = 5 then '1321'
when Nat_GroupID = 6 then '1600'
when Nat_GroupID = 7 then '1500'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
T_OrderDetailT_TestSasCode as LayananID,

File diff suppressed because it is too large Load Diff

View File

@@ -578,6 +578,7 @@ class Transactionv3 extends MY_Controller
when Nat_GroupID = 4 then '1303'
when Nat_GroupID = 5 then '1321'
when Nat_GroupID = 6 then '1600'
when Nat_GroupID = 7 then '1500'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
@@ -1122,6 +1123,7 @@ class Transactionv3 extends MY_Controller
when Nat_GroupID = 4 then '1303'
when Nat_GroupID = 5 then '1321'
when Nat_GroupID = 6 then '1600'
when Nat_GroupID = 7 then '1500'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
@@ -1918,6 +1920,7 @@ class Transactionv3 extends MY_Controller
when Nat_GroupID = 4 then '1303'
when Nat_GroupID = 5 then '1321'
when Nat_GroupID = 6 then '1600'
when Nat_GroupID = 7 then '1500'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
@@ -2417,6 +2420,7 @@ class Transactionv3 extends MY_Controller
when Nat_GroupID = 4 then '1303'
when Nat_GroupID = 5 then '1321'
when Nat_GroupID = 6 then '1600'
when Nat_GroupID = 7 then '1500'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
@@ -2862,6 +2866,7 @@ class Transactionv3 extends MY_Controller
when Nat_GroupID = 4 then '1303'
when Nat_GroupID = 5 then '1321'
when Nat_GroupID = 6 then '1600'
when Nat_GroupID = 7 then '1500'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
@@ -2909,7 +2914,15 @@ class Transactionv3 extends MY_Controller
T_OrderDetailIsActive = 'Y'
UNION
SELECT T_OrderDetailID as TrxLayananID,
Nat_GroupID as ProfitCostCenterCode,
case
when Nat_GroupID = 1 then '1100'
when Nat_GroupID = 2 then '1200'
when Nat_GroupID = 3 then '1200'
when Nat_GroupID = 4 then '1303'
when Nat_GroupID = 5 then '1321'
when Nat_GroupID = 6 then '1600'
when Nat_GroupID = 7 then '1500'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
T_OrderDetailT_TestSasCode as LayananID,

File diff suppressed because it is too large Load Diff

View File

@@ -12,10 +12,11 @@ class Patient extends MY_Controller
$this->db_onedev = $this->load->database("onedev", true);
}
public function add_notes($orderid){
public function add_notes($orderid)
{
$sql = " SELECT F_PaymentT_OrderHeaderID as note_order_id,
F_PaymentID as note_id,
F_PaymentDate as note_date,
DATE_FORMAT(F_PaymentDate,'%d-%m-%Y') as note_date,
F_PaymentNumber as note_number,
GROUP_CONCAT(M_PaymentTypeName separator ' , ') as paymenttypes_name,
MAX(F_PaymentTotal) as note_amount,
@@ -33,7 +34,6 @@ class Patient extends MY_Controller
if ($query) {
$rows = $query->result_array();
return $rows;
} else {
$this->sys_error_db("get notes", $this->db_onedev);
exit;
@@ -53,6 +53,7 @@ class Patient extends MY_Controller
$search = $prm["search"];
$status = $prm["status"];
$company = $prm["company"];
$userid = $this->sys_user["M_UserID"];
$filter_company = '';
if ($company != '0' || $company != 0)
$filter_company = " AND CorporateID = {$company}";
@@ -69,10 +70,11 @@ class Patient extends MY_Controller
$sql = "SELECT count(*) as total
FROM t_orderheader
left join f_bill_detail on F_BillDetailT_OrderHeaderID = T_OrderHeaderID and F_BillDetailIsActive = 'Y'
JOIN m_user ON M_UserID = {$userid} AND T_OrderHeaderM_BranchID = M_UserLoginM_BranchID AND M_UserIsActive = 'Y'
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
JOIN m_title ON M_PatientM_TitleID = M_TitleID
JOIN corporate ON T_OrderHeaderCorporateID = CorporateID $filter_company
left join f_bill_detail on F_BillDetailT_OrderHeaderID = T_OrderHeaderID and F_BillDetailIsActive = 'Y'
LEFT JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
LEFT JOIN x_wa_outbox
@@ -118,10 +120,11 @@ class Patient extends MY_Controller
IFNULL(XWaOutboxIsSent,'') as XWaOutboxIsSent,
IFNULL(XWaOutboxRetry,0) as XWaOutboxRetry
FROM t_orderheader
left join f_bill_detail on F_BillDetailT_OrderHeaderID = T_OrderHeaderID and F_BillDetailIsActive = 'Y'
JOIN m_user ON M_UserID = {$userid} AND T_OrderHeaderM_BranchID = M_UserLoginM_BranchID AND M_UserIsActive = 'Y'
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
JOIN m_title ON M_PatientM_TitleID = M_TitleID
JOIN corporate ON T_OrderHeaderCorporateID = CorporateID $filter_company
left join f_bill_detail on F_BillDetailT_OrderHeaderID = T_OrderHeaderID and F_BillDetailIsActive = 'Y'
LEFT JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
LEFT JOIN x_wa_outbox
@@ -135,6 +138,7 @@ class Patient extends MY_Controller
limit $number_limit offset $number_offset";
//echo $sql;
$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) {
@@ -157,7 +161,8 @@ class Patient extends MY_Controller
function searchcompany(){
function searchcompany()
{
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
@@ -174,8 +179,7 @@ class Patient extends MY_Controller
'search' => '%'
];
if ($prm['search'] != '' )
{
if ($prm['search'] != '') {
if ($prm['search'] == 'Semua')
$prm['search'] = "";
@@ -192,8 +196,7 @@ class Patient extends MY_Controller
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
} else {
$this->sys_error_db("m_city count", $this->db_onedev);
exit;
}
@@ -215,11 +218,9 @@ class Patient extends MY_Controller
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
} else {
$this->sys_error_db("corporate rows", $this->db_onedev);
exit;
}
}
}

View File

@@ -0,0 +1,225 @@
<?php
class Patient extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Patient API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
public function add_notes($orderid){
$sql = " SELECT F_PaymentT_OrderHeaderID as note_order_id,
F_PaymentID as note_id,
F_PaymentDate as note_date,
F_PaymentNumber as note_number,
GROUP_CONCAT(M_PaymentTypeName separator ' , ') as paymenttypes_name,
MAX(F_PaymentTotal) as note_amount,
M_StaffName as note_user,
F_PaymentDetailIsActive as note_active
FROM f_payment
JOIN f_paymentdetail ON F_PaymentDetailF_PaymentID = F_PaymentID
JOIN m_paymenttype ON F_PaymentDetailM_PaymentTypeID = M_PaymentTypeID
LEFT JOIN m_user ON F_PaymentDetailUserID = M_UserID
LEFT JOIN m_staff ON M_UserM_StaffID = M_StaffID
WHERE
F_PaymentT_OrderHeaderID = {$orderid}
GROUP BY F_PaymentID";
$query = $this->db_onedev->query($sql);
if ($query) {
$rows = $query->result_array();
return $rows;
} else {
$this->sys_error_db("get notes", $this->db_onedev);
exit;
}
}
public function search()
{
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$startdate = $prm['startdate'];
$enddate = $prm['enddate'] . " 23:59:59";
$search = $prm["search"];
$status = $prm["status"];
$company = $prm["company"];
$filter_company = '';
if($company != '0' || $company != 0)
$filter_company = " AND CorporateID = {$company}";
$number_limit = 10;
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
$where = " ( DATE(T_OrderHeaderDate) = '{$startdate}' ) AND ";
if($search != ''){
$where = "( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' ) AND ";
if(strlen($search) == 10){
$where = "T_OrderHeaderLabNumber = '{$search}' AND ";
}
}
$sql = "SELECT count(*) as total
FROM t_orderheader
left join f_bill_detail on F_BillDetailT_OrderHeaderID = T_OrderHeaderID and F_BillDetailIsActive = 'Y'
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
JOIN m_title ON M_PatientM_TitleID = M_TitleID
JOIN corporate ON T_OrderHeaderCorporateID = CorporateID $filter_company
LEFT JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
LEFT JOIN x_wa_outbox
ON T_OrderHeaderID = XWaOutboxRefID
AND XWaOutboxIsActive = 'Y'
WHERE T_OrderHeaderIsActive = 'Y' AND
$where
( ('{$status}' = 'N' AND (Last_StatusPaymentIsLunas = 'N' OR Last_StatusPaymentID IS NULL)) OR ('{$status}' = 'Y' AND Last_StatusPaymentIsLunas = 'Y') ) and F_BillDetailID is null";
$query = $this->db_onedev->query($sql);
$tot_count = 0;
$tot_page = 0;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
$tot_page = ceil($tot_count/$number_limit);
} else {
$this->sys_error_db("t_samplestorage count", $this->db_onedev);
exit;
}
$sql = "SELECT t_orderheader.*,
M_PatientNoReg,
DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y %H:%i') as order_date,
CONCAT(M_TitleName,'. ',M_PatientName) as M_PatientName,
M_PatientName as M_PatientName_eng,
M_TitleName,
CorporateName as M_CompanyName,
CorporateName as CorporateName,
Mgm_McuLabel as M_MouName,
Mgm_McuLabel,
IFNULL(Last_StatusPaymentBillTotal, T_OrderHeaderTotal) as totalbill,
IFNULL(Last_StatusPaymentPaid,0) as paid,
(IFNULL(Last_StatusPaymentBillTotal, T_OrderHeaderTotal) - IFNULL(Last_StatusPaymentPaid,0)) as unpaid,
Last_StatusPaymentIsLunas as flaglunas,
'' as notes,
0 as mindp_percent,
0 as mindp_amount,
F_BillDetailID,
IFNULL(M_PatientHp,'') as M_PatientHp,
IFNULL(M_PatientID,0) as M_PatientID,
IFNULL(XWaOutboxIsSent,'') as XWaOutboxIsSent,
IFNULL(XWaOutboxRetry,0) as XWaOutboxRetry
FROM t_orderheader
left join f_bill_detail on F_BillDetailT_OrderHeaderID = T_OrderHeaderID and F_BillDetailIsActive = 'Y'
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
JOIN m_title ON M_PatientM_TitleID = M_TitleID
JOIN corporate ON T_OrderHeaderCorporateID = CorporateID $filter_company
LEFT JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
LEFT JOIN x_wa_outbox
ON T_OrderHeaderID = XWaOutboxRefID
AND XWaOutboxIsActive = 'Y'
AND XWaOutboxType = 'KWITANSI'
WHERE T_OrderHeaderIsActive = 'Y' AND
$where
( ('{$status}' = 'N' AND (Last_StatusPaymentIsLunas = 'N' OR Last_StatusPaymentID IS NULL)) OR ('{$status}' = 'Y' AND Last_StatusPaymentIsLunas = 'Y') ) and F_BillDetailID is null
ORDER BY T_OrderHeaderID ASC
limit $number_limit offset $number_offset";
//echo $sql;
$query = $this->db_onedev->query($sql, $sql_param);
$rows = $query->result_array();
if($rows){
foreach($rows as $k => $v){
$rows[$k]['notes'] = $this->add_notes($v['T_OrderHeaderID']);
}
}
$sql = "SELECT * FROM `s_menu` WHERE `S_MenuName` = 'Registration (Walk In)' AND `S_MenuIsActive` = 'Y' ORDER BY `S_MenuID` DESC LIMIT 1";
$query = $this->db_onedev->query($sql);
$menu = $query->row_array();
if($menu){
$menu_url = $menu['S_MenuUrl'];
}
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query(), "menu_url" => $menu_url);
$this->sys_ok($result);
exit;
}
function searchcompany(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$filter_date = '';
if(isset($prm['xdate']))
$filter_date = " JOIN t_orderheader ON T_OrderHeaderCorporateID = CorporateID AND DATE(T_OrderHeaderDate) = '{$prm['xdate']}' AND T_OrderHeaderIsActive = 'Y' ";
$q = [
'search' => '%'
];
if ($prm['search'] != '' )
{
if($prm['search'] == 'Semua')
$prm['search'] = "";
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM corporate
WHERE
CorporateName like ?
AND CorporateIsActive = '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_city count",$this->db_onedev);
exit;
}
$rows = array('id'=>0,'name'=>'Semua');
$sql = "
SELECT CorporateID as id, CorporateName as name
FROM corporate
$filter_date
WHERE
CorporateName like ?
AND CorporateIsActive = 'Y'
ORDER BY CorporateName DESC
";
$query = $this->db_onedev->query($sql, array($q['search']));
// echo $this->db_onedev->last_query();
if ($query) {
$rows = $query->result_array();
array_push($rows,array('id'=>0,'name'=>'Semua'));
//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("corporate rows",$this->db_onedev);
exit;
}
}
}

View File

@@ -159,14 +159,14 @@ class Payment extends MY_Controller
);
$this->sys_ok($result);
} catch (Exception $exc) {
$this->sys_error($exc->getMessage());
}
}
// * List Outbox yang mau dikirim
public function listOutbox(){
public function listOutbox()
{
try {
$prm = $this->sys_input;
$status = $prm["statusOutbox"];
@@ -221,7 +221,6 @@ class Payment extends MY_Controller
$result = $query->result_array();
$this->sys_ok($result);
} catch (Exception $e) {
$msg = $e->getMessage();
$this->sys_error($msg);
@@ -230,7 +229,8 @@ class Payment extends MY_Controller
}
// ** Upload File Kwitansi dari Birt ke CDN Qontak
public function uploadFile(){
public function uploadFile()
{
try {
$url = "https://service-chat.qontak.com/api/open/v1/file_uploader";
$fileName = $this->sys_input["fileName"];
@@ -347,7 +347,6 @@ class Payment extends MY_Controller
}
$this->db_onedev->trans_complete();
} catch (Exception $e) {
$msg = $e->getMessage();
$this->db_onedev->trans_rollback();
@@ -357,7 +356,8 @@ class Payment extends MY_Controller
}
// * Send WA Msg Using Qontak
public function qontakSendMsg(){
public function qontakSendMsg()
{
try {
$url = "https://service-chat.qontak.com/api/open/v1/broadcasts/whatsapp/direct";
@@ -529,7 +529,8 @@ class Payment extends MY_Controller
}
}
public function changeStatusOutbox(){
public function changeStatusOutbox()
{
try {
$this->db_onedev->trans_start();
@@ -592,6 +593,7 @@ class Payment extends MY_Controller
'' as selected_card,
'' as selected_edc,
'' as selected_account,
'' as selected_promo,
CASE
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
@@ -610,6 +612,7 @@ class Payment extends MY_Controller
foreach ($rows as $k => $v) {
$rows[$k]['selected_card'] = array('id' => 0, 'name' => '');
$rows[$k]['selected_edc'] = array('id' => 0, 'name' => '');
$rows[$k]['selected_promo'] = array('id' => 0, 'name' => '', 'type' => '', 'value' => 0);
if ($v['chex'] == 'N')
$rows[$k]['chex'] = false;
else
@@ -668,7 +671,47 @@ class Payment extends MY_Controller
exit;
}
function searchcard(){
function lookup_promos()
{
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$bank_id = $prm['bank_id'];
$query = "SELECT DISTINCT
M_PromoID as id,
M_PromoName as name,
M_PromoDiscountType as type,
M_PromoValue as value
FROM m_promo
JOIN m_promo_bank ON M_PromoBankM_PromoID = M_PromoID
WHERE
M_PromoIsActive = 'Y'
AND M_PromoBankIsActive = 'Y'
AND M_PromoBankNat_BankID = ?
AND CURDATE() BETWEEN M_PromoStartDate AND M_PromoEndDate
ORDER BY M_PromoName DESC";
$qry = $this->db_onedev->query($query, array($bank_id));
if (!$qry) {
$this->sys_error_db("List Promo", $this->db_onedev);
exit;
}
$rows = $qry->result_array();
$result = array(
"total" => count($rows),
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function searchcard()
{
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
@@ -682,8 +725,7 @@ class Payment extends MY_Controller
'search' => '%'
];
if ($prm['search'] != '')
{
if ($prm['search'] != '') {
$q['search'] = "%{$prm['search']}%";
}
@@ -697,8 +739,7 @@ class Payment extends MY_Controller
AND Nat_BankIsActive = 'Y'
ORDER BY Nat_BankName DESC
";
}
else{
} else {
$sql = "
SELECT count(*) as total
FROM nat_bank
@@ -711,8 +752,7 @@ class Payment extends MY_Controller
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
} else {
$this->sys_error_db("m_city count", $this->db_onedev);
exit;
}
@@ -725,8 +765,7 @@ class Payment extends MY_Controller
AND Nat_BankIsActive = 'Y'
ORDER BY Nat_BankName DESC
";
}
else{
} else {
$sql = "
SELECT Nat_BankID as id, Nat_BankName as name
FROM nat_bank
@@ -743,8 +782,7 @@ class Payment extends MY_Controller
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
} else {
$this->sys_error_db("m_city rows", $this->db_onedev);
exit;
}
@@ -832,14 +870,8 @@ class Payment extends MY_Controller
$paid_before = (int)($rowPaidBefore['total_paid'] ?? 0);
$remaining_before_tx = $bill_total - $paid_before;
if ($remaining_before_tx < 0) $remaining_before_tx = 0;
if ($remaining_before_tx === 0) {
throw new Exception("Tagihan sudah lunas / 0. Tidak bisa bayar lagi.");
}
$requested_paid = 0;
$promo_bill_total = null;
foreach ($payments as $v) {
if (empty($v['chex'])) continue;
@@ -860,17 +892,21 @@ class Payment extends MY_Controller
} else {
$requested_paid += $left;
}
if ($code === 'PROMO') {
$promo_bill_total = $left;
}
}
if ($requested_paid <= 0) {
throw new Exception("Nominal pembayaran 0 / tidak valid.");
if ($promo_bill_total !== null) {
$bill_total = (int)$promo_bill_total;
}
$remaining_before_tx = $bill_total - $paid_before;
if ($remaining_before_tx < 0) $remaining_before_tx = 0;
$paid_to_record = min($requested_paid, $remaining_before_tx);
if ($paid_to_record <= 0) {
throw new Exception("Nominal pembayaran 0 / tidak valid.");
}
$qHeader = $this->db_onedev->query(
"INSERT INTO f_payment(
@@ -897,7 +933,7 @@ class Payment extends MY_Controller
foreach ($payments as $v) {
if (empty($v['chex'])) continue;
if ($remaining_alloc <= 0) break;
//if ($remaining_alloc <= 0) break;
$code = (string)($v['code'] ?? '');
$typeId = (int)($v['id'] ?? 0);
@@ -907,19 +943,12 @@ class Payment extends MY_Controller
$actual = (int)($v['leftvalue'] ?? 0);
$change = (int)($v['rightvalue'] ?? 0);
if ($actual < 0) $actual = 0;
if ($change < 0) $change = 0;
$net = $actual;
if($actual > 0){
$net = $actual - max(0, $change);
$amount = intval($v['leftvalue']) - intval($v['rightvalue']);
}
else{
$amount = $actual;
}
if ($net < 0) $net = 0;
$amount = min($net, $remaining_alloc);
$change_new = $actual - $amount;
if ($change_new < 0) $change_new = 0;
$q = $this->db_onedev->query(
"INSERT INTO f_paymentdetail(
@@ -932,7 +961,7 @@ class Payment extends MY_Controller
F_PaymentDetailLastUpdated,
F_PaymentDetailUserID
) VALUES (?,?,?,?,?,NOW(),NOW(),?)",
[$headerid, $typeId, $amount, $actual, $change_new, $xuserid]
[$headerid, $typeId, $amount, $actual, $change, $xuserid]
);
if (! $q) {
@@ -952,6 +981,7 @@ class Payment extends MY_Controller
$selected_card = (int)($v['selected_card']['id'] ?? 0);
$selected_edc = (int)($v['selected_edc']['id'] ?? 0);
$selected_account = (int)($v['selected_account']['id'] ?? 0);
$selected_promo = (int)($v['selected_promo']['id'] ?? 0);
$bankAccountId = 0;
if ($code === 'TRANSFER' || $code === 'QRIS') {
@@ -984,6 +1014,30 @@ class Payment extends MY_Controller
$paymentDetailId = (int)$this->db_onedev->insert_id();
if ($code === 'PROMO') {
if ($selected_promo <= 0) {
throw new Exception("Promo tidak valid.");
}
$qPromo = $this->db_onedev->query(
"INSERT INTO t_promo(
T_PromoT_OrderHeaderID,
T_PromoF_PaymentDetailID,
T_PromoF_PaymentID,
T_PromoM_PromoID,
T_PromoIsActive,
T_PromoCreated,
T_PromoCreatedUserID
) VALUES (?,?,?,?, 'Y', NOW(), ?)",
[$orderid, $paymentDetailId, $headerid, $selected_promo, $xuserid]
);
if (! $qPromo) {
$this->sys_error_db("t_promo insert", $this->db_onedev);
exit;
}
}
if ($code === 'VOUCHER') {
$vn = trim((string)($v['rightvalue'] ?? ''));
if ($vn !== '' && $amount > 0) {
@@ -1003,13 +1057,19 @@ class Payment extends MY_Controller
$remaining_alloc -= $amount;
}
$paid_after = $paid_before + $paid_to_record;
if ($paid_after > $bill_total) $paid_after = $bill_total;
$paid_all = 0;
$unpaid = 0;
$sql = "SELECT SUM(F_PaymentTotal) AS total_paid, T_OrderHeaderTotal AS total_bill
FROM
f_payment
JOIN t_orderheader ON T_OrderHeaderID = F_PaymentT_OrderHeaderID AND T_OrderHeaderIsActive = 'Y'
WHERE F_PaymentT_OrderHeaderID = ? AND F_PaymentIsActive = 'Y'
GROUP BY F_PaymentT_OrderHeaderID";
$row = $this->db_onedev->query($sql, [$orderid])->row_array();
$paid_all = (int)($row['total_paid'] ?? 0);
$unpaid = (int)($row['total_bill'] ?? 0) - $paid_all;
$unpaid = $bill_total - $paid_after;
if ($unpaid < 0) $unpaid = 0;
$lunas = ($paid_after >= $bill_total) ? 'Y' : 'N';
$lunas = ($unpaid <= 0) ? 'Y' : 'N';
$last = $this->db_onedev->query(
"SELECT Last_StatusPaymentID
@@ -1029,7 +1089,7 @@ class Payment extends MY_Controller
Last_StatusPaymentIsLunas = ?,
Last_StatusPaymentLastUpdated = NOW()
WHERE Last_StatusPaymentID = ?",
[$bill_total, $paid_after, $unpaid, $lunas, (int)$last['Last_StatusPaymentID']]
[$row['total_bill'], $paid_all, $unpaid, $lunas, (int)$last['Last_StatusPaymentID']]
);
if (! $q) {
$this->sys_error_db("last_statuspayment update", $this->db_onedev);
@@ -1046,7 +1106,7 @@ class Payment extends MY_Controller
Last_StatusPaymentCreated,
Last_StatusPaymentUserID
) VALUES (?,?,?,?,?,NOW(),?)",
[$orderid, $bill_total, $paid_after, $unpaid, $lunas, $xuserid]
[$orderid, $row['total_bill'], $paid_all, $unpaid, $lunas, $xuserid]
);
if (! $q) {
$this->sys_error_db("last_statuspayment insert", $this->db_onedev);
@@ -1182,7 +1242,6 @@ class Payment extends MY_Controller
"menu_walk_in" => $row_menu ? $row_menu['S_MenuUrl'] : ''
]);
exit;
} catch (Exception $e) {
$this->db_onedev->trans_rollback();
$this->sys_error($e->getMessage());
@@ -1248,31 +1307,23 @@ class Payment extends MY_Controller
) x";
$query = $this->db_onedev->query($sql, array($prm['order_id']));
//echo $this->db_onedev->last_query();
if ($query)
{
if ($query) {
$datas = $query->result_array();
foreach ($datas as $key => $value) {
$sql = "SELECT M_LocationID as location_id, M_LocationName as location_name FROM m_location WHERE M_LocationT_SampleStationID = ? AND M_LocationIsActive = 'Y' ";
$query = $this->db_onedev->query($sql, array($value['station_id']));
if ($query)
{
if ($query) {
$datas[$key]['locations'] = $query->result_array();
}
else
{
} else {
$datas[$key]['locations'] = [];
}
}
$this->sys_ok(["datas" => $datas]);
}
else{
} else {
echo $this->db_onedev->last_query();
$this->sys_error_db("gagal ambil data", $this->db_onedev);
exit;
}
}
function save_control()
@@ -1303,8 +1354,7 @@ class Payment extends MY_Controller
$query = $this->db_onedev->query($sql, array($value['order_id'], $value['location_id'], $value['station_id'], $userid, $value['order_id'], $value['location_id'], $value['station_id'], $userid));
}
$this->sys_ok(["datas" => '']);
}
else{
} else {
$this->sys_error_db("data not valid", $this->db_onedev);
exit;
}
@@ -1449,7 +1499,6 @@ class Payment extends MY_Controller
"headerId" => (int)$header['VoucherHeaderID']
]);
exit;
} catch (Exception $e) {
$this->sys_error($e->getMessage());
exit;

View File

@@ -20,6 +20,7 @@ tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/devcpone-sync.XXXXXX")
trap 'rm -rf "$tmpdir"' EXIT HUP INT TERM
manifest="$tmpdir/files.list"
verify_list="$tmpdir/files.verify"
if git rev-parse --verify HEAD^ >/dev/null 2>&1; then
git diff -M --name-only -z --diff-filter=ACMR HEAD^ HEAD > "$manifest"
@@ -31,12 +32,20 @@ if [ ! -s "$manifest" ]; then
exit 0
fi
ssh_cmd="ssh"
ssh_args="-o BatchMode=yes"
if [ -f "$ssh_key" ]; then
ssh_cmd="$ssh_cmd -i $ssh_key"
ssh_args="-i $ssh_key $ssh_args"
fi
ssh_cmd="$ssh_cmd -o BatchMode=yes"
ssh $ssh_args "$remote_host" "mkdir -p '$remote_root'" >/dev/null
rsync -a --relative --from0 --files-from="$manifest" -e "ssh $ssh_args" "$repo_root"/ "$remote_host:$remote_root"/
ssh "$remote_host" "mkdir -p '$remote_root'" >/dev/null
rsync -a --relative --from0 --files-from="$manifest" -e "$ssh_cmd" "$repo_root"/ "$remote_host:$remote_root"/
tr '\0' '\n' < "$manifest" > "$verify_list"
while IFS= read -r relpath; do
[ -n "$relpath" ] || continue
ssh $ssh_args "$remote_host" "test -e '$remote_root/$relpath'" || {
printf '%s\n' "devcpone verify failed: missing $remote_root/$relpath" >&2
exit 1
}
done < "$verify_list"