894 lines
29 KiB
PHP
894 lines
29 KiB
PHP
<?php
|
|
|
|
class Polakelainan 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 lookupkelainandetailbyname()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$kelainangroup = $prm['kelainangroup'];
|
|
$kelainandetail = $prm['kelainandetail'];;
|
|
$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 one_etl.mcu_kelainan
|
|
JOIN one_etl.mcu_kelainangroup ON Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID AND Mcu_KelainanGroupIsActive = 'Y'
|
|
WHERE
|
|
Mcu_KelainanGroupName LIKE CONCAT('%','{$kelainangroup}','%') AND
|
|
Mcu_KelainanName LIKE CONCAT('%','{$kelainandetail}','%') AND
|
|
Mcu_KelainanIsActive = 'Y' GROUP BY Mcu_KelainanID) 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("one_etl.mcu_kelainan count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Mcu_KelainanID as id,
|
|
Mcu_KelainanName as name,
|
|
Mcu_KelainanGroupID,
|
|
Mcu_KelainanGroupName,
|
|
one_etl.mcu_kelainan.*,
|
|
IF(Mcu_KelainanClasification <> '','Y','N') as isclasification
|
|
from one_etl.mcu_kelainan
|
|
JOIN one_etl.mcu_kelainangroup ON Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID AND Mcu_KelainanGroupIsActive = 'Y'
|
|
WHERE
|
|
Mcu_KelainanGroupName LIKE CONCAT('%','{$kelainangroup}','%') AND
|
|
Mcu_KelainanName LIKE CONCAT('%','{$kelainandetail}','%') AND
|
|
Mcu_KelainanIsActive = 'Y'
|
|
GROUP BY Mcu_KelainanID
|
|
ORDER BY Mcu_KelainanGroupName ASC, Mcu_KelainanName 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("one_etl.mcu_kelainan 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 lookupkelainangroupbyname()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$kelainangroup = $prm['kelainangroup'];
|
|
$kelainandetail = $prm['kelainandetail'];
|
|
$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 one_etl.mcu_kelainangroup
|
|
LEFT JOIN one_etl.mcu_kelainan ON Mcu_KelainanGroupID = Mcu_KelainanMcu_KelainanGroupID AND Mcu_KelainanIsActive = 'Y'
|
|
where
|
|
Mcu_KelainanGroupName LIKE CONCAT('%','{$kelainangroup}','%') AND
|
|
IFNULL(Mcu_KelainanName,'') LIKE CONCAT('%','{$kelainandetail}','%') AND
|
|
Mcu_KelainanGroupIsActive = 'Y'
|
|
GROUP BY Mcu_KelainanGroupID) 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("one_etl.mcu_kelainangroup count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Mcu_KelainanGroupID as id,
|
|
Mcu_KelainanGroupName as name,
|
|
Mcu_KelainanGroupName as namex,
|
|
one_etl.mcu_kelainangroup.*
|
|
from one_etl.mcu_kelainangroup
|
|
LEFT JOIN one_etl.mcu_kelainan ON Mcu_KelainanGroupID = Mcu_KelainanMcu_KelainanGroupID AND Mcu_KelainanIsActive = 'Y'
|
|
where
|
|
Mcu_KelainanGroupName LIKE CONCAT('%','{$kelainangroup}','%') AND
|
|
IFNULL(Mcu_KelainanName,'') LIKE CONCAT('%','{$kelainandetail}','%') AND
|
|
Mcu_KelainanGroupIsActive = 'Y'
|
|
GROUP BY Mcu_KelainanGroupID
|
|
ORDER BY Mcu_KelainanGroupName 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("one_etl.mcu_kelainangroup 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 addnewkelainangroup()
|
|
{
|
|
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 one_etl.mcu_kelainangroup(
|
|
Mcu_KelainanGroupName,
|
|
Mcu_KelainanGroupCreated,
|
|
Mcu_KelainanGroupLastUpdated
|
|
)
|
|
values( ?, now(), now())";
|
|
$query = $this->db_onedev->query(
|
|
$sql,
|
|
array(
|
|
$name
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("one_etl.mcu_kelainangroup 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 editkelainangroup()
|
|
{
|
|
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 one_etl.mcu_kelainangroup SET
|
|
Mcu_KelainanGroupName = ?,
|
|
Mcu_KelainanGroupLastUpdated = now()
|
|
where
|
|
Mcu_KelainanGroupID = ?
|
|
";
|
|
$querycompany = $this->db_onedev->query(
|
|
$sqlcompany,
|
|
array(
|
|
$name,
|
|
$id
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$querycompany) {
|
|
$this->sys_error_db("one_etl.mcu_kelainangroup 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 addnewkelainandetail()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$kelainangroupid = $prm['kelainangroupid'];
|
|
$name = $prm['name'];
|
|
$klasifikasi = $prm['klasifikasi'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
if ($kelainangroupid == 0) {
|
|
$errors = array();
|
|
if ($kelainangroupid == 0) {
|
|
array_push($errors, array('field' => 'kelainangroup', 'msg' => 'Grup Kelainan dipilih dulu dong'));
|
|
}
|
|
$result = array("total" => -1, "errors" => $errors, "records" => 0);
|
|
$this->sys_ok($result);
|
|
} else {
|
|
if ($prm['xid'] == 0) {
|
|
$sql = "insert into one_etl.mcu_kelainan(
|
|
Mcu_KelainanMcu_KelainanGroupID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanUserID,
|
|
Mcu_KelainanLastUpdated,
|
|
Mcu_KelainanCreated)
|
|
values(?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query(
|
|
$sql,
|
|
array(
|
|
$kelainangroupid,
|
|
$name,
|
|
$klasifikasi,
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("one_etl.mcu_kelainan 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 {
|
|
$sql = "UPDATE one_etl.mcu_kelainan SET Mcu_KelainanMcu_KelainanGroupID = '{$kelainangroupid}',
|
|
Mcu_KelainanName = '{$name}',
|
|
Mcu_KelainanClasification = '{$klasifikasi}',
|
|
Mcu_KelainanUserID = '{$userid}'
|
|
WHERE Mcu_KelainanID = '{$prm['xid']}'";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
$result = array("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
}
|
|
}
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
public function deletekelainangroup()
|
|
{
|
|
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 one_etl.mcu_kelainangroup SET
|
|
Mcu_KelainanGroupIsActive = 'N',
|
|
Mcu_KelainanGroupLastUpdated = now()
|
|
WHERE
|
|
Mcu_KelainanGroupID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query(
|
|
$sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("one_etl.mcu_kelainangroup delete");
|
|
exit;
|
|
}
|
|
$sql = "update one_etl.mcu_kelainan SET
|
|
Mcu_KelainanIsActive = 'N',
|
|
Mcu_KelainanLastUpdated = now()
|
|
WHERE
|
|
Mcu_KelainanMcu_KelainanGroupID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query(
|
|
$sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("one_etl.mcu_kelainan 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 deletekelainandetail()
|
|
{
|
|
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 one_etl.mcu_kelainan SET
|
|
Mcu_KelainanIsActive = 'N',
|
|
Mcu_KelainanLastUpdated = now()
|
|
WHERE
|
|
Mcu_KelainanID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query(
|
|
$sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("one_etl.mcu_kelainan delete");
|
|
exit;
|
|
}
|
|
|
|
// update ihs number
|
|
$sql_upt = "UPDATE one_health.organization SET
|
|
organizationIsActive = 'N',
|
|
organizationLastUpdated = NOW(),
|
|
organizationUserID = ?
|
|
WHERE organizationMcu_KelainanID = ?";
|
|
$qry_upt = $this->db_onedev->query($sql_upt, array(
|
|
$userid,
|
|
$prm['id']
|
|
));
|
|
if (!$query) {
|
|
$this->sys_error_db("organization 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 searchkelainangroup()
|
|
{
|
|
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 one_etl.mcu_kelainangroup
|
|
WHERE
|
|
Mcu_KelainanGroupName like ?
|
|
AND Mcu_KelainanGroupIsActive = '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("one_etl.mcu_kelainangroup count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT Mcu_KelainanGroupID, Mcu_KelainanGroupName
|
|
FROM one_etl.mcu_kelainangroup
|
|
WHERE
|
|
Mcu_KelainanGroupName like ?
|
|
AND Mcu_KelainanGroupIsActive = 'Y'
|
|
ORDER BY Mcu_KelainanGroupName 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("one_etl.mcu_kelainangroup rows", $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchkelainangroupbyname()
|
|
{
|
|
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 one_etl.mcu_kelainangroup
|
|
WHERE
|
|
Mcu_KelainanGroupName like ?
|
|
AND Mcu_KelainanGroupIsActive = '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("one_etl.mcu_kelainangroup count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT Mcu_KelainanGroupID, Mcu_KelainanGroupName
|
|
FROM one_etl.mcu_kelainangroup
|
|
WHERE
|
|
Mcu_KelainanGroupName like ?
|
|
AND Mcu_KelainanGroupIsActive = 'Y'
|
|
ORDER BY Mcu_KelainanGroupName 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("one_etl.mcu_kelainangroup 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 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_city 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_DistrictM_CityID = '{$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_DistrictM_CityID = '{$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' AND M_MouIsReleased = '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' AND M_MouIsReleased = '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);
|
|
}
|
|
}
|
|
}
|