Files
BE_IBL/application/controllers/regonline/Resultoption.php
2026-04-15 15:23:57 +07:00

973 lines
30 KiB
PHP

<?php
class Resultoption extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "BRANCH API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
function lookupattributebyname(){
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$attribute = $prm['branch'];
$all = $prm['all'];
$limit = '';
if($all == 'N'){
$limit = ' LIMIT 10';
}
$number_limit = 10;
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
$sql = "select COUNT(*) as total FROM
(SELECT * from t_testresultoption
JOIN t_test ON T_TestID = T_TestResultOptionT_TestID
JOIN t_resultoption ON T_ResultOptionID = T_TestResultOptionT_ResultOptionID
WHERE
(T_TestName LIKE CONCAT('%','{$attribute}','%') OR
T_TestSasCode LIKE CONCAT('%','{$attribute}','%')) AND
T_TestResultOptionIsActive = 'Y'
GROUP BY T_TestID) a";
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
$query = $this->db_onedev->query($sql);
// echo $this->db_onedev->last_query();
$tot_count = 0;
$tot_page = 0;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
$tot_page = ceil($tot_count/$number_limit);
} else {
$this->sys_error_db("t_testresultoption count", $this->db_onedev);
exit;
}
$sql = "select T_TestResultOptionID as id,
T_TestID,
CONCAT('[',T_TestSasCode,'] ',T_TestName) T_TestName,
T_TestSasCode,
T_ResultOptionID,
T_ResultOptionName,
t_testresultoption.*,
'xxx' as resultoptions
from t_testresultoption
JOIN t_test ON T_TestID = T_TestResultOptionT_TestID
LEFT JOIN t_resultoption ON T_ResultOptionID = T_TestResultOptionT_ResultOptionID
WHERE
(T_TestName LIKE CONCAT('%','{$attribute}','%') OR
T_TestSasCode LIKE CONCAT('%','{$attribute}','%')) AND
T_TestResultOptionIsActive = 'Y'
GROUP BY T_TestID
ORDER BY T_TestSasCode ASC, T_ResultOptionName ASC
limit $number_limit offset $number_offset";
$sql_param = array($search);
$query = $this->db_onedev->query($sql);
//echo $this->db_onedev->last_query();
if ($query) {
$rows = $query->result_array();
if($rows){
foreach($rows as $k => $v){
$option = $v['T_TestResultOptionT_ResultOptionID'];
$test = $v['T_TestResultOptionT_TestID'];
$x = $this->db_onedev->query("select concat( '[', group_concat( json_object('id',IFNULL(T_TestResultOptionID,T_ResultOptionID), 'optionname', T_ResultOptionName,'status', IF(IFNULL(T_ResultOptionID,0) = 0 AND T_ResultOptionDefault = 'N', 'N','Y')) separator ',' ), ']' )
as n FROM
(SELECT T_TestResultOptionID,T_TestResultOptionT_TestID,T_ResultOptionID,T_ResultOptionName,T_ResultOptionDefault
FROM t_resultoption
JOIN t_testresultoption ON T_TestResultOptionT_ResultOptionID = T_ResultOptionID AND T_TestResultOptionT_TestID = $test AND T_TestResultOptionIsActive = 'Y'
WHERE T_ResultOptionIsActive = 'Y'
GROUP BY T_ResultOptionID) a")->row();
$rows[$k]['resultoptionx'] = json_decode($x->n);
$rows[$k]['resultoptions'] = $this->add_resultoption($option,$test);
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
}
}
} else {
$this->sys_error_db("t_testresultoption select");
exit;
}
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function add_resultoption($option,$test){
$query =" SELECT t_testresultoption.*, t_resultoption.*,IF(T_TestResultOptionID IS NULL,'N','Y') as isresultoption, IFNULL(T_TestResultOptionID,0) as xid
FROM t_resultoption
LEFT JOIN t_testresultoption ON T_TestResultOptionT_ResultOptionID = T_ResultOptionID AND T_TestResultOptionT_TestID = $test AND T_TestResultOptionIsActive = 'Y'
WHERE T_ResultOptionIsActive = 'Y'
GROUP BY T_ResultOptionID";
//echo $query;
$rows = $this->db_onedev->query($query)->result_array();
if(!$rows)
$rows = array();
return $rows;
}
function getresultoption(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$rows = [];
$query =" SELECT *,IF(T_ResultOptionDefault = 'N','N','Y') as isresultoption, 0 as xid
FROM t_resultoption
WHERE
T_ResultOptionIsActive = 'Y'
";
//echo $query;
$rows['resultoptions'] = $this->db_onedev->query($query)->result_array();
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
public function lookupregionalbyname()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$regional = $prm['regional'];
$attribute = $prm['attribute'];
$limit = '';
if($all == 'N'){
$limit = ' LIMIT 10';
}
$number_limit = 10;
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
$sql = "select COUNT(*) as total
FROM(SELECT *
from s_regional
LEFT JOIN t_testresultoption ON S_RegionalID = T_TestResultOptionS_RegionalID AND T_TestResultOptionIsActive = 'Y'
where
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
IFNULL(T_TestResultOptionName,'') LIKE CONCAT('%','{$attribute}','%') AND
S_RegionalIsActive = 'Y'
GROUP BY S_RegionalID) a";
$sql_param = array($search);
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
$query = $this->db_onedev->query($sql);
$tot_count = 0;
$tot_page = 0;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
$tot_page = ceil($tot_count/$number_limit);
} else {
$this->sys_error_db("s_regional count", $this->db_onedev);
exit;
}
$sql = "select S_RegionalID as id,
S_RegionalName as name,
S_RegionalName as namex,
s_regional.*
from s_regional
LEFT JOIN t_testresultoption ON S_RegionalID = T_TestResultOptionS_RegionalID AND T_TestResultOptionIsActive = 'Y'
where
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
IFNULL(T_TestResultOptionName,'') LIKE CONCAT('%','{$attribute}','%') AND
S_RegionalIsActive = 'Y'
GROUP BY S_RegionalID
ORDER BY S_RegionalName ASC
limit $number_limit offset $number_offset";
$sql_param = array($search);
$query = $this->db_onedev->query($sql);
//echo $this->db_onedev->last_query();
if ($query) {
$rows = $query->result_array();
} else {
$this->sys_error_db("s_regional select");
exit;
}
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function addnewregional()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$name = $prm['name'];
$sql = "insert into s_regional(
S_RegionalName,
S_RegionalCreated,
S_RegionalLastUpdated
)
values( ?, now(), now())";
$query = $this->db_onedev->query($sql,
array(
$name
)
);
//echo $query;
if (!$query) {
$this->sys_error_db("s_regional insert");
exit;
}
$last_id = $this->db_onedev->insert_id();
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
$last_id = $this->db_onedev->insert_id();
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function editregional()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$id = $prm['id'];
$name = $prm['name'];
$userid = $this->sys_user["M_UserID"];
$sqlcompany = "update s_regional SET
S_RegionalName = ?,
S_RegionalLastUpdated = now()
where
S_RegionalID = ?
";
$querycompany = $this->db_onedev->query($sqlcompany,
array(
$name,
$id
)
);
// echo $query;
if (!$querycompany) {
$this->sys_error_db("s_regional update");
exit;
}
$result = array ("total" => 1, "records" => array("xid" => $id));
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function addnewresultoption()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$T_TestResultOptionT_TestID = $prm['testid'];
$userid = $this->sys_user["M_UserID"];
if($T_TestResultOptionT_TestID == 0){
$errors = array();
if($T_TestResultOptionT_TestID == 0){
array_push($errors,array('field'=>'regional','msg'=>'Pemeriksaan dipilih dulu dong'));
}
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
$this->sys_ok($result);
}else{
if($prm['xid'] == 0){
foreach($prm['orderregtimes'] as $k=>$v){
if($v['isresultoption'] === 'Y'){
$xtime = $v['T_ResultOptionID'];
$sql = "INSERT INTO t_testresultoption(
T_TestResultOptionT_TestID,
T_TestResultOptionT_ResultOptionID,
T_TestResultOptionUserID,
T_TestResultOptionLastUpdated,
T_TestResultOptionCreated)
VALUES(?,?,?,now(),now())";
$query = $this->db_onedev->query($sql,array($T_TestResultOptionT_TestID,$xtime,$userid));
}
}
if (!$query) {
$this->sys_error_db("t_testresultoption insert",$this->db_onedev);
exit;
}
$last_id = $this->db_onedev->insert_id();
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
}else{
foreach($prm['orderregtimes'] as $k=>$v){
if($v['isresultoption'] === 'Y' && $v['xid'] == 0){
$xtime = $v['T_ResultOptionID'];
$sql = "INSERT INTO t_testresultoption(
T_TestResultOptionT_TestID,
T_TestResultOptionT_ResultOptionID,
T_TestResultOptionUserID,
T_TestResultOptionLastUpdated,
T_TestResultOptionCreated)
VALUES(?,?,?,now(),now())";
$query = $this->db_onedev->query($sql,array($T_TestResultOptionT_TestID,$xtime,$userid));
}else if($v['isresultoption'] === 'N'){
$sql ="UPDATE t_testresultoption SET
T_TestResultOptionIsActive = 'N',
T_TestResultOptionUserID = '{$userid}',
T_TestResultOptionLastUpdated = now()
WHERE
T_TestResultOptionID = ?";
$query = $this->db_onedev->query($sql,array($v['xid']));
}
}
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
}
}
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function deleteregional()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$userid = $this->sys_user["M_UserID"];
$sql = "update s_regional SET
S_RegionalIsActive = 'N',
S_RegionalLastUpdated = now()
WHERE
S_RegionalID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("s_regional delete");
exit;
}
$sql = "update t_testresultoption SET
T_TestResultOptionIsActive = 'N',
T_TestResultOptionLastUpdated = now()
WHERE
T_TestResultOptionS_RegionalID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("t_testresultoption delete");
exit;
}
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function deleteattribute()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$userid = $this->sys_user["M_UserID"];
$sql = "update t_testresultoption SET
T_TestResultOptionIsActive = 'N',
T_TestResultOptionLastUpdated = now()
WHERE
T_TestResultOptionID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("t_testresultoption delete");
exit;
}
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function searchtest(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['tes'] != '')
{
$q['search'] = "%{$prm['tes']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM t_test
WHERE
T_TestName like ?
AND T_TestIsActive = 'Y'";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("t_test count",$this->db_onedev);
exit;
}
$sql = "
SELECT T_TestID,CONCAT('[',T_TestSasCode,'] ',T_TestName) as T_TestName
FROM t_test
WHERE
CONCAT('[',T_TestSasCode,'] ',T_TestName) like ?
AND T_TestIsActive = 'Y'
ORDER BY T_TestSasCode ASC
";
$query = $this->db_onedev->query($sql, array($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("t_test rows",$this->db_onedev);
exit;
}
}
function searchregionalbyname(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM s_regional
WHERE
S_RegionalName like ?
AND S_RegionalIsActive = 'Y'";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("s_regional count",$this->db_onedev);
exit;
}
$sql = "
SELECT S_RegionalID, S_RegionalName
FROM s_regional
WHERE
S_RegionalName like ?
AND S_RegionalIsActive = 'Y'
ORDER BY S_RegionalName ASC
";
$query = $this->db_onedev->query($sql, array($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("s_regional rows",$this->db_onedev);
exit;
}
}
function searchsubcategory(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM t_resultoption
WHERE
T_ResultOptionName like ?
AND T_ResultOptionIsActive = 'Y'";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("t_resultoption count",$this->db_onedev);
exit;
}
$sql = "
SELECT T_CategoryID, T_CategoryName,T_ResultOptionID,CONCAT(T_ResultOptionName,'[',T_CategoryName,'] ') T_ResultOptionName
FROM t_resultoption
JOIN t_category ON T_CategoryID = T_ResultOptionT_CategoryID
WHERE
CONCAT(T_ResultOptionName,'[',T_CategoryName,'] ') like ?
AND T_ResultOptionIsActive = 'Y'
ORDER BY T_ResultOptionName ASC
";
$query = $this->db_onedev->query($sql, array($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("t_resultoption rows",$this->db_onedev);
exit;
}
}
function searchdistrict(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_district
WHERE
M_DistrictName like ?
AND M_DistrictT_ResultOptionID = '{$id}'
AND M_DistrictIsActive = 'Y'";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_district count",$this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM m_district
WHERE
M_DistrictName like ?
AND M_DistrictT_ResultOptionID = '{$id}'
AND M_DistrictIsActive = 'Y'
ORDER BY M_DistrictName ASC
";
$query = $this->db_onedev->query($sql, array($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_district rows",$this->db_onedev);
exit;
}
}
function searchkelurahan(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_kelurahan
WHERE
M_KelurahanName like ?
AND M_KelurahanM_DistrictID = '{$id}'
AND M_KelurahanIsActive = 'Y'";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_district count",$this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM m_kelurahan
WHERE
M_KelurahanName like ?
AND M_KelurahanM_DistrictID = '{$id}'
AND M_KelurahanIsActive = 'Y'
ORDER BY M_KelurahanName ASC
";
$query = $this->db_onedev->query($sql, array($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_district rows",$this->db_onedev);
exit;
}
}
function searchcompany(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_company
WHERE
M_CompanyName like ?
AND M_CompanyIsActive = 'Y'";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_company count",$this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM m_company
WHERE
M_CompanyName like ?
AND M_CompanyIsActive = 'Y'
ORDER BY M_CompanyName ASC
";
$query = $this->db_onedev->query($sql, array($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;
}
}
function searchmou(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_mou
WHERE
M_MouName like ?
AND M_MouM_CompanyID = '{$id}'
AND M_MouIsActive = 'Y'";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_mou count",$this->db_onedev);
exit;
}
$sql = "SELECT *
FROM m_mou
WHERE
M_MouName like ?
AND M_MouM_CompanyID = '{$id}'
AND M_MouIsActive = 'Y'
ORDER BY M_MouName ASC
";
$query = $this->db_onedev->query($sql, array($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_mou rows",$this->db_onedev);
exit;
}
}
function searchdoctor(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
FROM m_doctor
WHERE M_DoctorIsActive = 'Y') a
WHERE
M_DoctorName like ?";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_doctor count",$this->db_onedev);
exit;
}
$sql = "SELECT * FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
FROM m_doctor
WHERE M_DoctorIsActive = 'Y') a
WHERE
M_DoctorName like ?
GROUP BY M_DoctorID
ORDER BY M_DoctorName ASC";
$query = $this->db_onedev->query($sql, array($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_doctor rows",$this->db_onedev);
exit;
}
}
function selectaddressdoctor(){
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$rows = [];
$query ="SELECT M_DoctorAddressID,
CONCAT(M_DoctorAddressNote, ': ',M_DoctorAddressDescription) as M_DoctorAddressNote
FROM
m_doctoraddress
WHERE M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = '{$id}'";
//echo $query;
$rows['addressdoctors'] = $this->db_onedev->query($query)->result_array();
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}