Initial import
This commit is contained in:
128
one-api/application/controllers/mockup/fo/cashier/Patient.php
Normal file
128
one-api/application/controllers/mockup/fo/cashier/Patient.php
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user