diff --git a/application/controllers/mockup/fo/cashiernewpayment-v27/Patient.php b/application/controllers/mockup/fo/cashiernewpayment-v27/Patient.php index 203c3197..6c6fefd6 100644 --- a/application/controllers/mockup/fo/cashiernewpayment-v27/Patient.php +++ b/application/controllers/mockup/fo/cashiernewpayment-v27/Patient.php @@ -6,11 +6,12 @@ class Patient extends MY_Controller { echo "Patient API"; } - public function __construct() - { - parent::__construct(); - $this->db_onedev = $this->load->database("onedev", true); - } + public function __construct() + { + parent::__construct(); + $this->db_onedev = $this->load->database("onedev", true); + $this->load->library('ibl_encryptor'); + } public function add_notes($orderid) { @@ -112,15 +113,17 @@ class Patient extends MY_Controller } - $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, - CONCAT(M_TitleLangName,'. ',M_PatientName) as M_PatientName_eng, - M_PatientIDNumber, - M_TitleName, - M_CompanyName, - M_MouName, + $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, + CONCAT(M_TitleLangName,'. ',M_PatientName) as M_PatientName_eng, + M_PatientName_enc, + M_PatientIDNumber, + M_TitleName, + M_TitleLangName, + M_CompanyName, + M_MouName, T_OrderHeaderTotal as totalbill, IFNULL(Last_StatusPaymentPaid,0) as paid, (T_OrderHeaderTotal + fn_fo_chasier_get_admin_charge(T_OrderHeaderID) )- ifnull(fn_fo_chasier_get_total_payment(T_OrderHeaderID),0) as unpaid, @@ -152,12 +155,19 @@ class Patient extends MY_Controller // echo $sql; $query = $this->db_onedev->query($sql, $sql_param); $rows = $query->result_array(); - $qrySrc = $this->db_onedev->last_query(); - if ($rows) { - foreach ($rows as $k => $v) { - $rows[$k]['notes'] = $this->add_notes($v['T_OrderHeaderID']); - } - } + $qrySrc = $this->db_onedev->last_query(); + if ($rows) { + foreach ($rows as $k => $v) { + $plainName = trim($this->ibl_encryptor->decrypt($v['M_PatientName_enc'] ?? '') ?? ''); + if ($plainName === '') { + $plainName = trim((string)($v['M_PatientName'] ?? '')); + } + $rows[$k]['M_PatientName_print'] = trim(($v['M_TitleName'] ?? '') . '. ' . $plainName); + $rows[$k]['M_PatientName_print_eng'] = trim(($v['M_TitleLangName'] ?? '') . '. ' . $plainName); + unset($rows[$k]['M_PatientName_enc']); + $rows[$k]['notes'] = $this->add_notes($v['T_OrderHeaderID']); + } + } $result = array("total" => $tot_page, "records" => $rows, "sql" => $qrySrc);