Initial import
This commit is contained in:
@@ -0,0 +1,574 @@
|
||||
<?php
|
||||
class XCourier extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Email API";
|
||||
/*truncate result_authorization;
|
||||
truncate result_office;
|
||||
truncate result_email;
|
||||
truncate t_orderauthorization;*/
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_join_result_email = '';
|
||||
$sql_having = 'AND status_done = "N"';
|
||||
$sql_where = '';
|
||||
|
||||
|
||||
if($prm['filter_status'] != 'ready'){
|
||||
$sql_having = ' AND status_done = "Y"';
|
||||
}
|
||||
|
||||
if($prm['name'] != ''){
|
||||
$sql_where .= " AND M_PatientName LIKE CONCAT('%','{$prm['name']}','%')";
|
||||
|
||||
}
|
||||
|
||||
if($prm['nolab'] != ''){
|
||||
$sql_where .= " AND T_OrderHeaderLabNumber LIKE CONCAT('%','{$prm['nolab']}','%')";
|
||||
|
||||
}
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
T_OrderHeaderID as orderid,
|
||||
T_OrderPromiseID as promiseid,
|
||||
T_OrderDeliveryID as orderdeliveryid,
|
||||
Nat_GroupID as group_id,
|
||||
CONCAT(T_OrderHeaderID,'.',T_OrderPromiseID) as uniqid,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
||||
DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as date_order,
|
||||
DATE_FORMAT(T_OrderPromiseDateTime,'%d-%m-%Y %H:%m') as date_promise,
|
||||
DATE(T_OrderPromiseDateTime) as raw_date_promise,
|
||||
'' as xgroups,
|
||||
fn_sum_print_by_order_promise(T_OrderHeaderID,T_OrderPromiseID) as sum_print,
|
||||
fn_result_handling_check_done(T_OrderHeaderID,T_OrderPromiseID) as status_done,
|
||||
fn_result_handling_check_status_verification(T_OrderHeaderID) as check_ver_status,
|
||||
fn_result_handling_color_row(T_OrderPromiseDateTime) as color_row,
|
||||
IFNULL(M_StaffName,'Belum ditentukan') as courier_name,
|
||||
IFNULL(M_StaffID,0) as courier_value
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
JOIN t_orderdelivery ON T_OrderDeliveryT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_OrderDeliveryM_DeliveryTypeID = 2 AND T_OrderDeliveryIsActive = 'Y'
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID AND T_OrderPromiseIsActive = 'Y'
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
LEFT JOIN result_courierspk_detail ON Result_CourierSPKDetailT_OrderDeliveryID = T_OrderDeliveryID AND Result_CourierSPKDetailIsActive = 'Y'
|
||||
LEFT JOIN result_courierspk ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
||||
LEFT JOIN m_courier ON Result_CourierSPKM_CourierID = M_CourierID
|
||||
LEFT JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
$sql_join_result_office
|
||||
WHERE
|
||||
T_OrderDetailIsActive = 'Y' AND
|
||||
T_OrderPromiseDateTime < CONCAT('{$prm['datepromise']}',' 23:59:59')
|
||||
$sql_where
|
||||
GROUP BY T_OrderHeaderID, T_OrderPromiseID
|
||||
HAVING check_ver_status <> 0 $sql_having
|
||||
ORDER BY T_OrderPromiseDateTime ASC, T_OrderHeaderID ASC
|
||||
) xs
|
||||
";
|
||||
//echo $sql;
|
||||
$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("t_samplestorageout count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
T_OrderHeaderID as orderid,
|
||||
T_OrderPromiseID as promiseid,
|
||||
T_OrderDeliveryID as orderdeliveryid,
|
||||
Nat_GroupID as group_id,
|
||||
CONCAT(T_OrderHeaderID,'.',T_OrderPromiseID) as uniqid,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
||||
DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as date_order,
|
||||
DATE_FORMAT(T_OrderPromiseDateTime,'%d-%m-%Y %H:%m') as date_promise,
|
||||
DATE(T_OrderPromiseDateTime) as raw_date_promise,
|
||||
'' as xgroups,
|
||||
fn_sum_print_by_order_promise(T_OrderHeaderID,T_OrderPromiseID) as sum_print,
|
||||
fn_result_handling_check_done(T_OrderHeaderID,T_OrderPromiseID) as status_done,
|
||||
fn_result_handling_check_status_verification(T_OrderHeaderID) as check_ver_status,
|
||||
fn_result_handling_color_row(T_OrderPromiseDateTime) as color_row,
|
||||
IFNULL(M_StaffName,'Belum ditentukan') as courier_name,
|
||||
IFNULL(M_StaffID,0) as courier_value
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
JOIN t_orderdelivery ON T_OrderDeliveryT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_OrderDeliveryM_DeliveryTypeID = 2 AND T_OrderDeliveryIsActive = 'Y'
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID AND T_OrderPromiseIsActive = 'Y'
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
LEFT JOIN result_courierspk_detail ON Result_CourierSPKDetailT_OrderDeliveryID = T_OrderDeliveryID AND Result_CourierSPKDetailIsActive = 'Y'
|
||||
LEFT JOIN result_courierspk ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
||||
LEFT JOIN m_courier ON Result_CourierSPKM_CourierID = M_CourierID
|
||||
LEFT JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
$sql_join_result_office
|
||||
WHERE
|
||||
T_OrderDetailIsActive = 'Y' AND
|
||||
T_OrderPromiseDateTime < CONCAT('{$prm['datepromise']}',' 23:59:59')
|
||||
$sql_where
|
||||
GROUP BY T_OrderHeaderID, T_OrderPromiseID
|
||||
HAVING check_ver_status <> 0 $sql_having
|
||||
ORDER BY T_OrderPromiseDateTime ASC, T_OrderHeaderID ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$sql = "SELECT IF(T_TestIsNonLab = '','LAB',T_TestIsNonLab) as xgroup,
|
||||
SUM(T_OrderDetailPrintCount) as print_count,
|
||||
fn_result_handling_get_cout_print_by_type(T_OrderDetailT_OrderHeaderID,T_OrderDetailT_OrderPromiseID,T_TestIsNonLab) as print_type,
|
||||
fn_result_handling_status_button(T_OrderDetailT_OrderHeaderID,T_OrderDetailT_OrderPromiseID,T_TestIsNonLab) as status,
|
||||
fn_check_delivery_other_from_fo('{$v['orderid']}','{$v['promiseid']}','{$v['raw_date_promise']}') as fo_authorize
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$v['orderid']} AND
|
||||
T_OrderDetailT_OrderPromiseID = {$v['promiseid']} AND
|
||||
T_OrderDetailT_TestIsResult = 'Y' AND
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY T_TestIsNonLab";
|
||||
//echo $sql;
|
||||
|
||||
|
||||
$rows[$k]['xgroups'] = $this->db_onedev->query($sql)->result();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$tot_count = 25;
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getstaffs(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_StaffID as id, M_StaffName as name
|
||||
FROM m_staff
|
||||
WHERE
|
||||
M_StaffIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['staffs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doauthorization(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($prm['type'] == 'LAB'){
|
||||
$prm['type'] = '';
|
||||
}
|
||||
$sql = "INSERT INTO result_authorization (
|
||||
Result_AuthorizationDateTime,
|
||||
Result_AuthorizationM_StaffID,
|
||||
Result_AuthorizationT_OrderHeaderID,
|
||||
Result_AuthorizationT_OrderPromiseID,
|
||||
Result_AuthorizationNat_GroupID,
|
||||
Result_AuthorizationT_TestIsNonLab,
|
||||
Result_AuthorizationUserID,
|
||||
Result_AuthorizationCreated
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
{$prm['staff']['id']},
|
||||
{$prm['orderid']},
|
||||
{$prm['promiseid']},
|
||||
{$prm['groupid']},
|
||||
'{$prm['type']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
$insert_auth = $this->db_onedev->query($sql);
|
||||
$id_auth = $this->db_onedev->insert_id();
|
||||
if($insert_auth){
|
||||
$sql = "SELECT T_OrderDetailID as id
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsNonLab = '{$prm['type']}'
|
||||
LEFT JOIN t_orderauthorization ON T_OrderAuthorizationT_OrderDetailID = T_OrderDetailID AND T_OrderAuthorizationIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailPrintCount > 0 AND T_OrderDetailT_OrderHeaderID = {$prm['orderid']} AND
|
||||
T_OrderDetailT_OrderPromiseID = {$prm['promiseid']} AND
|
||||
T_OrderDetailT_TestIsResult = 'Y' AND
|
||||
ISNULL(T_OrderAuthorizationID) AND T_OrderDetailIsActive = 'Y'";
|
||||
// echo $sql;
|
||||
$dt_rst_detail = $this->db_onedev->query($sql)->result();
|
||||
foreach($dt_rst_detail as $k => $v){
|
||||
$sql = "INSERT INTO t_orderauthorization (
|
||||
T_OrderAuthorizationT_OrderDetailID,
|
||||
T_OrderAuthorizationResult_AuthorizationID,
|
||||
T_OrderAuthorizationCreated,
|
||||
T_OrderAuthorizationUserID
|
||||
)
|
||||
VALUES(
|
||||
{$v->id},
|
||||
{$id_auth},
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_orderdelivery WHERE T_OrderDeliveryM_DeliveryTypeID = 2 AND T_OrderDeliveryT_OrderHeaderID = {$prm['orderid']} AND T_OrderDeliveryIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$xrst_courier = $this->db_onedev->query($sql)->result_array();
|
||||
foreach($xrst_courier as $k => $v){
|
||||
$sql = "INSERT INTO result_courier (
|
||||
Result_CourierT_OrderHeaderID,
|
||||
Result_CourierT_OrderDeliveryID,
|
||||
Result_CourierT_OrderPromiseID,
|
||||
Result_CourierResult_AuthorizationID,
|
||||
Result_CourierIsNonLab,
|
||||
Result_CourierUserID,
|
||||
Result_CourierCreated
|
||||
)
|
||||
VALUES(
|
||||
{$prm['orderid']},
|
||||
{$v['T_OrderDeliveryID']},
|
||||
{$prm['promiseid']},
|
||||
{$id_auth},
|
||||
'{$prm['type']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
//echo $sql;
|
||||
$insert_ro = $this->db_onedev->query($sql);
|
||||
$id_rc = $this->db_onedev->insert_id();
|
||||
|
||||
$sql = "UPDATE result_courierspk_detail SET
|
||||
Result_CourierSPKDetailStatus = 'O'
|
||||
WHERE
|
||||
Result_CourierSPKDetailT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND Result_CourierSPKDetailT_OrderPromiseID = {$prm['promiseid']}
|
||||
AND Result_CourierSPKDetailStatus = 'N'
|
||||
AND Result_CourierSPKDetail = 'Y'";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function lookupsamples()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$search = $prm["search"];
|
||||
if($search){
|
||||
$sql_where = "WHERE ( T_OrderHeaderLabNumber LIKE CONCAT('%',?,'%') OR M_PatientName LIKE CONCAT('%',?,'%')) AND Summary_SampleStorageStatus = 'FILLED'";
|
||||
$sql_param = array($search,$search);
|
||||
}
|
||||
else{
|
||||
$sql_where = "WHERE Summary_SampleStorageStatus = 'FILLED'";
|
||||
$sql_param = array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM summary_samplestorage
|
||||
JOIN t_ordersample ON T_OrderSampleID = Summary_SampleStorageT_OrderSampleID
|
||||
JOIN t_orderheader ON T_OrderSampleT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_almari ON Summary_SampleStorageM_AlmariID = M_AlmariID
|
||||
JOIN m_rack ON Summary_SampleStorageM_AlmariID = M_RackID
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("t_samplestorageout count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT Summary_SampleStorageID as id,
|
||||
T_OrderSampleBarcode as barcode,
|
||||
'' as almari,
|
||||
'' as rack,
|
||||
Summary_SampleStorageRowPosition as row,
|
||||
Summary_SampleStorageColPosition as col,
|
||||
m_almari.*,
|
||||
m_rack.*,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, Summary_SampleStorageT_OrderSampleID as ordersampleid
|
||||
FROM summary_samplestorage
|
||||
JOIN t_ordersample ON T_OrderSampleID = Summary_SampleStorageT_OrderSampleID
|
||||
JOIN t_orderheader ON T_OrderSampleT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_almari ON Summary_SampleStorageM_AlmariID = M_AlmariID
|
||||
JOIN m_rack ON Summary_SampleStorageM_RackID = M_RackID
|
||||
$sql_where
|
||||
ORDER BY T_OrderHeaderID ASC
|
||||
limit 0,20";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result();
|
||||
if($rows){
|
||||
foreach($rows as $kx => $vx){
|
||||
$vx->almari = array('id'=>$vx->M_AlmariID,'name'=>'[ '.$vx->M_AlmariCode.' ] '.$vx->M_AlmariName,'code'=>$vx->M_AlmariCode);
|
||||
$vx->rack = array('id'=>$vx->M_RackID,'name'=>$vx->M_RackCode.' ( '.$vx->M_RackRows.' x '.$vx->M_RackColumns.' )','code'=>$vx->M_RackCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function lookupnonsamples()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$search = $prm["search"];
|
||||
if($search){
|
||||
$sql_where = "WHERE M_NonSampleName LIKE CONCAT('%',?,'%')) AND M_NonSampleIsActive = 'Y'";
|
||||
$sql_param = array($search,$search);
|
||||
}
|
||||
else{
|
||||
$sql_where = "WHERE M_NonSampleIsActive = 'Y'";
|
||||
$sql_param = array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM m_nonsample
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("t_samplestorageout count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT M_NonSampleID as id,
|
||||
M_NonSampleName as name
|
||||
FROM m_nonsample
|
||||
$sql_where
|
||||
ORDER BY M_NonSampleName ASC
|
||||
limit 0,20";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result();
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenewvendor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="INSERT INTO m_vendorsample (
|
||||
M_VendorSampleName,
|
||||
M_VendorSampleAddress,
|
||||
M_VendorSampleCreated,
|
||||
M_VendorSampleUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['vendor_name']}',
|
||||
'{$prm['vendor_address']}',
|
||||
NOW(),
|
||||
'{$userid}'
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$savevendor = $this->db_onedev->query($query);
|
||||
|
||||
$query =" SELECT M_VendorSampleID as id, M_VendorSampleName as name
|
||||
FROM m_vendorsample
|
||||
WHERE
|
||||
M_VendorSampleIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenewitem(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="INSERT INTO m_nonsample (
|
||||
M_NonSampleName,
|
||||
M_NonSampleCreated,
|
||||
M_NonSampleUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['name']}',
|
||||
NOW(),
|
||||
'{$userid}'
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$savevendor = $this->db_onedev->query($query);
|
||||
|
||||
$query =" SELECT M_NonSampleID as id, M_NonSampleName as name
|
||||
FROM m_nonsample
|
||||
WHERE
|
||||
M_NonSampleIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function searchstaff(){
|
||||
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_staff
|
||||
WHERE
|
||||
M_StaffName like ?
|
||||
AND M_StaffIsActive = '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_staff count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_staff
|
||||
WHERE
|
||||
M_StaffName like ?
|
||||
AND M_StaffIsActive = 'Y'
|
||||
ORDER BY M_StaffName DESC
|
||||
";
|
||||
$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_staff rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user