Initial import
This commit is contained in:
247
one-api/application/controllers/mockup/refout/Testref.php
Normal file
247
one-api/application/controllers/mockup/refout/Testref.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
|
||||
class Testref extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "TEST REF MASTER API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 10;
|
||||
$tot_count = 0;
|
||||
|
||||
$page = $prm['page'];
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
$q = [
|
||||
'search' => isset($prm['search']) ? "%{$prm['search']}%" : '%',
|
||||
'company_id'=> isset($prm['company_id']) ? $prm['company_id'] : '0'
|
||||
];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT COUNT(Nat_TestID) total
|
||||
FROM nat_test
|
||||
LEFT JOIN t_testref ON T_TestRefNat_TestID = Nat_TestID
|
||||
AND ((T_TestRefM_CompanyID = ? and ? <> 0) OR ? = 0)
|
||||
AND T_TestRefIsActive = 'Y'
|
||||
LEFT JOIN m_company ON T_TestRefM_CompanyID = M_CompanyID
|
||||
WHERE (Nat_TestName LIKE ? OR Nat_TestCode LIKE ?)";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($q['company_id'], $q['company_id'], $q['company_id'],
|
||||
$q['search'], $q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Test Ref Master count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT T_TestRefID, Nat_TestID, Nat_TestName, Nat_TestCode, M_CompanyID, M_CompanyName,
|
||||
T_TestRefIsInternal, M_BranchID, M_BranchName, T_SampleTypeID, T_SampleTypeName
|
||||
FROM nat_test
|
||||
LEFT JOIN t_testref ON T_TestRefNat_TestID = Nat_TestID
|
||||
AND ((T_TestRefM_CompanyID = ? and ? <> 0) OR ? = 0)
|
||||
AND T_TestRefIsActive = 'Y'
|
||||
LEFT JOIN m_company ON T_TestRefM_CompanyID = M_CompanyID
|
||||
LEFT JOIN m_branch ON T_TestRefM_BranchID = M_BranchID
|
||||
LEFT JOIN t_sampletype ON T_SampleTypeID = T_TestRefT_SampleTypeID
|
||||
WHERE (Nat_TestName LIKE ? OR Nat_TestCode LIKE ?)
|
||||
limit {$offset}, {$max_rst}";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($q['company_id'], $q['company_id'], $q['company_id'],
|
||||
$q['search'], $q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "total_page" => ceil($tot_count/$max_rst), "cur_page" => $page, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Test Ref Master rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_company_all()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
$sql = "select M_CompanyID, M_CompanyName,
|
||||
IFNULL( concat('[', group_concat( json_object('M_MouID', M_MouID, 'M_MouName', M_MouName, 'M_MouStartDate', M_MouStartDate, 'M_MouEndDate', M_MouEndDate) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
left join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouIsApproved = 'Y' and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now())
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName like ?
|
||||
group by m_companyid";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_branch_all()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT M_BranchID, M_BranchName
|
||||
FROM m_branch
|
||||
WHERE M_BranchIsActive = 'Y'
|
||||
ORDER BY M_BranchName";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$result = array("records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Branch rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = (array) json_decode($prm['data']);
|
||||
|
||||
if (!isset($data['company_id']))
|
||||
$data['company_id'] = 0;
|
||||
|
||||
if (!isset($data['branch_id']))
|
||||
$data['branch_id'] = 0;
|
||||
|
||||
// overwrite
|
||||
$prm = $data;
|
||||
if (isset($prm['testref_id']))
|
||||
{
|
||||
$sql = "UPDATE t_testref
|
||||
SET T_TestRefIsInternal = ?,
|
||||
T_TestRefM_BranchID = ?,
|
||||
T_TestRefM_CompanyID= ?,
|
||||
T_TestRefT_SampleTypeID = ?
|
||||
WHERE T_TestRefID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['is_internal'], $prm['branch_id'], $prm['company_id'], $prm['sampletype_id'], $prm['testref_id']]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "INSERT INTO t_testref(T_TestRefIsInternal, T_TestRefM_BranchID, T_TestRefM_CompanyID, T_TestRefNat_TestID, T_TestRefT_SampleTypeID)
|
||||
VALUES(?, ?, ?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['is_internal'], $prm['branch_id'], $prm['company_id'], $prm['nattest_id'], $prm['sampletype_id']]);
|
||||
}
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$this->sys_ok($this->db_smartone->insert_id());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Test Ref Insert Update",$this->db_smartone);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
if (isset($prm['testref_id']))
|
||||
{
|
||||
$sql = "UPDATE t_testref
|
||||
SET T_TestRefIsActive = 'N', T_TestRefUserID = ?
|
||||
WHERE T_TestRefID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$this->sys_user['M_UserID'], $prm['testref_id']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$this->sys_ok("OK");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Test Ref Remove",$this->db_smartone);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Test Ref Remove",$this->db_smartone);
|
||||
}
|
||||
}
|
||||
|
||||
public function search_sampletype()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
$sql = "select T_SampleTypeID, T_SampleTypeName
|
||||
from t_sampletype
|
||||
where T_SampleTypeIsActive = 'Y'
|
||||
and T_SampleTypeName like ?
|
||||
order by T_SampleTypeName";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Sample Type rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
214
one-api/application/controllers/mockup/refout/refout/Refout.php
Normal file
214
one-api/application/controllers/mockup/refout/refout/Refout.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
|
||||
class Refout extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "REF OUT API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 10;
|
||||
$tot_count =0;
|
||||
|
||||
$page = $prm['page'];
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
$q = [
|
||||
'search' => isset($prm['search']) ? "%{$prm['search']}%" : '%',
|
||||
'company_id'=> isset($prm['company_id']) ? $prm['company_id'] : '0'
|
||||
];
|
||||
|
||||
$q_wh_company = "T_OrderRefOutToM_CompanyID";
|
||||
if ($prm['is_internal'] == 'Y')
|
||||
$q_wh_company = "T_OrderRefOutToM_BranchID";
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT COUNT(DISTINCT T_OrderHeaderID, IFNULL(b.T_SampleTypeID, a.T_SampleTypeID)) total
|
||||
FROM t_orderrefout
|
||||
JOIN t_orderheader ON T_OrderRefOutT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientId = M_PatientID
|
||||
JOIN t_orderdetail ON T_OrderRefOutT_OrderDetailID = T_OrderDetailID
|
||||
AND T_OrderDetailVerification = 'X' AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TEstID
|
||||
JOIN t_sampletype a ON T_TestT_SampleTypeID = a.T_SampleTypeID
|
||||
LEFT JOIN t_specimenlocal ON T_SpecimenLocalNat_TestID = T_TestNat_TestID
|
||||
AND T_SpecimenLocalIsActive = 'Y'
|
||||
LEFT JOIN t_sampletype b ON b.T_SampleTypeID = T_SpecimenLocalT_SampleTypeID
|
||||
WHERE T_OrderRefOutIsActive = 'Y'
|
||||
AND T_OrderRefOutIsConfirm = 'N'
|
||||
AND {$q_wh_company} = ?
|
||||
AND T_OrderRefOutDate >= DATE_SUB(now(), INTERVAL 30 DAY)
|
||||
AND (T_OrderHeaderLabNumber LIKE ? OR M_PatientName LIKE ?)";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($q['company_id'], $q['search'], $q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Ref Out count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT GROUP_CONCAT(T_OrderRefOutID SEPARATOR ',') T_OrderRefOutID,
|
||||
T_OrderDetailID, T_OrderHeaderId, T_OrderHeaderLabNumber,
|
||||
GROUP_CONCAT(T_TestID) T_TestID, GROUP_CONCAT(T_TestName) T_TestName,
|
||||
IFNULL(b.T_SampleTypeID, a.T_SampleTypeID) T_SampleTypeID,
|
||||
IFNULL(b.T_SampleTypeName, a.T_SampleTypeName) T_SampleTypeName,
|
||||
fn_global_patient_name(T_OrderHeaderM_PatientID) patient_name
|
||||
FROM t_orderrefout
|
||||
JOIN t_orderheader ON T_OrderRefOutT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientId = M_PatientID
|
||||
JOIN t_orderdetail ON T_OrderRefOutT_OrderDetailID = T_OrderDetailID
|
||||
AND T_OrderDetailVerification = 'X' AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TEstID
|
||||
JOIN t_sampletype a ON T_TestT_SampleTypeID = a.T_SampleTypeID
|
||||
LEFT JOIN t_specimenlocal ON T_SpecimenLocalNat_TestID = T_TestNat_TestID
|
||||
AND T_SpecimenLocalIsActive = 'Y'
|
||||
LEFT JOIN t_sampletype b ON b.T_SampleTypeID = T_SpecimenLocalT_SampleTypeID
|
||||
WHERE T_OrderRefOutIsActive = 'Y'
|
||||
AND T_OrderRefOutIsConfirm = 'N'
|
||||
AND {$q_wh_company} = ?
|
||||
AND T_OrderRefOutDate >= DATE_SUB(now(), INTERVAL 30 DAY)
|
||||
AND (T_OrderHeaderLabNumber LIKE ? OR M_PatientName LIKE ?)
|
||||
GROUP BY T_OrderHeaderID, T_SampleTypeID
|
||||
ORDER BY T_OrderHeaderLabNumber DESC
|
||||
limit {$offset}, {$max_rst}";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($q['company_id'], $q['search'], $q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "total_page" => ceil($tot_count/$max_rst), "cur_page" => $page, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Ref Out rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 10;
|
||||
$tot_count = 0;
|
||||
$search = isset($prm['search']) ? "%{$prm['search']}%" : '%';
|
||||
|
||||
$q_lj_company = "JOIN m_company ON T_OrderRefOutToM_CompanyID = M_CompanyID AND M_CompanyIsLabTo = 'Y'";
|
||||
$q_cn_company = "M_CompanyID";
|
||||
$q_cn_company_name = "M_CompanyName";
|
||||
if ($prm['is_internal'] == 'Y') {
|
||||
$q_lj_company = "JOIN m_branch ON T_OrderRefOutToM_BranchID = M_BranchID";
|
||||
$q_cn_company = "M_BranchID";
|
||||
$q_cn_company_name = "M_BranchName";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT COUNT(DISTINCT {$q_cn_company}) total
|
||||
FROM t_orderrefout
|
||||
JOIN t_orderdetail ON T_OrderRefOutT_OrderDetailID = T_OrderDetailID
|
||||
{$q_lj_company}
|
||||
WHERE T_OrderRefOutDate >= DATE_SUB(now(), INTERVAL 30 DAY)
|
||||
AND T_OrderRefOutIsActive = 'Y'
|
||||
AND T_OrderRefOutIsConfirm = 'N'
|
||||
AND T_OrderDetailVerification = 'X'
|
||||
AND T_OrderRefOutIsInternal = ?
|
||||
AND {$q_cn_company_name} LIKE ?";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['is_internal'], $search));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Order Ref Out count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$q_sl_company = "M_CompanyID company_id, M_CompanyName company_name";
|
||||
if ($prm['is_internal'] == "Y")
|
||||
$q_sl_company = "M_BranchID company_id, M_BranchName company_name";
|
||||
|
||||
$sql = "SELECT T_OrderRefOutID, {$q_sl_company}
|
||||
FROM t_orderrefout
|
||||
JOIN t_orderdetail ON T_OrderRefOutT_OrderDetailID = T_OrderDetailID
|
||||
{$q_lj_company}
|
||||
WHERE T_OrderRefOutDate >= DATE_SUB(now(), INTERVAL 30 DAY)
|
||||
AND T_OrderRefOutIsActive = 'Y'
|
||||
AND T_OrderRefOutIsConfirm = 'N'
|
||||
AND T_OrderDetailVerification = 'X'
|
||||
AND T_OrderRefOutIsInternal = ?
|
||||
AND {$q_cn_company_name} LIKE ?
|
||||
GROUP BY {$q_cn_company}
|
||||
limit 0, {$max_rst}";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['is_internal'], $search));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => "");
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Order Ref Out rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function send()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 10;
|
||||
$tot_count = 0;
|
||||
|
||||
$this->db_smartone->trans_start();
|
||||
|
||||
// HEADER
|
||||
$sql = "INSERT INTO t_orderrefoutheader(T_OrderRefOutHeaderDate, T_OrderRefOutHeaderNumber, T_ORderRefOutHeaderUserID)
|
||||
SELECT now(), fn_numbering('REF.OUT'), ? as user_id";
|
||||
$query = $this->db_smartone->query($sql, [$this->sys_user['M_UserID']]);
|
||||
|
||||
if (!$query)
|
||||
{
|
||||
$this->sys_error_db("REF OUT SEND", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = $this->db_smartone->insert_id();
|
||||
|
||||
$sql = "UPDATE t_orderrefout
|
||||
SET T_OrderRefOutIsConfirm = 'Y', T_OrderRefOutT_OrderRefOutHeaderID = ?, T_OrderRefOutConfirmUserID = ?
|
||||
WHERe T_OrderRefOutID IN ({$prm['ids']})";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$id, $this->sys_user['M_UserID']]);
|
||||
|
||||
$this->db_smartone->trans_complete();
|
||||
|
||||
if ($query) {
|
||||
$this->sys_ok($prm['ids']);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Ref Out Confirm", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
191
one-api/application/controllers/mockup/refout/status/Status.php
Normal file
191
one-api/application/controllers/mockup/refout/status/Status.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
class Status extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "REF OUT STATUS API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 10;
|
||||
$tot_count =0;
|
||||
|
||||
$page = $prm['page'];
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
$q = [
|
||||
'search' => isset($prm['search']) ? "%{$prm['search']}%" : '%'
|
||||
];
|
||||
|
||||
$q_company = "m_company";
|
||||
if ($prm['is_internal'] == 'Y')
|
||||
$q_company = "m_branch";
|
||||
|
||||
$sql = "SELECT COUNT(T_OrderRefOutHeaderID) total
|
||||
FROM t_orderrefoutheader
|
||||
JOIN {$q_company} ON T_OrderRefOutHeader{$q_company}ID = {$q_company}ID
|
||||
LEFT JOIN m_courier ON T_OrderRefOutHeaderM_CourierID = M_CourierID
|
||||
LEFT JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
WHERE T_OrderRefOutHeaderIsSent = ?
|
||||
AND T_OrderRefOutHeaderIsActive = 'Y'
|
||||
AND ({$q_company}Name LIKE ? OR T_OrderRefOutHeaderNumber LIKE ?)";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['status'], $q['search'], $q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Ref Out Status count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT T_OrderRefOutHeaderID, T_OrderRefOutHeaderDate,
|
||||
{$q_company}ID company_id, {$q_company}Name company_name,
|
||||
T_OrderRefOutHeaderNumber, T_OrderRefOutHeaderIsSent,
|
||||
M_StaffID, M_StaffName, M_KelurahanName, M_DistrictName,
|
||||
M_CityName, M_ProvinceName, {$q_company}Address company_address,
|
||||
M_CourierID, M_StaffName
|
||||
FROM t_orderrefoutheader
|
||||
JOIN {$q_company} ON T_OrderRefOutHeader{$q_company}ID = {$q_company}ID
|
||||
LEFT JOIN m_courier ON T_OrderRefOutHeaderM_CourierID = M_CourierID
|
||||
LEFT JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
LEFT JOIN m_kelurahan ON {$q_company}M_KelurahanID = M_KelurahanID
|
||||
LEFT JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
LEFT JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
LEFT JOIN m_province ON M_CityM_ProvinceID = M_ProvinceID
|
||||
WHERE T_OrderRefOutHeaderIsSent = ?
|
||||
AND T_OrderRefOutHeaderIsActive = 'Y'
|
||||
AND ({$q_company}Name LIKE ? OR T_OrderRefOutHeaderNumber LIKE ?)
|
||||
limit {$offset}, {$max_rst}";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['status'], $q['search'], $q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "total_page" => ceil($tot_count/$max_rst), "cur_page" => $page, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Ref Out Status rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_sample()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 100;
|
||||
$tot_count =0;
|
||||
|
||||
$page = $prm['page'];
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
$q = [
|
||||
'search' => isset($prm['search']) ? "%{$prm['search']}%" : '%'
|
||||
];
|
||||
|
||||
$sql = "SELECT COUNT(T_OrderRefOutSampleID) total
|
||||
FROM t_orderrefoutsample
|
||||
JOIN t_orderrefoutheader ON T_OrderRefOutSampleT_OrderRefOutHeaderID = T_OrderRefOutHeaderID
|
||||
JOIN t_barcodelab ON T_OrderRefOutSampleT_BarcodeLabID = T_BarcodeLabID
|
||||
WHERE T_ORderRefOutSampleIsActive = 'Y'
|
||||
AND T_OrderRefOutSampleT_OrderRefOutHeaderID = ?";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['header_id']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Ref Out Status count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT T_OrderRefOutSampleID, T_BarcodeLabBarcode, T_SampleTypeName, 'N' selected
|
||||
FROM t_orderrefoutsample
|
||||
JOIN t_orderrefoutheader ON T_OrderRefOutSampleT_OrderRefOutHeaderID = T_OrderRefOutHeaderID
|
||||
JOIN t_barcodelab ON T_OrderRefOutSampleT_BarcodeLabID = T_BarcodeLabID
|
||||
JOIN t_sampletype ON T_OrderRefOutSampleT_SampleTypeID = T_SampleTypeID
|
||||
WHERE T_ORderRefOutSampleIsActive = 'Y'
|
||||
AND T_OrderRefOutSampleT_OrderRefOutHeaderID = ?
|
||||
limit {$offset}, {$max_rst}";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['header_id']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "total_page" => ceil($tot_count/$max_rst), "cur_page" => $page, "records" => $rows, "total_display" => sizeof($rows), "query" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Ref Out Status rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_courier()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 100;
|
||||
|
||||
$sql = "SELECT M_CourierID, M_StaffName
|
||||
FROM m_courier
|
||||
JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
WHERE M_CourierIsActive = 'Y'";
|
||||
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Ref Out Courier",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function send()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_refout_status_send(?, ?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['header_id'], $prm['ids'], $prm['courier_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
if ($row->status == "OK")
|
||||
{
|
||||
$this->sys_ok($row);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("Ref Out Confirm", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user