793 lines
22 KiB
PHP
793 lines
22 KiB
PHP
<?php
|
|
class Multirule extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Multirule API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
$this->load->helper(array('form', 'url'));
|
|
}
|
|
|
|
function getdetails($id){
|
|
$rows = [];
|
|
|
|
$sql = "SELECT Nat_MultiruleID,
|
|
Nat_MultiruleT_TestID,
|
|
Nat_MultiruleName,
|
|
Nat_MultiruleM_ValueID,
|
|
M_ValueName,
|
|
'' as criterias
|
|
FROM nat_multirule
|
|
LEFT JOIN m_value ON Nat_MultiruleM_ValueID = M_ValueID
|
|
WHERE Nat_MultiruleT_TestID = {$id} AND Nat_MultiruleIsActive = 'Y'";
|
|
//echo $sql;
|
|
$rows = $this->db_onedev->query($sql)->result_array();
|
|
return $rows;
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
$rows[$k]['criterias'] = $this->getcriterias($v['Nat_MultiruleID']);
|
|
}
|
|
}
|
|
|
|
}
|
|
function getcriterias($id){
|
|
$rows = [];
|
|
|
|
$sql = "SELECT Nat_MultiruleDetailID,
|
|
Nat_MultiruleDetailNat_MultiruleID,
|
|
Nat_MultiruleDetailT_TestID,
|
|
T_TestName
|
|
Nat_MultiruleDetailM_ValueID,
|
|
M_ValueName
|
|
FROM nat_multiruledetail
|
|
LEFT JOIN t_test ON Nat_MultiruleDetailT_TestID = T_TestID
|
|
LEFT JOIN m_value ON Nat_MultiruleDetailM_ValueID = M_ValueID
|
|
WHERE Nat_MultiruleDetailNat_MultiruleID = {$id} AND Nat_MultiruleDetailIsActive = 'Y'";
|
|
//echo $sql;
|
|
$rows = $this->db_onedev->query($sql)->result_array();
|
|
return $rows;
|
|
|
|
}
|
|
function lookupdetail(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$sql = "SELECT Nat_MultiruleDetailID,
|
|
Nat_MultiruleDetailNat_MultiruleID,
|
|
Nat_MultiruleDetailT_TestID,
|
|
T_TestName,
|
|
Nat_MultiruleDetailM_ValueID,
|
|
M_ValueName
|
|
FROM nat_multirule_detail
|
|
LEFT JOIN t_test ON Nat_MultiruleDetailT_TestID = T_TestID
|
|
LEFT JOIN m_value ON Nat_MultiruleDetailM_ValueID = M_ValueID
|
|
WHERE Nat_MultiruleDetailNat_MultiruleID = {$id} AND Nat_MultiruleDetailIsActive = 'Y'";
|
|
// echo $sql;
|
|
$rows = $this->db_onedev->query($sql)->result();
|
|
|
|
$result = array ("total" => count($rows), "records" => $rows);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function search()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$search = $prm["search"];
|
|
|
|
$sql_where = "WHERE T_TestIsResult = 'Y' AND T_TestIsActive = 'Y' AND T_TestIsQuantitative = 'Y'";
|
|
|
|
//$sql_param = array();
|
|
if ($search != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " ( T_TestCode like '%$search%' OR T_TestName like '%$search%' ) ";
|
|
}
|
|
|
|
|
|
$sql = " SELECT count(*) as total
|
|
FROM t_test
|
|
$sql_where
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
|
|
$tot_count = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
} else {
|
|
$this->sys_error_db("t_test count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT t_test.*, '' as details
|
|
FROM t_test
|
|
$sql_where
|
|
GROUP BY T_TestCode
|
|
ORDER BY T_TestCode ASC
|
|
limit 0,$tot_count";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
$rows = $query->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
$rows[$k]['details'] = $this->getdetails($v['T_TestID']);
|
|
}
|
|
}
|
|
|
|
|
|
//$this->_add_address($rows);
|
|
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function selectvaluex(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_value
|
|
WHERE
|
|
M_ValueIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['valuexs'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
function getordersamples(){
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$doctorid = $prm['doctorid'];
|
|
$doctoraddressid = $prm['doctoraddressid'];
|
|
$sql = "SELECT
|
|
0 as idx,
|
|
M_SexName,
|
|
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
|
T_SampleTypeName as samplename,
|
|
T_OrderHeaderLabNumber as labnumber,
|
|
T_OrderHeaderID as orderid,
|
|
T_SampleTypeID as sampleid,
|
|
'Y' as active,
|
|
'N' as flag_image
|
|
FROM t_samplingso
|
|
JOIN t_orderheader ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_sampletype ON T_SamplingSoT_SampleTypeID = T_SampleTypeID
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
|
WHERE
|
|
T_SamplingSoM_DoctorID = {$doctorid} AND T_SamplingSoM_DoctorAddressID = {$doctoraddressid} AND T_SamplingSoVerifyFlagWL = 'N' AND T_SamplingSoIsActive = 'Y'";
|
|
//echo $sql;
|
|
$rows = $this->db_onedev->query($sql)->result_array();
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
function getnormalvalue(){
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$methodeid = $prm['methodeid'];
|
|
/*$sql = "SELECT
|
|
0 as idx,
|
|
M_SexName,
|
|
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
|
T_SampleTypeName as samplename,
|
|
T_OrderHeaderLabNumber as labnumber,
|
|
T_OrderHeaderID as orderid,
|
|
T_SampleTypeID as sampleid,
|
|
'Y' as active,
|
|
'N' as flag_image
|
|
FROM t_samplingso
|
|
JOIN t_orderheader ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_sampletype ON T_SamplingSoT_SampleTypeID = T_SampleTypeID
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
|
WHERE
|
|
T_SamplingSoM_DoctorID = {$doctorid} AND T_SamplingSoM_DoctorAddressID = {$doctoraddressid} AND T_SamplingSoVerifyFlagWL = 'N' AND T_SamplingSoIsActive = 'Y'";
|
|
//echo $sql;
|
|
$rows = $this->db_onedev->query($sql)->result_array();*/
|
|
if($methodeid == 1){
|
|
$rows = array(
|
|
array(
|
|
'id'=>1,
|
|
'normalvalue_description'=>'
|
|
<span class="flex body-2 font-weight-black">MALE</span>
|
|
<span class="flex title font-weight-thin">[</span>
|
|
<span class="flex body-2 text-uppercase black--text">
|
|
7th - 14th
|
|
</span>
|
|
<span class="flex title font-weight-thin">]</span>
|
|
<span class="flex body-2 font-weight-black">0 - 51</span>',
|
|
'mininclusive'=>'N',
|
|
'minvalue'=>'0',
|
|
'maxinclusive'=>'N',
|
|
'maxvalue'=>'0',
|
|
'active'=>'Y'
|
|
),
|
|
array(
|
|
'id'=>2,
|
|
'normalvalue_description'=>'
|
|
<span class="flex body-2 font-weight-black">MALE</span>
|
|
<span class="flex title font-weight-thin">[</span>
|
|
<span class="flex body-2 text-uppercase black--text">
|
|
15th - 24th
|
|
</span>
|
|
<span class="flex title font-weight-thin">]</span>
|
|
<span class="flex body-2 font-weight-black">20 - 60</span>',
|
|
'mininclusive'=>'N',
|
|
'minvalue'=>'0',
|
|
'maxinclusive'=>'N',
|
|
'maxvalue'=>'0',
|
|
'active'=>'Y'
|
|
),
|
|
array(
|
|
'id'=>3,
|
|
'normalvalue_description'=>'
|
|
<span class="flex body-2 font-weight-black">FEMALE</span>
|
|
<span class="flex title font-weight-thin">[</span>
|
|
<span class="flex body-2 text-uppercase black--text">
|
|
7th - 14th
|
|
</span>
|
|
<span class="flex title font-weight-thin">]</span>
|
|
<span class="flex body-2 font-weight-black">0 - 31</span>',
|
|
'mininclusive'=>'N',
|
|
'minvalue'=>'0',
|
|
'maxinclusive'=>'N',
|
|
'maxvalue'=>'0',
|
|
'active'=>'Y'
|
|
),
|
|
array(
|
|
'id'=>4,
|
|
'normalvalue_description'=>'
|
|
<span class="flex body-2 font-weight-black">FEMALE</span>
|
|
<span class="flex title font-weight-thin">[</span>
|
|
<span class="flex body-2 text-uppercase black--text">
|
|
15th - 24th
|
|
</span>
|
|
<span class="flex title font-weight-thin">]</span>
|
|
<span class="flex body-2 font-weight-black">10 - 60</span>',
|
|
'mininclusive'=>'N',
|
|
'minvalue'=>'0',
|
|
'maxinclusive'=>'N',
|
|
'maxvalue'=>'0',
|
|
'active'=>'Y'
|
|
)
|
|
);
|
|
}
|
|
|
|
if($methodeid == 2){
|
|
$rows = array(
|
|
array(
|
|
'id'=>1,
|
|
'normalvalue_description'=>'
|
|
<span class="flex body-2 font-weight-black">MALE</span>
|
|
<span class="flex title font-weight-thin">[</span>
|
|
<span class="flex body-2 text-uppercase black--text">
|
|
7th - 14th
|
|
</span>
|
|
<span class="flex title font-weight-thin">]</span>
|
|
<span class="flex body-2 font-weight-black">10 - 31</span>',
|
|
'mininclusive'=>'N',
|
|
'minvalue'=>'0',
|
|
'maxinclusive'=>'N',
|
|
'maxvalue'=>'0',
|
|
'active'=>'Y'
|
|
),
|
|
array(
|
|
'id'=>2,
|
|
'normalvalue_description'=>'
|
|
<span class="flex body-2 font-weight-black">MALE</span>
|
|
<span class="flex title font-weight-thin">[</span>
|
|
<span class="flex body-2 text-uppercase black--text">
|
|
15th - 24th
|
|
</span>
|
|
<span class="flex title font-weight-thin">]</span>
|
|
<span class="flex body-2 font-weight-black">20 - 40</span>',
|
|
'mininclusive'=>'N',
|
|
'minvalue'=>'0',
|
|
'maxinclusive'=>'N',
|
|
'maxvalue'=>'0',
|
|
'active'=>'Y'
|
|
),
|
|
array(
|
|
'id'=>3,
|
|
'normalvalue_description'=>'
|
|
<span class="flex body-2 font-weight-black">FEMALE</span>
|
|
<span class="flex title font-weight-thin">[</span>
|
|
<span class="flex body-2 text-uppercase black--text">
|
|
7th - 14th
|
|
</span>
|
|
<span class="flex title font-weight-thin">]</span>
|
|
<span class="flex body-2 font-weight-black">15 - 41</span>',
|
|
'mininclusive'=>'N',
|
|
'minvalue'=>'0',
|
|
'maxinclusive'=>'N',
|
|
'maxvalue'=>'0',
|
|
'active'=>'Y'
|
|
),
|
|
array(
|
|
'id'=>4,
|
|
'normalvalue_description'=>'
|
|
<span class="flex body-2 font-weight-black">FEMALE</span>
|
|
<span class="flex title font-weight-thin">[</span>
|
|
<span class="flex body-2 text-uppercase black--text">
|
|
15th - 24th
|
|
</span>
|
|
<span class="flex title font-weight-thin">]</span>
|
|
<span class="flex body-2 font-weight-black">30 - 60</span>',
|
|
'mininclusive'=>'N',
|
|
'minvalue'=>'0',
|
|
'maxinclusive'=>'N',
|
|
'maxvalue'=>'0',
|
|
'active'=>'Y'
|
|
)
|
|
);
|
|
}
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
|
|
}
|
|
|
|
function getgroups(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT Nat_GroupID as id, Nat_GroupName as title, CONCAT('GROUP : ',Nat_GroupName) as fulltitle, '' as childrens
|
|
FROM nat_group
|
|
WHERE
|
|
Nat_GroupIsActive = 'Y' AND ( Nat_GroupCode = 2 OR Nat_GroupCode = 3 )
|
|
";
|
|
//echo $query;
|
|
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
|
if($rows['groups']){
|
|
foreach($rows['groups'] as $k => $v){
|
|
$childrens = array(array('id'=>0, 'title'=>'Semua', 'fulltitle'=>'Subgroub : Semua'));
|
|
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as title, CONCAT('SUBGROUP : ',Nat_SubGroupName) as fulltitle
|
|
FROM nat_subgroup
|
|
WHERE
|
|
Nat_SubGroupNat_GroupID = {$v['id']} AND Nat_SubGroupIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$xrst = $this->db_onedev->query($query)->result_array();
|
|
if($xrst){
|
|
foreach($xrst as $ki => $vi){
|
|
array_push($childrens,$vi);
|
|
}
|
|
}
|
|
$rows['groups'][$k]['childrens'] = $childrens ;
|
|
}
|
|
}
|
|
$query =" SELECT M_LangID as id, M_LangName as name
|
|
FROM m_lang
|
|
WHERE
|
|
M_LangIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['langs'] = $this->db_onedev->query($query)->result_array();
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getsubgroups(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$rows = array(array('id'=>0, 'title'=>'Semua', 'fulltitle'=>'Subgroub : Semua'));
|
|
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as title, CONCAT('SUBGROUP : ',Nat_SubGroupName) as fulltitle
|
|
FROM nat_subgroup
|
|
WHERE
|
|
Nat_SubGroupNat_GroupID = {$prm['id']} AND Nat_SubGroupIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rst = $this->db_onedev->query($query)->result_array();
|
|
if($rst){
|
|
foreach($rst as $k => $v){
|
|
array_push($rows,$v);
|
|
}
|
|
}
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getstation(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT T_SampleStationID as id, T_SampleStationName as name
|
|
FROM t_samplestation
|
|
WHERE
|
|
T_SampleStationIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['stations'] = $this->db_onedev->query($query)->result_array();
|
|
//print_r($statuses);
|
|
foreach($statuses as $k=>$v){
|
|
array_push($rows['statuses'],$v);
|
|
}
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getdoctoraddress(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT M_DoctorAddressID as id, M_DoctorAddressDescription as name
|
|
FROM m_doctoraddress
|
|
WHERE
|
|
M_DoctorAddressM_DoctorID = {$prm['id']} AND M_DoctorAddressIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
public function savemultirule()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$testid = $prm['testid'];
|
|
$multirulename = $prm['multirulename'];
|
|
$valueid = $prm['valueid'];
|
|
|
|
$sql = "insert into nat_multirule(
|
|
Nat_MultiruleT_TestID,
|
|
Nat_MultiruleName,
|
|
Nat_MultiruleM_ValueID,
|
|
Nat_MultiruleCreated,
|
|
Nat_MultiruleLastUpdated
|
|
)
|
|
values( ?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$testid,
|
|
$multirulename,
|
|
$valueid
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_multirule insert");
|
|
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 savemultiruledetailold()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$testid = $prm['testid'];
|
|
$multiruleid = $prm['multiruleid'];
|
|
$valueid = $prm['valueid'];
|
|
|
|
$sql = "insert into nat_multiruledetail(
|
|
Nat_MultiruleDetailT_TestID,
|
|
Nat_MultiruleDetailNat_MultiruleID,
|
|
Nat_MultiruleDetailM_ValueID,
|
|
Nat_MultiruleDetailCreated,
|
|
Nat_MultiruleDetailLastUpdated
|
|
)
|
|
values( ?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$testid,
|
|
$multiruleid,
|
|
$valueid
|
|
)
|
|
);
|
|
echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_multiruledetail insert");
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
function savemultiruledetail(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$query ="INSERT INTO nat_multirule_detail (
|
|
Nat_MultiruleDetailT_TestID,
|
|
Nat_MultiruleDetailNat_MultiruleID,
|
|
Nat_MultiruleDetailM_ValueID,
|
|
Nat_MultiruleDetailCreated,
|
|
Nat_MultiruleDetailLastUpdated
|
|
)
|
|
VALUES(
|
|
'{$prm['testid']}',
|
|
'{$prm['multiruleid']}',
|
|
'{$prm['valueid']}',
|
|
NOW(),
|
|
now()
|
|
)
|
|
";
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
"id" => $last_id
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function searchtest(){
|
|
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_test
|
|
WHERE
|
|
T_TestName like ?
|
|
AND T_TestIsActive = 'Y'
|
|
AND T_TestIsResult = '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("t_test count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *
|
|
FROM t_test
|
|
WHERE
|
|
T_TestName like ?
|
|
AND T_TestIsActive = 'Y'
|
|
AND T_TestIsResult = 'Y'
|
|
ORDER BY T_TestName 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("t_test rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function deletetrx(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$query ="UPDATE so_walklettercourier SET
|
|
So_WalkLetterCourierIsActive = 'N',
|
|
So_WalkLetterCourierUserID = '{$userid}'
|
|
WHERE
|
|
So_WalkLetterCourierID = {$prm['trx_id']}
|
|
";
|
|
//echo $query;
|
|
$saveheader = $this->db_onedev->query($query);
|
|
$last_id = $prm['trx_id'];
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
"numbering" => $prm['trx_numbering'],
|
|
"id" => $prm['trx_id']
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
function doaction(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
if($prm['act'] == 'RELEASEC' || $prm['act'] === 'RCVDOC' ){
|
|
$sql = "UPDATE so_walklettercourier SET
|
|
So_WalkLetterCourierStatus = '{$prm['act']}',
|
|
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
|
So_WalkLetterCourierUserID = {$userid}
|
|
WHERE
|
|
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
|
";
|
|
$this->db_onedev->query($sql);
|
|
}
|
|
|
|
if($prm['act'] === 'DONE'){
|
|
$details = $prm['details'];
|
|
$count_n = 0;
|
|
foreach($details as $k => $v){
|
|
if($v['flag_image_receive'] === 'N'){
|
|
$count_n++;
|
|
}
|
|
if($v['flag_result_receive'] === 'N'){
|
|
$count_n++;
|
|
}
|
|
$query ="UPDATE so_walklettercourierdetail SET
|
|
So_WalkLetterCourierDetailFlagReceiveImage = '{$v['flag_image_receive']}',
|
|
So_WalkLetterCourierDetailFlagReceiveResult = '{$v['flag_result_receive']}',
|
|
So_WalkLetterCourierDetailUserID = '{$userid}'
|
|
WHERE
|
|
So_WalkLetterCourierDetailID = {$v['idx']}
|
|
";
|
|
//echo $query;
|
|
$savedetail = $this->db_onedev->query($query);
|
|
}
|
|
$status = 'DONE';
|
|
if($count_n > 0){
|
|
$status = 'PARTDONE';
|
|
}
|
|
$sql = "UPDATE so_walklettercourier SET
|
|
So_WalkLetterCourierStatus = '{$status}',
|
|
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
|
So_WalkLetterCourierUserID = {$userid}
|
|
WHERE
|
|
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
|
";
|
|
$this->db_onedev->query($sql);
|
|
}
|
|
|
|
if($prm['act'] == 'FORCEDONE'){
|
|
$sql = "UPDATE so_walklettercourier SET
|
|
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
|
So_WalkLetterCourierStatus = 'DONE',
|
|
So_WalkLetterCourierUserID = {$userid}
|
|
WHERE
|
|
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
|
";
|
|
$this->db_onedev->query($sql);
|
|
}
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
exit;
|
|
}
|
|
|
|
|
|
|
|
} |