818 lines
24 KiB
PHP
818 lines
24 KiB
PHP
<?php
|
|
class Bestseller extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Test API";
|
|
}
|
|
|
|
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;
|
|
}
|
|
$code = $prm["scode"];
|
|
$nama = $prm["name"];
|
|
$prm['current_page'] = isset($prm['current_page'])?$prm['current_page']:1;
|
|
|
|
// echo $nik;
|
|
|
|
$sql_where = "WHERE T_TestIsActive = 'Y' AND T_TestIsPrice = 'Y' ";
|
|
$sql_param = array();
|
|
if ($nama != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " T_TestName like ? ";
|
|
$sql_param[] = "%$nama%";
|
|
}
|
|
if ($code != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " T_TestSasCode like ? ";
|
|
$sql_param[] = "%$code%";
|
|
}
|
|
|
|
//if ($sql_where != "") $sql_where .= " and ";
|
|
|
|
// Order masih dalam status registrasi
|
|
//$sql_where .= " M_StaffIsActive = 'Y' ";
|
|
$number_limit = 50;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
|
|
|
|
$sql = "SELECT count(*) as total
|
|
FROM t_test
|
|
LEFT JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
|
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
|
LEFT JOIN nat_test ON T_TestNat_TestID = Nat_TestID
|
|
LEFT JOIN nat_subsubgroup ON nat_subsubgroupID = Nat_Testnat_subsubgroupID
|
|
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
|
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
|
LEFT JOIN m_bestseller ON M_BestSellerT_TestID = T_TestID AND M_BestSellerIsActive = 'Y'
|
|
$sql_where
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
|
|
$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("m_doctor count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT *, T_TestIsNonLab as T_TestIsNonLabID,IF(T_TestIsNonLab = '', 'LAB',T_TestIsNonLab) as T_TestIsNonLabs, T_TestSasCode as db_T_TestSasCode,
|
|
IF(ISNULL(M_BestSellerID),'N','Y') as status
|
|
FROM t_test
|
|
LEFT JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
|
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
|
LEFT JOIN nat_test ON T_TestNat_TestID = Nat_TestID
|
|
LEFT JOIN nat_subsubgroup ON nat_subsubgroupID = Nat_Testnat_subsubgroupID
|
|
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
|
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
|
LEFT JOIN m_bestseller ON M_BestSellerT_TestID = T_TestID AND M_BestSellerIsActive = 'Y'
|
|
$sql_where
|
|
ORDER BY T_TestSasCode ASC
|
|
limit $number_limit offset $number_offset";
|
|
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$rows = $query->result_array();
|
|
|
|
|
|
|
|
//$this->_add_address($rows);
|
|
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getsexreg(){
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM nat_group
|
|
WHERE
|
|
Nat_GroupIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM nat_subgroup
|
|
WHERE
|
|
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['groupid']}
|
|
";
|
|
//echo $query;
|
|
$rows['subgroupes'] = $this->db_onedev->query($query)->result_array();
|
|
$query =" SELECT *
|
|
FROM nat_subsubgroup
|
|
WHERE
|
|
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupSubGroupID = {$prm['subgroupid']}
|
|
";
|
|
//echo $query;
|
|
$rows['subsubgroupes'] = $this->db_onedev->query($query)->result_array();
|
|
$query =" SELECT *
|
|
FROM nat_testtype
|
|
WHERE
|
|
Nat_TestTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
|
$rows['nonlabs'] = array(array("T_TestIsNonLabID"=>"","T_TestIsNonLab"=>"LAB"),array("T_TestIsNonLabID"=>"XRAY","T_TestIsNonLab"=>"XRAY"), array("T_TestIsNonLabID"=>"USG","T_TestIsNonLab"=>"USG"),array("T_TestIsNonLabID"=>"ELECTROMEDIS","T_TestIsNonLab"=>"ELECTROMEDIS"));
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getsubgroup(){
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM nat_subgroup
|
|
WHERE
|
|
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['groupid']}
|
|
";
|
|
//echo $query;
|
|
$rows['subgroupes'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getsubsubgroup(){
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM nat_subsubgroup
|
|
WHERE
|
|
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupSubGroupID = {$prm['subgroupid']}
|
|
";
|
|
//echo $query;
|
|
$rows['subsubgroupes'] = $this->db_onedev->query($query)->result_array();
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getinitdatas(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$rows = [];
|
|
$query =" SELECT Nat_GroupID as id, Nat_GroupName as name
|
|
FROM nat_group
|
|
WHERE
|
|
Nat_GroupIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
|
/*$query =" SELECT Nat_SubGroupID as id, CONCAT('[ ',Nat_SubGroupCode,' ] ', Nat_SubGroupName) as name
|
|
FROM nat_subgroup
|
|
WHERE
|
|
Nat_SubGroupIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['subgroups'] = $this->db_onedev->query($query)->result_array();*/
|
|
$query =" SELECT T_TestTypeID as id, T_TestTypeName as name
|
|
FROM t_testtype
|
|
WHERE
|
|
T_TestTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
|
$rows['nonlabs'] = array(array("T_TestIsNonLabID"=>"","T_TestIsNonLab"=>"LAB"),array("T_TestIsNonLabID"=>"XRAY","T_TestIsNonLab"=>"XRAY"), array("T_TestIsNonLabID"=>"USG","T_TestIsNonLab"=>"USG"),array("T_TestIsNonLabID"=>"ELECTROMEDIS","T_TestIsNonLab"=>"ELECTROMEDIS"));
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function get_subgroups(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$rows = [];
|
|
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as name
|
|
FROM nat_subgroup
|
|
WHERE
|
|
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['id']}
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getracks(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$rows = [];
|
|
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
|
FROM summary_samplestorage
|
|
WHERE
|
|
Summary_SampleStorageStatus = 'FILLED'
|
|
";
|
|
//echo $query;
|
|
$filledrows = $this->db_onedev->query($query)->result_array();
|
|
$query =" SELECT {$prm['id']} as almariid,
|
|
M_RackID as id,
|
|
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
|
M_RackCode as code,
|
|
M_RackRows as row,
|
|
M_RackColumns as col,
|
|
'' as rackcontens
|
|
FROM m_rack
|
|
WHERE
|
|
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$datarows = $this->db_onedev->query($query)->result_array();
|
|
foreach($datarows as $k => $v){
|
|
$rows = $v['row'];
|
|
$cols = $v['col'];
|
|
$rackcontens = array();
|
|
for ($x = 1; $x <= $rows; $x++) {
|
|
$children = array();
|
|
for ($i = 1; $i <= $cols; $i++) {
|
|
$content = $x.' x '.$i;
|
|
$xrow = $x;
|
|
$xcol = $i;
|
|
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
|
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
|
}
|
|
array_push($rackcontens,$children);
|
|
}
|
|
$datarows[$k]['rackcontens'] = $rackcontens;
|
|
}
|
|
|
|
|
|
$result = array(
|
|
"total" => count($datarows) ,
|
|
"records" => $datarows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
|
|
function checkexistfilled($datas,$rackid,$row,$col){
|
|
$rtn = 'N';
|
|
foreach($datas as $k => $v){
|
|
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
|
$rtn = 'Y';
|
|
}
|
|
}
|
|
return $rtn;
|
|
}
|
|
|
|
|
|
function searchunit(){
|
|
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 nat_unit
|
|
WHERE
|
|
Nat_UnitName like ?
|
|
AND Nat_unitIsActive = '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 Nat_UnitId as id, Nat_UnitName as name
|
|
FROM nat_unit
|
|
WHERE
|
|
Nat_UnitName like ?
|
|
AND Nat_unitIsActive = 'Y'
|
|
ORDER BY Nat_UnitName 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 searchsample(){
|
|
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_sampletype
|
|
WHERE
|
|
T_SampleTypeName like ?
|
|
AND T_SampleTypeIsActive = '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_sampletype count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT T_SampleTypeID,T_SampleTypeName
|
|
FROM t_sampletype
|
|
WHERE
|
|
T_SampleTypeName like ?
|
|
AND T_SampleTypeIsActive = 'Y'
|
|
ORDER BY T_SampleTypeName 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("t_sampletype rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function save(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
if($prm['T_TestFontSize'] == '')
|
|
$prm['T_TestFontSize'] = 10;
|
|
|
|
if($prm['T_TestIsPrice'] == 'N')
|
|
$prm['T_TestIsPrintNota'] = 'N';
|
|
|
|
$query ="UPDATE t_test SET
|
|
T_TestSasCode = '{$prm['T_TestSasCode']}',
|
|
T_TestName = '{$prm['T_TestName']}',
|
|
T_TestShortName = '{$prm['T_TestShortName']}',
|
|
T_TestShortNameBarcode = '{$prm['T_TestShortNameBarcode']}',
|
|
T_TestNat_GroupID = '{$prm['T_TestNat_GroupID']}',
|
|
T_TestNat_SubgroupID = '{$prm['T_TestNat_SubgroupID']}',
|
|
T_TestT_SampleTypeID = '{$prm['T_TestT_SampleTypeID']}',
|
|
T_TestFontSize = '{$prm['T_TestFontSize']}',
|
|
T_TestFontColor = '{$prm['T_TestFontColor']}',
|
|
T_TestIsBold = '{$prm['T_TestIsBold']}',
|
|
T_TestIsItalic = '{$prm['T_TestIsItalic']}',
|
|
T_TestIsQuantitative = '{$prm['T_TestIsQuantitative']}',
|
|
T_TestIsDeltaCheck = '{$prm['T_TestIsDeltaCheck']}',
|
|
T_TestIsResult = '{$prm['T_TestIsResult']}',
|
|
T_TestIsPrice = '{$prm['T_TestIsPrice']}',
|
|
T_TestIsPrintResult = '{$prm['T_TestIsPrintResult']}',
|
|
T_TestIsPrintNota = '{$prm['T_TestIsPrintNota']}',
|
|
T_TestIsTrendAnalysis = '{$prm['T_TestIsTrendAnalysis']}',
|
|
T_TestIsWorklist = '{$prm['T_TestIsWorklist']}',
|
|
T_TestIsNonLab = '{$prm['T_TestIsNonLab']}',
|
|
T_TestWorklistName = '{$prm['T_TestWorklistName']}',
|
|
T_TestMaxDiscount = '{$prm['T_TestMaxDiscount']}'
|
|
WHERE T_TestID = '{$prm['T_TestID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
if($rows){
|
|
}
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
function checkcodeexist(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$rtn = 'N';
|
|
$query =" SELECT COUNT(*) as countx
|
|
FROM t_test
|
|
WHERE T_TestCode = '{$prm['code']}' AND T_TestIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rst = $this->db_onedev->query($query)->row()->countx;
|
|
if($rst > 0)
|
|
$rtn = 'Y';
|
|
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => $rtn,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getdataselected(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$id = $prm['T_TestID'];
|
|
|
|
$query =" SELECT
|
|
T_TestCode as code,
|
|
T_TestName as name,
|
|
T_TestShortName as shortname,
|
|
T_TestShortNameBarcode as codebarcode,
|
|
'' as xgroup,
|
|
Nat_GroupID as group_id,
|
|
Nat_GroupName as group_name,
|
|
'' as subgroup,
|
|
Nat_SubGroupID as subgroup_id,
|
|
Nat_SubGroupName as subgroup_name,
|
|
'' as type,
|
|
T_TestT_TestTypeID as type_id,
|
|
T_TestTypeName as type_name,
|
|
'' as unit,
|
|
Nat_TestNat_UnitID as unit_id,
|
|
Nat_UnitName as unit_name,
|
|
'' as sample,
|
|
T_TestIsNonLab as nonlab,
|
|
T_TestT_SampleTypeID as sample_id,
|
|
T_SampleTypeName as sample_name,
|
|
T_TestFontSize as fontsize,
|
|
T_TestFontColor as fontcolor,
|
|
T_TestIsBold as flagbold,
|
|
T_TestIsItalic as flagitalic,
|
|
T_TestFlagGluc as flaggluc,
|
|
T_TestIsQuantitative as flagquantitative,
|
|
T_TestIsDeltaCheck as deltacheck,
|
|
T_TestIsResult as isresult,
|
|
T_TestIsPrice as isprice,
|
|
T_TestIsPrintResult as printresult,
|
|
T_TestIsPrintNota as printnote,
|
|
T_TestIsTrendAnalysis as trendanalysis,
|
|
T_TestIsWorklist as isworklist,
|
|
'N' as islongresult,
|
|
T_TestWorklistName as worklistname,
|
|
T_TestFlagLow as flaglow,
|
|
T_TestFlagHigh as flaghigh
|
|
FROM t_test
|
|
JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
|
JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
|
JOIN t_testtype ON T_TestT_TestTypeID = T_TestTypeID
|
|
LEFT JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
|
WHERE T_TestID = '{$id}'
|
|
";
|
|
//echo $query;
|
|
$rows['xform'] = $this->db_onedev->query($query)->row_array();
|
|
if($rows['xform']){
|
|
$rows['xform']['unit'] = array();
|
|
if($rows['xform']['isresult'] == 'Y')
|
|
$rows['xform']['unit'] = array('id'=>$rows['xform']['unit_id'],'name'=>$rows['xform']['unit_name']);
|
|
|
|
$rows['xform']['sample'] = array();
|
|
if($rows['xform']['isresult'] == 'Y')
|
|
$rows['xform']['sample'] = array('id'=>$rows['xform']['sample_id'],'name'=>$rows['xform']['sample_name']);
|
|
|
|
$rows['xform']['xgroup'] = array('id'=>$rows['xform']['group_id'],'name'=>$rows['xform']['group_name']);
|
|
$rows['xform']['subgroup'] = array('id'=>$rows['xform']['subgroup_id'],'name'=>$rows['xform']['subgroup_name']);
|
|
$rows['xform']['type'] = array('id'=>$rows['xform']['type_id'],'name'=>$rows['xform']['type_name']);
|
|
|
|
|
|
if($rows['xform']['nonlab'] == '')
|
|
$rows['xform']['nonlab'] = array('id'=>'','name'=>'LAB');
|
|
else
|
|
$rows['xform']['nonlab'] = array('id'=>$rows['xform']['nonlab'],'name'=>$rows['xform']['nonlab']);
|
|
|
|
unset($rows['xform']['sample_id']);
|
|
unset($rows['xform']['unit_id']);
|
|
unset($rows['xform']['group_id']);
|
|
unset($rows['xform']['subgroup_id']);
|
|
unset($rows['xform']['sample_name']);
|
|
unset($rows['xform']['unit_name']);
|
|
unset($rows['xform']['group_name']);
|
|
unset($rows['xform']['subgroup_name']);
|
|
}
|
|
|
|
$sql = "SELECT Nat_SubGroupID as id, Nat_SubGroupName as name FROM nat_subgroup WHERE Nat_SubGroupNat_GroupID = {$prm['Nat_GroupID']} AND Nat_SubGroupIsActive = 'Y'";
|
|
//echo $sql;
|
|
$rows['subgroups'] = $this->db_onedev->query($sql)->result_array();
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function doaddtest(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rtn = true;
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$codefrom = $prm['codefrom'];
|
|
$codetoward = $prm['codetoward'];
|
|
$leng = strlen($codetoward);
|
|
$code_parent = substr($codetoward, 0,-2);
|
|
$sql = "SELECT count(*) as existtest FROM t_test WHERE T_TestSasCode LIKE '{$code_parent}%' AND T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'";
|
|
//echo $sql;
|
|
$xcount = $this->db_onedev->query($sql)->row()->existtest;
|
|
if($xcount == 0){
|
|
$sql = "
|
|
select T_TestID ,T_TestSasCode,
|
|
case
|
|
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
|
else
|
|
concat( substr(T_TestSasCode,1,{$leng}) + 2 , substr(T_TestSasCode, {$leng} +1) )
|
|
end as NewCode,
|
|
T_TestName
|
|
from
|
|
t_test
|
|
where T_TestSasCode like '{$code_parent}%' AND length(T_TestSasCode) = {$leng} AND T_TestSasCode >= '{$codetoward}'
|
|
UNION
|
|
select T_TestID , T_TestSasCode,
|
|
case
|
|
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
|
else
|
|
concat( substr(T_TestSasCode,1,{$leng}) + 1 , substr(T_TestSasCode, {$leng} +1) )
|
|
end as NewCode,
|
|
T_TestName
|
|
from
|
|
t_test
|
|
where ( T_TestSasCode like '{$code_parent}%' AND T_TestSasCode > '{$codetoward}' ) OR T_TestSasCode = '{$codetoward}'
|
|
";
|
|
//echo $sql;
|
|
$toupdate = $this->db_onedev->query($sql)->result();
|
|
if($toupdate){
|
|
foreach($toupdate as $k => $v){
|
|
$sql = "UPDATE t_test SET T_TestSasCode = '{$v->NewCode}' WHERE T_TestID = {$v->T_TestID} ";
|
|
$this->db_onedev->query($sql);
|
|
}
|
|
}
|
|
|
|
$sql = "SELECT * FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y'";
|
|
$parentid = $this->db_onedev->query($sql)->row()->T_TestID;
|
|
|
|
$query ="INSERT INTO t_test (
|
|
T_TestParentT_TestID,
|
|
T_TestT_TestID,
|
|
T_TestCode,
|
|
T_TestSasCode,
|
|
T_TestName,
|
|
T_TestShortName,
|
|
T_TestShortNameBarcode,
|
|
T_TestNat_GroupID,
|
|
T_TestNat_SubGroupID,
|
|
T_TestT_SampleTypeID,
|
|
T_TestFontSize,
|
|
T_TestFontColor,
|
|
T_TestIsBold,
|
|
T_TestIsItalic,
|
|
T_TestFlagGluc,
|
|
T_TestIsQuantitative,
|
|
T_TestIsDeltaCheck,
|
|
T_TestIsResult,
|
|
T_TestIsPrice,
|
|
T_TestIsPrintResult,
|
|
T_TestIsPrintNota,
|
|
T_TestIsTrendAnalysis,
|
|
T_TestIsWorklist,
|
|
T_TestIsNonLab,
|
|
T_TestWorklistName,
|
|
T_TestFlagLow,
|
|
T_TestFlagHigh,
|
|
T_TestUserID,
|
|
T_TestCreated
|
|
)
|
|
SELECT
|
|
{$parentid},
|
|
T_TestID,
|
|
T_TestCode,
|
|
'{$codetoward}',
|
|
T_TestName,
|
|
T_TestShortName,
|
|
T_TestShortNameBarcode,
|
|
T_TestNat_GroupID,
|
|
T_TestNat_SubGroupID,
|
|
T_TestT_SampleTypeID,
|
|
T_TestFontSize,
|
|
T_TestFontColor,
|
|
T_TestIsBold,
|
|
T_TestIsItalic,
|
|
T_TestFlagGluc,
|
|
T_TestIsQuantitative,
|
|
T_TestIsDeltaCheck,
|
|
T_TestIsResult,
|
|
T_TestIsPrice,
|
|
T_TestIsPrintResult,
|
|
T_TestIsPrintNota,
|
|
T_TestIsTrendAnalysis,
|
|
T_TestIsWorklist,
|
|
T_TestIsNonLab,
|
|
T_TestWorklistName,
|
|
T_TestFlagLow,
|
|
T_TestFlagHigh,
|
|
{$userid},
|
|
NOW()
|
|
FROM t_test
|
|
WHERE
|
|
T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'
|
|
|
|
";
|
|
//echo $query;
|
|
$this->db_onedev->query($query);
|
|
$sql = "SELECT T_TestID FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y' LIMIT 1";
|
|
$data_parent = $this->db_onedev->query($sql)->row();
|
|
if($data_parent){
|
|
$testidparent = $data_parent->T_TestID;
|
|
$sql = "UPDATE t_test SET T_TestIsParent = 'Y' WHERE T_TestID = {$testidparent}";
|
|
$this->db_onedev->query($sql);
|
|
}
|
|
}
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => $xcount,
|
|
"debug"=>$query
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function check_exist_code(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "SELECT COUNT(*) as x_count FROM t_test WHERE T_TestSasCode = '{$prm['newcode']}' AND T_TestID <> {$prm['trx']['T_TestID']} AND T_TestIsActive = 'Y'";
|
|
//echo $sql;
|
|
$x_count = $this->db_onedev->query($sql)->row();
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => $x_count,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function checkedhs(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$sql = "SELECT * FROM `m_branch` WHERE `M_BranchIsDefault` = 'Y' LIMIT 1";
|
|
$data_cabang = $this->db_onedev->query($sql)->row_array();
|
|
|
|
foreach($prm['test'] as $k => $v){
|
|
if($v['status'] == 'Y'){
|
|
$sql = "INSERT INTO m_bestseller (
|
|
M_BestSellerM_BranchID,
|
|
M_BestSellerT_TestID,
|
|
M_BestSellerUserID,
|
|
M_BestSellerCreated,
|
|
M_BestSellerLastUpdated
|
|
)
|
|
VALUES (
|
|
{$data_cabang['M_BranchID']},
|
|
{$v['T_TestID']},
|
|
{$userid},
|
|
NOW(),
|
|
NOW()
|
|
)
|
|
ON DUPLICATE KEY UPDATE M_BestSellerIsActive = 'Y', M_BestSellerUserID = {$userid}, M_BestSellerLastUpdated = NOW() ";
|
|
}
|
|
else{
|
|
$sql = "UPDATE m_bestseller
|
|
SET M_BestSellerIsActive = 'N', M_BestSellerUserID = {$userid} , M_BestSellerLastUpdated = NOW()
|
|
WHERE
|
|
M_BestSellerM_BranchID = {$data_cabang['M_BranchID']} AND
|
|
M_BestSellerT_TestID = {$v['T_TestID']}";
|
|
}
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
}
|
|
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array()
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
} |