1171 lines
35 KiB
PHP
1171 lines
35 KiB
PHP
<?php
|
|
|
|
class Methodeunit extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Methode Unit API";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
function lookupmethodeunitbyname(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$test = $prm['test'];
|
|
$methodeunit = $prm['methodeunit'];;
|
|
$all = $prm['all'];
|
|
$limit = '';
|
|
if($all == 'N'){
|
|
$limit = ' LIMIT 100';
|
|
}
|
|
$number_limit = 100;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
$sql = "select COUNT(*) as total
|
|
FROM(SELECT *
|
|
from nat_methodeunit
|
|
JOIN nat_test ON Nat_MethodeUnitNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
|
|
JOIN nat_unit ON Nat_MethodeUnitNat_UnitID = Nat_UnitID
|
|
JOIN nat_methode ON Nat_MethodeUnitNat_MethodeID = Nat_MethodeID
|
|
WHERE
|
|
Nat_TestName LIKE CONCAT('%','{$test}','%') AND
|
|
Nat_MethodeName LIKE CONCAT('%','{$methodeunit}','%') AND
|
|
Nat_MethodeUnitIsActive = 'Y' GROUP BY Nat_MethodeUnitID) 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("nat_methodeunit count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_MethodeUnitID as id,
|
|
Nat_MethodeName as name,
|
|
Nat_TestID,
|
|
Nat_TestName,
|
|
Nat_MethodeID,
|
|
Nat_MethodeName,
|
|
Nat_UnitID,
|
|
Nat_UnitName,
|
|
nat_methodeunit.*
|
|
from nat_methodeunit
|
|
JOIN nat_test ON Nat_MethodeUnitNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
|
|
JOIN nat_unit ON Nat_MethodeUnitNat_UnitID = Nat_UnitID
|
|
JOIN nat_methode ON Nat_MethodeUnitNat_MethodeID = Nat_MethodeID
|
|
WHERE
|
|
Nat_TestName LIKE CONCAT('%','{$test}','%') AND
|
|
Nat_MethodeName LIKE CONCAT('%','{$methodeunit}','%') AND
|
|
Nat_MethodeUnitIsActive = 'Y'
|
|
GROUP BY Nat_MethodeUnitID
|
|
ORDER BY Nat_MethodeUnitID 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_methodeunit 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 lookuptestbyname()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$test = $prm['test'];
|
|
$methode = $prm['methodeunit'];
|
|
$limit = '';
|
|
if($all == 'N'){
|
|
$limit = ' LIMIT 100';
|
|
}
|
|
$number_limit = 100;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
$sql = "select COUNT(*) as total
|
|
FROM(SELECT *
|
|
from nat_test
|
|
LEFT JOIN nat_methodeunit ON Nat_TestID = Nat_MethodeUnitNat_TestID AND Nat_MethodeUnitIsActive = 'Y'
|
|
LEFT JOIN nat_methode ON Nat_MethodeUnitNat_MethodeID = Nat_MethodeID
|
|
where
|
|
Nat_TestName LIKE CONCAT('%','{$test}','%') AND
|
|
IFNULL(Nat_MethodeName,'') LIKE CONCAT('%','{$methode}','%') AND
|
|
Nat_TestIsActive = 'Y' AND Nat_TestIsResult = 'Y'
|
|
GROUP BY Nat_TestID) 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("nat_test count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_TestID as id,
|
|
Nat_TestName as name,
|
|
Nat_TestName as namex,
|
|
nat_test.*
|
|
from nat_test
|
|
LEFT JOIN nat_methodeunit ON Nat_TestID = Nat_MethodeUnitNat_TestID AND Nat_MethodeUnitIsActive = 'Y'
|
|
LEFT JOIN nat_methode ON Nat_MethodeUnitNat_MethodeID = Nat_MethodeID
|
|
where
|
|
Nat_TestName LIKE CONCAT('%','{$test}','%') AND
|
|
IFNULL(Nat_MethodeName,'') LIKE CONCAT('%','{$methode}','%') AND
|
|
Nat_TestIsActive = 'Y' AND Nat_TestIsResult = 'Y'
|
|
GROUP BY Nat_TestID
|
|
ORDER BY Nat_TestName 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_test 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 lookup()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$test = $prm['test'];
|
|
$methodeunit = $prm['methodeunit'];
|
|
$limit = '';
|
|
if($all == 'N'){
|
|
$limit = ' LIMIT 100';
|
|
}
|
|
$number_limit = 100;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
$sql = "select COUNT(*) as total
|
|
FROM(SELECT *
|
|
from nat_test
|
|
LEFT JOIN nat_methodeunit ON Nat_TestID = Nat_MethodeUnitNat_TestID AND Nat_MethodeUnitIsActive = 'Y'
|
|
LEFT JOIN nat_methode ON Nat_MethodeUnitNat_MethodeID = Nat_MethodeID
|
|
where
|
|
Nat_TestName LIKE CONCAT('%','{$test}','%') AND
|
|
IFNULL(Nat_MethodeName,'') LIKE CONCAT('%','{$methodeunit}','%') AND
|
|
Nat_TestIsActive = 'Y' AND Nat_TestIsResult = 'Y'
|
|
GROUP BY Nat_TestID) 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("nat_test count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_TestID as id,
|
|
Nat_TestName as name,
|
|
Nat_TestName as namex,
|
|
nat_test.*,
|
|
Nat_MethodeID,
|
|
Nat_MethodeName,
|
|
IFNULL(Nat_UnitID,0) as Nat_UnitID,
|
|
IFNULL(Nat_UnitName,'') as Nat_UnitName
|
|
|
|
from nat_test
|
|
LEFT JOIN nat_methodeunit ON Nat_TestID = Nat_MethodeUnitNat_TestID AND Nat_MethodeUnitIsActive = 'Y'
|
|
LEFT JOIN nat_methode ON Nat_MethodeUnitNat_MethodeID = Nat_MethodeID
|
|
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
|
where
|
|
Nat_TestName LIKE CONCAT('%','{$test}','%') AND
|
|
IFNULL(Nat_MethodeName,'') LIKE CONCAT('%','{$methodeunit}','%') AND
|
|
Nat_TestIsActive = 'Y' AND Nat_TestIsResult = 'Y'
|
|
GROUP BY Nat_TestID
|
|
ORDER BY Nat_TestID 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_test 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 addnewtest()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$name = $prm['name'];
|
|
$groupid = $prm['groupid'];
|
|
$sql = "insert into nat_test(
|
|
Nat_TestName,
|
|
Nat_TestNat_GroupID,
|
|
Nat_TestIsService,
|
|
Nat_TestCreated,
|
|
Nat_TestLastUpdated
|
|
)
|
|
values( ?, ?, ?, now(), now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$name,
|
|
$groupid,
|
|
$isservice
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_test 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 edittest()
|
|
{
|
|
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'];
|
|
$groupid = $prm['groupid'];
|
|
$isservice = $prm['isservice'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$sqlcompany = "update nat_test SET
|
|
Nat_TestName = ?,
|
|
Nat_TestNat_GroupID = ?,
|
|
Nat_TestIsService = ?,
|
|
Nat_TestLastUpdated = now()
|
|
where
|
|
Nat_TestID = ?
|
|
";
|
|
$querycompany = $this->db_onedev->query($sqlcompany,
|
|
array(
|
|
$name,
|
|
$groupid,
|
|
$isservice,
|
|
$id
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$querycompany) {
|
|
$this->sys_error_db("nat_test 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 addnewmethodeunit()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$testid = $prm['testid'];
|
|
$unitid = $prm['unitid'];
|
|
$methodeid = $prm['methodeid'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
|
|
if($prm['xid'] == 0){
|
|
$sql = "insert into nat_methodeunit(
|
|
Nat_MethodeUnitNat_MethodeID,
|
|
Nat_MethodeUnitNat_TestID,
|
|
Nat_MethodeUnitNat_UnitID,
|
|
Nat_MethodeUnitUserID,
|
|
Nat_MethodeUnitLastUpdated,
|
|
Nat_MethodeUnitCreated)
|
|
values(?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$methodeid,
|
|
$testid,
|
|
$unitid,
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_methodeunit 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_methodeunit SET
|
|
Nat_MethodeUnitNat_MethodeID = '{$methodeid}',
|
|
Nat_MethodeUnitNat_UnitID = '{$unitid}',
|
|
Nat_MethodeUnitUserID = '{$userid}'
|
|
WHERE Nat_MethodeUnitID = '{$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 deletetest()
|
|
{
|
|
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_test SET
|
|
Nat_TestIsActive = 'N',
|
|
Nat_TestLastUpdated = now()
|
|
WHERE
|
|
Nat_TestID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_test delete");
|
|
exit;
|
|
}
|
|
$sql = "update nat_methodeunit SET
|
|
Nat_MethodeUnitIsActive = 'N',
|
|
Nat_MethodeUnitLastUpdated = now()
|
|
WHERE
|
|
Nat_MethodeUnitNat_TestID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_methodeunit 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 deletemethodeunit()
|
|
{
|
|
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_methodeunit SET
|
|
Nat_MethodeUnitIsActive = 'N',
|
|
Nat_MethodeUnitLastUpdated = now()
|
|
WHERE
|
|
Nat_MethodeUnitID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_methodeunit 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 searchgroup(){
|
|
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_group
|
|
WHERE
|
|
Nat_GroupName like ?
|
|
AND Nat_GroupIsActive = '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_group count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT Nat_GroupID, Nat_GroupName
|
|
FROM nat_group
|
|
WHERE
|
|
Nat_GroupName like ?
|
|
AND Nat_GroupIsActive = 'Y'
|
|
ORDER BY Nat_GroupName 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_group 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 nat_test
|
|
WHERE
|
|
Nat_TestName like ?
|
|
AND Nat_TestIsActive = 'Y' AND Nat_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("nat_test count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT Nat_TestID, Nat_TestName, Nat_UnitID, Nat_UnitName
|
|
FROM nat_test
|
|
JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
|
WHERE
|
|
Nat_TestName like ?
|
|
AND Nat_TestIsActive = 'Y' AND Nat_TestIsResult = 'Y'
|
|
ORDER BY Nat_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("nat_test rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchmethode(){
|
|
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 searchunit(){
|
|
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_unit
|
|
WHERE
|
|
Nat_UnitName like ?
|
|
AND Nat_UnitIsActive = '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_unit count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT Nat_UnitID, Nat_UnitName
|
|
FROM nat_unit
|
|
WHERE
|
|
Nat_UnitName like ?
|
|
AND Nat_UnitIsActive = 'Y'
|
|
ORDER BY Nat_UnitName 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_unit rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchtestbyname(){
|
|
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_test
|
|
WHERE
|
|
Nat_TestName like ?
|
|
AND Nat_TestIsActive = 'Y' AND Nat_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("nat_test count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT Nat_TestID, Nat_TestName, Nat_UnitID, Nat_UnitName
|
|
FROM nat_test
|
|
JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
|
WHERE
|
|
Nat_TestName like ?
|
|
AND Nat_TestIsActive = 'Y' AND Nat_TestIsResult = 'Y'
|
|
ORDER BY Nat_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("nat_test 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'";
|
|
$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'
|
|
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 ?
|
|
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;
|
|
$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);
|
|
}
|
|
|
|
}
|
|
} |