Files
BE_CPONE/application/controllers/homeservice/registrasi/Info.php
2026-04-27 10:26:26 +07:00

151 lines
5.3 KiB
PHP

<?php
class Info extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "CONTROL API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
public function lookupareabyname()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$area = $prm['area'];
$limit = '';
$number_limit = 4;
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
$sql = "SELECT COUNT(*) as total
from hs_area
JOIN m_district ON M_DistrictID = Hs_AreaM_DistrictID
LEFT JOIN m_kelurahan ON M_KelurahanM_DistrictID = M_DistrictID AND M_KelurahanIsActive = 'Y'
where
CONCAT(M_KelurahanName, ' , Kec. ', M_DistrictName) LIKE CONCAT('%','{$area}','%') AND
(Hs_AreaM_KelurahanID = 0 OR(Hs_AreaM_KelurahanID > 0 AND M_KelurahanID = Hs_AreaM_KelurahanID)) AND
Hs_AreaIsActive = '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("hs_area count", $this->db_onedev);
exit;
}
$sql = "select hs_area.*,
M_KelurahanID as id,
CONCAT(M_KelurahanName, ' , Kec. ', M_DistrictName) as name,
FORMAT(Hs_AreaFee,0) as fee
from hs_area
JOIN m_district ON M_DistrictID = Hs_AreaM_DistrictID
LEFT JOIN m_kelurahan ON M_KelurahanM_DistrictID = M_DistrictID AND M_KelurahanIsActive = 'Y'
where
CONCAT(M_KelurahanName, ' , Kec. ', M_DistrictName) LIKE CONCAT('%','{$area}','%') AND
(Hs_AreaM_KelurahanID = 0 OR(Hs_AreaM_KelurahanID > 0 AND M_KelurahanID = Hs_AreaM_KelurahanID)) AND
Hs_AreaIsActive = 'Y'
GROUP BY M_KelurahanID
ORDER BY M_KelurahanName, M_DistrictName 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("hs_area 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 lookupkuota()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$startdate = $prm['startdate'];
$limit = '';
$number_limit = 4;
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
$sql = "SELECT COUNT(*) as total
from hs_schedule
JOIN hs_scheduledetail ON Hs_ScheduleDetailHs_ScheduleID = Hs_ScheduleID AND Hs_ScheduleDetailIsActive = 'Y'
LEFT JOIN m_reg_time ON M_RegTimeID = Hs_ScheduleDetailHs_TimeID
where
Hs_ScheduleIsActive = 'Y' AND Hs_ScheduleM_RegDayID = 1";
$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("hs_schedule count", $this->db_onedev);
exit;
}
$sql = "select hs_schedule.*,
Hs_ScheduleDetailID as id,
M_RegTimeID,
M_RegTimeName,
Hs_ScheduleKuota as kuota
from hs_schedule
JOIN hs_scheduledetail ON Hs_ScheduleDetailHs_ScheduleID = Hs_ScheduleID AND Hs_ScheduleDetailIsActive = 'Y'
LEFT JOIN m_reg_time ON M_RegTimeID = Hs_ScheduleDetailHs_TimeID
where
Hs_ScheduleIsActive = 'Y' AND Hs_ScheduleM_RegDayID = 1
GROUP BY Hs_ScheduleDetailID
ORDER BY M_RegTimeID 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("hs_schedule 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);
}
}
}