551 lines
14 KiB
PHP
Executable File
551 lines
14 KiB
PHP
Executable File
<?php
|
|
|
|
class Testrequirement extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "TEST REQUIREMENT API";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
|
|
function lookuptest(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$sql = "select Nat_TestRequirementID as id,
|
|
Nat_TestRequirementNat_RequirementID as requirementid,
|
|
Nat_TestRequirementNat_TestID as testid,
|
|
Nat_TestID,
|
|
Nat_TestName,
|
|
Nat_TestName as name,
|
|
'xxx' as action
|
|
from nat_testrequirement
|
|
LEFT JOIN nat_test ON Nat_TestRequirementNat_TestID = Nat_TestID
|
|
where
|
|
Nat_TestRequirementNat_RequirementID = {$id} AND Nat_TestRequirementIsActive = 'Y'";
|
|
//echo $sql;
|
|
$rows = $this->db_onedev->query($sql)->result();
|
|
|
|
$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_requirement
|
|
where
|
|
Nat_RequirementIsActive = 'Y'";
|
|
$sql_param = array($search);
|
|
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
|
|
|
|
|
$sql = "select Nat_RequirementID as id, Nat_RequirementName as name,Nat_RequirementName as description,
|
|
'xxx' as test
|
|
from nat_requirement
|
|
where
|
|
( Nat_RequirementName LIKE CONCAT('%','{$search}','%')
|
|
)AND
|
|
Nat_RequirementIsActive = 'Y' $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_requirement 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 addnewrequirement()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$name_requirement = $prm['name'];
|
|
$sqlrequirement = "insert into nat_requirement(
|
|
Nat_RequirementName
|
|
Nat_RequirementCreated,
|
|
Nat_RequirementLastUpdated
|
|
)
|
|
values( ?, now(), now())";
|
|
$queryrequirement = $this->db_onedev->query($sqlrequirement,
|
|
array(
|
|
$name_requirement
|
|
)
|
|
);
|
|
echo $query;
|
|
if (!$queryrequirement) {
|
|
$this->sys_error_db("nat_requirement insert");
|
|
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 editrequirement()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$id_requirement = $prm['id'];
|
|
$name_requirement = $prm['name'];
|
|
$sqlrequirement = "update nat_requirement SET
|
|
Nat_RequirementName = ?,
|
|
Nat_RequirementLastUpdated = now()
|
|
where
|
|
Nat_RequirementID = ?
|
|
";
|
|
$queryrequirement = $this->db_onedev->query($sqlrequirement,
|
|
array(
|
|
$name_requirement,
|
|
$id_requirement
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$queryrequirement) {
|
|
$this->sys_error_db("nat_requirement update");
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => $id_requirement));
|
|
$this->sys_ok($result);
|
|
|
|
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
public function addnewtest()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$requirementid = $prm['requirementid'];
|
|
$testid = $prm['testid'];
|
|
|
|
|
|
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
|
$sql = "insert into nat_testrequirement(
|
|
Nat_TestRequirementNat_RequirementID,
|
|
Nat_TestRequirementNat_TestID,
|
|
Nat_TestRequirementLastUpdated
|
|
)
|
|
values( ?,?,now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$requirementid,
|
|
$testid
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_testrequirement insert");
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}else{
|
|
|
|
$testid = $prm['testid'];
|
|
$sql = "UPDATE nat_testrequirement SET Nat_TestRequirementNat_TestID = '{$testid}'";
|
|
//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 deletetest()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "update nat_testrequirement SET
|
|
Nat_TestRequirementIsActive = 'N',
|
|
Nat_TestRequirementLastUpdated = now()
|
|
WHERE
|
|
Nat_TestRequirementID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_testrequirement 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 deleterequirement()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "update nat_requirement SET
|
|
Nat_RequirementIsActive = 'N',
|
|
Nat_RequirementLastUpdated = now()
|
|
WHERE
|
|
Nat_RequirementID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_requirement delete");
|
|
exit;
|
|
}
|
|
|
|
$sql = "UPDATE nat_testrequirement SET
|
|
Nat_TestRequirementIsActive = 'N',
|
|
Nat_TestRequirementLastUpdated = now()
|
|
WHERE
|
|
Nat_TestRequirementNat_RequirementID = ?
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_testrequirement 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 selectrequirementtype(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM nat_requirementtype
|
|
WHERE
|
|
Nat_RequirementTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['requirementtypes'] = $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 *, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorNames
|
|
FROM m_doctor
|
|
WHERE M_DoctorIsActive = 'Y') a
|
|
WHERE
|
|
M_DoctorNames like ?
|
|
AND M_DoctorIsActive = 'Y'
|
|
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 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 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;
|
|
}
|
|
|
|
}
|