Initial import
This commit is contained in:
217
one-api/application/controllers/mockup/clinic/fo/Payment.php
Normal file
217
one-api/application/controllers/mockup/clinic/fo/Payment.php
Normal file
@@ -0,0 +1,217 @@
|
||||
|
||||
<?php
|
||||
|
||||
class Payment extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Payment API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("clinicdev", true);
|
||||
}
|
||||
|
||||
public function get_order() {
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$rst = ["order_header"=>[], "order_detail"=>[]];
|
||||
|
||||
$sql = "
|
||||
select T_OrderHeaderID as order_id,
|
||||
T_OrderHeaderLabNumber as order_no,
|
||||
T_OrderHeaderDate as order_date,
|
||||
T_OrderHeaderSubTotal as order_subtotal,
|
||||
T_OrderHeaderRounding as order_rounding,
|
||||
T_OrderHeaderTotal as order_total,
|
||||
M_PatientName as patient_name,
|
||||
M_PatientNoReg as patient_mr,
|
||||
M_MouName as order_mou,
|
||||
M_CompanyName as order_company
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
where T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, array($prm['id']));
|
||||
if ($query) {
|
||||
$rows = (array) $query->row();
|
||||
$rst['order_header'] = $rows;
|
||||
// $result = array("status" => "OK" , "data" => $rst);
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
// { n:1, d_id:1, t_id:1, t_name:'SGOT', t_price:80000, t_disctotal:7000, t_total:73000 },
|
||||
// { n:2, d_id:2, t_id:2, t_name:'SGPT', t_price:75000, t_disctotal:8000, t_total:67000 }
|
||||
// T_OrderDetailPrice double [0]
|
||||
// T_OrderDetailPriceForDisc double [0]
|
||||
// T_OrderDetailDisc double [0]
|
||||
// T_OrderDetailDiscAmount double [0]
|
||||
// T_OrderDetailTotal
|
||||
|
||||
$sql = "
|
||||
select T_OrderDetailID as d_id,
|
||||
T_OrderDetailT_TestID as t_id,
|
||||
T_OrderDetailT_TestName as t_name,
|
||||
T_OrderDetailPrice as t_price,
|
||||
T_OrderDetailDiscTotal as t_disctotal,
|
||||
T_OrderDetailTotal as t_total
|
||||
from t_orderdetail
|
||||
where T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_ORderDetailIsActive = 'Y'";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['id']));
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rst['order_detail'] = $rows;
|
||||
|
||||
$result = array("status" => "OK" , "data" => $rst);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 100;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_paymenttype
|
||||
where M_PaymentTypeIsActive = 'Y'
|
||||
and M_PaymentTypeName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_paymenttype count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_PaymentTypeID payment_type_id, M_PaymentTypeName payment_type_name, M_PaymentTypeCode payment_type_code,
|
||||
0 payment_amount, '' payment_note, 'Nomor Kartu' payment_note_label, 'N' payment_enable,
|
||||
0 payment_change, 0 payment_actual, 0 payment_card_id, 0 payment_edc_id, 0 payment_account_id
|
||||
from m_paymenttype
|
||||
where M_PaymentTypeIsActive = 'Y'
|
||||
and M_PaymentTypeName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $v) {
|
||||
|
||||
if ($v['payment_type_code'] == 'CASH')
|
||||
$v['payment_note_label'] = 'Kembali';
|
||||
if ($v['payment_type_code'] == 'VOUCHER')
|
||||
$v['payment_note_label'] = 'Nomor Voucher';
|
||||
|
||||
$rows[$k] = $v;
|
||||
}
|
||||
|
||||
$result = $rows;
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_paymenttype rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$payment_json = json_encode($prm['payments']);
|
||||
|
||||
$sql = "CALL sp_fo_payment('{$prm['order_id']}', '{$payment_json}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save payment", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function log_nota()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$dblog = $this->load->database('onelog', true);
|
||||
|
||||
$p = $this->db_smartone->where('c_orderheaderid', $prm['order_id'])
|
||||
->get('c_orderheader')
|
||||
->row();
|
||||
|
||||
$uid = $this->sys_user['M_UserID'];
|
||||
$q = $dblog->set("Log_ClinicUserID", $uid)
|
||||
->set("Log_ClinicJson", json_encode(["order_id"=>$prm['order_id'], "patient_id"=>$p->C_OrderHeaderM_PatientID]))
|
||||
->set("Log_ClinicCode", "CLINIC.PRINT.RECEIPT")
|
||||
->insert('log_clinic');
|
||||
|
||||
if ($q) {
|
||||
$id = $dblog->insert_id();
|
||||
$this->sys_ok($id);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("LOG Nota",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_bank()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT Nat_BankID, Nat_BankName
|
||||
FROM nat_bank ORDER BY Nat_BankName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows, "total"=>sizeof($rows)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("NAT BANK",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user