2032 lines
72 KiB
PHP
2032 lines
72 KiB
PHP
<?php
|
|
|
|
class Refreceivesample extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "REF RECEIVE SAMPLE API";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
public function lookup()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$deliveryorder = $prm['deliveryorder'];
|
|
$search = $prm['search'];
|
|
$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 incoming_ref
|
|
LEFT JOIN incoming_ref_detail ON incomingRefID = incomingRefDetailIncomingRefID
|
|
JOIN m_branch ON incomingRefM_BranchID = M_BranchID
|
|
where
|
|
incomingRefT_RefDeliveryOrderDate = '{$deliveryorder}' AND
|
|
(incomingRefT_RefDeliveryOrderNumber LIKE CONCAT('%','{$search}','%') OR M_BranchName LIKE CONCAT('%','{$search}','%'))
|
|
GROUP BY incomingRefID) a";
|
|
$sql_param = array($search);
|
|
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
|
$query = $this->db_onedev->query($sql);
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
$tot_page = ceil($tot_count/$number_limit);
|
|
} else {
|
|
$this->sys_error_db("incoming_ref count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT
|
|
incoming_ref.*,
|
|
incomingRefID as id,
|
|
M_BranchID,
|
|
M_BranchName,
|
|
M_BranchAddress,
|
|
M_BranchM_CompanyID,
|
|
M_CompanyName,
|
|
M_BranchM_MouID,
|
|
M_MouName,
|
|
M_BranchM_DoctorID,
|
|
M_DoctorName,
|
|
M_BranchM_DoctorAddressID,
|
|
CONCAT(M_DoctorAddressNote, '' , M_DoctorAddressDescription) as address,
|
|
DATE_FORMAT(incomingRefT_RefDeliveryOrderDate,'%d%m%Y') as startdate,
|
|
DATE_FORMAT(incomingRefT_RefDeliveryOrderDate,'%d-%m-%Y') as incomingRefT_RefDeliveryOrderDatex
|
|
FROM incoming_ref
|
|
LEFT JOIN m_branch ON incomingRefM_BranchID = M_BranchID
|
|
LEFT JOIN m_company ON M_BranchM_CompanyID = M_CompanyID
|
|
LEFT JOIN m_mou ON M_BranchM_MouID = M_MouID
|
|
LEFT JOIN m_doctor ON M_BranchM_DoctorID = M_DoctorID
|
|
LEFT JOIN m_doctoraddress ON M_BranchM_DoctorAddressID = M_DoctorAddressID
|
|
where
|
|
incomingRefT_RefDeliveryOrderDate = '{$deliveryorder}' AND
|
|
(incomingRefT_RefDeliveryOrderNumber LIKE CONCAT('%','{$search}','%') OR M_BranchName LIKE CONCAT('%','{$search}','%'))
|
|
GROUP BY incomingRefID
|
|
ORDER BY incomingRefID DESC";
|
|
// 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("incoming_ref 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 lookupbybarcode()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$deliveryorder = $prm['deliveryorder'];
|
|
$search = $prm['search'];
|
|
$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 incoming_ref
|
|
LEFT JOIN incoming_ref_detail ON incomingRefID = incomingRefDetailIncomingRefID
|
|
JOIN m_branch ON incomingRefM_BranchID = M_BranchID
|
|
where
|
|
incomingRefT_RefDeliveryOrderDate = '{$deliveryorder}' AND
|
|
(incomingRefT_RefDeliveryOrderNumber LIKE CONCAT('%','{$search}','%') OR M_BranchName LIKE CONCAT('%','{$search}','%'))
|
|
GROUP BY incomingRefID) a";
|
|
$sql_param = array($search);
|
|
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
|
$query = $this->db_onedev->query($sql);
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
$tot_page = ceil($tot_count/$number_limit);
|
|
} else {
|
|
$this->sys_error_db("incoming_ref count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT * FROM (SELECT
|
|
incoming_ref.*,
|
|
incomingRefID as id,
|
|
M_BranchID,
|
|
M_BranchName,
|
|
M_BranchAddress,
|
|
M_BranchM_CompanyID,
|
|
M_CompanyName,
|
|
M_BranchM_MouID,
|
|
M_MouName,
|
|
M_BranchM_DoctorID,
|
|
M_DoctorName,
|
|
M_BranchM_DoctorAddressID,
|
|
CONCAT(M_DoctorAddressNote, '' , M_DoctorAddressDescription) as address,
|
|
DATE_FORMAT(incomingRefT_RefDeliveryOrderDate,'%d%m%Y') as startdate,
|
|
DATE_FORMAT(incomingRefT_RefDeliveryOrderDate,'%d-%m-%Y') as incomingRefT_RefDeliveryOrderDatex
|
|
FROM incoming_ref
|
|
LEFT JOIN m_branch ON incomingRefM_BranchID = M_BranchID
|
|
LEFT JOIN m_company ON M_BranchM_CompanyID = M_CompanyID
|
|
LEFT JOIN m_mou ON M_BranchM_MouID = M_MouID
|
|
LEFT JOIN m_doctor ON M_BranchM_DoctorID = M_DoctorID
|
|
LEFT JOIN m_doctoraddress ON M_BranchM_DoctorAddressID = M_DoctorAddressID
|
|
JOIN incoming_ref_detail ON incomingRefID = incomingRefDetailIncomingRefID
|
|
where
|
|
incomingRefT_RefDeliveryOrderDate = '{$deliveryorder}' AND
|
|
LEFT(incomingRefDetailT_BarcodeLabBarcode,12) = '{$search}'
|
|
) a
|
|
GROUP BY incomingRefID
|
|
ORDER BY incomingRefID DESC
|
|
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("incoming_ref select");
|
|
exit;
|
|
}
|
|
|
|
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
function searchworklist(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM t_worklist
|
|
where
|
|
T_WorklistIsActive = 'Y' AND T_WorklistName like ?
|
|
";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_branch count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT *
|
|
FROM t_worklist
|
|
where
|
|
T_WorklistIsActive = 'Y' AND T_WorklistName like ?
|
|
GROUP BY T_WorklistID
|
|
ORDER BY T_WorklistName ASC";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_branch rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchcourier(){
|
|
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_courier
|
|
JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
|
WHERE
|
|
M_StaffName like ?
|
|
AND M_CourierIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_branch count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT *
|
|
FROM m_courier
|
|
JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
|
WHERE
|
|
M_StaffName like ?
|
|
AND M_CourierIsActive = 'Y'
|
|
ORDER BY M_StaffName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_branch rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchbranch(){
|
|
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_branch
|
|
WHERE
|
|
M_BranchName like ?
|
|
AND M_BranchIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_branch count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT *
|
|
FROM m_branch
|
|
LEFT JOIN m_city ON M_BranchM_CityID = M_CityID
|
|
LEFT JOIN m_district ON M_BranchM_DistrictID = M_DistrictID
|
|
LEFT JOIN m_kelurahan ON M_BranchM_KelurahanID = M_KelurahanID
|
|
WHERE
|
|
M_BranchName like ?
|
|
AND M_BranchIsActive = 'Y'
|
|
ORDER BY M_BranchName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_branch rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchdestination(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$tipe = $prm['tipe'];
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
if ($tipe == 'Internal'){
|
|
$sql = "SELECT count(*) as total
|
|
FROM
|
|
(SELECT
|
|
M_BranchID as M_DestinationID,
|
|
M_BranchName as M_DestinationName,
|
|
M_BranchAddress as M_DestinationAddress,
|
|
'' as M_DestinationUp,
|
|
M_CityID,
|
|
M_CityName,
|
|
M_DistrictID,
|
|
M_DistrictName,
|
|
M_KelurahanID,
|
|
M_KelurahanName
|
|
FROM m_branch
|
|
LEFT JOIN m_city ON M_BranchM_CityID = M_CityID
|
|
LEFT JOIN m_district ON M_BranchM_DistrictID = M_DistrictID
|
|
LEFT JOIN m_kelurahan ON M_BranchM_KelurahanID = M_KelurahanID
|
|
WHERE
|
|
M_BranchName like ?
|
|
AND M_BranchIsActive = 'Y'
|
|
ORDER BY M_BranchName ASC )a
|
|
";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_branch count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT
|
|
M_BranchID as M_DestinationID,
|
|
M_BranchName as M_DestinationName,
|
|
M_BranchAddress as M_DestinationAddress,
|
|
'' as M_DestinationUp,
|
|
M_CityID,
|
|
M_CityName,
|
|
M_DistrictID,
|
|
M_DistrictName,
|
|
M_KelurahanID,
|
|
M_KelurahanName
|
|
FROM m_branch
|
|
LEFT JOIN m_city ON M_BranchM_CityID = M_CityID
|
|
LEFT JOIN m_district ON M_BranchM_DistrictID = M_DistrictID
|
|
LEFT JOIN m_kelurahan ON M_BranchM_KelurahanID = M_KelurahanID
|
|
WHERE
|
|
M_BranchName like ?
|
|
AND M_BranchIsActive = 'Y'
|
|
ORDER BY M_BranchName ASC";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_branch rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}else{
|
|
$sql = "SELECT count(*) as total
|
|
FROM
|
|
(SELECT
|
|
M_LabReferenceID as M_DestinationID,
|
|
M_LabReferenceName as M_DestinationName,
|
|
M_LabReferenceAddress as M_DestinationAddress,
|
|
M_LabReferenceUp as M_DestinationUp,
|
|
M_CityID,
|
|
M_CityName,
|
|
M_DistrictID,
|
|
M_DistrictName,
|
|
M_KelurahanID,
|
|
M_KelurahanName
|
|
FROM m_labreference
|
|
LEFT JOIN m_city ON M_LabReferenceM_CityID = M_CityID
|
|
LEFT JOIN m_district ON M_LabReferenceM_DistrictID = M_DistrictID
|
|
LEFT JOIN m_kelurahan ON M_LabReferenceM_KelurahanID = M_KelurahanID
|
|
WHERE
|
|
M_LabReferenceName like ?
|
|
AND M_LabReferenceIsActive = 'Y'
|
|
ORDER BY M_LabReferenceName ASC)a
|
|
";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_branch count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT
|
|
M_LabReferenceID as M_DestinationID,
|
|
M_LabReferenceName as M_DestinationName,
|
|
M_LabReferenceAddress as M_DestinationAddress,
|
|
M_LabReferenceUp as M_DestinationUp,
|
|
M_CityID,
|
|
M_CityName,
|
|
M_DistrictID,
|
|
M_DistrictName,
|
|
M_KelurahanID,
|
|
M_KelurahanName
|
|
FROM m_labreference
|
|
LEFT JOIN m_city ON M_LabReferenceM_CityID = M_CityID
|
|
LEFT JOIN m_district ON M_LabReferenceM_DistrictID = M_DistrictID
|
|
LEFT JOIN m_kelurahan ON M_LabReferenceM_KelurahanID = M_KelurahanID
|
|
WHERE
|
|
M_LabReferenceName like ?
|
|
AND M_LabReferenceIsActive = 'Y'
|
|
ORDER BY M_LabReferenceName ASC";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_branch rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
function selected_sample()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
|
|
$sql = $this->db_onedev->query("SELECT COUNT(*) as semua FROM incoming_ref_detail
|
|
WHERE incomingRefDetailIncomingRefID = '{$id}'")->row();
|
|
$semua = $sql->semua;
|
|
|
|
$sql = $this->db_onedev->query("SELECT count(*) as terima FROM incoming_ref_detail
|
|
WHERE incomingRefDetailIncomingRefID = '{$id}' AND incmoingRefDetailStatus = 'R'")->row();
|
|
$terima = $sql->terima;
|
|
|
|
$sql = "SELECT * FROM (SELECT incoming_ref_detail.*,
|
|
incmoingRefDetailStatus as ischoose,
|
|
LEFT(incomingRefDetailT_BarcodeLabBarcode,12) as nosample,
|
|
'{$semua}' as semua,
|
|
'{$terima}' as terima
|
|
from incoming_ref_detail
|
|
where
|
|
incomingRefDetailIncomingRefID = '{$id}') a
|
|
GROUP BY nosample";
|
|
$query = $this->db_onedev->query($sql);
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
} else {
|
|
$this->sys_error_db( $this->db_onedev->last_query() );
|
|
exit;
|
|
}
|
|
$result = array ("total" => count($rows), "records" => $rows, "semua" => $semua, "terima" => $terima);
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function confirmdeliveryorder(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
foreach($prm['dodetail'] as $k=>$v){
|
|
if($v['ischoose'] == 'R'){
|
|
$query = "UPDATE incoming_ref_detail SET
|
|
incmoingRefDetailStatus = 'R',
|
|
incomingRefDetailCreated = now(),
|
|
incomingRefDetailLastUpdated = now()
|
|
WHERE incomingRefDetailIncomingRefID = ? AND LEFT(incomingRefDetailT_BarcodeLabBarcode,12) = ?";
|
|
$insert_new_test = $this->db_onedev->query($query,array(
|
|
$prm['id'],
|
|
$v['nosample']
|
|
));
|
|
}
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
|
|
}
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function createorder(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
foreach($prm['dodetail'] as $k=>$v){
|
|
$query = "UPDATE incoming_ref_detail SET
|
|
incmoingRefDetailStatus = 'Y',
|
|
incomingRefDetailCreated = now(),
|
|
incomingRefDetailLastUpdated = now()
|
|
WHERE incomingRefDetailIncomingRefID = ? AND LEFT(incomingRefDetailT_BarcodeLabBarcode,12) = ?";
|
|
$insert_new_test = $this->db_onedev->query($query,array(
|
|
$prm['id'],
|
|
$v['nosample']
|
|
));
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
|
|
}
|
|
|
|
$query = "SELECT incoming_ref_detail.*
|
|
FROM incoming_ref_detail
|
|
WHERE
|
|
incomingRefDetailIncomingRefID = '{$prm['id']}'";
|
|
$refdetail = $this->db_onedev->query($query)->result_array();
|
|
|
|
foreach($refdetail as $k => $v){
|
|
$x = $this->db_onedev->query("select incomingRefDetailPatient
|
|
as n from incoming_ref_detail
|
|
WHERE incomingRefDetailID = '{$v['incomingRefDetailID']}'")->row();
|
|
$patient = json_decode($x->n, true);
|
|
// insert pasien
|
|
$querypatient = "INSERT INTO m_patient (
|
|
M_PatientM_TitleID,
|
|
M_PatientName,
|
|
M_PatientDOB,
|
|
M_PatientM_SexID,
|
|
M_PatientM_ReligionID,
|
|
M_PatientEmail,
|
|
M_PatientPOB,
|
|
M_PatientHP,
|
|
M_PatientPhone,
|
|
M_PatientM_IdTypeID,
|
|
M_PatientIDNumber,
|
|
M_PatientNote,
|
|
M_PatientUserID,
|
|
M_PatientOldID,
|
|
M_PatientCreated,
|
|
M_PatientLastUpdated)
|
|
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,now(),now())";
|
|
|
|
$insert_new_patient = $this->db_onedev->query($querypatient,array(
|
|
$patient['M_PatientM_TitleID'],
|
|
$patient['M_PatientName'],
|
|
$patient['M_PatientDOB'],
|
|
$patient['M_PatientM_SexID'],
|
|
$patient['M_PatientM_ReligionID'],
|
|
$patient['M_PatientEmail'],
|
|
$patient['M_PatientPOB'],
|
|
$patient['M_PatientHP'],
|
|
$patient['M_PatientPhone'],
|
|
$patient['M_PatientM_IdTypeID'],
|
|
$patient['M_PatientIDNumber'],
|
|
$patient['M_PatientNote'],
|
|
$patient['M_PatientID'],
|
|
$userid
|
|
));
|
|
// echo $insert_new_patient;
|
|
$last_id = $this->db_onedev->insert_id();
|
|
// echo $last_id;
|
|
$query = "UPDATE incoming_ref_detail SET
|
|
incmoingRefDetailStatus = 'Y',
|
|
incomingRefDetailNewM_PatientID = ?,
|
|
incomingRefDetailM_PatientAge = '',
|
|
incomingRefDetailCreated = now(),
|
|
incomingRefDetailLastUpdated = now()
|
|
WHERE incomingRefDetailIncomingRefID = ? AND incomingRefDetailT_OrderHeaderID = ?";
|
|
$insert_new_test = $this->db_onedev->query($query,array(
|
|
$last_id,
|
|
$prm['id'],
|
|
$v['incomingRefDetailT_OrderHeaderID']
|
|
));
|
|
|
|
$saveorderlab = $this->orderlab($v['incomingRefDetailID'],$v['incomingRefDetailIncomingRefID']);
|
|
$sqlreceivepatient = "UPDATE incoming_ref_detail SET
|
|
incomingRefDetailNewT_OrderHeaderID = '{$saveorderlab->id}'
|
|
WHERE incomingRefDetailID = {$v['incomingRefDetailID']}";
|
|
}
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function orderlab($orderdetail_id,$order_id){
|
|
//$order_id = $prm['orderid'];
|
|
//$patientage = $prm['patientage'];
|
|
//echo $order_id;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
/***t_orderheader***/
|
|
$sql = "SELECT incoming_ref.* ,incoming_ref_detail.*, m_branch.*
|
|
FROM incoming_ref_detail
|
|
LEFT JOIN incoming_ref ON incomingRefDetailIncomingRefID = incomingRefID
|
|
LEFT JOIN m_branch ON incomingRefM_BranchID = M_BranchID
|
|
WHERE
|
|
incomingRefDetailID = '{$orderdetail_id}'";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("select incoming_ref_detail", $this->db_onedev);
|
|
exit;
|
|
}
|
|
$data_order = $query->row_array();
|
|
$xheader = array(
|
|
'patient_id' => $data_order['incomingRefDetailNewM_PatientID'],
|
|
'age' => $data_order['incomingRefDetailM_PatientAge'],
|
|
'sender_doctor_id' => $data_order['M_BranchM_DoctorID'],
|
|
'sender_address_id' => $data_order['M_BranchM_DoctorAddressID'],
|
|
'company_id' => $data_order['M_BranchM_CompanyID'],
|
|
'mou_id' => $data_order['M_BranchM_MouID'],
|
|
'lang_id' => '1',
|
|
'lang_si' => 'N',
|
|
'doctor_note' => '',
|
|
'fo_note' => $data_order['M_BranchM_MouID'],
|
|
'queue' => '',
|
|
'received_sample' => 'N',
|
|
'lang_id_2' => '2',
|
|
'lang_si_2' => 'N',
|
|
);
|
|
|
|
$xdelivery = array();
|
|
$query = " SELECT incoming_ref.*,m_branch.*
|
|
FROM incoming_ref_detail
|
|
LEFT JOIN incoming_ref ON incomingRefDetailIncomingRefID = incomingRefID
|
|
LEFT JOIN m_branch ON incomingRefM_BranchID = M_BranchID
|
|
WHERE
|
|
incomingRefDetailID = '{$orderdetail_id}'";
|
|
//echo $query;
|
|
$delver = $this->db_onedev->query($query)->result_array();
|
|
foreach($delver as $k => $v){
|
|
$xdel = array(
|
|
'address_id' => $v['M_BranchID'],
|
|
'delivery_id' => '10',
|
|
'delivery_type_id' => '2',
|
|
'senderdoctorid' => $v['M_BranchM_DoctorID'],
|
|
'senderaddressid' => $v['M_BranchM_DoctorAddressID'],
|
|
'note' => $v['M_BranchAddress'],
|
|
'kelurahan' => $v['M_BranchM_KelurahanID']
|
|
);
|
|
array_push($xdelivery,$xdel);
|
|
}
|
|
//print_r($xdelivery );
|
|
$query = " SELECT incoming_ref.*, m_branch.*,incoming_ref_detail.*,IFNULL(T_PriceAmount,0) as T_PriceAmount,IFNULL(T_PriceDisc,0) as T_PriceDisc,IFNULL(T_PriceDiscRp,0) as T_PriceDiscRp,
|
|
'PX' as testtype,
|
|
'N' as ispaket
|
|
FROM incoming_ref_detail
|
|
LEFT JOIN incoming_ref ON incomingRefDetailIncomingRefID = incomingRefID
|
|
LEFT JOIN m_branch ON incomingRefM_BranchID = M_BranchID
|
|
LEFT JOIN t_price ON incomingRefDetailT_TestID = T_PriceT_TestID AND
|
|
M_BranchM_CompanyID = T_PriceM_CompanyID AND
|
|
M_BranchM_MouID = T_PriceM_MouID AND T_PriceIsActive = 'Y'
|
|
WHERE
|
|
incomingRefDetailID = '{$orderdetail_id}'";
|
|
//echo $query;
|
|
$data_order_detail = $this->db_onedev->query($query)->result_array();
|
|
$xdetails = array();
|
|
foreach($data_order_detail as $k => $v){
|
|
$xdet = array(
|
|
't_id' => $v['incomingRefDetailT_TestID'],
|
|
't_cito' => 'N',
|
|
't_price' => $v['T_PriceAmount'],
|
|
't_disc' => $v['T_PriceDisc'],
|
|
't_discrp' => $v['T_PriceDiscRp'],
|
|
't_req' => 'Y',
|
|
't_reqnote' => '',
|
|
't_ispacket' => $v['ispaket'],
|
|
't_packettype' => $v['testtype'],
|
|
't_packetid' => '0'
|
|
);
|
|
array_push($xdetails,$xdet);
|
|
}
|
|
|
|
$xreq = array(
|
|
'status' => 'Y',
|
|
'reqs' => '[]'
|
|
);
|
|
$header_json = json_encode($xheader);
|
|
$delivery_json = json_encode($xdelivery);
|
|
$detail_json = json_encode($xdetails);
|
|
$req_json = json_encode($xreq);
|
|
$sql = "CALL `sp_fo_register_save_v5`(
|
|
0,
|
|
'{$header_json}',
|
|
'{$delivery_json}',
|
|
'{$detail_json}',
|
|
'{$req_json}',
|
|
'{$userid}'
|
|
);";
|
|
//echo $sql;
|
|
$r = $this->db_onedev->query($sql)->row();
|
|
$this->clean_mysqli_connection($this->db_onedev->conn_id);
|
|
return json_decode($r->data);
|
|
/***t_orderheader***/
|
|
}
|
|
/***begin-verification***/
|
|
function add_address_patient($orderid){
|
|
$query =" SELECT M_PatientAddressID as id,
|
|
M_PatientAddressNote as note,
|
|
M_PatientAddressDescription as description,
|
|
M_PatientAddressM_KelurahanID as vilageid
|
|
FROM m_patientaddress
|
|
JOIN t_orderheader ON M_PatientAddressM_PatientID = T_OrderHeaderM_PatientID
|
|
WHERE
|
|
T_OrderHeaderID = {$orderid} AND M_PatientAddressIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
if($rows)
|
|
return $rows;
|
|
else
|
|
return array();
|
|
}
|
|
|
|
function add_address_doctor($orderid){
|
|
$query =" SELECT M_DoctorAddressID as id,
|
|
M_DoctorAddressNote as note,
|
|
M_DoctorAddressDescription as description,
|
|
M_DoctorAddressM_KelurahanID as vilageid
|
|
FROM m_doctoraddress
|
|
JOIN t_orderheader ON T_OrderHeaderSenderM_DoctorID = M_DoctorAddressM_DoctorID
|
|
WHERE
|
|
T_OrderHeaderID = {$orderid} AND M_DoctorAddressIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
if($rows)
|
|
return $rows;
|
|
else
|
|
return array();
|
|
}
|
|
|
|
function add_verification_patient($orderid){
|
|
$query =" SELECT Fo_VerificationsLabelID as id,
|
|
0 as xid,
|
|
'Y' as chex,
|
|
'' as note,
|
|
Fo_VerificationsLabelName as label
|
|
FROM fo_verificationslabel
|
|
LEFT JOIN fo_verificationsvalue ON Fo_VerificationsValueFo_VerificationsLabelID = Fo_VerificationsLabelID AND Fo_VerificationsValueT_OrderHeaderID = $orderid
|
|
WHERE
|
|
Fo_VerificationsLabelID = 1 AND Fo_VerificationsLabelIsActive = 'Y'
|
|
GROUP BY Fo_VerificationsLabelID
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
foreach($rows as $k => $v){
|
|
if($v['chex'] == 'N')
|
|
$rows[$k]['chex'] = false;
|
|
else
|
|
$rows[$k]['chex'] = true;
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
function add_verification_doctor($orderid){
|
|
$query =" SELECT Fo_VerificationsLabelID as id,
|
|
0 as xid,
|
|
'Y' as chex,
|
|
'' as note,
|
|
Fo_VerificationsLabelName as label
|
|
FROM fo_verificationslabel
|
|
LEFT JOIN fo_verificationsvalue ON Fo_VerificationsValueFo_VerificationsLabelID = Fo_VerificationsLabelID AND Fo_VerificationsValueT_OrderHeaderID = $orderid
|
|
WHERE
|
|
Fo_VerificationsLabelID = 2 AND Fo_VerificationsLabelIsActive = 'Y'
|
|
GROUP BY Fo_VerificationsLabelID
|
|
";
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
foreach($rows as $k => $v){
|
|
if($v['chex'] == 'N')
|
|
$rows[$k]['chex'] = false;
|
|
else
|
|
$rows[$k]['chex'] = true;
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
function add_verification_companymou($orderid){
|
|
$query =" SELECT Fo_VerificationsLabelID as id,
|
|
0 as xid,
|
|
'Y' as chex,
|
|
'' as note,
|
|
Fo_VerificationsLabelName as label
|
|
FROM fo_verificationslabel
|
|
LEFT JOIN fo_verificationsvalue ON Fo_VerificationsValueFo_VerificationsLabelID = Fo_VerificationsLabelID AND Fo_VerificationsValueT_OrderHeaderID = $orderid
|
|
WHERE
|
|
Fo_VerificationsLabelID = 3 AND Fo_VerificationsLabelIsActive = 'Y'
|
|
GROUP BY Fo_VerificationsLabelID
|
|
";
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
foreach($rows as $k => $v){
|
|
if($v['chex'] == 'N')
|
|
$rows[$k]['chex'] = false;
|
|
else
|
|
$rows[$k]['chex'] = true;
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
function add_verification_payment($orderid){
|
|
$query =" SELECT Fo_VerificationsLabelID as id,
|
|
0 as xid,
|
|
'Y' as chex,
|
|
'' as note,
|
|
Fo_VerificationsLabelName as label,
|
|
'reguler' as type
|
|
FROM fo_verificationslabel
|
|
LEFT JOIN fo_verificationsvalue ON Fo_VerificationsValueFo_VerificationsLabelID = Fo_VerificationsLabelID AND Fo_VerificationsValueT_OrderHeaderID = $orderid
|
|
WHERE
|
|
Fo_VerificationsLabelButton = 'PAYMENT' AND Fo_VerificationsLabelIsActive = 'Y'
|
|
GROUP BY Fo_VerificationsLabelID
|
|
";
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
foreach($rows as $k => $v){
|
|
if($v['chex'] == 'N')
|
|
$rows[$k]['chex'] = false;
|
|
else
|
|
$rows[$k]['chex'] = true;
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
function add_verification_supplies($orderid){
|
|
$query =" SELECT M_SuppliesID as id,
|
|
0 as xid,
|
|
'Y' as chex,
|
|
1 as qty,
|
|
M_SuppliesName as name,
|
|
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as lastupdated,
|
|
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as tx_lastupdated
|
|
FROM m_supplies
|
|
LEFT JOIN t_ordersupplies ON T_OrderSuppliesT_OrderHeaderID = $orderid AND T_OrderSuppliesM_SuppliesID = M_SuppliesID
|
|
WHERE
|
|
M_SuppliesIsActive = 'Y'
|
|
";
|
|
//echo $query ;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
foreach($rows as $k => $v){
|
|
if($v['chex'] == 'N')
|
|
$rows[$k]['chex'] = false;
|
|
else
|
|
$rows[$k]['chex'] = true;
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
|
|
function add_verification_barcode($orderid){
|
|
$query =" SELECT T_SampleTypeID as id,
|
|
T_SampleTypeName as name,
|
|
'' as children
|
|
FROM t_orderheader
|
|
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
|
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
WHERE
|
|
T_OrderHeaderID = {$orderid}
|
|
GROUP BY T_SampleTypeID
|
|
";
|
|
// echo $query ;
|
|
$rows = $this->db_onedev->query($query)->result();
|
|
foreach($rows as $k => $v){
|
|
$query = "SELECT T_SampleTypeID as id, 0 as xid,
|
|
'Y' as chex,
|
|
T_TestName as testname,
|
|
T_SampleTypeName as samplename,
|
|
IF(ISNULL(T_BarcodeLabID),CONCAT(T_OrderHeaderLabNumber,'.',T_SampleTypeID,'.',1),T_BarcodeLabBarcode) as barcodenumber
|
|
FROM t_orderdetail
|
|
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
|
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
LEFT JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
|
T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID AND T_BarcodeLabIsActive = 'Y'
|
|
WHERE
|
|
T_OrderDetailT_OrderHeaderID = {$orderid} AND T_SampleTypeID = {$v->id}
|
|
GROUP BY T_BarcodeLabID ";
|
|
$v->children = $this->db_onedev->query($query)->result_array();
|
|
foreach($v->children as $ki => $vi){
|
|
if($vi['chex'] == 'N')
|
|
$v->children[$ki]['chex'] = false;
|
|
else
|
|
$v->children[$ki]['chex'] = true;
|
|
}
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
function add_verification_delivery($orderid){
|
|
$query =" SELECT T_OrderDeliveryID as id,
|
|
0 as xid,
|
|
M_DeliveryTypeCode as code,
|
|
'Y' as chex,
|
|
M_DeliveryID as deliveryid,
|
|
M_DeliveryTypeID as typedeliveryid,
|
|
T_OrderDeliveryM_KelurahanID as vilageid,
|
|
IF(ISNULL(Fo_VerificationDeliveryID),'',Fo_VerificationDeliveryReason) as note,
|
|
'reguler' as type,
|
|
CASE
|
|
WHEN T_OrderDeliveryM_DeliveryID = 1 THEN M_DeliveryName
|
|
WHEN T_OrderDeliveryM_DeliveryID = 4 THEN CONCAT(M_DeliveryName, ' : ', M_DoctorAddressDescription)
|
|
WHEN T_OrderDeliveryM_DeliveryID = 2 THEN CONCAT(M_DeliveryName, ' : ', M_PatientAddressDescription)
|
|
WHEN ( T_OrderDeliveryM_DeliveryID = 7 OR T_OrderDeliveryM_DeliveryID = 9 ) THEN CONCAT(M_DeliveryName, ' : ', M_DoctorHP)
|
|
WHEN ( T_OrderDeliveryM_DeliveryID = 6 OR T_OrderDeliveryM_DeliveryID = 8 ) THEN CONCAT(M_DeliveryName, ' : ', M_PatientHP)
|
|
ELSE
|
|
CONCAT(M_DeliveryName,' : ',T_OrderDeliveryDestination)
|
|
END as label,
|
|
CASE
|
|
WHEN T_OrderDeliveryM_DeliveryID = 1 THEN ''
|
|
WHEN T_OrderDeliveryM_DeliveryID = 4 THEN M_DoctorAddressDescription
|
|
WHEN T_OrderDeliveryM_DeliveryID = 2 THEN M_PatientAddressDescription
|
|
WHEN ( T_OrderDeliveryM_DeliveryID = 7 OR T_OrderDeliveryM_DeliveryID = 9 ) THEN M_DoctorHP
|
|
WHEN ( T_OrderDeliveryM_DeliveryID = 6 OR T_OrderDeliveryM_DeliveryID = 8 ) THEN M_PatientHP
|
|
ELSE
|
|
T_OrderDeliveryDestination
|
|
END as destination,
|
|
CASE
|
|
WHEN T_OrderDeliveryM_DeliveryID = 4 THEN M_DoctorAddressID
|
|
WHEN T_OrderDeliveryM_DeliveryID = 2 THEN M_PatientAddressID
|
|
ELSE
|
|
0
|
|
END as addressid
|
|
FROM t_orderdelivery
|
|
JOIN t_orderheader ON T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN m_delivery ON T_OrderDeliveryM_DeliveryID = M_DeliveryID
|
|
JOIN m_deliverytype ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
|
LEFT JOIN m_doctoraddress ON T_OrderDeliveryAddressID = M_DoctorAddressID AND T_OrderDeliveryM_DeliveryID = 4
|
|
LEFT JOIN m_patientaddress ON T_OrderDeliveryAddressID = M_PatientAddressID AND T_OrderDeliveryM_DeliveryID = 2
|
|
LEFT JOIN fo_verification_delivery ON Fo_VerificationDeliveryT_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID AND Fo_VerificationDeliveryIsActive = 'Y'
|
|
LEFT JOIN m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID AND ( T_OrderDeliveryM_DeliveryID = 7 OR T_OrderDeliveryM_DeliveryID = 9 )
|
|
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND ( T_OrderDeliveryM_DeliveryID = 6 OR T_OrderDeliveryM_DeliveryID = 8 )
|
|
WHERE
|
|
T_OrderDeliveryT_OrderHeaderID = {$orderid} AND T_OrderDeliveryIsActive = 'Y'
|
|
GROUP BY T_OrderDeliveryID
|
|
UNION
|
|
SELECT 0 as id,
|
|
0 as xid,
|
|
M_DeliveryTypeCode as code,
|
|
'Y' as chex,
|
|
Fo_VerificationDeliveryAddM_DeliveryID as deliveryid,
|
|
Fo_VerificationDeliveryAddM_DeliveryTypeID as typedeliveryid,
|
|
Fo_VerificationDeliveryAddM_KelurahanID as vilageid,
|
|
IF(ISNULL(Fo_VerificationDeliveryAddID),'',Fo_VerificationDeliveryAddReason) as note,
|
|
'reguler' as type,
|
|
CASE
|
|
WHEN Fo_VerificationDeliveryAddM_DeliveryID = 1 THEN M_DeliveryName
|
|
WHEN Fo_VerificationDeliveryAddM_DeliveryID = 4 THEN CONCAT(M_DeliveryName, ' : ', M_DoctorAddressDescription)
|
|
WHEN Fo_VerificationDeliveryAddM_DeliveryID = 2 THEN CONCAT(M_DeliveryName, ' : ', M_PatientAddressDescription)
|
|
WHEN ( Fo_VerificationDeliveryAddM_DeliveryID = 7 OR Fo_VerificationDeliveryAddM_DeliveryID = 9 ) THEN CONCAT(M_DeliveryName, ' : ', M_DoctorHP)
|
|
WHEN ( Fo_VerificationDeliveryAddM_DeliveryID = 6 OR Fo_VerificationDeliveryAddM_DeliveryID = 8 ) THEN CONCAT(M_DeliveryName, ' : ', M_PatientHP)
|
|
ELSE
|
|
CONCAT(M_DeliveryName,' : ',Fo_VerificationDeliveryAddDestination)
|
|
END as label,
|
|
CASE
|
|
WHEN Fo_VerificationDeliveryAddM_DeliveryID = 1 THEN ''
|
|
WHEN Fo_VerificationDeliveryAddM_DeliveryID = 4 THEN M_DoctorAddressDescription
|
|
WHEN Fo_VerificationDeliveryAddM_DeliveryID = 2 THEN M_PatientAddressDescription
|
|
WHEN ( Fo_VerificationDeliveryAddM_DeliveryID = 7 OR Fo_VerificationDeliveryAddM_DeliveryID = 9 ) THEN M_DoctorHP
|
|
WHEN ( Fo_VerificationDeliveryAddM_DeliveryID = 6 OR Fo_VerificationDeliveryAddM_DeliveryID = 8 ) THEN M_PatientHP
|
|
ELSE
|
|
Fo_VerificationDeliveryAddDestination
|
|
END as destination,
|
|
CASE
|
|
WHEN Fo_VerificationDeliveryAddM_DeliveryID = 4 THEN M_DoctorAddressID
|
|
WHEN Fo_VerificationDeliveryAddM_DeliveryID = 2 THEN M_PatientAddressID
|
|
ELSE
|
|
0
|
|
END as addressid
|
|
FROM fo_verification_delivery_add
|
|
JOIN t_orderheader ON Fo_VerificationDeliveryAddT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN m_delivery ON Fo_VerificationDeliveryAddM_DeliveryID = M_DeliveryID
|
|
JOIN m_deliverytype ON Fo_VerificationDeliveryAddM_DeliveryTypeID = M_DeliveryTypeID
|
|
LEFT JOIN m_doctoraddress ON Fo_VerificationDeliveryAddAddressID = M_DoctorAddressID AND Fo_VerificationDeliveryAddM_DeliveryID = 4
|
|
LEFT JOIN m_patientaddress ON Fo_VerificationDeliveryAddAddressID = M_PatientAddressID AND Fo_VerificationDeliveryAddM_DeliveryID = 2
|
|
LEFT JOIN m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID AND ( Fo_VerificationDeliveryAddM_DeliveryID = 7 OR Fo_VerificationDeliveryAddM_DeliveryID = 9 )
|
|
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND ( Fo_VerificationDeliveryAddM_DeliveryID = 6 OR Fo_VerificationDeliveryAddM_DeliveryID = 8 )
|
|
WHERE
|
|
Fo_VerificationDeliveryAddT_OrderHeaderID = {$orderid} AND Fo_VerificationDeliveryAddIsActive = 'Y'
|
|
";
|
|
//echo $query ;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
foreach($rows as $k => $v){
|
|
if($v['chex'] == 'N')
|
|
$rows[$k]['chex'] = false;
|
|
else
|
|
$rows[$k]['chex'] = true;
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
function add_verification_test($orderid){
|
|
$query =" SELECT * FROM (
|
|
SELECT T_OrderDetailID as id,
|
|
0 as xid,
|
|
'Y' as chex,
|
|
IF(ISNULL(Fo_VerificationTestID),'',Fo_VerificationTestReason) as note,
|
|
T_TestID as pxid,
|
|
T_TestName as pxname,
|
|
T_OrderDetailIsCito as flagcito,
|
|
T_OrderDetailPrice as bruto,
|
|
T_OrderDetailDiscTotal as discount,
|
|
T_OrderDetailTotal as total,
|
|
'N' as addon
|
|
FROM t_orderdetail
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsPrice = 'Y'
|
|
LEFT JOIN fo_verification_test ON Fo_VerificationTestT_OrderDetailID = T_OrderDetailID
|
|
WHERE
|
|
T_OrderDetailT_OrderHeaderID = $orderid AND T_OrderDetailIsActive = 'Y'
|
|
UNION
|
|
SELECT 0 as id,
|
|
IFNULL(Fo_VerificationTestAddID,0) as xid,
|
|
IF(ISNULL(Fo_VerificationTestAddIsOK),'N',Fo_VerificationTestAddIsOK) as chex,
|
|
'' as note,
|
|
Fo_VerificationTestAddT_TestID as pxid,
|
|
T_TestName as pxname,
|
|
Fo_VerificationTestAddIsCito as flagcito,
|
|
Fo_VerificationTestAddBruto as bruto,
|
|
Fo_VerificationTestAddDiscount as discount,
|
|
Fo_VerificationTestAddTotal as total,
|
|
'N' as addon
|
|
FROM fo_verification_test_add
|
|
JOIN t_test ON Fo_VerificationTestAddT_TestID = T_TestID
|
|
WHERE
|
|
Fo_VerificationTestAddT_OrderHeaderID = $orderid AND Fo_VerificationTestAddIsActive = 'Y' ) x
|
|
GROUP BY pxid
|
|
";
|
|
//echo $query ;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
foreach($rows as $k => $v){
|
|
if($v['chex'] == 'N')
|
|
$rows[$k]['chex'] = false;
|
|
else
|
|
$rows[$k]['chex'] = true;
|
|
|
|
if($v['addon'] == 'N')
|
|
$rows[$k]['addon'] = false;
|
|
else
|
|
$rows[$k]['addon'] = true;
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
function add_verification_info($orderid){
|
|
$query =" SELECT Fo_VerificationsLabelID as id,
|
|
0 as xid,
|
|
'Y' as chex,
|
|
IF(ISNULL(Fo_VerificationID),'',Fo_VerificationReason) as note,
|
|
Fo_VerificationsLabelName as label
|
|
FROM fo_verificationslabel
|
|
LEFT JOIN fo_verificationsvalue ON Fo_VerificationsValueFo_VerificationsLabelID = Fo_VerificationsLabelID AND Fo_VerificationsValueT_OrderHeaderID = $orderid
|
|
WHERE
|
|
Fo_VerificationsLabelButton = 'INFO' AND Fo_VerificationsLabelIsActive = 'Y'
|
|
GROUP BY Fo_VerificationsLabelID
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
foreach($rows as $k => $v){
|
|
if($v['chex'] == 'N')
|
|
$rows[$k]['chex'] = false;
|
|
else
|
|
$rows[$k]['chex'] = true;
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
|
|
public function savetrxverification($orderid,$prm)
|
|
{
|
|
try {
|
|
//print_r($prm);
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$xuserid = $this->sys_user["M_UserID"];
|
|
//# ambil parameter input
|
|
|
|
//print_r($xprm);
|
|
//$prm = $xprm['patient'];
|
|
$fostatusid = 3;
|
|
$fologcode = 'FO.VERIFICATION.CONFIRM';
|
|
|
|
|
|
|
|
//print_r($prm);
|
|
$xverificationnote = $prm['verification_note'];
|
|
//echo $xverificationnote;
|
|
$id = $orderid;
|
|
/*$sql = "update t_orderheader
|
|
set
|
|
T_OrderHeaderVerificationNote = ''
|
|
where
|
|
T_OrderHeaderID = $id";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);*/
|
|
|
|
//print_r($prm['verification_patient']);
|
|
$xverification_patient = $this->saveverifications($id,$prm['verification_patient'],'PASIEN',$xuserid);
|
|
$xverification_doctor = $this->saveverifications($id,$prm['verification_doctor'],'ORDER',$xuserid);
|
|
$xverification_companymou = $this->saveverifications($id,$prm['verification_companymou'],'ORDER',$xuserid);
|
|
//$xverification_payment = $this->saveverifications($id,$prm['verification_payment'],'PAYMENT',$xuserid);
|
|
//$xverification_info = $this->saveverifications($id,$prm['verification_info'],'INFO',$xuserid);
|
|
|
|
$xverification_delivery = $this->saveverification_delivery($id,$prm['verification_delivery'],$xuserid);
|
|
$xverification_px = $this->saveverification_px($id,$prm['verification_px'],$xuserid);
|
|
|
|
$sql = "insert into fo_status(
|
|
Fo_StatusDate,
|
|
Fo_StatusT_OrderHeaderID,
|
|
Fo_StatusM_StatusID,
|
|
Fo_StatusM_UserID,
|
|
Fo_StatusCreated,
|
|
Fo_StatusUpdated)
|
|
values( now(), ?, ?, ?, now(),now())";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$id,
|
|
$fostatusid,
|
|
$xuserid
|
|
)
|
|
);
|
|
//echo $this->db_onedev->last_query();
|
|
if (!$query) {
|
|
$this->sys_error_db("fo_status insert");
|
|
exit;
|
|
}
|
|
|
|
|
|
$data_log = array();
|
|
$data_log['orderid'] = $id;
|
|
$data_log['verification_patient'] = $prm['verification_patient'];
|
|
$data_log['verification_doctor'] = $prm['verification_doctor'];
|
|
$data_log['verification_companymou'] = $prm['verification_companymou'];
|
|
$data_log['verification_payment'] = $prm['verification_payment'];
|
|
$data_log['verification_info'] = $prm['verification_info'];
|
|
$data_log['verification_px'] = $prm['verification_px'];
|
|
$data_log['verification_delivery'] = $prm['verification_delivery'];
|
|
|
|
$json_dt_log = json_encode($data_log);
|
|
$sql = "insert into one_log.log_fo(
|
|
Log_FoDate,
|
|
Log_FoCode,
|
|
Log_FoJson,
|
|
Log_FoUserID)
|
|
values( now(), ?, ?, ?)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$fologcode,
|
|
$json_dt_log,
|
|
$xuserid
|
|
)
|
|
);
|
|
|
|
if (!$query) {
|
|
$this->sys_error_db("one_log.fo_log insert");
|
|
exit;
|
|
}
|
|
|
|
if($xstatus == 'Y'){
|
|
$msg = 'Verifikasi berhasil dilakukan';
|
|
}
|
|
else{
|
|
$msg = 'Tolak Verifikasi berhasil dilakukan';
|
|
$sql = "INSERT INTO t_ordermessage (
|
|
T_OrderMessageT_OrderHeaderID,
|
|
T_OrderMessageType,
|
|
T_OrderMessageMessage,
|
|
T_OrderMessageFromUserID,
|
|
T_OrderMessageCreated,
|
|
T_OrderMessageLastUpdated
|
|
)
|
|
VALUES(
|
|
{$id},
|
|
'FO.VERIFICATION.REJECT',
|
|
'{$xverificationnote}',
|
|
{$xuserid},
|
|
NOW(),
|
|
NOW()
|
|
)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("one_log.t_ordermessage insert");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
|
|
return rows;
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
|
|
function saveverifications($id,$verifications,$type,$userid)
|
|
{
|
|
try {
|
|
//$xverificationtypeid = $this->db_onedev->query("SELECT * FROM fo_verificationslabel WHERE Fo_VerificationsLabelButton = '{$type}' AND Fo_VerificationsLabelIsActive = 'Y'")->row()->Fo_VerificationsLabelID;
|
|
//echo $xverificationtypeid;
|
|
//print_r($verifications);
|
|
foreach($verifications as $k => $v){
|
|
//print_r($v);
|
|
if($v['xid'] === 0 || $v['xid'] === '0'){
|
|
$sql = "insert into fo_verificationsvalue(
|
|
Fo_VerificationsValueT_OrderHeaderID,
|
|
Fo_VerificationsValueFo_VerificationsLabelID,
|
|
Fo_VerificationsValueCheck,
|
|
Fo_VerificationsValueNote,
|
|
Fo_VerificationsValueCreated,
|
|
Fo_VerificationsValueLastUpdated,
|
|
Fo_VerificationsValueUserID)
|
|
values( ?, ?, ?, ?, now(),now(),?)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$id,
|
|
$v['id'],
|
|
$v['chex'] == true ?'Y':'N',
|
|
$v['note'],
|
|
$userid
|
|
)
|
|
);
|
|
//echo $this->db_onedev->last_query();
|
|
//echo "///////////////////////";
|
|
if (!$query) {
|
|
$this->sys_error_db("fo_verificationsvalue insert");
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function saveverification_delivery($id,$deliveries,$userid)
|
|
{
|
|
try {
|
|
foreach($deliveries as $k => $v){
|
|
if($v['id'] === 0){
|
|
$sql = "insert into fo_verification_delivery_add(
|
|
Fo_VerificationDeliveryAddT_OrderHeaderID,
|
|
Fo_VerificationDeliveryAddM_DeliveryID,
|
|
Fo_VerificationDeliveryAddM_DeliveryTypeID,
|
|
Fo_VerificationDeliveryAddDestination,
|
|
Fo_VerificationDeliveryAddAddressID,
|
|
Fo_VerificationDeliveryAddM_KelurahanID,
|
|
Fo_VerificationDeliveryAddOK,
|
|
Fo_VerificationDeliveryAddReason,
|
|
Fo_VerificationDeliveryAddCreated,
|
|
Fo_VerificationDeliveryAddLastUpdated,
|
|
Fo_VerificationDeliveryAddUserID)
|
|
values( ?, ?, ?, ?,?,?,?,?, now(),now(),?)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$id,
|
|
$v['deliveryid'],
|
|
$v['typedeliveryid'],
|
|
$v['destination'],
|
|
$v['addressid'],
|
|
$v['vilageid'],
|
|
$v['chex'] == true ?'Y':'N',
|
|
$v['note'],
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
echo $this->db_onedev->last_query();
|
|
$this->sys_error_db("fo_verification_delivery_add insert");
|
|
exit;
|
|
}
|
|
|
|
}else{
|
|
$sql = "insert into fo_verification_delivery(
|
|
Fo_VerificationDeliveryT_OrderHeaderID,
|
|
Fo_VerificationDeliveryT_OrderDeliveryID,
|
|
Fo_VerificationDeliveryIsOK,
|
|
Fo_VerificationDeliveryReason,
|
|
Fo_VerificationDeliveryCreated,
|
|
Fo_VerificationDeliveryLastUpdated,
|
|
Fo_VerificationDeliveryUserID)
|
|
values( ?, ?, ?, ?, now(),now(),?)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$id,
|
|
$v['id'],
|
|
$v['chex'] == true ?'Y':'N',
|
|
$v['note'],
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
echo $this->db_onedev->last_query();
|
|
$this->sys_error_db("fo_verification_delivery insert");
|
|
exit;
|
|
}
|
|
//echo $this->db_onedev->last_query();
|
|
}
|
|
}
|
|
return true;
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function saveverification_px($id,$pxs,$userid)
|
|
{
|
|
try {
|
|
foreach($pxs as $k => $v){
|
|
|
|
if(intval($v['id']) == 0){
|
|
$cxh = $v['chex'] == true ?'Y':'N';
|
|
$sql = "insert into fo_verification_test_add(
|
|
Fo_VerificationTestAddT_OrderHeaderID,
|
|
Fo_VerificationTestAddT_TestID,
|
|
Fo_VerificationTestAddBruto,
|
|
Fo_VerificationTestAddDiscount,
|
|
Fo_VerificationTestAddTotal,
|
|
Fo_VerificationTestAddIsOK,
|
|
Fo_VerificationTestAddIsCito,
|
|
Fo_VerificationTestAddCreated,
|
|
Fo_VerificationTestAddLastUpdated,
|
|
Fo_VerificationTestAddUserID)
|
|
values( $id, {$v['pxid']}, {$v['bruto']}, {$v['discount']},{$v['total']},'{$cxh}','{$v['flagcito']}',now(),now(),{$userid})";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
//echo $this->db_onedev->last_query();
|
|
if (!$query) {
|
|
$this->sys_error_db("fo_verification_test_add insert");
|
|
exit;
|
|
}
|
|
}else{
|
|
$sql = "insert into fo_verification_test(
|
|
Fo_VerificationTestT_OrderHeaderID,
|
|
Fo_VerificationTestT_OrderDetailID,
|
|
Fo_VerificationTestIsOK,
|
|
Fo_VerificationTestReason,
|
|
Fo_VerificationTestCreated,
|
|
Fo_VerificationTestLastUpdated,
|
|
Fo_VerificationTestUserID)
|
|
values( ?, ?, ?, ?, now(),now(),?)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$id,
|
|
$v['id'],
|
|
$v['chex'] == true ?'Y':'N',
|
|
$v['note'],
|
|
$userid
|
|
)
|
|
);
|
|
//echo $this->db_onedev->last_query();
|
|
if (!$query) {
|
|
$this->sys_error_db("fo_verification_test insert");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
return true;
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
|
|
/***end-verification***/
|
|
|
|
public function addnewdeliveryorderdetail()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$deliveryorderid = $prm['deliveryorderid'];
|
|
$code = $prm['code'];
|
|
$name = $prm['name'];
|
|
$address = $prm['address'];
|
|
$phone = $prm['phone'];
|
|
$cityid = $prm['cityid'];
|
|
$districtid = $prm['districtid'];
|
|
$kelurahanid = $prm['kelurahanid'];
|
|
$ipadrress = $prm['ipaddress'];
|
|
$basename = $prm['basename'];
|
|
$isdefault = $prm['isdefault'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
if($deliveryorderid == 0 || $cityid == 0 || $districtid == 0 || $kelurahanid == 0){
|
|
$errors = array();
|
|
if($deliveryorderid == 0){
|
|
array_push($errors,array('field'=>'deliveryorder','msg'=>'Regional dipilih dulu dong'));
|
|
}
|
|
if($cityid == 0){
|
|
array_push($errors,array('field'=>'city','msg'=>'Kota dipilih dulu dong'));
|
|
}
|
|
if($districtid == 0){
|
|
array_push($errors,array('field'=>'district','msg'=>'Kecamatan dipilih dulu dong'));
|
|
}
|
|
if($kelurahanid == 0){
|
|
array_push($errors,array('field'=>'kelurahan','msg'=>'Kelurahan dipilih dulu dong'));
|
|
}
|
|
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
|
$this->sys_ok($result);
|
|
}else{
|
|
if($prm['xid'] == 0){
|
|
$query = "SELECT COUNT(*) as exist FROM incoming_ref_detail WHERE incomingRefDetailIsActive = 'Y' AND incomingRefDetailCode = '{$code}'";
|
|
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
|
if($exist_code == 0){
|
|
$sql = "insert into incoming_ref_detail(
|
|
incomingRefDetailIncomingRefID,
|
|
incomingRefDetailCode,
|
|
T_OrderHeaderLabNumber,
|
|
incomingRefDetailAddress,
|
|
incomingRefDetailPhone,
|
|
incomingRefDetailM_CityID,
|
|
incomingRefDetailM_DistrictID,
|
|
incomingRefDetailM_KelurahanID,
|
|
incomingRefDetailIPAddress,
|
|
incomingRefDetailBaseName,
|
|
incomingRefDetailIsDefault,
|
|
incomingRefDetailUserID,
|
|
incomingRefDetailLastUpdated,
|
|
incomingRefDetailCreated)
|
|
values(?,?,?,?,?,?,?,?,?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$deliveryorderid,
|
|
$code,
|
|
$name,
|
|
$address,
|
|
$phone,
|
|
$cityid,
|
|
$districtid,
|
|
$kelurahanid,
|
|
$ipadrress,
|
|
$basename,
|
|
$isdefault,
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("incoming_ref_detail insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$last_id = $this->db_onedev->insert_id();
|
|
if ($isdefault == "Y" ) {
|
|
$sql = "update incoming_ref_detail set incomingRefDetailIsDefault= 'N'
|
|
where incomingRefDetailID <> ? ";
|
|
$this->db_onedev->query($sql,array($last_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 incoming_ref_detail WHERE incomingRefDetailIsActive = 'Y' AND incomingRefDetailCode = '{$code}' AND incomingRefDetailID <> {$prm['xid']}";
|
|
//echo $query;
|
|
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
|
// echo $exist_code;
|
|
if($exist_code == 0){
|
|
$sql = "UPDATE incoming_ref_detail SET incomingRefDetailIncomingRefID = '{$deliveryorderid}',
|
|
incomingRefDetailCode = '{$code}',
|
|
T_OrderHeaderLabNumber = '{$name}',
|
|
incomingRefDetailAddress = '{$address}',
|
|
incomingRefDetailPhone = '{$phone}',
|
|
incomingRefDetailM_CityID = '{$cityid}',
|
|
incomingRefDetailM_DistrictID = '{$districtid}',
|
|
incomingRefDetailM_KelurahanID = '{$kelurahanid}',
|
|
incomingRefDetailIPAddress = '{$ipadrress}',
|
|
incomingRefDetailBaseName = '{$basename}',
|
|
incomingRefDetailIsDefault = '{$isdefault}',
|
|
incomingRefDetailUserID = '{$userid}'
|
|
WHERE incomingRefDetailID = '{$prm['xid']}'";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if ($isdefault == "Y" ) {
|
|
$sql = "update incoming_ref_detail set incomingRefDetailIsDefault= 'N'
|
|
where incomingRefDetailID <> ? ";
|
|
$this->db_onedev->query($sql,array($prm['xid']));
|
|
}
|
|
$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 deletedeliveryorder()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$id = $prm['id'];
|
|
$sql = "update incoming_ref SET
|
|
incomingRefincomingRefT_RefDeliveryIsActive = 'N',
|
|
incomingRefincomingRefT_RefDeliveryLastUpdated = now()
|
|
WHERE
|
|
incomingRefID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("incoming_ref delete");
|
|
exit;
|
|
}
|
|
$sql = "update incoming_ref_detail SET
|
|
incomingRefDetailIsActive = 'N',
|
|
incomingRefDetailLastUpdated = now()
|
|
WHERE
|
|
incomingRefDetailIncomingRefID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("incoming_ref_detail delete");
|
|
exit;
|
|
}
|
|
$sql = "CALL `sp_refdeliveryorderdetail_delete`(".$id.",".$userid.")";
|
|
$query = $this->db_onedev->query($sql);
|
|
|
|
if (!$query) {
|
|
$this->sys_error_db("incoming_ref_detail 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 deletedeliveryorderdetail()
|
|
{
|
|
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 incoming_ref_detail SET
|
|
incomingRefDetailIsActive = 'N',
|
|
incomingRefDetailLastUpdated = now()
|
|
WHERE
|
|
incomingRefDetailID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("incoming_ref_detail 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 searchdeliveryorder(){
|
|
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 incoming_ref
|
|
WHERE
|
|
incomingRefincomingRefT_RefDeliveryName like ?
|
|
AND incomingRefincomingRefT_RefDeliveryIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("incoming_ref count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT incomingRefID, incomingRefincomingRefT_RefDeliveryName
|
|
FROM incoming_ref
|
|
WHERE
|
|
incomingRefincomingRefT_RefDeliveryName like ?
|
|
AND incomingRefincomingRefT_RefDeliveryIsActive = 'Y'
|
|
ORDER BY incomingRefincomingRefT_RefDeliveryName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("incoming_ref rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchdeliveryorderbyname(){
|
|
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 incoming_ref
|
|
WHERE
|
|
incomingRefincomingRefT_RefDeliveryName like ?
|
|
AND incomingRefincomingRefT_RefDeliveryIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("incoming_ref count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT incomingRefID, incomingRefincomingRefT_RefDeliveryName
|
|
FROM incoming_ref
|
|
WHERE
|
|
incomingRefincomingRefT_RefDeliveryName like ?
|
|
AND incomingRefincomingRefT_RefDeliveryIsActive = 'Y'
|
|
ORDER BY incomingRefincomingRefT_RefDeliveryName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("incoming_ref rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
|
|
function searchcity(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_city
|
|
WHERE
|
|
M_CityName like ?
|
|
AND M_CityIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_city count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityName like ?
|
|
AND M_CityIsActive = 'Y'
|
|
ORDER BY M_CityName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_city rows",$this->db_onedev);
|
|
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_onedev->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_onedev);
|
|
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_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_district rows",$this->db_onedev);
|
|
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_onedev->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_onedev);
|
|
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_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_district rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
}
|