Initial import
This commit is contained in:
784
application/controllers/confirm-result/Confirmresult.php
Normal file
784
application/controllers/confirm-result/Confirmresult.php
Normal file
@@ -0,0 +1,784 @@
|
||||
<?php
|
||||
class Confirmresult extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// db wilayah contoh surabaya
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
|
||||
// string database
|
||||
$this->db_str_doctor = 'one_doctor';
|
||||
$this->M_MouM_CompanyID = "1235";
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "request upload";
|
||||
}
|
||||
|
||||
// search v1 tanpa proteksi lunas dan ini yang lama
|
||||
public function search_v1()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
// if (isset($prm['search'])) {
|
||||
// $search = trim($prm["search"]);
|
||||
// if ($search != "") {
|
||||
// $search = '%' . $prm['search'] . '%';
|
||||
// }else{
|
||||
// $search = '%%';
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$where = " T_OrderHeaderIsActive = 'Y' ";
|
||||
|
||||
$startdate = $prm['startdate'];
|
||||
$enddate = $prm['enddate'];
|
||||
|
||||
$filter_date = " AND DATE(T_OrderHeaderDate) BETWEEN '{$startdate}' AND '{$enddate}'";
|
||||
if ($startdate != '' && $enddate != '') {
|
||||
$where = " T_OrderHeaderIsActive = 'Y' $filter_date ";
|
||||
}
|
||||
|
||||
if ($search != '')
|
||||
$where .= " AND ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' )";
|
||||
|
||||
|
||||
$sortBy = $prm['sortBy'];
|
||||
// $sortStatus = $prm['sortStatus'];
|
||||
$q_sort = '';
|
||||
$limit = '';
|
||||
if ($sortBy) {
|
||||
$q_sort = "ORDER BY " . $sortBy;
|
||||
}
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "select count(*) as total
|
||||
from (
|
||||
select
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
)
|
||||
as nama_pasien,
|
||||
fn_get_doctor_fullname($this->db_str_doctor.order_fo.OrderFoM_DoctorID) as nama_dokter,
|
||||
M_MouName as nama_mou,
|
||||
T_OrderHeaderTotal as total,
|
||||
if($this->db_str_doctor.request_upload.RequestUploadIsUploaded is NULL,'N',RequestUploadIsUploaded) as RequestIsUploaded
|
||||
from t_orderheader
|
||||
join $this->db_str_doctor.order_fo
|
||||
ON OrderFoT_OrderHeaderID = T_OrderHeaderID
|
||||
AND OrderFoIsActive = 'Y'
|
||||
join $this->db_str_doctor.order_patient
|
||||
ON OrderFoOrderPatientID = OrderPatientID
|
||||
AND OrderPatientIsActive = 'Y'
|
||||
left join $this->db_str_doctor.request_upload
|
||||
ON T_OrderHeaderID = RequestUploadT_OrderHeaderID
|
||||
AND RequestUploadIsActive = 'Y'
|
||||
AND RequestUploadIsUploaded = 'N'
|
||||
join m_mou
|
||||
ON OrderFoM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouM_CompanyID = 1235
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
// $sql_param = array($search);
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
|
||||
$query_filter = $this->db->query($sql_filter);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql_data = "select
|
||||
ifnull(RequestUploadIsUploaded,'x') as RequestUploadIsUploaded,
|
||||
if(RequestUploadLastUpdated is null,'', DATE_FORMAT(RequestUploadLastUpdated,'%d-%m-%Y %H:%i'))
|
||||
as RequestUploadLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
OrderPatientID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
)
|
||||
as nama_pasien,
|
||||
fn_get_doctor_fullname($this->db_str_doctor.order_fo.OrderFoM_DoctorID) as nama_dokter,
|
||||
M_MouName as nama_mou,
|
||||
T_OrderHeaderTotal as total,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join $this->db_str_doctor.order_fo
|
||||
ON OrderFoT_OrderHeaderID = T_OrderHeaderID
|
||||
AND OrderFoIsActive = 'Y'
|
||||
join $this->db_str_doctor.order_patient
|
||||
ON OrderFoOrderPatientID = OrderPatientID
|
||||
AND OrderPatientIsActive = 'Y'
|
||||
left join $this->db_str_doctor.request_upload
|
||||
ON T_OrderHeaderID = RequestUploadT_OrderHeaderID
|
||||
AND RequestUploadIsActive = 'Y'
|
||||
AND RequestUploadIsUploaded = 'N'
|
||||
join m_mou
|
||||
ON OrderFoM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouM_CompanyID = 1235
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db->query($sql_data);
|
||||
//echo $this->db->last_query();
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload select");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
// $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows, 'sql'=> $this->db->last_query());
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// search dibawah ini dengan proteksi lunas
|
||||
// pas di listing ketambahan WHERE
|
||||
// (F_OrderheaderLunas = Y
|
||||
// OR M_MouIsBill = Y)
|
||||
// AND T_OrderHeaderID ada di tabel result_processtooffice
|
||||
// update code tanggal 20-07-2023
|
||||
|
||||
public function search()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
$mouID = $prm["mou_id"];
|
||||
|
||||
// if (isset($prm['search'])) {
|
||||
// $search = trim($prm["search"]);
|
||||
// if ($search != "") {
|
||||
// $search = '%' . $prm['search'] . '%';
|
||||
// }else{
|
||||
// $search = '%%';
|
||||
// }
|
||||
// }
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = " AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
if (isset($prm['mou_id'])) {
|
||||
# code...
|
||||
if (
|
||||
$mouID != "" || $mouID != 0 || $mouID != "0"
|
||||
) {
|
||||
$mouID = $prm['mou_id'];
|
||||
$where_company .= " AND M_MouID = $mouID";
|
||||
}
|
||||
}
|
||||
|
||||
// if (isset($prm['companyid'])) {
|
||||
// $companyid = trim($prm["companyid"]);
|
||||
// // selain all dan kosong
|
||||
// if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
// $companyid = $prm['companyid'];
|
||||
// $where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
// }else{
|
||||
// $where_company = "";
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$where = "";
|
||||
|
||||
$startdate = $prm['startdate'];
|
||||
$enddate = $prm['enddate'];
|
||||
|
||||
$filter_date = " DATE(T_OrderHeaderDate) BETWEEN '{$startdate}' AND '{$enddate}'";
|
||||
if ($startdate != '' && $enddate != '') {
|
||||
$where = "$filter_date ";
|
||||
}
|
||||
|
||||
if ($search != '') {
|
||||
$where .= " AND ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$sortBy = $prm['sortBy'];
|
||||
// $sortStatus = $prm['sortStatus'];
|
||||
$q_sort = '';
|
||||
$limit = '';
|
||||
if ($sortBy) {
|
||||
$q_sort = "ORDER BY " . $sortBy;
|
||||
}
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "select count(*) as total
|
||||
from (
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db->query($sql_filter);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql_data = "
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db->query($sql_data);
|
||||
//echo $this->db->last_query();
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
// $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows, 'sql'=> $this->db->last_query());
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses insert log
|
||||
public function proses_insert_one_result_log($OneResultConfirmStatus, $OneResultLogOneResultConfirmID)
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql_insert = "INSERT INTO one_result_log(
|
||||
OneResultLogAction,
|
||||
OneResultLogM_UserID,
|
||||
OneResultLogDate,
|
||||
OneResultLogOneResultConfirmID
|
||||
) values (
|
||||
?,
|
||||
?,
|
||||
NOW(),
|
||||
?
|
||||
)";
|
||||
|
||||
$qry = $this->db->query(
|
||||
$sql_insert,
|
||||
[
|
||||
$OneResultConfirmStatus,
|
||||
$userID,
|
||||
$OneResultLogOneResultConfirmID
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert one_result_log | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
return $this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses confirm
|
||||
public function process_confirm()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$OneResultConfirmT_OrderHeaderID = $prm['OneResultConfirmT_OrderHeaderID'];
|
||||
|
||||
$sql_insert = "INSERT INTO one_result_confirm(
|
||||
OneResultConfirmT_OrderHeaderID,
|
||||
OneResultConfirmStatus,
|
||||
OneResultConfirmM_UserID,
|
||||
OneResultConfirmCreated
|
||||
) values (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
|
||||
$qry = $this->db->query(
|
||||
$sql_insert,
|
||||
[
|
||||
$OneResultConfirmT_OrderHeaderID,
|
||||
"C",
|
||||
$userID
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert one_result_confirm | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$OneResultLogOneResultConfirmID = $this->db->insert_id();
|
||||
|
||||
// Confirmed
|
||||
$OneResultConfirmStatus = "C";
|
||||
$this->proses_insert_one_result_log($OneResultConfirmStatus, $OneResultLogOneResultConfirmID);
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
// $result = array(
|
||||
// "total" => 1 ,
|
||||
// "records" => $prm
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses reupload
|
||||
public function process_reupload()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$OneResultConfirmID = $prm['OneResultConfirmID'];
|
||||
|
||||
$sql_update = "UPDATE one_result_confirm
|
||||
SET
|
||||
OneResultConfirmStatus = ?,
|
||||
OneResultConfirmRetry = ?,
|
||||
OneResultConfirmLastUpdated = NOW()
|
||||
WHERE OneResultConfirmID = ?";
|
||||
|
||||
$qry = $this->db->query(
|
||||
$sql_update,
|
||||
[
|
||||
"R",
|
||||
"0",
|
||||
$OneResultConfirmID,
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update one_result_confirm | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Confirmed
|
||||
$OneResultConfirmStatus = "R";
|
||||
$this->proses_insert_one_result_log($OneResultConfirmStatus, $OneResultConfirmID);
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
// $result = array(
|
||||
// "total" => 1 ,
|
||||
// "records" => $prm
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// autocomplete M_CompanyID
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
|
||||
$sql = "Select M_CompanyID, M_CompanyName
|
||||
from m_company
|
||||
where M_CompanyName like ?
|
||||
and M_CompanyIsActive = 'Y'
|
||||
limit 0,30";
|
||||
$query = $this->db->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("", $this->db);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
$result = array("data" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
public function search_mou()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
$companyID = $prm["company_id"];
|
||||
|
||||
$sql = "SELECT
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouM_CompanyID
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = ?
|
||||
AND M_MouName LIKE ?
|
||||
AND M_MouIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, array($companyID, $qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("", $this->db);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_MouID" => 0, "M_MouName" => "Semua", "M_MouM_CompanyID" => 0);
|
||||
$result = array("data" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user