Initial import

This commit is contained in:
sas.fajri
2026-04-27 10:26:26 +07:00
commit bf9b9097ee
2388 changed files with 3002242 additions and 0 deletions

View File

@@ -0,0 +1,213 @@
<?php
class AntrianCounterDedicated extends MY_Controller
{
var $db_antrione;
var $load;
function __construct()
{
parent::__construct();
$this->db_antrione = $this->load->database("antrione", true);
}
function index()
{
echo "Api: Training Playground";
}
function list_location()
{
try {
$sql = "SELECT * FROM location WHERE locationIsActive = 'Y'";
$qry = $this->db_antrione->query($sql);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$data = $qry->result_array();
$result = array(
"records" => $data,
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function list_counter($branchID)
{
try {
// $prm = $this->sys_input;
// $locationID = array();
// if (isset($prm['locationID'])) {
// $locationID = trim($prm["locationID"]);
// }
$sql = "SELECT counter.* , locationID, locationName,
fn_get_serviceID(counterID,counterIsDedicated) as serviceID
FROM counter
JOIN location ON counterLocationID = locationID
AND locationIsActive = 'Y'
WHERE counterIsActive = 'Y'
AND counterBranchID = ?;
";
// $sql = "SELECT *
// FROM counter
// WHERE counterIsActive = 'Y'
// AND counterLocationID = ?";
$qry = $this->db_antrione->query($sql, [$branchID]);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$data = $qry->result_array();
$result = array(
"records" => $data,
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function get_antrian()
{
try {
$prm = $this->sys_input;
$arrCounter = array();
if (isset($prm['arr_counter'])) {
array_push($prm['arr_counter'], 0);
$arrCounter = implode(",", $prm["arr_counter"]);
}
$branchID = $prm["branchID"];
$sqlNotServed = "SELECT queueID,
statusID, IFNULL(queueNumber,'') as queueNumber,
IFNULL(queueSkipDate, 'NEW') as skipQueue,
( CASE
WHEN statusID = 1 THEN 1
END ) as order_status
FROM queue
JOIN service
ON serviceID = queueServiceID
AND serviceIsActive = 'Y'
AND serviceIsConsultDoctor = 'N'
AND queueBranchID = {$branchID}
JOIN status
ON statusID = queueStatusID
WHERE queueIsActive = 'Y'
AND statusID IN (1)
AND queueLocationID IN (SELECT GROUP_CONCAT(counterLocationID) FROM counter WHERE counterID IN ($arrCounter))
AND queueCounterID IN ($arrCounter)
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
ORDER BY IFNULL(queueSkipDate, queueCreated)";
$qryNotServed = $this->db_antrione->query($sqlNotServed, []);
$last_qry_not = $this->db_antrione->last_query();
if (!$qryNotServed) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry_not
);
$this->sys_error_db($error);
exit;
}
$notServed = $qryNotServed->result_array();
$sqlCall = "SELECT queueID,
statusID, IFNULL(queueNumber,'') as queueNumber,
queueCounterID,
counterCode,
counterID,
( CASE
WHEN statusID = 2 THEN 1
WHEN statusID = 5 THEN 2
END ) as order_status
FROM queue
JOIN service
ON serviceID = queueServiceID
AND serviceIsActive = 'Y'
AND serviceIsConsultDoctor = 'N'
AND queueBranchID = {$branchID}
JOIN status
ON statusID = queueStatusID
JOIN counter ON queueCounterID = counterID
WHERE queueIsActive = 'Y'
AND statusID IN (2, 5)
AND queueCounterID IN ($arrCounter)
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
ORDER BY order_status, queueCreated asc";
$qryCall = $this->db_antrione->query($sqlCall, []);
$last_qry_served = $this->db_antrione->last_query();
if (!$qryCall) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry_served
);
$this->sys_error_db($error);
exit;
}
$call = $qryCall->result_array();
$sqlServed = "SELECT queueID,
statusID, IFNULL(queueNumber,'') as queueNumber,
queueCounterID,
counterCode,
counterID,
( CASE
WHEN statusID = 3 THEN 1
END ) as order_status
FROM queue
JOIN service
ON serviceID = queueServiceID
AND serviceIsActive = 'Y'
AND serviceIsConsultDoctor = 'N'
AND queueBranchID = {$branchID}
JOIN status
ON statusID = queueStatusID
JOIN counter ON queueCounterID = counterID
WHERE queueIsActive = 'Y'
AND statusID IN (3)
AND queueCounterID IN ($arrCounter)
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
ORDER BY order_status, queueCreated asc";
$qryServed = $this->db_antrione->query($sqlServed, []);
$last_qry_call = $this->db_antrione->last_query();
if (!$qryServed) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry_call
);
$this->sys_error_db($error);
exit;
}
$served = $qryServed->result_array();
$data = [];
$data["served"] = $served;
$data['not_served'] = $notServed;
$data['call'] = $call;
$data['qry_call'] = $last_qry_call;
$data['qry_not_served'] = $last_qry_not;
$data['qry_serve'] = $last_qry_served;
$result = array(
$data
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}

View File

@@ -0,0 +1,243 @@
<?php
class Layanandokter extends MY_Controller
{
var $db_antrione;
var $load;
function __construct()
{
parent::__construct();
$this->db_antrione = $this->load->database("antrione", true);
}
function index()
{
echo ('API SERVICE');
}
function list_layanan_dokter()
{
try {
// if (!$this->isLogin) {
// $this->sys_error("Invalid Token");
// exit;
// }
$prm = $this->sys_input;
$serviceId = "0";
if (isset($prm['serviceId'])) {
// $serviceId = trim(str_replace("[]","",$prm["serviceId"]));
$serviceId = implode(",", $prm['serviceId']);
}
// $serviceIdfix = "1,15";
// belum dilayani
$sql_belum_dilayani = "SELECT queueID,
statusID,
IFNULL(queueNumber,'') as queueNumber,
IFNULL(serviceDoctorName,'') as serviceDoctorName,
CONCAT(queueNumber,'-',serviceDoctorName) as antrian_selanjutnya,
( CASE
WHEN statusID = 1 THEN 1
END ) as order_status
FROM queue
JOIN service
ON serviceID = queueServiceID
AND serviceIsActive = 'Y'
JOIN status
ON statusID = queueStatusID
WHERE queueIsActive = 'Y'
AND statusID IN (1)
AND serviceIsConsultDoctor = 'Y'
AND serviceId IN ($serviceId)
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
ORDER BY IFNULL(queueSkipDate, queueCreated)";
$qry_belum_dilayani = $this->db_antrione->query($sql_belum_dilayani);
$last_qry_belum_dilayani = $this->db_antrione->last_query();
if (!$qry_belum_dilayani) {
// $error = array(
// "message" => $this->db_antrione->error()["message"],
// "sql" => $last_qry
// );
// $this->sys_error_db($error);
// exit;
$this->db_antrione->trans_rollback();
echo json_encode(
array("status" => "ERR", "message" => $last_qry_belum_dilayani)
);
exit;
}
$belum_dilayani = $qry_belum_dilayani->result_array();
$arr_serviceName = [];
$result = [];
foreach ($belum_dilayani as $key => $val) {
$serviceName = $val['serviceDoctorName'];
if (in_array($serviceName, $arr_serviceName)) {
continue;
}
$result[] = $val;
$arr_serviceName[] = $serviceName;
}
$belum_dilayani = $result;
$sql_call = "SELECT queueID,
statusID,
queueServiceID as serviceID,
IFNULL(queueNumber,'') as queueNumber,
IFNULL(serviceDoctorName,'') as serviceDoctorName,
CONCAT(queueNumber,'-',serviceDoctorName) as antrian_selanjutnya,
( CASE
WHEN statusID = 2 THEN 1
WHEN statusID = 5 THEN 3
END ) as order_status
FROM queue
JOIN service
ON serviceID = queueServiceID
AND serviceIsActive = 'Y'
JOIN status
ON statusID = queueStatusID
WHERE queueIsActive = 'Y'
AND statusID IN (2,5)
AND serviceIsConsultDoctor = 'Y'
AND serviceId IN ($serviceId)
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
ORDER BY order_status, queueCreated asc";
$qry_call = $this->db_antrione->query($sql_call);
$last_qry_call = $this->db_antrione->last_query();
if (!$qry_call) {
$this->db_antrione->trans_rollback();
echo json_encode(
array("status" => "ERR", "message" => $last_qry_call)
);
exit;
}
$call = $qry_call->result_array();
$arr_serviceName = [];
$result = [];
foreach ($call as $key => $val) {
$serviceName = $val['serviceDoctorName'];
if (in_array($serviceName, $arr_serviceName)) {
continue;
}
$result[] = $val;
$arr_serviceName[] = $serviceName;
}
$call = $result;
// sedang dilayani
$sql_sedang_dilayani = "SELECT queueID,
queueServiceID as serviceID,
IFNULL(queueNumber,'') as queueNumber,
IFNULL(serviceDoctorName,'') as serviceDoctorName,
CONCAT(queueNumber,'-',serviceDoctorName) as antrian_selanjutnya,
( CASE
WHEN statusID = 3 THEN 1
END ) as order_status
FROM queue
JOIN service
ON serviceID = queueServiceID
AND serviceIsActive = 'Y'
JOIN status
ON statusID = queueStatusID
WHERE queueIsActive = 'Y'
AND statusID IN (3)
AND serviceIsConsultDoctor = 'Y'
AND serviceId IN ($serviceId)
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
ORDER BY order_status, queueCreated asc";
$qry_sedang_dilayani = $this->db_antrione->query($sql_sedang_dilayani);
$last_qry_sedang_dilayani = $this->db_antrione->last_query();
if (!$qry_sedang_dilayani) {
// $error = array(
// "message" => $this->db_antrione->error()["message"],
// "sql" => $last_qry
// );
// $this->sys_error_db($error);
// exit;
$this->db_antrione->trans_rollback();
echo json_encode(
array("status" => "ERR", "message" => $last_qry_sedang_dilayani)
);
exit;
}
$sedang_dilayani = $qry_sedang_dilayani->result_array();
$data = [];
$data['call'] = $call;
$data['belumDilayani'] = $belum_dilayani;
$data['sedangDilayani'] = $sedang_dilayani;
$result = array(
$data
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function list_service()
{
try {
$sql = "SELECT * FROM service WHERE serviceIsActive = 'Y'
and serviceIsConsultDoctor = 'Y'";
$qry = $this->db_antrione->query($sql, []);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$data = $qry->result_array();
$result = array(
"records" => $data,
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function list_service_not_consult()
{
try {
$sql = "SELECT * FROM service
WHERE serviceIsActive = 'Y'";
$qry = $this->db_antrione->query($sql, []);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$data = $qry->result_array();
$result = array(
"records" => $data,
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}

View File

@@ -0,0 +1,252 @@
<?php
class Location extends MY_Controller
{
var $db_antrione;
function __construct()
{
parent::__construct();
$this->db_antrione = $this->load->database("antrione", true);
}
function index()
{
$cek = $this->db_antrione->query("select database() as current_db")->result();
// echo $this->db->last_query();
print_r($cek);
}
function save()
{
try{
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$this->db_antrione->trans_begin();
$prm = $this->sys_input;
$userid = $this->sys_user['M_UserID'];
$code = "";
if (isset($prm['code'])) {
$code = trim($prm["code"]);
}
$name = "";
if (isset($prm['name'])) {
$name = trim($prm["name"]);
}
$sql_data = "INSERT INTO location(
locationCode,
locationName,
locationUserID,
locationCreated,
locationLastUpdated)
VALUES (?, ?, ?, NOW(), NOW())";
$qry_data = $this->db_antrione->query($sql_data, [$code, $name, $userid]);
$last_qry = $this->db_antrione->last_query();
echo $last_qry;
// if(!$qry_data) {
// $this->db_antrione->trans_rollback();
// $error = array(
// "message" => $this->db_antrione->error()["message"],
// "sql" => $last_qry
// );
// $this->sys_error_db($error, $this->db_antrione);
// exit;
// }
// $this->db_antrione->trans_commit();
// $result = array(
// "affected_rows" => $this->db_antrione->affected_rows(),
// "inserted_id" => $this->db_antrione->insert_id()
// );
// $this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function search()
{
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$search = "";
if(isset($prm["search"])) {
$search = trim($prm["search"]);
if ($search != ""){
$search = "%" . $prm["search"] . "%";
}else{
$search = "%%";
}
}
$sortBy = $prm["sortBy"];
$sortStatus = $prm["sortStatus"];
if($sortBy){
$q_sort = "ORDER BY ".$sortBy." ".$sortStatus;
}
$number_offset = 0;
$number_limit = 10;
if($prm["current_page"] > 0) {
$number_offset = ($prm["current_page"] - 1) * $number_limit;
}
$sql_filter = "SELECT count(DISTINCT locationID) as total
FROM location
WHERE locationName like ? AND locationIsActive = 'Y'";
$qry_filter = $this->db_antrione->query($sql_filter, [$search]);
// $last_qry = $this->db_antrione->last_query();
// print_r($last_qry);
$tot_count = 0;
$tot_page = 0;
if($qry_filter) {
$tot_count = $qry_filter->result_array()[0]["total"];
$tot_page = ceil($tot_count/$number_limit);
}else{
$this->sys_error_db("location select count", $this->db_antrione);
exit;
}
$sql_data = "SELECT DISTINCT locationID as id,
locationName, locationIsActive
FROM location
WHERE locationName like ? AND locationIsActive = 'Y'
$q_sort
limit ? offset ?";
$qry_data = $this->db_antrione->query($sql_data, [$search, $number_limit, $number_offset]);
if($qry_data) {
$rows = $qry_data->result_array();
}else{
$this->sys_error_db("location select", $this->db_antrione);
exit;
}
$result = array(
"total" => $tot_page,
"total_filter" => $tot_count,
"records" => $rows
);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function edit()
{
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$this->db_antrione->trans_begin();
$prm = $this->sys_input;
$userid = $this->sys_user['M_UserID'];
$name = "";
if (isset($prm['name'])) {
$name = trim($prm["name"]);
}
$id = "";
if (isset($prm['id'])) {
if (is_numeric($prm["id"])){
$id = trim($prm["id"]);
}
}
$sql = "UPDATE location
SET locationName = ?,
locationUserID = ?,
locationLastUpdated = NOW()
WHERE locationID = ?";
$qry = $this->db_antrione->query($sql, [$name, $userid, $id]);
$last_qry = $this->db_antrione->last_query();
// print_r($last_qry);
if(!$qry) {
$this->db_antrione->trans_rollback();
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error, $this->db_antrione);
exit;
}
$this->db_antrione->trans_commit();
$result = array(
"total" => 1,
"affected_rows" => $this->db_antrione->affected_rows()
);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function delete()
{
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$this->db_antrione->trans_begin();
$prm = $this->sys_input;
$userid = $this->sys_user['M_UserID'];
$id = "";
if(isset($prm['id'])) {
if(is_numeric($prm["id"])) {
$id = trim($prm["id"]);
}
}
$sql = "UPDATE location
SET locationIsActive = 'N',
locationUserID = ?,
locationLastUpdated = NOW()
WHERE locationID = ?";
$qry = $this->db_antrione->query($sql, [$userid, $id]);
$last_qry = $this->db_antrione->last_query();
if(!$qry){
$this->db_antrione->trans_rollback();
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error, $this->db_antrione);
exit;
}
// print_r($last_qry);
$this->db_antrione->trans_commit();
$result = array(
"affected_rows" => $this->db_antrione->affected_rows()
);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}
?>

View File

@@ -0,0 +1,131 @@
<?php
class Nonlab extends MY_Controller
{
function get_call($station_id=NULL,$trx_date=NULL,$status=NULL) {
$this->db_onedev = $this->load->database("onedev", true);
$sql = " SELECT CONCAT(IFNULL(M_TitleName,''),' ',IFNULL(M_PatientPrefix,''),M_PatientName,IFNULL(M_PatientSuffix,'')) as patient_name,
T_SamplingQueueLastStatusID as trx_id,
T_SampleStationName as sample_station,
T_OrderHeaderLabNumber as nolab,
T_OrderHeaderLabNumberExt as nolab_ext
FROM t_sampling_queue_last_status
JOIN t_orderheader ON T_OrderHeaderID = T_SamplingQueueLastStatusT_OrderHeaderID
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
JOIN t_samplestation ON T_SamplingQueueLastStatusT_SampleStationID = T_SampleStationID AND
T_SampleStationIsActive = 'Y'
WHERE
T_SamplingQueueLastStatusT_SampleStationID = ? AND
T_SamplingQueueLastStatusT_SamplingQueueStatusID = ? AND
DATE(T_SamplingQueueLastStatusLastUpdated) = ? AND
T_SamplingQueueLastStatusIsActive = 'Y'";
$query = $this->db_onedev->query($sql,array($station_id,$status,$trx_date));
if ($query)
{
$row = $query->result_array();
$s_data = $row;
$this->sys_ok($s_data);
exit;
}
//echo $this->db_onedev->last_query();
$this->sys_error_db("NOT FOUND CALL", $this->db_onedev);
}
function get_data($station_id=NULL,$trx_date=NULL) {
$this->db_onedev = $this->load->database("onedev", true);
$sql = "SELECT T_OrderHeaderID as order_id,
T_OrderHeaderLabNumber as nolab,
T_OrderHeaderLabNumberExt as nolab_ext,
CONCAT(IFNULL(M_TitleName,''),' ',IFNULL(M_PatientPrefix,''),M_PatientName,IFNULL(M_PatientSuffix,'')) as patient_name,
IFNULL(T_SamplingQueueStatusName,'new') as status,
IFNULL(T_SamplingQueueLastStatusT_SamplingQueueStatusID,0) as last_status_id
FROM t_orderheader
JOIN t_orderheaderaddon ON T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
LEFT JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = ?
JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
T_SamplingSoT_TestID = T_TestID AND
T_SamplingSoT_SampleStationID = T_SampleStationID AND
T_SamplingSoIsActive = 'Y'
LEFT JOIN t_sampling_queue_last_status ON T_OrderHeaderID = T_SamplingQueueLastStatusT_OrderHeaderID
LEFT JOIN t_sampling_queue_status ON T_SamplingQueueLastStatusT_SamplingQueueStatusID = T_SamplingQueueStatusID AND
T_SamplingCallStatusIsActive = 'Y'
WHERE
T_OrderHeaderIsActive = 'Y' AND
( DATE(T_OrderHeaderAddonIsComingDate) = ? OR DATE(T_OrderHeaderDate) = ? )
GROUP BY T_OrderHeaderID
HAVING fn_fo_get_laststatus(T_OrderHeaderID) IN (3,5) AND last_status_id NOT IN (1,3,5)
ORDER BY T_OrderHeaderIsCito DESC, T_OrderHeaderID ASC";
//echo $sql;
$query = $this->db_onedev->query($sql,array($station_id,$trx_date,$trx_date));
if ($query)
{
$row = $query->result_array();
$s_data = $row;
$this->sys_ok($s_data);
exit;
}
//echo $this->db_onedev->last_query();
$this->sys_error_db("NOT FOUND CALL", $this->db_onedev);
}
function get_station(){
$this->db_onedev = $this->load->database("onedev", true);
$sql = " SELECT T_SampleStationID as id,
T_SampleStationCode as code,
T_SampleStationName as name,
T_SampleStationIsNonLab as is_nonlab
FROM t_samplestation
WHERE
T_SampleStationIsActive = 'Y'";
$query = $this->db_onedev->query($sql);
if ($query)
{
$row = $query->result_array();
$s_data = $row;
$this->sys_ok($s_data);
exit;
}
$this->sys_error_db("NOT FOUND CALL", $this->db_onedev);
}
function get_images(){
$dir = "/home/one/project/one/one-media/one-antrian/nonlab/";
$files = scandir($dir);
$results = [];
foreach ($files as $key => $value) {
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
if (!is_dir($path)) {
$results[] = $_SERVER['SERVER_NAME']."/one-media/one-antrian/nonlab/".basename($path, ".pdf");
} else if ($value != "." && $value != "..") {
getDirContents($path, $results);
$results[] = $_SERVER['SERVER_NAME']."/one-media/one-antrian/nonlab/".basename($path, ".pdf");
}
}
$this->sys_ok($results);
exit;
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,349 @@
<?php
class Service extends MY_Controller
{
var $db_antrione;
var $load;
function __construct()
{
parent::__construct();
$this->db_antrione = $this->load->database("antrione", true);
}
function index()
{
echo ('API SERVICE');
}
function search()
{
try {
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
// print_r($prm);
// exit;
$search = "%%";
if (isset($prm['search'])) {
$search = trim($prm["search"]);
$search = '%' . $prm['search'] . '%';
}
$order_by = "serviceCode";
if (isset($prm['order_by'])) {
$order_by = trim($prm["order_by"]);
}
$order = "asc";
if (isset($prm['order'])) {
$order = trim($prm["order"]);
}
$sort = "order by " . $order_by . " " . $order;
$page = $prm["page"];
$ROW_PER_PAGE = 10;
$start_offset = 0;
if (isset($prm["page"])) {
if (
is_numeric($prm["page"]) && $prm["page"] > 0
) {
$start_offset = ($page - 1) * $ROW_PER_PAGE;
}
}
$total_count = 0;
$total_page = 0;
$sqlCount = "SELECT COUNT(*) AS total FROM service
WHERE serviceIsActive = 'Y'
AND ( serviceCode LIKE ? OR serviceName LIKE ?)
ORDER BY serviceCode";
$qryCount = $this->db_antrione->query($sqlCount, [$search, $search]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCount) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$sql = "SELECT * FROM service
WHERE serviceIsActive = 'Y'
AND ( serviceCode LIKE ? OR serviceName LIKE ?)
$sort
LIMIT 10 OFFSET ?";
$qry = $this->db_antrione->query($sql, [$search, $search, $start_offset]);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$total = $qryCount->row_array();
$total_count = $total['total'];
$total_page = ceil($total_count / $ROW_PER_PAGE);
$data = $qry->result_array();
$result = array(
"total_filter" => $total_count,
"total" => $total_page,
"records" => $data,
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function add()
{
try {
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$code = "";
if (isset($prm['code'])) {
$code = trim($prm["code"]);
}
$name = "";
if (isset($prm['name'])) {
$name = trim($prm["name"]);
}
$priority = "";
if (isset($prm['priority'])) {
$priority = trim($prm["priority"]);
}
$foOrder = "";
if (isset($prm['foOrder'])) {
$foOrder = trim($prm["foOrder"]);
}
$isConsultDoctor = "";
if (isset($prm['isConsultDoctor'])) {
$isConsultDoctor = trim($prm["isConsultDoctor"]);
}
$nameDoctor = "";
if (isset($prm['nameDoctor'])) {
$nameDoctor = trim($prm["nameDoctor"]);
}
if ($isConsultDoctor == 'Y') {
if ($code == "" || $name == "" || $priority == "" || $foOrder == "" || $nameDoctor == "") {
$this->sys_error("code, name, priority, fo order, nama dokter is mandatory");
exit;
}
} else {
if ($code == "" || $name == "" || $priority == "" || $foOrder == "") {
$this->sys_error("code, name, priority, fo order is mandatory");
exit;
}
}
$this->db_antrione->trans_begin();
$sql = "INSERT INTO service
(serviceCode,
serviceName,
servicePriority,
serviceIsFoOrder,
serviceIsConsultDoctor,
serviceDoctorName
)
VALUES(?, ?, ?, ?, ?, ?)";
$qry = $this->db_antrione->query($sql, [$code, $name, $priority, $foOrder, $isConsultDoctor, $nameDoctor]);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$insertedId = $this->db_antrione->insert_id();
$sqlNumbering = "INSERT INTO numbering
(numberingServiceID,
numberingPrefix,
numberingDigit,
numberingReset)
VALUES(? ,? , 4, 'D')";
$qryNumbering = $this->db_antrione->query($sqlNumbering, [$insertedId, $insertedId]);
if (!$qryNumbering) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$this->db_antrione->trans_complete();
$result = array(
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function update()
{
try {
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$code = "";
if (isset($prm['code'])) {
$code = trim($prm["code"]);
}
$id = "";
if (isset($prm['id'])) {
$id = trim($prm["id"]);
}
$name = "";
if (isset($prm['name'])) {
$name = trim($prm["name"]);
}
$priority = "";
if (isset($prm['priority'])) {
$priority = trim($prm["priority"]);
}
$foOrder = "";
if (isset($prm['foOrder'])) {
$foOrder = trim($prm["foOrder"]);
}
$isConsultDoctor = "";
if (isset($prm['isConsultDoctor'])) {
$isConsultDoctor = trim($prm["isConsultDoctor"]);
}
$nameDoctor = "";
if (isset($prm['nameDoctor'])) {
$nameDoctor = trim($prm["nameDoctor"]);
}
if ($isConsultDoctor == 'Y') {
if ($code == "" || $name == "" || $priority == "" || $foOrder == "" || $nameDoctor == "") {
$this->sys_error("code, name, priority, fo order, nama dokter is mandatory");
exit;
}
} else {
if ($code == "" || $name == "" || $priority == "" || $foOrder == "") {
$this->sys_error("code, name, priority, fo order is mandatory");
exit;
}
}
$sql = "UPDATE service SET serviceCode = ?,
serviceName = ?,
servicePriority = ?,
serviceIsFoOrder = ?,
serviceIsConsultDoctor = ?,
serviceDoctorName = ?
WHERE serviceID = ?";
$qry = $this->db_antrione->query($sql, [$code, $name, $priority, $foOrder, $isConsultDoctor, $nameDoctor, $id]);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$result = array(
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function delete()
{
try {
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = "";
if (isset($prm['id'])) {
$id = trim($prm["id"]);
}
$this->db_antrione->trans_begin();
$sql = "UPDATE service SET
serviceIsActive = 'N'
WHERE serviceID = ?";
$qry = $this->db_antrione->query($sql, [intval($id)]);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$sqlNumbering = "UPDATE numbering SET
numberingIsActive = 'N'
WHERE numberingServiceID = ?";
$qryNumbering = $this->db_antrione->query($sqlNumbering, [intval($id)]);
$last_qry = $this->db_antrione->last_query();
if (!$qryNumbering) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$this->db_antrione->trans_complete();
$result = array(
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function listService()
{
try {
$sql = "SELECT * FROM service WHERE serviceIsActive = 'Y'";
$qry = $this->db_antrione->query($sql, []);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$data = $qry->result_array();
$result = array(
"records" => $data,
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}

View File

@@ -0,0 +1,319 @@
<?php
class Ticket extends MY_Controller
{
var $db_antrione;
var $load;
var $IP_SOCKET_IO;
function __construct()
{
parent::__construct();
$this->db_antrione = $this->load->database("antrione", true);
$this->IP_SOCKET_IO = "127.0.0.1";
// $this->IP_SOCKET_IO = "devone.aplikasi.web.id";
}
function index()
{
echo ('API GET ANTRIAN NUMBER');
}
function getAntrian()
{
try {
$prm = $this->sys_input;
$serviceId = '';
if (isset($prm['service_id'])) {
$serviceId = trim($prm["service_id"]);
}
$boothId = '';
if (isset($prm['booth_id'])) {
$boothId = trim($prm["booth_id"]);
}
$branchID = '';
if (isset($prm['branch_id'])) {
$branchID = trim($prm["branch_id"]);
}
if ($serviceId == '' || $boothId == '' || $branchID == '') {
$this->sys_error_db("service id, booth id, branch id are mandatory");
exit;
}
$this->db_antrione->trans_begin();
$sqlCek = "SELECT * FROM service
WHERE serviceIsActive = 'Y'
AND serviceID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$serviceCek = $qryCek->result_array();
// print_r($serviceCek);
// exit;
if (count($serviceCek) == 0) {
$error = array(
"message" => "service tidak ada ",
);
$this->sys_error_db($error);
$this->db_antrione->trans_rollback();
exit;
}
$sqlGetLocation = "SELECT *, SUM(fn_get_max_queue(counterID, counterBranchID)) as maxQueue FROM counter
LEFT JOIN counter_service ON counterID = counterServiceCounterID
AND counterServiceIsActive = 'Y'
JOIN location ON counterLocationID = locationID
AND locationIsActive = 'Y'
WHERE (counterIsDedicated = 'N' OR counterServiceServiceID = ?)
AND counterBranchID = ?
AND counterIsActive = 'Y'
GROUP BY locationID
ORDER BY locationID";
// $sqlGetLocation = "SELECT *, SUM(counterMaxQueue) as maxQueue FROM
// counter_service
// JOIN counter ON counterServiceCounterID = counterID
// AND counterIsActive = 'Y'
// JOIN location ON counterLocationID = locationID
// AND locationIsActive = 'Y'
// WHERE counterServiceServiceID = ?
// AND counterServiceIsActive = 'Y'
// GROUP BY locationID
// ORDER BY locationID";
$qrygetLocation = $this->db_antrione->query($sqlGetLocation, [$serviceId, $branchID]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$location = $qrygetLocation->result_array();
// print_r($location);
// exit;
$ticketMsg = '';
$locationIdFinal = 0;
$countLocation = count($location);
$masukMana = "";
if ($countLocation == 0) {
$locationIdFinal = 1;
$ticketMsg = "Anda Akan Dilayan Di Front Office";
$masukMana = "TIdak ada counter yang melayani";
}
if ($countLocation == 1) {
$locationId = intval($location[0]['locationID']);
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
WHERE
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND queueIsActive = 'Y'
AND queueStatusID <> 4
AND queueLocationID = ?
AND queueServiceID = ?
AND queueBranchID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId, $branchID]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queue = $qryCek->row_array();
$queueNum = intval($queue['total']);
if ($queueNum < $location[0]["maxQueue"]) {
$locationIdFinal = $location[0]['locationID'];
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $location[0]['locationName'];
$masukMana = "ada 1 counter yang melayani";
} else {
$locationIdFinal = 1;
$ticketMsg = "Anda Akan Dilayan Di Front Office Lantai 1";
$masukMana = "ada 1 counter yang melayani";
}
}
if ($countLocation > 1) {
$locationDedicated = array();
foreach ($location as $value) {
$locationId = intval($value["locationID"]);
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
WHERE
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND queueIsActive = 'Y'
AND queueStatusID <> 4
AND queueLocationID = ?
AND queueServiceID = ?
AND queueBranchID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId, $branchID]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queue = $qryCek->row_array();
$queueNum = intval($queue['total']);
if ($value['counterIsDedicated'] == 'Y' && $queueNum < $value["maxQueue"]) {
$locationDedicated = $value;
break;
}
}
// print_r($locationDedicated);
// exit;
if ($locationDedicated) {
$locationIdFinal = $locationDedicated['locationID'];
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $locationDedicated['locationName'];
} else {
for ($i = 0; $i < $countLocation; $i++) {
$val = $location[$i];
$maxQueue = intval($val["maxQueue"]);
$locationId = intval($val["locationID"]);
$locationName = $val['locationName'];
$isDedicated = $val['counterIsDedicated'];
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
WHERE
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND queueIsActive = 'Y'
AND queueStatusID <> 4
AND queueLocationID = ?
AND queueServiceID = ?
AND queueBranchID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId, $branchID]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queue = $qryCek->row_array();
$queueNum = intval($queue['total']);
if ($countLocation == ($i + 1) && $queueNum >= $maxQueue) {
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $location[0]['locationName'];
$locationIdFinal = $location[0]['locationID'];
$masukMana = "countLocation == key && queueNum >= maxQueue";
break;
}
if ($queueNum < $maxQueue) {
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $locationName;
$masukMana = "queueNum < maxQueue";
$locationIdFinal = $locationId;
break;
}
if ($queueNum >= $maxQueue) {
$masukMana = "queueNum >= maxQueue";
continue;
}
}
}
}
// print_r([$masukMana, $queueNum, $location, $queue, $ticketMsg]);
// exit;
$sqlGetNumber = "SELECT fn_get_numbering(?, ?) AS number";
$qryGetNumber = $this->db_antrione->query($sqlGetNumber, [$serviceId, $branchID]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$number = $qryGetNumber->row_array();
$numberQueue = $number['number'];
$uniqueCode = bin2hex(random_bytes(13)); // Generate a unique code of 25 characters
$sqlInsert = "INSERT INTO queue
(queueNumber,
queueStatusID,
queueServiceID,
queueLocationID,
queueTicketBoothID,
queueBranchID,
queueCode)
VALUES
(?, 1, ?, ?, ?, ?, ?)";
$qryInsert = $this->db_antrione->query($sqlInsert, [$numberQueue, $serviceId, $locationIdFinal, $boothId, $branchID, $uniqueCode]);
$last_qry = $this->db_antrione->last_query();
if (!$qryInsert) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queueId = $this->db_antrione->insert_id();
$sqlLog = "INSERT INTO queuelog
(queueLogDate,
queueLogStatusID,
queueLogCounterID)
VALUES(NOW(),1,0)";
$qryLog = $this->db_antrione->query($sqlLog);
$last_qry = $this->db_antrione->last_query();
if (!$qryLog) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$logId = $this->db_antrione->insert_id();
$sqlUpdate = "UPDATE queue SET
queueQueueLogID = ?
WHERE queueID = ?";
$qryUpdate = $this->db_antrione->query($sqlUpdate, [$logId, $queueId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryUpdate) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$logId = $this->db_antrione->insert_id();
$this->db_antrione->trans_complete();
$result = array(
"number" => $numberQueue,
"location" => $ticketMsg,
"bagian" => $masukMana,
"code" => $uniqueCode,
"maxQueuePerLantai" => $location
);
file_get_contents("http://" . $this->IP_SOCKET_IO . ":9088/broadcast/printed.fo.{$serviceId}.{$branchID}");
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}

View File

@@ -0,0 +1,302 @@
<?php
class Ticketrspad extends MY_Controller
{
var $db_antrione;
var $load;
function __construct()
{
parent::__construct();
$this->db_antrione = $this->load->database("antrione", true);
$this->IP_SOCKET_IO = "devone.aplikasi.web.id";
}
function index()
{
echo ('API GET ANTRIAN NUMBER');
}
function getAntrian()
{
try {
$prm = $this->sys_input;
$serviceId = '';
if (isset($prm['service_id'])) {
$serviceId = trim($prm["service_id"]);
}
$boothId = '';
if (isset($prm['booth_id'])) {
$boothId = trim($prm["booth_id"]);
}
if ($serviceId == '' || $boothId == '') {
$this->sys_error_db("service id & booth id is mandatory");
exit;
}
$this->db_antrione->trans_begin();
$sqlCek = "SELECT * FROM service
WHERE serviceIsActive = 'Y'
AND serviceID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$serviceCek = $qryCek->result_array();
if (count($serviceCek) == 0) {
$error = array(
"message" => "service tidak ada ",
);
$this->sys_error_db($error);
$this->db_antrione->trans_rollback();
exit;
}
$sqlGetLocation = "SELECT *, SUM(fn_get_max_queue(counterID)) as maxQueue FROM counter
LEFT JOIN counter_service ON counterID = counterServiceCounterID
AND counterServiceIsActive = 'Y'
JOIN location ON counterLocationID = locationID
AND locationIsActive = 'Y'
WHERE (counterIsDedicated = 'N' OR counterServiceServiceID = ?)
AND counterIsActive = 'Y'
GROUP BY locationID
ORDER BY locationID";
// $sqlGetLocation = "SELECT *, SUM(counterMaxQueue) as maxQueue FROM
// counter_service
// JOIN counter ON counterServiceCounterID = counterID
// AND counterIsActive = 'Y'
// JOIN location ON counterLocationID = locationID
// AND locationIsActive = 'Y'
// WHERE counterServiceServiceID = ?
// AND counterServiceIsActive = 'Y'
// GROUP BY locationID
// ORDER BY locationID";
$qrygetLocation = $this->db_antrione->query($sqlGetLocation, [$serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$location = $qrygetLocation->result_array();
// print_r($location);
// exit;
$ticketMsg = '';
$locationIdFinal = 0;
$countLocation = count($location);
$masukMana = "";
if ($countLocation == 0) {
$locationIdFinal = 1;
$ticketMsg = "Anda Akan Dilayan Di Front Office";
$masukMana = "TIdak ada counter yang melayani";
}
if ($countLocation == 1) {
$locationId = intval($location[0]['locationID']);
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
WHERE
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND queueIsActive = 'Y'
AND queueStatusID <> 4
AND queueLocationID = ?
AND queueServiceID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queue = $qryCek->row_array();
$queueNum = intval($queue['total']);
if ($queueNum < $location[0]["maxQueue"]) {
$locationIdFinal = $location[0]['locationID'];
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $location[0]['locationName'];
$masukMana = "ada 1 counter yang melayani";
} else {
$locationIdFinal = 1;
$ticketMsg = "Anda Akan Dilayan Di Front Office Lantai 1";
$masukMana = "ada 1 counter yang melayani";
}
}
if ($countLocation > 1) {
$locationDedicated = array();
foreach ($location as $value) {
$locationId = intval($value["locationID"]);
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
WHERE
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND queueIsActive = 'Y'
AND queueStatusID <> 4
AND queueLocationID = ?
AND queueServiceID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queue = $qryCek->row_array();
$queueNum = intval($queue['total']);
if ($value['counterIsDedicated'] == 'Y' && $queueNum < $value["maxQueue"]) {
$locationDedicated = $value;
break;
}
}
// print_r($locationDedicated);
// exit;
if ($locationDedicated) {
$locationIdFinal = $locationDedicated['locationID'];
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $locationDedicated['locationName'];
} else {
for ($i = 0; $i < $countLocation; $i++) {
$val = $location[$i];
$maxQueue = intval($val["maxQueue"]);
$locationId = intval($val["locationID"]);
$locationName = $val['locationName'];
$isDedicated = $val['counterIsDedicated'];
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
WHERE
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND queueIsActive = 'Y'
AND queueStatusID <> 4
AND queueLocationID = ?
AND queueServiceID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queue = $qryCek->row_array();
$queueNum = intval($queue['total']);
if ($countLocation == ($i + 1) && $queueNum >= $maxQueue) {
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $location[0]['locationName'];
$locationIdFinal = $location[0]['locationID'];
$masukMana = "countLocation == key && queueNum >= maxQueue";
break;
}
if ($queueNum < $maxQueue) {
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $locationName;
$masukMana = "queueNum < maxQueue";
$locationIdFinal = $locationId;
break;
}
if ($queueNum >= $maxQueue) {
$masukMana = "queueNum >= maxQueue";
continue;
}
}
}
}
// print_r([$masukMana, $queueNum, $location, $queue, $ticketMsg]);
// exit;
$sqlGetNumber = "SELECT fn_get_numbering(?) AS number";
$qryGetNumber = $this->db_antrione->query($sqlGetNumber, [$serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$number = $qryGetNumber->row_array();
$numberQueue = $number['number'];
$sqlInsert = "INSERT INTO queue
(queueNumber,
queueStatusID,
queueServiceID,
queueLocationID,
queueTicketBoothID)
VALUES
(?, 1, ?, ?, ?)";
$qryInsert = $this->db_antrione->query($sqlInsert, [$numberQueue, $serviceId, $locationIdFinal, $boothId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryInsert) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queueId = $this->db_antrione->insert_id();
$sqlLog = "INSERT INTO queuelog
(queueLogDate,
queueLogStatusID,
queueLogCounterID)
VALUES(NOW(),1,0)";
$qryLog = $this->db_antrione->query($sqlLog);
$last_qry = $this->db_antrione->last_query();
if (!$qryLog) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$logId = $this->db_antrione->insert_id();
$sqlUpdate = "UPDATE queue SET
queueQueueLogID = ?
WHERE queueID = ?";
$qryUpdate = $this->db_antrione->query($sqlUpdate, [$logId, $queueId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryUpdate) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$logId = $this->db_antrione->insert_id();
$this->db_antrione->trans_complete();
$result = array(
"number" => $numberQueue,
"location" => $ticketMsg,
"bagian" => $masukMana,
"maxQueuePerLantai" => $location
);
file_get_contents("http://" . $this->IP_SOCKET_IO . ":9099/broadcast/printed.fo.{$serviceId}");
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}