Initial import
This commit is contained in:
910
one-api/application/controllers/v1/masterdata/Unit.php
Normal file
910
one-api/application/controllers/v1/masterdata/Unit.php
Normal file
@@ -0,0 +1,910 @@
|
||||
<?php
|
||||
|
||||
class Unit extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "UNIT API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupunitbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$unit = $prm['unit'];
|
||||
$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_unit
|
||||
WHERE
|
||||
(Nat_UnitCode LIKE CONCAT('%','{$unit}','%') OR
|
||||
Nat_UnitName LIKE CONCAT('%','{$unit}','%')) AND
|
||||
Nat_UnitIsActive = 'Y' GROUP BY Nat_UnitID) a";
|
||||
// $total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->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_unit count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Nat_UnitID as id,
|
||||
Nat_UnitName as name,
|
||||
Nat_UnitCode as code,nat_unit.*
|
||||
from nat_unit
|
||||
WHERE
|
||||
(Nat_UnitCode LIKE CONCAT('%','{$unit}','%') OR
|
||||
Nat_UnitName LIKE CONCAT('%','{$unit}','%')) AND
|
||||
Nat_UnitIsActive = 'Y'
|
||||
GROUP BY Nat_UnitID
|
||||
ORDER BY Nat_UnitCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql);
|
||||
// echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("nat_unit 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 lookupregionalbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$regional = $prm['regional'];
|
||||
$unit = $prm['unit'];
|
||||
$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_unit ON Nat_GroupID = Nat_UnitNat_GroupID AND Nat_UnitIsActive = 'Y'
|
||||
where
|
||||
Nat_GroupName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(Nat_UnitName,'') LIKE CONCAT('%','{$unit}','%') AND
|
||||
Nat_GroupIsActive = 'Y'
|
||||
GROUP BY Nat_GroupID) a";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Nat_GroupID as id,
|
||||
Nat_GroupName as name,
|
||||
Nat_GroupName as namex,
|
||||
nat_group.*
|
||||
from nat_group
|
||||
LEFT JOIN nat_unit ON Nat_GroupID = Nat_UnitNat_GroupID AND Nat_UnitIsActive = 'Y'
|
||||
where
|
||||
Nat_GroupName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(Nat_UnitName,'') LIKE CONCAT('%','{$unit}','%') 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_regional->query($sql);
|
||||
//echo $this->db_regional->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 addnewregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$sql = "insert into nat_group(
|
||||
Nat_GroupName,
|
||||
Nat_GroupCreated,
|
||||
Nat_GroupLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$name
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_group insert");
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editregional()
|
||||
{
|
||||
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'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlcompany = "update nat_group SET
|
||||
Nat_GroupName = ?,
|
||||
Nat_GroupLastUpdated = now()
|
||||
where
|
||||
Nat_GroupID = ?
|
||||
";
|
||||
$querycompany = $this->db_regional->query($sqlcompany,
|
||||
array(
|
||||
$name,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("nat_group 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 addnewunit()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$Nat_UnitCode = $prm['Nat_UnitCode'];
|
||||
$Nat_UnitName = $prm['Nat_UnitName'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_unit WHERE Nat_UnitIsActive = 'Y' AND Nat_UnitCode = '{$Nat_UnitCode}'";
|
||||
$exist_code = $this->db_regional->query($query)->row()->exist;
|
||||
if($exist_code == 0){
|
||||
$sql = "insert into nat_unit(
|
||||
Nat_UnitCode,
|
||||
Nat_UnitName,
|
||||
Nat_UnitLastUpdated,
|
||||
Nat_UnitCreated)
|
||||
values(?,?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$Nat_UnitCode,
|
||||
$Nat_UnitName)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_unit insert",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_unit WHERE Nat_UnitIsActive = 'Y' AND Nat_UnitCode = '{$Nat_UnitCode}' AND Nat_UnitID <> {$prm['xid']}";
|
||||
//echo $query;
|
||||
$exist_code = $this->db_regional->query($query)->row()->exist;
|
||||
// echo $exist_code;
|
||||
if($exist_code == 0){
|
||||
$sql = "UPDATE nat_unit SET
|
||||
Nat_UnitCode = '{$Nat_UnitCode}',
|
||||
Nat_UnitName = '{$Nat_UnitName}'
|
||||
WHERE Nat_UnitID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteregional()
|
||||
{
|
||||
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_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_group delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update nat_unit SET
|
||||
Nat_UnitIsActive = 'N',
|
||||
Nat_UnitLastUpdated = now()
|
||||
WHERE
|
||||
Nat_UnitNat_GroupID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_unit 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 deleteunit()
|
||||
{
|
||||
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_unit SET
|
||||
Nat_UnitIsActive = 'N',
|
||||
Nat_UnitLastUpdated = now()
|
||||
WHERE
|
||||
Nat_UnitID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_unit 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_regional->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_regional);
|
||||
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_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchregionalbyname(){
|
||||
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_regional->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_regional);
|
||||
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_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
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_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
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_regional->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_regional);
|
||||
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_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
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_regional->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_regional);
|
||||
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_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
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_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
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_regional->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_regional);
|
||||
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_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
// echo $this->db_regional->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_regional);
|
||||
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_regional->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_regional);
|
||||
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_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
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_regional->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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user