864 lines
28 KiB
PHP
864 lines
28 KiB
PHP
<?php
|
|
|
|
class Advicekelainan extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "ABNORMAL API";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
// $this->db_onedev = $this->load->database("regional", true);
|
|
}
|
|
|
|
function lookupkelainanbyname()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$name = $prm['name'];
|
|
$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 mcu_kelainan
|
|
WHERE
|
|
Mcu_KelainanIsActive = 'Y' AND
|
|
Mcu_KelainanName like '%{$name}%'
|
|
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("mcu_kelainan count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT mcu_kelainan.*,
|
|
Mcu_KelainanID as id
|
|
from mcu_kelainan
|
|
WHERE
|
|
Mcu_KelainanIsActive = 'Y' AND
|
|
Mcu_KelainanName like '%{$name}%'
|
|
GROUP BY Mcu_KelainanID
|
|
ORDER BY 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("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);
|
|
}
|
|
}
|
|
function lookupadvicebyid()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$adviceina = $prm['adviceina'];
|
|
$adviceeng = $prm['adviceeng'];
|
|
$status = $prm['status'];
|
|
$all = $prm['all'];
|
|
$filter = '';
|
|
if ($status != 'A') {
|
|
$filter .= "AND status = '{$status}' ";
|
|
} else {
|
|
$filter .= "";
|
|
}
|
|
$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 *, IF(IFNULL(Nat_AdvicekelainanID,0) > 0 , 'Y', 'N') as status
|
|
from nat_advice
|
|
LEFT JOIN nat_advice_kelainan ON Nat_AdviceID = Nat_AdvicekelainanNat_AdviceID AND Nat_AdvicekelainanMcu_KelainanID = $id AND Nat_AdvicekelainanIsActive = 'Y'
|
|
LEFT JOIN mcu_kelainan ON Nat_AdvicekelainanMcu_KelainanID = Mcu_KelainanID AND Mcu_KelainanIsActive = 'Y'
|
|
WHERE
|
|
Nat_AdviceIsActive = 'Y' GROUP BY Nat_AdviceID) a
|
|
WHERE
|
|
Nat_AdviceIna like '%{$adviceina}%' AND
|
|
Nat_AdviceEng like '%{$adviceeng}%' $filter";
|
|
// $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("nat_advice count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT * FROM(select Nat_AdviceID as id,
|
|
Nat_AdviceID,
|
|
Nat_AdviceIna,
|
|
Nat_AdviceEng,
|
|
Nat_AdvicekelainanID,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanName,
|
|
Nat_AdvicekelainanMcu_KelainanID,
|
|
Nat_AdvicekelainanNat_AdviceID,
|
|
IF(IFNULL(Nat_AdvicekelainanID,0) > 0 , 'Y', 'N') as status
|
|
from nat_advice
|
|
LEFT JOIN nat_advice_kelainan ON Nat_AdviceID = Nat_AdvicekelainanNat_AdviceID AND Nat_AdvicekelainanMcu_KelainanID = $id AND Nat_AdvicekelainanIsActive = 'Y'
|
|
LEFT JOIN mcu_kelainan ON Nat_AdvicekelainanMcu_KelainanID = Mcu_KelainanID AND Mcu_KelainanIsActive = 'Y'
|
|
WHERE
|
|
Nat_AdviceIsActive = 'Y') a
|
|
WHERE
|
|
Nat_AdviceIna like '%{$adviceina}%' AND
|
|
Nat_AdviceEng like '%{$adviceeng}%' $filter
|
|
GROUP BY Nat_AdviceID
|
|
ORDER BY Nat_AdviceID 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("nat_advice 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 listingadvice()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$adviceina = $prm['adviceina'];
|
|
$adviceeng = $prm['adviceeng'];
|
|
$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 nat_advice
|
|
WHERE
|
|
Nat_AdviceIsActive = 'Y' AND
|
|
Nat_AdviceIna like '%{$adviceina}%' AND
|
|
Nat_AdviceEng like '%{$adviceeng}%'";
|
|
// $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("nat_advice count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT *
|
|
from nat_advice
|
|
WHERE
|
|
Nat_AdviceIsActive = 'Y' AND
|
|
Nat_AdviceIna like '%{$adviceina}%' AND
|
|
Nat_AdviceEng like '%{$adviceeng}%'
|
|
ORDER BY Nat_AdviceID 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("nat_advice 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 getsexreg()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query = " SELECT *
|
|
FROM nat_sex
|
|
WHERE
|
|
Nat_SexIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query = " SELECT *
|
|
FROM m_advice_fisiktype
|
|
WHERE
|
|
M_AdviceFisikTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['normalvaluetypees'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query = " SELECT *
|
|
FROM nat_flag
|
|
WHERE
|
|
Nat_FlagIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['flages'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
|
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
|
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
|
";
|
|
//echo $query;
|
|
$rows['ageunites'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
|
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
|
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
|
";
|
|
//echo $query;
|
|
$rows['minageunites'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
|
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
|
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
|
";
|
|
//echo $query;
|
|
$rows['maxageunites'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query = "
|
|
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
|
UNION
|
|
SELECT Nat_SexID, Nat_SexName
|
|
FROM nat_sex
|
|
WHERE
|
|
Nat_SexIsActive = 'Y'
|
|
|
|
";
|
|
//echo $query;
|
|
$rows['f_sexs'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query = "
|
|
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
|
UNION
|
|
SELECT Nat_FlagID, Nat_FlagName
|
|
FROM nat_flag
|
|
WHERE
|
|
Nat_FlagIsActive = 'Y'";
|
|
//echo $query;
|
|
$rows['f_flags'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query = "
|
|
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
|
UNION
|
|
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
|
UNION
|
|
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
|
";
|
|
//echo $query;
|
|
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows),
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
function getstatus()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
|
|
$query = "
|
|
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
|
UNION
|
|
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
|
UNION
|
|
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
|
";
|
|
//echo $query;
|
|
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows),
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
public function addnewkelainan()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$code = $prm['code'];
|
|
$name = $prm['name'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$sql = "insert into mcu_kelainan(
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanName,
|
|
M_AdviceKelainanUserID,
|
|
Mcu_KelainanCreated,
|
|
Mcu_KelainanLastUpdated
|
|
)
|
|
values(?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query(
|
|
$sql,
|
|
array(
|
|
$code,
|
|
$name,
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("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);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
function editkelainan()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query = " UPDATE mcu_kelainan SET
|
|
Mcu_KelainanClasification = '{$prm['code']}',
|
|
Mcu_KelainanName = '{$prm['name']}',
|
|
M_AdviceKelainanUserID = {$userid}
|
|
WHERE
|
|
Mcu_KelainanID = {$prm['id']}
|
|
";
|
|
|
|
//echo $query;
|
|
$action = $this->db_onedev->query($query);
|
|
|
|
if ($action) {
|
|
$result = array(
|
|
"total" => 1,
|
|
"records" => array(),
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
} else {
|
|
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
public function addnewadvice()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$kelainanid = $prm['kelainanid'];
|
|
$adviceina = $prm['adviceina'];
|
|
$adviceeng = $prm['adviceeng'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$sql = "insert into nat_advice(
|
|
Nat_AdviceIna,
|
|
Nat_AdviceEng,
|
|
Nat_AdviceUserID,
|
|
Nat_AdviceCreated,
|
|
Nat_AdviceLastUpdated
|
|
)
|
|
values(?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query(
|
|
$sql,
|
|
array(
|
|
$adviceina,
|
|
$adviceeng,
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("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);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function saveaddeditadvice()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$kelainanid = $prm['kelainanid'];
|
|
$adviceid = $prm['Nat_AdviceID'];
|
|
$advicekelainanid = $prm['Nat_AdvicekelainanID'];
|
|
$status = $prm['status'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
if ($status == 'Y') {
|
|
$sql = "insert into nat_advice_kelainan(
|
|
Nat_AdvicekelainanMcu_KelainanID,
|
|
Nat_AdvicekelainanNat_AdviceID,
|
|
Nat_AdvicekelainanUserID,
|
|
Nat_AdvicekelainanCreated,
|
|
Nat_AdvicekelainanLastUpdated
|
|
)
|
|
values(?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query(
|
|
$sql,
|
|
array(
|
|
$kelainanid,
|
|
$adviceid,
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_advice_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 nat_advice_kelainan SET
|
|
Nat_AdvicekelainanIsActive = 'N',
|
|
Nat_AdvicekelainanUserID = ?,
|
|
Nat_AdvicekelainanCreated = now(),
|
|
Nat_AdvicekelainanLastUpdated = now()
|
|
WHERE Nat_AdvicekelainanID = ?";
|
|
$query = $this->db_onedev->query(
|
|
$sql,
|
|
array(
|
|
$userid,
|
|
$advicekelainanid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_advice_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);
|
|
}
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
function saveeditsaran()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query = " UPDATE nat_advice SET
|
|
Nat_AdviceIna = '{$prm['ina']}',
|
|
Nat_AdviceEng = '{$prm['eng']}',
|
|
Nat_AdviceIsActive = '{$prm['status']}',
|
|
Nat_AdviceUserID = {$userid}
|
|
WHERE
|
|
Nat_AdviceID = {$prm['id']}
|
|
";
|
|
|
|
//echo $query;
|
|
$action = $this->db_onedev->query($query);
|
|
|
|
if ($action) {
|
|
$result = array(
|
|
"total" => 1,
|
|
"records" => array(),
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
} else {
|
|
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function savealladvice()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$details = $prm['details'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach ($details as $k => $v) {
|
|
$query = "UPDATE nat_advice_kelainan SET
|
|
Nat_AdvicekelainanMcu_KelainanID = '{$v['Nat_AdvicekelainanMcu_KelainanID']}',
|
|
Nat_AdvicefisikAdviceIna = '{$v['Nat_AdvicefisikAdviceIna']}',
|
|
Nat_AdvicefisikAdviceEng = '{$v['Nat_AdvicefisikAdviceEng']}',
|
|
Nat_AdvicekelainanUserID = {$userid},
|
|
Nat_AdvicekelainanCreated = now(),
|
|
Nat_AdvicekelainanLastUpdated = now()
|
|
WHERE Nat_AdvicekelainanID = {$v['Nat_AdvicekelainanID']}";
|
|
|
|
//echo $query;
|
|
$action = $this->db_onedev->query($query);
|
|
}
|
|
|
|
|
|
if ($action) {
|
|
$result = array(
|
|
"total" => 1,
|
|
"records" => array(),
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
} else {
|
|
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
public function deletekelainan()
|
|
{
|
|
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 mcu_kelainan SET
|
|
Mcu_KelainanIsActive = 'N'
|
|
WHERE
|
|
Mcu_KelainanID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query(
|
|
$sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("mcu_kelainan delete");
|
|
exit;
|
|
}
|
|
$sql = "update nat_advice_kelainan SET
|
|
Nat_AdvicekelainanIsActive = 'N'
|
|
WHERE
|
|
Nat_AdvicekelainanMcu_KelainanID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query(
|
|
$sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_advice_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 deleteadvice()
|
|
{
|
|
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 mcu_kelainan SET
|
|
Mcu_KelainanIsActive = 'N'
|
|
WHERE
|
|
Mcu_KelainanID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query(
|
|
$sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("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);
|
|
}
|
|
}
|
|
|
|
function searchkelainan()
|
|
{
|
|
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_methode
|
|
WHERE
|
|
Nat_MethodeName like ?
|
|
AND Nat_MethodeIsActive = '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_methode count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT Nat_MethodeID, Nat_MethodeName
|
|
FROM nat_methode
|
|
WHERE
|
|
Nat_MethodeName like ?
|
|
AND Nat_MethodeIsActive = 'Y'
|
|
ORDER BY Nat_MethodeName 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_methode rows", $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchkelainanbyname()
|
|
{
|
|
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_methode
|
|
WHERE
|
|
Nat_MethodeName like ?
|
|
AND Nat_MethodeIsActive = '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_methode count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT Nat_MethodeID, Nat_MethodeName
|
|
FROM nat_methode
|
|
WHERE
|
|
Nat_MethodeName like ?
|
|
AND Nat_MethodeIsActive = 'Y'
|
|
ORDER BY Nat_MethodeName 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_methode rows", $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
|
|
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['search'] != '') {
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM t_test
|
|
WHERE
|
|
T_TestName like ?
|
|
AND T_TestIsActive = 'Y' AND T_TestIsResult = '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 *
|
|
FROM t_test
|
|
WHERE
|
|
T_TestName like ?
|
|
AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
|
ORDER BY T_TestName 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;
|
|
}
|
|
}
|
|
}
|