Initial import

This commit is contained in:
sas.fajri
2026-05-25 20:01:37 +07:00
commit 710d7c1b97
10371 changed files with 2381698 additions and 0 deletions

View File

@@ -0,0 +1,128 @@
<?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,
SUM(F_PaymentDetailAmount) as note_amount,
M_UserUsername 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
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()
{
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$startdate = $prm['startdate'] . " 00:00:01";
$enddate = $prm['enddate'] . " 23:59:59";
$search = $prm["search"];
$status = $prm["status"];
$number_limit = 10;
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
$where = " ( T_OrderHeaderDate BETWEEN '{$startdate}' AND '{$enddate}' ) AND ";
if($search != '')
$where = "( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' ) AND ";
$sql = " SELECT count(*) as total
FROM t_orderheader
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
JOIN m_title ON M_PatientM_TitleID = M_TitleID
JOIN m_sex ON M_PatientM_SexID = M_SexID
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
WHERE
$where
( ('{$status}' = 'N' AND (Last_StatusPaymentIsLunas = 'N' OR Last_StatusPaymentID IS NULL)) OR ('{$status}' = 'Y' AND Last_StatusPaymentIsLunas = 'Y') )";
$query = $this->db_onedev->query($sql, $sql_param);
$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,
M_PatientName,
M_TitleName,
M_CompanyName,
M_MouName,
T_OrderHeaderTotal as totalbill,
IFNULL(Last_StatusPaymentPaid,0) as paid,
IFNULL(Last_StatusPaymentUnpaid,T_OrderHeaderTotal)as unpaid,
Last_StatusPaymentIsLunas as flaglunas,
'' as notes,
M_MouMinDP as mindp_percent,
(M_MouMinDP/100) * T_OrderHeaderTotal as mindp_amount
FROM t_orderheader
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
JOIN m_title ON M_PatientM_TitleID = M_TitleID
JOIN m_sex ON M_PatientM_SexID = M_SexID
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
WHERE
$where
( ('{$status}' = 'N' AND (Last_StatusPaymentIsLunas = 'N' OR Last_StatusPaymentID IS NULL)) OR ('{$status}' = 'Y' AND Last_StatusPaymentIsLunas = 'Y') )
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']);
}
}
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
$this->sys_ok($result);
exit;
}
}

View File

@@ -0,0 +1,244 @@
<?php
class Payment extends MY_Controller
{
var $db_smartone;
public function index()
{
echo "API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
function lookup_type()
{
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$query = "SELECT M_PaymentTypeID as id,
M_PaymentTypeCode as code,
IF(M_PaymentTypeCode = 'CASH','Y','N') as chex,
M_PaymentTypeName as chexlabel,
'Jumlah' as leftlabel,
CASE
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
WHEN M_PaymentTypeCode = 'CREDIT' THEN 'Nomor Kartu'
ELSE 'Nomor Voucher'
END as rightlabel,
0 as leftvalue,
0 as rightvalue
FROM m_paymenttype WHERE M_PaymentTypeIsActive = 'Y'";
$rows = $this->db_onedev->query($query)->result_array();
foreach($rows as $k => $v){
if($v['chex'] == 'N')
$rows[$k]['chex'] = false;
else
$rows[$k]['chex'] = true;
}
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function pay()
{
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$xuserid = $this->sys_user['M_UserID'];
$prm = $this->sys_input;
$orderid = $prm['orderid'];
$payments = $prm['payments'];
//$xnumber = $this->db_onedev->query("SELECT `fn_numbering`('PAY') as numberx")->row()->numberx;
$sql = "INSERT INTO f_payment(F_PaymentT_OrderHeaderID,F_PaymentDate,F_PaymentCreated,F_PaymentM_UserID) VALUES (?,CURDATE(),NOW(),?)";
$query = $this->db_onedev->query($sql,
array(
$orderid, $xuserid
)
);
if (!$query) {
$this->sys_error_db("f_payment insert");
exit;
}
$headerid = $this->db_onedev->insert_id();
foreach($payments as $k => $v){
$actual = 0;
$change = 0;
$amount = $v['leftvalue'];
if($v['code'] == 'CASH'){
$actual = $v['leftvalue'];
$change = $v['rightvalue'];
if($actual > 0){
$amount = intval($v['leftvalue']) - intval($v['rightvalue']);
}
else{
$amount = $actual;
}
$sql = "INSERT INTO f_paymentdetail(
F_PaymentDetailF_PaymentID,
F_PaymentDetailM_PaymentTypeID,
F_PaymentDetailAmount,
F_PaymentDetailActual,
F_PaymentDetailChange,
F_PaymentDetailCreated,
F_PaymentDetailLastUpdated,
F_PaymentDetailUserID)
VALUES (
?,
?,
?,
?,
?,
now(),
now(),
?
)";
//echo $sql;
$query = $this->db_onedev->query($sql,
array(
$headerid,
$v['id'],
$amount,
$actual,
$change,
$xuserid
)
);
if (!$query) {
$this->sys_error_db("f_paymentdetail cash insert");
exit;
}
}
else{
if(intval($v['leftvalue']) > 0){
$actual = 0;
$change = 0;
$amount = $v['leftvalue'];
$sql = "INSERT INTO f_paymentdetail(
F_PaymentDetailF_PaymentID,
F_PaymentDetailM_PaymentTypeID,
F_PaymentDetailAmount,
F_PaymentDetailActual,
F_PaymentDetailChange,
F_PaymentDetailCreated,
F_PaymentDetailLastUpdated,
F_PaymentDetailUserID)
VALUES (
?,
?,
?,
?,
?,
now(),
now(),
?
)";
//echo $sql;
$query = $this->db_onedev->query($sql,
array(
$headerid,
$v['id'],
$amount,
$actual,
$change,
$xuserid
)
);
if (!$query) {
$this->sys_error_db("f_paymentdetail non cash insert");
exit;
}
}
}
}
$query = "SELECT M_PaymentTypeID as id,
M_PaymentTypeCode as code,
IF(M_PaymentTypeCode = 'CASH','Y','N') as chex,
M_PaymentTypeName as chexlabel,
'Jumlah' as leftlabel,
CASE
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
WHEN M_PaymentTypeCode = 'CREDIT' THEN 'Nomor Kartu'
ELSE 'Nomor Voucher'
END as rightlabel,
0 as leftvalue,
0 as rightvalue
FROM m_paymenttype WHERE M_PaymentTypeIsActive = 'Y'";
$rows = $this->db_onedev->query($query)->result_array();
foreach($rows as $k => $v){
if($v['chex'] == 'N')
$rows[$k]['chex'] = false;
else
$rows[$k]['chex'] = true;
}
$xdata = $this->db_onedev->query("SELECT F_PaymentID as idx, F_PaymentNumber as numberx FROM f_payment WHERE F_PaymentID = {$headerid}")->row();
$result = array(
"total" => count($rows) ,
"records" => array('types'=>$rows,'data'=>$xdata)
);
$this->sys_ok($result);
exit;
}
function delete_note()
{
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$xuserid = $this->sys_user['M_UserID'];
$prm = $this->sys_input;
$prmnota = $prm['nota'];
$catatan = $prm['catatan'];
$sql = "UPDATE f_payment SET F_PaymentIsActive = 'N', F_PaymentNote = '{$catatan}' WHERE F_PaymentID = {$prmnota['note_id']}";
//echo $sql;
$query = $this->db_onedev->query($sql);
if (!$query) {
$this->sys_error_db("f_payment delete");
exit;
}
$sql = "UPDATE f_paymentdetail SET F_PaymentDetailIsActive = 'N' WHERE F_PaymentDetailF_PaymentID = {$prmnota['note_id']}";
//echo $sql;
$query = $this->db_onedev->query($sql);
if (!$query) {
$this->sys_error_db("f_paymentdetail delete");
exit;
}
$result = array(
"total" => 1 ,
"records" => array('prm'=>$prm)
);
$this->sys_ok($result);
exit;
}
}