69 lines
2.1 KiB
PHP
69 lines
2.1 KiB
PHP
<?php
|
|
class Hs_payment extends MY_Controller {
|
|
function __construct() {
|
|
parent::__construct();
|
|
}
|
|
function by_id($paymentID,$userID =3) {
|
|
$sql = "select M_UserUserName from m_user where M_UserID = ?";
|
|
$qry = $this->db->query($sql,[$userID]);
|
|
if (!$qry) {
|
|
// echo $this->db->error()["message"];
|
|
echo json_encode([]);
|
|
exit;
|
|
}
|
|
$rows = $qry->result_array();
|
|
$userName = "RptAdmin";
|
|
if (count($rows) > 0) {
|
|
$userName = $rows[0]["M_UserUserName"];
|
|
}
|
|
$sql = "select
|
|
? M_UserName,
|
|
F_PaymentLogDetailsID ,
|
|
F_PaymentLogDetailsHS_DeliveryOrderID ,
|
|
F_PaymentLogDetailsF_PaymentID,
|
|
F_PaymentLogDetailsJSON ,
|
|
F_PaymentLogDetailsUserID ,
|
|
F_PaymentLogDetailsUsername
|
|
from one_hs.f_payment_log_details
|
|
where F_PaymentLogDetailsF_PaymentID =?";
|
|
$qry = $this->db->query($sql,[$userName,$paymentID]);
|
|
if (!$qry) {
|
|
// echo $this->db->error()["message"];
|
|
echo json_encode([]);
|
|
exit;
|
|
}
|
|
$rows = $qry->result_array();
|
|
$result = [];
|
|
foreach($rows as $r) {
|
|
$json= json_decode($r["F_PaymentLogDetailsJSON"],true);
|
|
unset($r["F_PaymentLogDetailsJSON"]);
|
|
|
|
$header= $json["details"][0];
|
|
$patient_name = $json["details"][0]["patient_name"];
|
|
$j_details = $json["details"][0]["details"];
|
|
$payment = $json["payment"];
|
|
unset($json["details"]);
|
|
unset($json["payment"]);
|
|
unset($payment["username"]);
|
|
unset($payment["payment_id"]);
|
|
$payment["payment_amount"] = $payment["amount"];
|
|
unset($payment["amount"]);
|
|
$r = array_merge($r,$json);
|
|
$r = array_merge($r,$payment);
|
|
foreach( $j_details as $j) {
|
|
$arr = ["patient_name"=>$patient_name,
|
|
"amount" => $j["amount"],
|
|
"discount" => $j["discount"],
|
|
"discountrp" => $j["discountrp"],
|
|
"subtotal" => $j["subtotal"],
|
|
"test_name" => $j["test_name"],
|
|
"total" => $j["total"]
|
|
];
|
|
$result[] = array_merge($r,$arr) ;
|
|
}
|
|
$idx = count($result) - 1;
|
|
}
|
|
echo json_encode($result);
|
|
}
|
|
}
|