134 lines
3.5 KiB
PHP
134 lines
3.5 KiB
PHP
<?php
|
|
|
|
class Px extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Px API";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
|
|
public function search()
|
|
{
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
$orderdate = $prm['orderdate'];
|
|
$cito = $prm['cito'] == true ?'Y':'N';
|
|
$mouid = $prm['mouid'];
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM t_price
|
|
JOIN t_test ON T_PriceT_TestID = T_TestID
|
|
JOIN m_mou ON M_MouID = T_PriceM_MouID
|
|
AND M_MouStartDate <= ?
|
|
AND M_MouEndDate >= ?
|
|
WHERE
|
|
|
|
T_PriceIsCito = ?
|
|
AND T_PriceM_MouID = ?
|
|
AND T_TestName like ?
|
|
|
|
AND T_PriceIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,array($orderdate,$orderdate,$cito,$mouid,$q['search']));
|
|
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_patient count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT T_PriceT_TestID as id,
|
|
T_TestCode as pxcode,
|
|
T_TestName as pxname,
|
|
T_TestIsResult as isresult,
|
|
T_PriceAmount as bruto,
|
|
T_PriceDisc as discount,
|
|
T_PriceDiscRp as discountrp,
|
|
((T_PriceDisc / 100) * T_PriceAmount) - T_PriceDiscRp as discounttotal,
|
|
( T_PriceAmount - ((T_PriceDisc / 100) * T_PriceAmount) - T_PriceDiscRp ) as total,
|
|
T_PriceIsCito as flagcito
|
|
FROM t_price
|
|
JOIN t_test ON T_PriceT_TestID = T_TestID
|
|
JOIN m_mou ON M_MouID = T_PriceM_MouID
|
|
AND M_MouStartDate <= ?
|
|
AND M_MouEndDate >= ?
|
|
WHERE
|
|
|
|
T_PriceIsCito = ?
|
|
AND T_PriceM_MouID = ?
|
|
AND T_TestName like ?
|
|
|
|
AND T_PriceIsActive = 'Y'
|
|
ORDER BY T_PricePriority DESC
|
|
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($orderdate,$orderdate,$cito,$mouid,$q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_company rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
public function search_()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$search = $prm["search"];
|
|
$sql_param = array("%$search%");
|
|
$sql = "select count(*) total
|
|
from
|
|
m_patienttype
|
|
where
|
|
M_PatientTypeName like ? and
|
|
M_PatientTypeIsActive = 'Y'";
|
|
$query = $this->db_smartone->query($sql, $sql_param);
|
|
$tot_count =0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
} else {
|
|
$this->sys_error_db("m_patienttype count", $this->db_smartone);
|
|
exit;
|
|
}
|
|
$sql = "select M_PatientTypeID, M_PatientTypeName
|
|
from
|
|
m_patienttype
|
|
where
|
|
M_PatientTypeName like ? and
|
|
M_PatientTypeIsActive = 'Y'
|
|
limit 0,10";
|
|
$query = $this->db_onedev->query($sql,$sql_param);
|
|
$rows = $query->result_array();
|
|
$this->_add_mou($rows);
|
|
$result = array("total" => $tot_count, "records" => $rows );
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
}
|