878 lines
27 KiB
PHP
878 lines
27 KiB
PHP
<?php
|
|
|
|
class Advicefisik 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 lookupfisikbyname(){
|
|
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 m_advice_fisik
|
|
WHERE
|
|
M_AdviceFisikIsActive = 'Y' AND
|
|
M_AdviceFisikLabel like '%{$name}%'
|
|
GROUP BY M_AdviceFisikID) 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("m_advice_fisik count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT m_advice_fisik.*,
|
|
M_AdviceFisikID as id
|
|
from m_advice_fisik
|
|
WHERE
|
|
M_AdviceFisikIsActive = 'Y' AND
|
|
M_AdviceFisikLabel like '%{$name}%'
|
|
GROUP BY M_AdviceFisikID
|
|
ORDER BY M_AdviceFisikLabel 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("m_advice_fisik 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_AdvicefisikID,0) > 0 , 'Y', 'N') as status
|
|
from nat_advice
|
|
LEFT JOIN nat_advice_fisik ON Nat_AdviceID = Nat_AdvicefisikNat_AdviceID AND Nat_AdvicefisikM_AdviceFisikID = $id AND Nat_AdvicefisikIsActive = 'Y'
|
|
LEFT JOIN m_advice_fisik ON Nat_AdvicefisikM_AdviceFisikID = M_AdviceFisikID AND M_AdviceFisikIsActive = '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_AdvicefisikID,
|
|
M_AdviceFisikCode,
|
|
M_AdviceFisikLabel,
|
|
Nat_AdvicefisikM_AdviceFisikID,
|
|
Nat_AdvicefisikNat_AdviceID,
|
|
IF(IFNULL(Nat_AdvicefisikID,0) > 0 , 'Y', 'N') as status
|
|
from nat_advice
|
|
LEFT JOIN nat_advice_fisik ON Nat_AdviceID = Nat_AdvicefisikNat_AdviceID AND Nat_AdvicefisikM_AdviceFisikID = $id AND Nat_AdvicefisikIsActive = 'Y'
|
|
LEFT JOIN m_advice_fisik ON Nat_AdvicefisikM_AdviceFisikID = M_AdviceFisikID AND M_AdviceFisikIsActive = '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 addnewfisik()
|
|
{
|
|
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 m_advice_fisik(
|
|
M_AdviceFisikCode,
|
|
M_AdviceFisikLabel,
|
|
M_AdviceFisikUserID,
|
|
M_AdviceFisikCreated,
|
|
M_AdviceFisikLastUpdated
|
|
)
|
|
values(?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$code,
|
|
$name,
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("m_advice_fisik 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 editfisik(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query = " UPDATE m_advice_fisik SET
|
|
M_AdviceFisikCode = '{$prm['code']}',
|
|
M_AdviceFisikLabel = '{$prm['name']}',
|
|
M_AdviceFisikUserID = {$userid}
|
|
WHERE
|
|
M_AdviceFisikID = {$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;
|
|
$fisikid = $prm['fisikid'];
|
|
$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("m_advice_fisik 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;
|
|
$fisikid = $prm['fisikid'];
|
|
$adviceid = $prm['Nat_AdviceID'];
|
|
$advicefisikid = $prm['Nat_AdvicefisikID'];
|
|
$status = $prm['status'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
if($status == 'Y'){
|
|
$sql = "insert into nat_advice_fisik(
|
|
Nat_AdvicefisikM_AdviceFisikID,
|
|
Nat_AdvicefisikNat_AdviceID,
|
|
Nat_AdvicefisikUserID,
|
|
Nat_AdvicefisikCreated,
|
|
Nat_AdvicefisikLastUpdated
|
|
)
|
|
values(?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$fisikid,
|
|
$adviceid,
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_advice_fisik 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_fisik SET
|
|
Nat_AdvicefisikIsActive = 'N',
|
|
Nat_AdvicefisikUserID = ?,
|
|
Nat_AdvicefisikCreated = now(),
|
|
Nat_AdvicefisikLastUpdated = now()
|
|
WHERE Nat_AdvicefisikID = ?";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$userid,
|
|
$advicefisikid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_advice_fisik 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_fisik SET
|
|
Nat_AdvicefisikM_AdviceFisikID = '{$v['Nat_AdvicefisikM_AdviceFisikID']}',
|
|
Nat_AdvicefisikAdviceIna = '{$v['Nat_AdvicefisikAdviceIna']}',
|
|
Nat_AdvicefisikAdviceEng = '{$v['Nat_AdvicefisikAdviceEng']}',
|
|
Nat_AdvicefisikUserID = {$userid},
|
|
Nat_AdvicefisikCreated = now(),
|
|
Nat_AdvicefisikLastUpdated = now()
|
|
WHERE Nat_AdvicefisikID = {$v['Nat_AdvicefisikID']}";
|
|
|
|
//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 deletefisik()
|
|
{
|
|
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 m_advice_fisik SET
|
|
M_AdviceFisikIsActive = 'N'
|
|
WHERE
|
|
M_AdviceFisikID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_advice_fisik delete");
|
|
exit;
|
|
}
|
|
$sql = "update nat_advice_fisik SET
|
|
Nat_AdvicefisikIsActive = 'N'
|
|
WHERE
|
|
Nat_AdvicefisikM_AdviceFisikID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_advice_fisik 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 m_advice_fisik SET
|
|
M_AdviceFisikIsActive = 'N'
|
|
WHERE
|
|
M_AdviceFisikID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_advice_fisik 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 searchfisik(){
|
|
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 searchfisikbyname(){
|
|
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;
|
|
}
|
|
}
|
|
} |