1146 lines
35 KiB
PHP
1146 lines
35 KiB
PHP
<?php
|
|
|
|
class Subgroup extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "SUB GROUP API";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
|
|
function lookupsubsubgroup(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$sql = "select Nat_SubSubGroupID as id,Nat_SubGroupID,Nat_SubGroupName,
|
|
nat_subsubgroup.*
|
|
from nat_subsubgroup
|
|
JOIN nat_subgroup ON Nat_SubSubGroupSubGroupID = Nat_SubGroupID
|
|
WHERE
|
|
Nat_SubSubGroupSubGroupID = {$id} AND Nat_SubSubGroupIsActive = 'Y'";
|
|
// echo $sql;
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$rows = $query->result_array();
|
|
if($rows){
|
|
}
|
|
|
|
$result = array ("total" => count($rows), "records" => $rows);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function lookup()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$search = $prm['search'];
|
|
$all = $prm['all'];
|
|
$limit = '';
|
|
if($all == 'N'){
|
|
$limit = ' LIMIT 10';
|
|
}
|
|
$sql = "select COUNT(*) as total
|
|
from nat_subgroup
|
|
where
|
|
Nat_SubGroupIsActive = 'Y'";
|
|
$sql_param = array($search);
|
|
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
|
|
|
|
|
$sql = "select Nat_SubGroupID as id,
|
|
Nat_SubGroupCode as code,
|
|
Nat_SubGroupName as name,
|
|
Nat_SubGroupNat_GroupID as groupid,
|
|
Nat_SubGroupLangName as namelang,
|
|
'' as T_TestIsNonLabName,Nat_GroupName ,Nat_GroupID,
|
|
nat_subgroup.*
|
|
from nat_subgroup
|
|
join nat_group on Nat_SubGroupNat_GroupID = Nat_GroupID
|
|
where
|
|
( Nat_SubGroupName LIKE CONCAT('%','{$search}','%') OR
|
|
Nat_SubGroupCode LIKE CONCAT('%','{$search}','%')
|
|
)AND
|
|
Nat_SubGroupIsActive = 'Y'
|
|
GROUP BY Nat_SubGroupID
|
|
ORDER BY Nat_SubGroupID ASC $limit";
|
|
$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("nat_subgroup select");
|
|
exit;
|
|
}
|
|
|
|
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
|
|
public function addnewsubgroup()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$name = $prm['name'];
|
|
$namelang = $prm['namelang'];
|
|
$code = $prm['code'];
|
|
$group = $prm['group'];
|
|
$query = "SELECT COUNT(*) as exist FROM nat_subgroup WHERE Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupCode = '{$code}'";
|
|
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
|
if($exist_code == 0){
|
|
$sql = "insert into nat_subgroup(
|
|
Nat_SubGroupCode,
|
|
Nat_SubGroupName,
|
|
Nat_SubGroupLangName,
|
|
Nat_SubGroupNat_GroupID,
|
|
Nat_SubGroupCreated,
|
|
Nat_SubGroupLastUpdated
|
|
)
|
|
values( ?, ?, ?,?, now(), now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$code,
|
|
$name,
|
|
$namelang,
|
|
$group
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_subgroup insert");
|
|
exit;
|
|
}
|
|
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
}else{
|
|
$errors = array();
|
|
if($exist_code != 0){
|
|
// array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
|
|
|
$sql = "insert into nat_subgroup(
|
|
Nat_SubGroupCode,
|
|
Nat_SubGroupName,
|
|
Nat_SubGroupLangName,
|
|
Nat_SubGroupNat_GroupID,
|
|
Nat_SubGroupCreated,
|
|
Nat_SubGroupLastUpdated
|
|
)
|
|
values( ?, ?, ?,?, now(), now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$code,
|
|
$name,
|
|
$namelang,
|
|
$group
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_subgroup insert");
|
|
exit;
|
|
}
|
|
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
}
|
|
//$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
|
// $this->sys_ok($result);
|
|
}
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
public function editsubgroup()
|
|
{
|
|
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'];
|
|
$namelang = $prm['namelang'];
|
|
$code = $prm['code'];
|
|
$group = $prm['group'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query = "SELECT COUNT(*) as exist FROM nat_subgroup WHERE Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupCode = '{$code}' AND Nat_SubGroupID <> {$prm['id']}";
|
|
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
|
if($exist_code == 0){
|
|
$sqlcompany = "update nat_subgroup SET
|
|
Nat_SubGroupCode = ?,
|
|
Nat_SubGroupName = ?,
|
|
Nat_SubGroupLangName = ?,
|
|
Nat_SubGroupNat_GroupID = ?,
|
|
Nat_SubGroupLastUpdated = now()
|
|
where
|
|
Nat_SubGroupID = ?
|
|
";
|
|
$querycompany = $this->db_onedev->query($sqlcompany,
|
|
array(
|
|
$code,
|
|
$name,
|
|
$namelang,
|
|
$group,
|
|
$id
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$querycompany) {
|
|
$this->sys_error_db("nat_subgroup update");
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => $id));
|
|
$this->sys_ok($result);
|
|
}else{
|
|
$errors = array();
|
|
if($exist_code != 0){
|
|
|
|
$sqlcompany = "update nat_subgroup SET
|
|
Nat_SubGroupCode = ?,
|
|
Nat_SubGroupName = ?,
|
|
Nat_SubGroupLangName = ?,
|
|
Nat_SubGroupNat_GroupID = ?,
|
|
Nat_SubGroupLastUpdated = now()
|
|
where
|
|
Nat_SubGroupID = ?
|
|
";
|
|
$querycompany = $this->db_onedev->query($sqlcompany,
|
|
array(
|
|
$code,
|
|
$name,
|
|
$namelang,
|
|
$group,
|
|
$id
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$querycompany) {
|
|
$this->sys_error_db("nat_subgroup update");
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => $id));
|
|
$this->sys_ok($result);
|
|
}
|
|
// $result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
|
// $this->sys_ok($result);
|
|
}
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function addnewsubsubgroup()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$subgroupid = $prm['subgroupid'];
|
|
$subsubgroupcode = $prm['subsubgroupcode'];
|
|
$subsubgroupname = $prm['subsubgroupname'];
|
|
$subsubgroupnamelang = $prm['subsubgroupnamelang'];
|
|
|
|
if($prm['xid'] == 0){
|
|
$query = "SELECT COUNT(*) as exist FROM nat_subsubgroup WHERE Nat_SubsubgroupIsActive = 'Y' AND Nat_SubsubgroupName = '{$name}'";
|
|
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
|
|
|
if($exist_name == 0){
|
|
$sql = "insert into nat_subsubgroup(
|
|
Nat_SubSubGroupSubGroupID,
|
|
Nat_SubSubGroupCode,
|
|
Nat_SubSubGroupName,
|
|
Nat_SubSubGroupLangName,
|
|
Nat_SubSubGroupLasUpdated
|
|
)
|
|
values( ?,?,?,? ,now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$subgroupid,
|
|
$subsubgroupcode ,
|
|
$subsubgroupname ,
|
|
$subsubgroupnamelang
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_subsubgroup insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}else{
|
|
$errors = array();
|
|
if($exist_name != 0){
|
|
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
|
}
|
|
|
|
|
|
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
|
$this->sys_ok($result);
|
|
}
|
|
}else{
|
|
$query = "SELECT COUNT(*) as exist FROM nat_subsubgroup WHERE Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupName = '{$subsubgroupname}' AND Nat_SubSubGroupID <> {$prm['xid']}";
|
|
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
|
//echo $query;
|
|
|
|
//echo $query;
|
|
if($exist_name == 0 ){
|
|
$sql = "UPDATE nat_subsubgroup SET Nat_SubSubGroupName = '{$subsubgroupname}', Nat_SubSubGroupCode = '{$subsubgroupcode}' ,Nat_SubSubGroupLangName = '{$subsubgroupnamelang}' WHERE Nat_SubSubGroupID = '{$prm['xid']}'";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}else{
|
|
$errors = array();
|
|
if($exist_name != 0){
|
|
array_push($errors,array('field'=>'name','msg'=>'name sudah ada yang pakai dong'));
|
|
}
|
|
|
|
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
|
$this->sys_ok($result);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function deletesubgroup()
|
|
{
|
|
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 nat_subgroup SET
|
|
Nat_SubGroupIsActive = 'N',
|
|
Nat_SubGroupLastUpdated = now()
|
|
WHERE
|
|
Nat_SubGroupID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_subgroup delete");
|
|
exit;
|
|
}
|
|
$sql = "update nat_subsubgroup SET
|
|
Nat_SubSubGroupIsActive = 'N',
|
|
Nat_SubSubGroupLastUpdated = now()
|
|
WHERE
|
|
Nat_SubSubGroupNat_SubGroupID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_subsubgroup 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 deletesubsubgroup()
|
|
{
|
|
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 nat_subsubgroup SET
|
|
Nat_SubSubGroupNat_SubGroupID = 0,
|
|
Nat_SubSubGroupLastUpdated = now()
|
|
WHERE
|
|
Nat_SubSubGroupID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_subsubgroup 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 selectnonlab(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$rows['nonlabs'] = array(array("T_TestIsNonLabID"=>"","T_TestIsNonLabName"=>"LAB"),array("T_TestIsNonLabID"=>"RADIODIAGNOSTIC","T_TestIsNonLabName"=>"RADIODIAGNOSTIC"), array("T_TestIsNonLabID"=>"ELEKTROMEDIS","T_TestIsNonLabName"=>"ELEKTROMEDIS"),array("T_TestIsNonLabID"=>"OTHERS","T_TestIsNonLabName"=>"OTHERS"));
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
|
|
function selectgroup(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM nat_group
|
|
WHERE
|
|
Nat_GroupIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['groups'] = $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);
|
|
}
|
|
|
|
}
|
|
function selectcompanybusiness(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *, COUNT(M_CompanyID) as used
|
|
FROM (SELECT m_companybusiness.*,M_CompanyID
|
|
FROM
|
|
m_companybusiness
|
|
LEFT JOIN m_company ON M_CompanyBusinessID = M_CompanyM_CompanyBusinessID AND M_CompanyIsActive = 'Y'
|
|
WHERE M_CompanyBusinessIsActive = 'Y') a
|
|
GROUP BY M_CompanyBusinessID
|
|
";
|
|
//echo $query;
|
|
$rows['companybusinesss'] = $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);
|
|
}
|
|
|
|
}
|
|
function selectcompanylevel(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$rows = [];
|
|
$query =" SELECT *,CONCAT(Nat_CompanyLevelName,' [',M_CompanyName,']') as Nat_CompanyLevelName, COUNT(M_CompanyID) as used
|
|
FROM (SELECT nat_companylevel.*,M_CompanyID,M_CompanyName
|
|
FROM
|
|
nat_companylevel
|
|
LEFT JOIN m_company ON Nat_CompanyLevelNat_CompanyID = M_CompanyID AND M_CompanyIsActive = 'Y'
|
|
WHERE Nat_CompanyLevelIsActive = 'Y') a
|
|
GROUP BY Nat_CompanyLevelID
|
|
";
|
|
//echo $query;
|
|
$rows['companylevels'] = $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);
|
|
}
|
|
|
|
}
|
|
function selecthierarchy(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *, COUNT(M_CompanyID) as used
|
|
FROM (SELECT nat_hierarchy.*,M_CompanyID
|
|
FROM
|
|
nat_hierarchy
|
|
LEFT JOIN m_company ON Nat_HierarchyID = M_CompanyNat_HierarchyID AND M_CompanyIsActive = 'Y'
|
|
WHERE Nat_HierarchyIsActive = 'Y') a
|
|
GROUP BY Nat_HierarchyID
|
|
";
|
|
//echo $query;
|
|
$rows['hierarchys'] = $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);
|
|
}
|
|
|
|
}
|
|
function selectdoctor(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_doctor
|
|
WHERE
|
|
M_DoctorIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['doctors'] = $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);
|
|
}
|
|
|
|
}
|
|
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
|
|
m_doctor
|
|
WHERE
|
|
M_DoctorName like ?
|
|
AND M_DoctorIsActive = '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_doctor count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT * FROM(
|
|
SELECT 0 as M_DoctorID, 'Semua Dokter' as M_DoctorName, 'Semua Dokter' as M_DoctorNames
|
|
UNION
|
|
SELECT M_DoctorID, M_DoctorName, CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as M_DoctorNames
|
|
FROM m_doctor
|
|
WHERE M_DoctorIsActive = 'Y') a
|
|
WHERE
|
|
M_DoctorNames like ?
|
|
ORDER BY M_DoctorName DESC
|
|
";
|
|
$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 searchsubsubgroup(){
|
|
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 nat_subsubgroup
|
|
WHERE
|
|
Nat_SubSubGroupName like ?
|
|
AND Nat_SubSubGroupIsActive = '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("nat_subsubgroup count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT Nat_SubSubGroupID, Nat_SubSubGroupName
|
|
FROM nat_subsubgroup
|
|
WHERE
|
|
Nat_SubSubGroupName like ?
|
|
AND Nat_SubSubGroupIsActive = 'Y'
|
|
GROUP BY Nat_SubSubGroupID
|
|
ORDER BY Nat_SubSubGroupName 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("nat_subsubgroup rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchtemplate(){
|
|
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 so_template
|
|
WHERE
|
|
So_TemplateName like ?
|
|
AND So_TemplateIsActive = '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("so_template count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT So_TemplateID, So_TemplateName
|
|
FROM so_template
|
|
WHERE
|
|
So_TemplateName like ?
|
|
AND So_TemplateIsActive = 'Y'
|
|
GROUP BY So_TemplateID
|
|
ORDER BY So_TemplateName 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("so_template rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchcompanylevel(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
|
|
$name = $prm['name'];
|
|
$hirarkiid = intval($prm['id']) - 1;
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM nat_companylevel
|
|
WHERE
|
|
Nat_CompanyLevelName like '%{$name}%'
|
|
AND
|
|
Nat_CompanyLevelNat_HierarchyID = '{$hirarkiid}'
|
|
AND Nat_CompanyLevelIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("nat_companylevel count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT * FROM(SELECT *, CONCAT(Nat_CompanyLevelName, ' [',M_CompanyName,']') as Nat_CompanyLevelNames
|
|
FROM nat_companylevel
|
|
LEFT JOIN m_company ON Nat_CompanyLevelNat_CompanyID = M_CompanyID
|
|
WHERE Nat_CompanyLevelIsActive = 'Y') a
|
|
WHERE
|
|
Nat_CompanyLevelName like '%{$name}%'
|
|
AND
|
|
Nat_CompanyLevelNat_HierarchyID = '{$hirarkiid}'
|
|
AND Nat_CompanyLevelIsActive = 'Y'
|
|
ORDER BY Nat_CompanyLevelName DESC
|
|
";
|
|
$query = $this->db_onedev->query($sql);
|
|
|
|
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("nat_companylevel rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchcity(){
|
|
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_city
|
|
WHERE
|
|
M_CityName like ?
|
|
AND M_CityIsActive = '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_city count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityName like ?
|
|
AND M_CityIsActive = 'Y'
|
|
ORDER BY M_CityName DESC
|
|
";
|
|
$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_city rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function getstaff(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_staff
|
|
WHERE
|
|
M_StaffIsActive = 'Y' AND M_StaffM_PositionID = 2";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getprovince(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_province
|
|
WHERE
|
|
M_ProvinceIsActive = 'Y'";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getcity(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityIsActive = 'Y' AND M_CityM_ProvinceID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getdistrict(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_district
|
|
WHERE
|
|
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getkelurahan(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_kelurahan
|
|
WHERE
|
|
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function selectbase(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT 'SPK' as baseid, 'SPK' as basename
|
|
UNION SELECT 'MOU' as baseid, 'MOU' as basename
|
|
";
|
|
//echo $query;
|
|
$rows['bases'] = $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);
|
|
}
|
|
|
|
}
|
|
function selectomzettype(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_omzettype
|
|
WHERE
|
|
M_OmzetTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['omzettypes'] = $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);
|
|
}
|
|
|
|
}
|
|
function selectmoutype(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_moutype
|
|
WHERE
|
|
M_MouTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['moutypes'] = $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);
|
|
}
|
|
|
|
}
|
|
function selectagingtype(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_agingtype
|
|
WHERE
|
|
M_AgingIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['agingtypes'] = $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);
|
|
}
|
|
|
|
}
|
|
|
|
}
|