80 lines
2.5 KiB
PHP
80 lines
2.5 KiB
PHP
<?php
|
|
class Fo_verification extends MY_Controller {
|
|
function index() {
|
|
echo "FO Verification";
|
|
}
|
|
function listing_order() {
|
|
//$this->sys_debug();
|
|
try {
|
|
//1. cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//2. ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$s_startdate = $prm["startdate"];
|
|
$s_enddate = $prm["enddate"];
|
|
$s_query= "%" . $prm["query"] . "%";
|
|
|
|
//2A. jumlah baris per page default 25 jika tidak di set
|
|
$row_per_page = 10;
|
|
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
|
$page = 1;
|
|
if (isset($prm["page"])) $page = $prm["page"];
|
|
$tot_count = 0;
|
|
$sql_param = array($s_startdate,$end);
|
|
|
|
//3. hitung total rows
|
|
$sql = "select count(*) as tot
|
|
from t_orderheader
|
|
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
where (T_OrderHeaderNumber like ? OR M_PatientName like ?) and T_OrderHeaderIsActive='Y'";
|
|
$query = $this->db->query($sql,$sql_param);
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["tot"];
|
|
} else {
|
|
$this->sys_error_db("t_orderheader count");
|
|
exit;
|
|
}
|
|
|
|
//4. cari records jika total count > 0
|
|
$rows = array();
|
|
if ($tot_count > 0) {
|
|
//4A. start_limit set ke 0 jika negative atau > total count
|
|
$start_limit = ($page - 1) * $row_per_page;
|
|
if ($start_limit > $tot_count) {
|
|
$start_limit = 0;
|
|
}
|
|
if ($start_limit < 0) {
|
|
$start_limit = 0;
|
|
}
|
|
$sql = "select T_OrderHeaderDate, T_OrderHeaderNumber,M_PatientNoReg,M_PatientName,M_DoctorName
|
|
from t_orderheader
|
|
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
LEFT JOIN m_doctor ON T_OrderHeaderM_DoctorID = M_DoctorID
|
|
where (T_OrderHeaderNumber like ? OR M_PatientName like ?) and T_OrderHeaderIsActive='Y'
|
|
limit $start_limit,$row_per_page";
|
|
$query = $this->db->query($sql,$sql_param);
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
} else {
|
|
$this->sys_error_db("t_orderheader rows");
|
|
exit;
|
|
}
|
|
}
|
|
$result = array ("total" => $tot_count, "records" => $rows);
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
?>
|