2518 lines
81 KiB
PHP
2518 lines
81 KiB
PHP
<?php
|
|
|
|
class Group extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "GROUP API";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
|
|
function lookupsubgroup(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$search = $prm['search'];
|
|
$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_subgroup
|
|
JOIN nat_group ON Nat_SubGroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
WHERE
|
|
( Nat_SubGroupName LIKE CONCAT('%','{$search}','%')) AND
|
|
($id = 0 or ($id > 0 and Nat_SubGroupNat_GroupID = $id))
|
|
AND Nat_SubGroupIsActive = 'Y'";
|
|
$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_subgroup count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_SubGroupID as id,
|
|
Nat_SubGroupName as name,
|
|
Nat_SubGroupCode as code,
|
|
IF(Nat_SubGroupCode = '',Nat_SubGroupName,CONCAT(Nat_SubGroupName, ' [',Nat_SubGroupCode,']')) as namex,
|
|
Nat_GroupID,
|
|
Nat_GroupName,
|
|
'' as isdefault,
|
|
nat_subgroup.*
|
|
from nat_subgroup
|
|
JOIN nat_group ON Nat_SubGroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
WHERE
|
|
( Nat_SubGroupName LIKE CONCAT('%','{$search}','%') OR
|
|
Nat_SubGroupCode LIKE CONCAT('%','{$search}','%') OR
|
|
Nat_GroupName LIKE CONCAT('%','{$search}','%')
|
|
) AND
|
|
($id = 0 or ($id > 0 and Nat_SubGroupNat_GroupID = $id))
|
|
AND Nat_SubGroupIsActive = 'Y'
|
|
ORDER BY Nat_SubGroupName 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_subgroup 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 lookupsubgroupbygroup(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$search = $prm['search'];
|
|
$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_subgroup
|
|
JOIN nat_group ON Nat_SubGroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
WHERE
|
|
Nat_GroupName LIKE CONCAT('%','{$search}','%')
|
|
AND Nat_SubGroupIsActive = 'Y'";
|
|
$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_subgroup count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_GroupID as id,
|
|
Nat_GroupName as name,
|
|
Nat_GroupCode as code,
|
|
IF(Nat_GroupCode = '',Nat_GroupName,CONCAT(Nat_GroupName, ' [',Nat_GroupCode,']')) as namex,
|
|
Nat_GroupID,
|
|
Nat_GroupName,
|
|
'' as isdefault,
|
|
nat_subgroup.*
|
|
from nat_subgroup
|
|
JOIN nat_group ON Nat_GroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
WHERE
|
|
Nat_GroupName LIKE CONCAT('%','{$search}','%')
|
|
AND Nat_GroupIsActive = 'Y'
|
|
ORDER BY Nat_GroupName 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_subgroup 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 lookupsubgroupbydistrict(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$search = $prm['search'];
|
|
$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_subgroup
|
|
JOIN nat_group ON Nat_GroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
JOIN nat_subsubgroup ON Nat_GroupID = Nat_SubSubGroupNat_GroupID AND Nat_SubSubGroupIsActive = 'Y'
|
|
WHERE
|
|
Nat_SubSubGroupName LIKE CONCAT('%','{$search}','%')
|
|
AND Nat_GroupIsActive = 'Y'";
|
|
$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_subgroup count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_GroupID as id,
|
|
Nat_GroupName as name,
|
|
Nat_GroupCode as code,
|
|
IF(Nat_GroupCode = '',Nat_GroupName,CONCAT(Nat_GroupName, ' [',Nat_GroupCode,']')) as namex,
|
|
Nat_GroupID,
|
|
Nat_GroupName,
|
|
'' as isdefault,
|
|
nat_subgroup.*
|
|
from nat_subgroup
|
|
JOIN nat_group ON Nat_GroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
JOIN nat_subsubgroup ON Nat_GroupID = Nat_SubSubGroupNat_GroupID AND Nat_SubSubGroupIsActive = 'Y'
|
|
WHERE
|
|
Nat_SubSubGroupName LIKE CONCAT('%','{$search}','%')
|
|
AND Nat_GroupIsActive = 'Y'
|
|
ORDER BY Nat_GroupName 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_subgroup 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 lookupdistrict(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$search = $prm['search'];
|
|
$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_subsubgroup
|
|
JOIN nat_subgroup ON Nat_SubSubGroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
WHERE
|
|
( Nat_SubSubGroupName LIKE CONCAT('%','{$search}','%')) AND
|
|
($id = 0 or ($id > 0 and Nat_SubSubGroupNat_GroupID = $id))
|
|
AND Nat_SubSubGroupIsActive = 'Y'";
|
|
$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_subsubgroup count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_SubSubGroupID as id,
|
|
Nat_SubSubGroupName as name,
|
|
Nat_SubSubGroupCode as code,
|
|
IF(Nat_SubSubGroupCode = '',Nat_SubSubGroupName,CONCAT(Nat_SubSubGroupName, ' [',Nat_SubSubGroupCode,']')) as namex,
|
|
Nat_GroupID,
|
|
Nat_GroupName,
|
|
IF(Nat_SubSubGroupIsDefault = 'N','Tidak','Ya') as isdefault,
|
|
nat_subsubgroup.*
|
|
from nat_subsubgroup
|
|
JOIN nat_subgroup ON Nat_SubSubGroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
WHERE
|
|
( Nat_SubSubGroupName LIKE CONCAT('%','{$search}','%') OR
|
|
Nat_SubSubGroupCode LIKE CONCAT('%','{$search}','%') OR
|
|
Nat_GroupName LIKE CONCAT('%','{$search}','%')
|
|
) AND
|
|
($id = 0 or ($id > 0 and Nat_SubSubGroupNat_GroupID = $id))
|
|
AND Nat_SubSubGroupIsActive = 'Y'
|
|
ORDER BY Nat_SubSubGroupName 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_subsubgroup 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 lookupdistrictbysubgroup(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$search = $prm['search'];
|
|
$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_subsubgroup
|
|
JOIN nat_subgroup ON Nat_SubSubGroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
WHERE
|
|
Nat_GroupName LIKE CONCAT('%','{$search}','%')
|
|
AND Nat_SubSubGroupIsActive = 'Y'";
|
|
$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_subsubgroup count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_SubSubGroupID as id,
|
|
Nat_SubSubGroupName as name,
|
|
Nat_SubSubGroupCode as code,
|
|
IF(Nat_SubSubGroupCode = '',Nat_SubSubGroupName,CONCAT(Nat_SubSubGroupName, ' [',Nat_SubSubGroupCode,']')) as namex,
|
|
Nat_GroupID,
|
|
Nat_GroupName,
|
|
IF(Nat_SubSubGroupIsDefault = 'N','Tidak','Ya') as isdefault,
|
|
nat_subsubgroup.*
|
|
from nat_subsubgroup
|
|
JOIN nat_subgroup ON Nat_SubSubGroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
WHERE
|
|
Nat_GroupName LIKE CONCAT('%','{$search}','%')
|
|
AND Nat_SubSubGroupIsActive = 'Y'
|
|
ORDER BY Nat_SubSubGroupName 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_subsubgroup 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 lookupdistrictbyprovince(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$search = $prm['search'];
|
|
$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_subsubgroup
|
|
JOIN nat_subgroup ON Nat_SubSubGroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
JOIN nat_group ON Nat_GroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
WHERE
|
|
Nat_GroupName LIKE CONCAT('%','{$search}','%')
|
|
AND Nat_SubSubGroupIsActive = 'Y'";
|
|
$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_subsubgroup count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_SubSubGroupID as id,
|
|
Nat_SubSubGroupName as name,
|
|
Nat_SubSubGroupCode as code,
|
|
IF(Nat_SubSubGroupCode = '',Nat_SubSubGroupName,CONCAT(Nat_SubSubGroupName, ' [',Nat_SubSubGroupCode,']')) as namex,
|
|
Nat_GroupID,
|
|
Nat_GroupName,
|
|
IF(Nat_SubSubGroupIsDefault = 'N','Tidak','Ya') as isdefault,
|
|
nat_subsubgroup.*
|
|
from nat_subsubgroup
|
|
JOIN nat_subgroup ON Nat_SubSubGroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
JOIN nat_group ON Nat_GroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
WHERE
|
|
Nat_GroupName LIKE CONCAT('%','{$search}','%')
|
|
AND Nat_SubSubGroupIsActive = 'Y'
|
|
ORDER BY Nat_SubSubGroupName 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_subsubgroup 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 lookupsubgroupbyname(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$province = $prm['province'];
|
|
$subgroup = $prm['subgroup'];
|
|
$district = $prm['district'];
|
|
$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 nat_subgroup
|
|
JOIN nat_group ON Nat_GroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
LEFT JOIN nat_subsubgroup ON Nat_GroupID = Nat_SubSubGroupNat_GroupID AND Nat_SubSubGroupIsActive = 'Y'
|
|
WHERE
|
|
Nat_GroupName LIKE CONCAT('%','{$province}','%') AND
|
|
Nat_GroupName LIKE CONCAT('%','{$subgroup}','%') AND
|
|
IFNULL(Nat_SubSubGroupName,'') LIKE CONCAT('%','{$district}','%') AND
|
|
Nat_GroupIsActive = 'Y' GROUP BY Nat_GroupID) 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_subgroup count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_GroupID as id,
|
|
Nat_GroupName as name,
|
|
Nat_GroupCode as code,
|
|
IF(Nat_GroupCode = '',Nat_GroupName,CONCAT(Nat_GroupName, ' [',Nat_GroupCode,']')) as namex,
|
|
Nat_GroupID,
|
|
Nat_GroupName,
|
|
IF(Nat_GroupIsDefault = 'N','Tidak','Ya') as isdefault,
|
|
nat_subgroup.*
|
|
from nat_subgroup
|
|
JOIN nat_group ON Nat_GroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
LEFT JOIN nat_subsubgroup ON Nat_GroupID = Nat_SubSubGroupNat_SubGroupID AND Nat_SubSubGroupIsActive = 'Y'
|
|
WHERE
|
|
Nat_GroupName LIKE CONCAT('%','{$province}','%') AND
|
|
Nat_GroupName LIKE CONCAT('%','{$subgroup}','%') AND
|
|
IFNULL(Nat_SubSubGroupName,'') LIKE CONCAT('%','{$district}','%') AND
|
|
Nat_GroupIsActive = 'Y'
|
|
GROUP BY Nat_GroupID
|
|
ORDER BY Nat_GroupName 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_subgroup 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 lookupdistrictbyname(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$province = $prm['province'];
|
|
$city = $prm['city'];
|
|
$district = $prm['district'];
|
|
$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 nat_subsubgroup
|
|
JOIN nat_subgroup ON Nat_SubSubGroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
JOIN nat_group ON Nat_GroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
WHERE
|
|
Nat_GroupName LIKE CONCAT('%','{$province}','%') AND
|
|
Nat_GroupName LIKE CONCAT('%','{$city}','%') AND
|
|
Nat_SubSubGroupName LIKE CONCAT('%','{$district}','%') AND
|
|
Nat_SubSubGroupIsActive = 'Y' GROUP BY Nat_SubSubGroupID) 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_subsubgroup count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_SubSubGroupID as id,
|
|
Nat_SubSubGroupName as name,
|
|
Nat_SubSubGroupCode as code,
|
|
IF(Nat_SubSubGroupCode = '',Nat_SubSubGroupName,CONCAT(Nat_SubSubGroupName, ' [',Nat_SubSubGroupCode,']')) as namex,
|
|
Nat_GroupID,
|
|
Nat_GroupName,
|
|
IF(Nat_SubSubGroupIsDefault = 'N','Tidak','Ya') as isdefault,
|
|
nat_subsubgroup.*
|
|
from nat_subsubgroup
|
|
JOIN nat_subgroup ON Nat_SubSubGroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
JOIN nat_group ON Nat_GroupNat_GroupID = Nat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
WHERE
|
|
Nat_GroupName LIKE CONCAT('%','{$province}','%') AND
|
|
Nat_GroupName LIKE CONCAT('%','{$city}','%') AND
|
|
Nat_SubSubGroupName LIKE CONCAT('%','{$district}','%') AND
|
|
Nat_SubSubGroupIsActive = 'Y'
|
|
GROUP BY Nat_SubSubGroupID
|
|
ORDER BY Nat_SubSubGroupName 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_subsubgroup 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;
|
|
$search = $prm['search'];
|
|
$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_group
|
|
where
|
|
( Nat_GroupName LIKE CONCAT('%','{$search}','%'))AND
|
|
Nat_GroupIsActive = 'Y'";
|
|
$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_group count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_GroupID as id,
|
|
Nat_GroupName as name,
|
|
Nat_GroupCode as code,
|
|
IF(Nat_GroupCode = '',Nat_GroupName,CONCAT(Nat_GroupName, ' [',Nat_GroupCode,']')) as namex,
|
|
IF(Nat_GroupIsDefault = 'N','Tidak','Ya') as isdefault,
|
|
nat_group.*
|
|
from nat_group
|
|
where
|
|
( Nat_GroupName LIKE CONCAT('%','{$search}','%') OR
|
|
Nat_GroupCode LIKE CONCAT('%','{$search}','%')
|
|
)AND
|
|
Nat_GroupIsActive = 'Y'
|
|
ORDER BY Nat_GroupName 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_group 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 lookupprovincebyname()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$province = $prm['province'];
|
|
$city = $prm['city'];
|
|
$district = $prm['district'];
|
|
$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 nat_group
|
|
LEFT JOIN nat_subgroup ON Nat_GroupID = Nat_GroupNat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
LEFT JOIN nat_subsubgroup ON Nat_GroupID = Nat_SubSubGroupNat_GroupID AND Nat_SubSubGroupIsActive = 'Y'
|
|
where
|
|
Nat_GroupName LIKE CONCAT('%','{$province}','%') AND
|
|
IFNULL(Nat_GroupName,'') LIKE CONCAT('%','{$city}','%') AND
|
|
IFNULL(Nat_SubSubGroupName,'') LIKE CONCAT('%','{$district}','%') AND
|
|
Nat_GroupIsActive = 'Y'
|
|
GROUP BY Nat_GroupID) 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_group count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_GroupID as id,
|
|
Nat_GroupName as name,
|
|
Nat_GroupCode as code,
|
|
IF(Nat_GroupCode = '',Nat_GroupName,CONCAT(Nat_GroupName, ' [',Nat_GroupCode,']')) as namex,
|
|
IF(Nat_GroupIsDefault = 'N','Tidak','Ya') as isdefault,
|
|
nat_group.*
|
|
from nat_group
|
|
LEFT JOIN nat_subgroup ON Nat_GroupID = Nat_GroupNat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
LEFT JOIN nat_subsubgroup ON Nat_GroupID = Nat_SubSubGroupNat_GroupID AND Nat_SubSubGroupIsActive = 'Y'
|
|
where
|
|
Nat_GroupName LIKE CONCAT('%','{$province}','%') AND
|
|
IFNULL(Nat_GroupName,'') LIKE CONCAT('%','{$city}','%') AND
|
|
IFNULL(Nat_SubSubGroupName,'') LIKE CONCAT('%','{$district}','%') AND
|
|
Nat_GroupIsActive = 'Y'
|
|
GROUP BY Nat_GroupID
|
|
ORDER BY Nat_GroupName 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_group 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 lookupprovincebydistrict()
|
|
{
|
|
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';
|
|
}
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
$sql = "select COUNT(*) as total
|
|
from nat_group
|
|
JOIN nat_subgroup ON Nat_GroupID = Nat_GroupNat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
JOIN nat_subsubgroup ON Nat_GroupID = Nat_SubSubGroupNat_GroupID AND Nat_SubSubGroupIsActive = 'Y'
|
|
where
|
|
Nat_SubSubGroupName LIKE CONCAT('%','{$search}','%')
|
|
AND
|
|
Nat_GroupIsActive = 'Y'";
|
|
$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_group count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_GroupID as id,
|
|
Nat_GroupName as name,
|
|
Nat_GroupCode as code,
|
|
IF(Nat_GroupCode = '',Nat_GroupName,CONCAT(Nat_GroupName, ' [',Nat_GroupCode,']')) as namex,
|
|
IF(Nat_GroupIsDefault = 'N','Tidak','Ya') as isdefault,
|
|
nat_group.*
|
|
from nat_group
|
|
JOIN nat_subgroup ON Nat_GroupID = Nat_GroupNat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
JOIN nat_subsubgroup ON Nat_GroupID = Nat_SubSubGroupNat_GroupID AND Nat_SubSubGroupIsActive = 'Y'
|
|
where
|
|
Nat_SubSubGroupName LIKE CONCAT('%','{$search}','%')
|
|
AND
|
|
Nat_GroupIsActive = 'Y'
|
|
ORDER BY Nat_GroupName 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_group 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 lookupprovincebycity()
|
|
{
|
|
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';
|
|
}
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
$sql = "select COUNT(*) as total
|
|
from nat_group
|
|
JOIN nat_subgroup ON Nat_GroupID = Nat_GroupNat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
where
|
|
Nat_GroupName LIKE CONCAT('%','{$search}','%')
|
|
AND
|
|
Nat_GroupIsActive = 'Y'";
|
|
$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_group count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_GroupID as id,
|
|
Nat_GroupName as name,
|
|
Nat_GroupCode as code,
|
|
IF(Nat_GroupCode = '',Nat_GroupName,CONCAT(Nat_GroupName, ' [',Nat_GroupCode,']')) as namex,
|
|
IF(Nat_GroupIsDefault = 'N','Tidak','Ya') as isdefault,
|
|
nat_group.*
|
|
from nat_group
|
|
JOIN nat_subgroup ON Nat_GroupID = Nat_GroupNat_GroupID AND Nat_GroupIsActive = 'Y'
|
|
where
|
|
Nat_GroupName LIKE CONCAT('%','{$search}','%')
|
|
AND
|
|
Nat_GroupIsActive = 'Y'
|
|
ORDER BY Nat_GroupName 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_group 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 addnewprovince()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$name = $prm['name'];
|
|
$code = $prm['code'];
|
|
$isdefault = $prm['isdefault'];
|
|
$sql = "insert into nat_group(
|
|
Nat_GroupName,
|
|
Nat_GroupCode,
|
|
Nat_GroupIsDefault,
|
|
Nat_GroupCreated,
|
|
Nat_GroupLastUpdated
|
|
)
|
|
values( ?, ?, ?, now(), now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$name,
|
|
$code,
|
|
$isdefault
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_group insert");
|
|
exit;
|
|
}
|
|
$last_id = $this->db_onedev->insert_id();
|
|
if ($isdefault == "Y" ) {
|
|
$sql = "update nat_group set Nat_GroupIsDefault= 'N'
|
|
where Nat_GroupID <> ? ";
|
|
$this->db_onedev->query($sql,array($last_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 editprovince()
|
|
{
|
|
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'];
|
|
$code = $prm['code'];
|
|
$isdefault = $prm['isdefault'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$sqlcompany = "update nat_group SET
|
|
Nat_GroupName = ?,
|
|
Nat_GroupCode = ?,
|
|
Nat_GroupIsDefault = ?,
|
|
Nat_GroupLastUpdated = now()
|
|
where
|
|
Nat_GroupID = ?
|
|
";
|
|
$querycompany = $this->db_onedev->query($sqlcompany,
|
|
array(
|
|
$name,
|
|
$code,
|
|
$isdefault,
|
|
$id
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$querycompany) {
|
|
$this->sys_error_db("nat_group update");
|
|
exit;
|
|
}
|
|
if ($isdefault == "Y" ) {
|
|
$sql = "update nat_group set Nat_GroupIsDefault= 'N'
|
|
where Nat_GroupID <> ? ";
|
|
$this->db_onedev->query($sql,array($id));
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => $id));
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function addnewcity()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$provinceid = $prm['provinceid'];
|
|
$code = $prm['code'];
|
|
$name = $prm['name'];
|
|
$isdefault = $prm['isdefault'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
if($prm['xid'] == 0){
|
|
|
|
$sql = "insert into nat_subgroup(
|
|
Nat_GroupNat_GroupID,
|
|
Nat_GroupCode,
|
|
Nat_GroupName,
|
|
Nat_GroupIsDefault,
|
|
Nat_GroupLastUpdated,
|
|
Nat_GroupCreated)
|
|
values(?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$provinceid,
|
|
$code,
|
|
$name,
|
|
$isdefault
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_subgroup insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$last_id = $this->db_onedev->insert_id();
|
|
if ($isdefault == "Y" ) {
|
|
$sql = "update nat_subgroup set Nat_GroupIsDefault= 'N'
|
|
where Nat_GroupID <> ? ";
|
|
$this->db_onedev->query($sql,array($last_id));
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}else{
|
|
|
|
//echo $query;
|
|
$sql = "UPDATE nat_subgroup SET Nat_GroupNat_GroupID = '{$provinceid}',
|
|
Nat_GroupCode = '{$code}',
|
|
Nat_GroupName = '{$name}',
|
|
Nat_GroupIsDefault = '{$isdefault}'
|
|
WHERE Nat_GroupID = '{$prm['xid']}'";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if ($isdefault == "Y" ) {
|
|
$sql = "update nat_subgroup set Nat_GroupIsDefault= 'N'
|
|
where Nat_GroupID <> ? ";
|
|
$this->db_onedev->query($sql,array($prm['xid']));
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
}
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function addnewdistrict()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$cityid = $prm['cityid'];
|
|
$code = $prm['code'];
|
|
$name = $prm['name'];
|
|
$isdefault = $prm['isdefault'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
if($prm['xid'] == 0){
|
|
|
|
$sql = "insert into nat_subsubgroup(
|
|
Nat_SubSubGroupNat_GroupID,
|
|
Nat_SubSubGroupCode,
|
|
Nat_SubSubGroupName,
|
|
Nat_SubSubGroupIsDefault,
|
|
Nat_SubSubGroupLastUpdated,
|
|
Nat_SubSubGroupCreated)
|
|
values(?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$cityid,
|
|
$code,
|
|
$name,
|
|
$isdefault
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_subsubgroup insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$last_id = $this->db_onedev->insert_id();
|
|
if ($isdefault == "Y" ) {
|
|
$sql = "update nat_subsubgroup set Nat_SubSubGroupIsDefault= 'N'
|
|
where Nat_SubSubGroupID <> ? ";
|
|
$this->db_onedev->query($sql,array($last_id));
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}else{
|
|
|
|
//echo $query;
|
|
$sql = "UPDATE nat_subsubgroup SET Nat_SubSubGroupNat_GroupID = '{$cityid}',
|
|
Nat_SubSubGroupCode = '{$code}',
|
|
Nat_SubSubGroupName = '{$name}',
|
|
Nat_SubSubGroupIsDefault = '{$isdefault}'
|
|
WHERE Nat_SubSubGroupID = '{$prm['xid']}'";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if ($isdefault == "Y" ) {
|
|
$sql = "update nat_subsubgroup set Nat_SubSubGroupIsDefault= 'N'
|
|
where Nat_SubSubGroupID <> ? ";
|
|
$this->db_onedev->query($sql,array($prm['xid']));
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
}
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function addnewconvert()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$code = $prm['code'];
|
|
$resultorigin = $prm['resultorigin'];
|
|
$resultconvert = $prm['resultconvert'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
if($prm['xid'] == 0){
|
|
|
|
$sql = "insert into m_instrumentconvert(
|
|
M_InstrumentConvertCode,
|
|
M_InstrumentConvertResultOrigin,
|
|
M_InstrumentConvertResultConvert,
|
|
M_InstrumentConvertUserID,
|
|
M_InstrumentConvertCreated,
|
|
M_InstrumentConvertLastUpdated
|
|
|
|
)
|
|
values( ?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$code,
|
|
$resultorigin,
|
|
$resultconvert,
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("m_instrumentconvert insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}else{
|
|
|
|
//echo $query;
|
|
$sql = "UPDATE m_instrumentconvert SET M_InstrumentConvertResultOrigin = '{$resultorigin}',
|
|
M_InstrumentConvertResultConvert = '{$resultconvert}',
|
|
M_InstrumentConvertUserID = '{$userid}' WHERE M_InstrumentConvertID = '{$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 deleteuser()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "update m_user SET
|
|
M_UserIsActive = 'N',
|
|
M_UserLastUpdated = now()
|
|
WHERE
|
|
M_UserID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_user 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 confirmmou()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "update m_mou SET
|
|
M_MouIsApproved = 'Y',
|
|
M_MouLastUpdated = now()
|
|
WHERE
|
|
M_MouID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_mou update");
|
|
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 verifymou()
|
|
{
|
|
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"];
|
|
$id = $prm['id'];
|
|
$sql = "update m_mou SET
|
|
M_MouIsVerified = 'Y',
|
|
M_MouVerifyDate = now(),
|
|
M_MouStatus = 'V',
|
|
M_MouVerifyUserID = '{$userid}',
|
|
M_MouLastUpdated = now()
|
|
WHERE
|
|
M_MouID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_mou update");
|
|
exit;
|
|
}
|
|
|
|
$querystatus ="INSERT g_moustatuslog
|
|
(G_MouStatusLogDate,
|
|
G_MouStatusLogM_MouID,
|
|
G_MouStatusLogStatus,
|
|
G_MouStatusLogUserID,
|
|
G_MouStatusLogCreated,
|
|
G_MouStatusLogLastUpdated)
|
|
VALUES(
|
|
date(now()),
|
|
'{$id}',
|
|
'V',
|
|
'{$userid}',
|
|
now(),
|
|
now())
|
|
";
|
|
$rows = $this->db_onedev->query($querystatus);
|
|
|
|
|
|
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function unverifymou()
|
|
{
|
|
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"];
|
|
$id = $prm['id'];
|
|
$sql = "update m_mou SET
|
|
M_MouIsVerified = 'N',
|
|
M_MouStatus = 'UV',
|
|
M_MouVerifyDate = now(),
|
|
M_MouVerifyUserID = '{$userid}',
|
|
M_MouLastUpdated = now()
|
|
WHERE
|
|
M_MouID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_mou update");
|
|
exit;
|
|
}
|
|
$querystatus ="INSERT g_moustatuslog
|
|
(G_MouStatusLogDate,
|
|
G_MouStatusLogM_MouID,
|
|
G_MouStatusLogStatus,
|
|
G_MouStatusLogUserID,
|
|
G_MouStatusLogCreated,
|
|
G_MouStatusLogLastUpdated)
|
|
VALUES(
|
|
date(now()),
|
|
'{$id}',
|
|
'UV',
|
|
'{$userid}',
|
|
now(),
|
|
now())
|
|
";
|
|
$rows = $this->db_onedev->query($querystatus);
|
|
|
|
|
|
|
|
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function releasemou()
|
|
{
|
|
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"];
|
|
$id = $prm['id'];
|
|
$sql = "update m_mou SET
|
|
M_MouIsReleased = 'Y',
|
|
M_MouStatus = 'R',
|
|
M_MouReleaseDate = now(),
|
|
M_MouReleaseUserID = '{$userid}',
|
|
M_MouIsApproved = 'Y',
|
|
M_MouLastUpdated = now()
|
|
WHERE
|
|
M_MouID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_mou update");
|
|
exit;
|
|
}
|
|
$querystatus ="INSERT g_moustatuslog
|
|
(G_MouStatusLogDate,
|
|
G_MouStatusLogM_MouID,
|
|
G_MouStatusLogStatus,
|
|
G_MouStatusLogUserID,
|
|
G_MouStatusLogCreated,
|
|
G_MouStatusLogLastUpdated)
|
|
VALUES(
|
|
date(now()),
|
|
'{$id}',
|
|
'R',
|
|
'{$userid}',
|
|
now(),
|
|
now())
|
|
";
|
|
$rows = $this->db_onedev->query($querystatus);
|
|
|
|
|
|
|
|
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function unreleasemou()
|
|
{
|
|
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"];
|
|
$id = $prm['id'];
|
|
$sql = "update m_mou SET
|
|
M_MouIsReleased = 'N',
|
|
M_MouStatus = 'UR',
|
|
M_MouReleaseDate = now(),
|
|
M_MouReleaseUserID = '{$userid}',
|
|
M_MouIsApproved = 'N',
|
|
M_MouLastUpdated = now()
|
|
WHERE
|
|
M_MouID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_mou update");
|
|
exit;
|
|
}
|
|
$querystatus ="INSERT g_moustatuslog
|
|
(G_MouStatusLogDate,
|
|
G_MouStatusLogM_MouID,
|
|
G_MouStatusLogStatus,
|
|
G_MouStatusLogUserID,
|
|
G_MouStatusLogCreated,
|
|
G_MouStatusLogLastUpdated)
|
|
VALUES(
|
|
date(now()),
|
|
'{$id}',
|
|
'UR',
|
|
'{$userid}',
|
|
now(),
|
|
now())
|
|
";
|
|
$rows = $this->db_onedev->query($querystatus);
|
|
|
|
|
|
|
|
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function deleteprovince()
|
|
{
|
|
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_group SET
|
|
Nat_GroupIsActive = 'N',
|
|
Nat_GroupLastUpdated = now()
|
|
WHERE
|
|
Nat_GroupID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_group delete");
|
|
exit;
|
|
}
|
|
$sql = "update nat_subgroup SET
|
|
Nat_GroupIsActive = 'N',
|
|
Nat_GroupLastUpdated = now()
|
|
WHERE
|
|
Nat_GroupNat_GroupID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_subgroup delete");
|
|
exit;
|
|
}
|
|
$sql = "update nat_subsubgroup
|
|
JOIN nat_subgroup ON Nat_SubSubGroupNat_GroupID = Nat_GroupID SET
|
|
Nat_SubSubGroupIsActive = 'N',
|
|
Nat_SubSubGroupLastUpdated = now()
|
|
WHERE
|
|
Nat_GroupNat_GroupID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_subsubgroup delete");
|
|
exit;
|
|
}
|
|
$sql = " ";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db(" 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 deletecity()
|
|
{
|
|
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_subgroup SET
|
|
Nat_GroupIsActive = 'N',
|
|
Nat_SubGroupLastUpdated = now()
|
|
WHERE
|
|
Nat_SubGroupID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_subgroup delete");
|
|
exit;
|
|
}
|
|
|
|
$sql = "update nat_subsubgroup SET
|
|
Nat_SubSubGroupIsActive = 'N',
|
|
Nat_SubSubGroupLastUpdated = now()
|
|
WHERE
|
|
Nat_SubSubGroupNat_SubGroupID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
|
|
$sql = " ";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db(" 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 deletedistrict()
|
|
{
|
|
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_subsubgroup SET
|
|
Nat_SubSubGroupIsActive = 'N',
|
|
Nat_SubSubGroupLastUpdated = now()
|
|
WHERE
|
|
Nat_SubSubGroupID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_subsubgroup delete");
|
|
exit;
|
|
}
|
|
|
|
$sql = " ";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db(" 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 selectnonlab(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$rows['nonlabs'] = array(array("T_TestIsNonLabID"=>"","T_TestIsNonLabName"=>"LAB"),array("T_TestIsNonLabID"=>"RADIODIAGNOSTIC","T_TestIsNonLabName"=>"RADIODIAGNOSTIC"), array("T_TestIsNonLabID"=>"ELEKTROMEDIS","T_TestIsNonLabName"=>"ELEKTROMEDIS"),array("T_TestIsNonLabID"=>"OTHERS","T_TestIsNonLabName"=>"OTHERS"));
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
function selectcompanybusiness(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *, COUNT(M_CompanyID) as used
|
|
FROM (SELECT m_companybusiness.*,M_CompanyID
|
|
FROM
|
|
m_companybusiness
|
|
LEFT JOIN m_company ON M_CompanyBusinessID = M_CompanyM_CompanyBusinessID AND M_CompanyIsActive = 'Y'
|
|
WHERE M_CompanyBusinessIsActive = 'Y') a
|
|
GROUP BY M_CompanyBusinessID
|
|
";
|
|
//echo $query;
|
|
$rows['companybusinesss'] = $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 selectcompanylevel(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$rows = [];
|
|
$query =" SELECT *,CONCAT(Nat_CompanyLevelName,' [',M_CompanyName,']') as Nat_CompanyLevelName, COUNT(M_CompanyID) as used
|
|
FROM (SELECT nat_companylevel.*,M_CompanyID,M_CompanyName
|
|
FROM
|
|
nat_companylevel
|
|
LEFT JOIN m_company ON Nat_CompanyLevelNat_CompanyID = M_CompanyID AND M_CompanyIsActive = 'Y'
|
|
WHERE Nat_CompanyLevelIsActive = 'Y') a
|
|
GROUP BY Nat_CompanyLevelID
|
|
";
|
|
//echo $query;
|
|
$rows['companylevels'] = $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 selecthierarchy(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *, COUNT(M_CompanyID) as used
|
|
FROM (SELECT nat_hierarchy.*,M_CompanyID
|
|
FROM
|
|
nat_hierarchy
|
|
LEFT JOIN m_company ON Nat_HierarchyID = M_CompanyNat_HierarchyID AND M_CompanyIsActive = 'Y'
|
|
WHERE Nat_HierarchyIsActive = 'Y') a
|
|
GROUP BY Nat_HierarchyID
|
|
";
|
|
//echo $query;
|
|
$rows['hierarchys'] = $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 0 as M_DoctorID, 'Semua Dokter' as M_DoctorName, 'Semua Dokter' as M_DoctorNames
|
|
UNION
|
|
SELECT M_DoctorID, M_DoctorName, CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as M_DoctorNames
|
|
FROM m_doctor
|
|
WHERE M_DoctorIsActive = 'Y') a
|
|
WHERE
|
|
M_DoctorNames like ?
|
|
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 searchprovince(){
|
|
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 searchprovincebyname(){
|
|
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 t_test
|
|
WHERE
|
|
T_TestName like ?
|
|
AND T_TestIsActive = '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 T_TestID, T_TestName
|
|
FROM t_test
|
|
WHERE
|
|
T_TestName like ?
|
|
AND T_TestIsActive = 'Y'
|
|
GROUP BY T_TestID
|
|
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;
|
|
}
|
|
}
|
|
function searchcompanylevel(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
|
|
$name = $prm['name'];
|
|
$hirarkiid = intval($prm['id']) - 1;
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM nat_companylevel
|
|
WHERE
|
|
Nat_CompanyLevelName like '%{$name}%'
|
|
AND
|
|
Nat_CompanyLevelNat_HierarchyID = '{$hirarkiid}'
|
|
AND Nat_CompanyLevelIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("nat_companylevel count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT * FROM(SELECT *, CONCAT(Nat_CompanyLevelName, ' [',M_CompanyName,']') as Nat_CompanyLevelNames
|
|
FROM nat_companylevel
|
|
LEFT JOIN m_company ON Nat_CompanyLevelNat_CompanyID = M_CompanyID
|
|
WHERE Nat_CompanyLevelIsActive = 'Y') a
|
|
WHERE
|
|
Nat_CompanyLevelName like '%{$name}%'
|
|
AND
|
|
Nat_CompanyLevelNat_HierarchyID = '{$hirarkiid}'
|
|
AND Nat_CompanyLevelIsActive = 'Y'
|
|
ORDER BY Nat_CompanyLevelName DESC
|
|
";
|
|
$query = $this->db_onedev->query($sql);
|
|
|
|
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_companylevel 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 nat_subgroup
|
|
WHERE
|
|
Nat_SubGroupName like ?
|
|
AND Nat_SubGroupIsActive = '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_subgroup count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *
|
|
FROM nat_subgroup
|
|
WHERE
|
|
Nat_SubGroupName like ?
|
|
AND Nat_SubGroupIsActive = 'Y'
|
|
ORDER BY Nat_SubGroupName 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("nat_subgroup rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchdistrict(){
|
|
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_subsubgroup
|
|
WHERE
|
|
Nat_SubSubGroupName like ?
|
|
AND Nat_SubSubGroupIsActive = '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_subsubgroup count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *
|
|
FROM nat_subsubgroup
|
|
WHERE
|
|
Nat_SubSubGroupName like ?
|
|
AND Nat_SubSubGroupIsActive = 'Y'
|
|
ORDER BY Nat_SubSubGroupName 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("nat_subsubgroup rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getstaff(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_staff
|
|
WHERE
|
|
M_StaffIsActive = 'Y' AND M_StaffM_PositionID = 2";
|
|
//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 getprovince(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM nat_group
|
|
WHERE
|
|
Nat_GroupIsActive = 'Y'";
|
|
//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 getcity(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM nat_subgroup
|
|
WHERE
|
|
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = ?
|
|
";
|
|
//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 getdistrict(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM nat_subsubgroup
|
|
WHERE
|
|
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupNat_SubGroupID = ?
|
|
";
|
|
//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 selectbase(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT 'SPK' as baseid, 'SPK' as basename
|
|
UNION SELECT 'MOU' as baseid, 'MOU' as basename
|
|
";
|
|
//echo $query;
|
|
$rows['bases'] = $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 selectomzettype(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_omzettype
|
|
WHERE
|
|
M_OmzetTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['omzettypes'] = $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 selectmoutype(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_moutype
|
|
WHERE
|
|
M_MouTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['moutypes'] = $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 selectagingtype(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_agingtype
|
|
WHERE
|
|
M_AgingIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['agingtypes'] = $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);
|
|
}
|
|
|
|
}
|
|
|
|
}
|