Files
BE_IBL/application/controllers/mockup/clinic/fo/Diagnose.php
2026-04-15 15:24:12 +07:00

70 lines
1.7 KiB
PHP
Executable File

<?php
class Diagnose extends MY_Controller
{
var $db_smartone;
public function index()
{
echo "Diagnose API";
}
public function __construct()
{
parent::__construct();
$this->db_smartone = $this->load->database("clinicdev", true);
}
public function search()
{
$prm = $this->sys_input;
$max_rst = 25;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "select count(*) total
from
m_diagnose
where M_DiagnoseIsActive = 'Y'
and M_DiagnoseName 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_diagnose count",$this->db_smartone);
exit;
}
$sql = "select M_DiagnoseID, M_DiagnoseName
from m_diagnose
where M_DiagnoseIsActive = 'Y'
and M_DiagnoseName like ?
limit {$max_rst}";
$query = $this->db_smartone->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
foreach ($rows as $k => $v)
$rows[$k]['mou'] = json_decode($v['mou']);
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_diagnose rows",$this->db_smartone);
exit;
}
}
}