Files
2026-04-27 10:31:17 +07:00

88 lines
2.2 KiB
PHP

<?php
class Language extends MY_Controller
{
var $db_smartone;
public function index()
{
echo "Patient API";
}
public function __construct()
{
parent::__construct();
$this->db_smartone = $this->load->database("onedev", true);
}
public function search()
{
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "select count(*) total
from
m_lang
where M_LangIsActive = 'Y'
and M_LangName 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_lang count",$this->db_smartone);
exit;
}
$sql = "select M_LangID as id, M_LangName as name
from m_lang
where M_LangIsActive = 'Y'
and M_LangName like ?";
$query = $this->db_smartone->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
$rows_ = [];
$si = [["is_si" => "N", "si_text" => ""], ["is_si" => "Y", "si_text" => "(SI)"]];
foreach ($rows as $k => $v)
{
foreach ($si as $l => $w)
{
$v['is_si'] = $w['is_si'];
$v['name'] .= $w['si_text'] == '' ? '' : ' ' . $w['si_text'];
$v['key'] = $v['id'] . '-' . $v['is_si'];
$rows_[] = $v;
}
}
$result = array("total" => $tot_count, "records" => $rows_, "total_display" => sizeof($rows_));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_doctor rows",$this->db_smartone);
exit;
}
}
public function search_()
{
$rows = array();
$rows[] = array("id" =>"ID", "name" => "Bahasa Indonesia");
$rows[] = array("id" =>"EN", "name" => "Bahasa Inggris");
$rows[] = array("id" =>"CH", "name" => "Bahasa Mandarin");
$result = array("records" => $rows);
$this->sys_ok($result);
exit;
}
}