Initial import
This commit is contained in:
878
application/controllers/v1/masterdata/Advicefisik.php
Normal file
878
application/controllers/v1/masterdata/Advicefisik.php
Normal file
@@ -0,0 +1,878 @@
|
||||
<?php
|
||||
|
||||
class Advicefisik extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "ABNORMAL API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupfisikbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$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 m_advice_fisik
|
||||
WHERE
|
||||
M_AdviceFisikIsActive = 'Y' AND
|
||||
M_AdviceFisikLabel like '%{$name}%'
|
||||
GROUP BY M_AdviceFisikID) a";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$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_advice_fisik count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT m_advice_fisik.*,
|
||||
M_AdviceFisikID as id
|
||||
from m_advice_fisik
|
||||
WHERE
|
||||
M_AdviceFisikIsActive = 'Y' AND
|
||||
M_AdviceFisikLabel like '%{$name}%'
|
||||
GROUP BY M_AdviceFisikID
|
||||
ORDER BY M_AdviceFisikLabel ASC
|
||||
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("m_advice_fisik 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 lookupadvicebyid(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$status = $prm['status'];
|
||||
$all = $prm['all'];
|
||||
$filter = '';
|
||||
if($status != 'A'){
|
||||
$filter .= "AND status = '{$status}' ";
|
||||
}else{
|
||||
$filter .= "";
|
||||
}
|
||||
$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 *, IF(IFNULL(Nat_AdvicefisikID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_fisik ON Nat_AdviceID = Nat_AdvicefisikNat_AdviceID AND Nat_AdvicefisikM_AdviceFisikID = $id AND Nat_AdvicefisikIsActive = 'Y'
|
||||
LEFT JOIN m_advice_fisik ON Nat_AdvicefisikM_AdviceFisikID = M_AdviceFisikID AND M_AdviceFisikIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' GROUP BY Nat_AdviceID) a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select Nat_AdviceID as id,
|
||||
Nat_AdviceID,
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdvicefisikID,
|
||||
M_AdviceFisikCode,
|
||||
M_AdviceFisikLabel,
|
||||
Nat_AdvicefisikM_AdviceFisikID,
|
||||
Nat_AdvicefisikNat_AdviceID,
|
||||
IF(IFNULL(Nat_AdvicefisikID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_fisik ON Nat_AdviceID = Nat_AdvicefisikNat_AdviceID AND Nat_AdvicefisikM_AdviceFisikID = $id AND Nat_AdvicefisikIsActive = 'Y'
|
||||
LEFT JOIN m_advice_fisik ON Nat_AdvicefisikM_AdviceFisikID = M_AdviceFisikID AND M_AdviceFisikIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y') a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter
|
||||
GROUP BY Nat_AdviceID
|
||||
ORDER BY Nat_AdviceID ASC
|
||||
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("nat_advice 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 listingadvice(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'
|
||||
ORDER BY Nat_AdviceID ASC
|
||||
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("nat_advice 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 getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM m_advice_fisiktype
|
||||
WHERE
|
||||
M_AdviceFisikTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['normalvaluetypees'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['flages'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['ageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['minageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['maxageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
||||
UNION
|
||||
SELECT Nat_SexID, Nat_SexName
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_sexs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
||||
UNION
|
||||
SELECT Nat_FlagID, Nat_FlagName
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['f_flags'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
||||
UNION
|
||||
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
||||
UNION
|
||||
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getstatus(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
|
||||
$query ="
|
||||
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
||||
UNION
|
||||
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
||||
UNION
|
||||
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
public function addnewfisik()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into m_advice_fisik(
|
||||
M_AdviceFisikCode,
|
||||
M_AdviceFisikLabel,
|
||||
M_AdviceFisikUserID,
|
||||
M_AdviceFisikCreated,
|
||||
M_AdviceFisikLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_advice_fisik insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function editfisik(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE m_advice_fisik SET
|
||||
M_AdviceFisikCode = '{$prm['code']}',
|
||||
M_AdviceFisikLabel = '{$prm['name']}',
|
||||
M_AdviceFisikUserID = {$userid}
|
||||
WHERE
|
||||
M_AdviceFisikID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
public function addnewadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$fisikid = $prm['fisikid'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into nat_advice(
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdviceUserID,
|
||||
Nat_AdviceCreated,
|
||||
Nat_AdviceLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$adviceina,
|
||||
$adviceeng,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_advice_fisik insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function saveaddeditadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$fisikid = $prm['fisikid'];
|
||||
$adviceid = $prm['Nat_AdviceID'];
|
||||
$advicefisikid = $prm['Nat_AdvicefisikID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($status == 'Y'){
|
||||
$sql = "insert into nat_advice_fisik(
|
||||
Nat_AdvicefisikM_AdviceFisikID,
|
||||
Nat_AdvicefisikNat_AdviceID,
|
||||
Nat_AdvicefisikUserID,
|
||||
Nat_AdvicefisikCreated,
|
||||
Nat_AdvicefisikLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fisikid,
|
||||
$adviceid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_fisik insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}else{
|
||||
$sql = "UPDATE nat_advice_fisik SET
|
||||
Nat_AdvicefisikIsActive = 'N',
|
||||
Nat_AdvicefisikUserID = ?,
|
||||
Nat_AdvicefisikCreated = now(),
|
||||
Nat_AdvicefisikLastUpdated = now()
|
||||
WHERE Nat_AdvicefisikID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$advicefisikid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_fisik insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveeditsaran(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE nat_advice SET
|
||||
Nat_AdviceIna = '{$prm['ina']}',
|
||||
Nat_AdviceEng = '{$prm['eng']}',
|
||||
Nat_AdviceIsActive = '{$prm['status']}',
|
||||
Nat_AdviceUserID = {$userid}
|
||||
WHERE
|
||||
Nat_AdviceID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
function savealladvice(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$details = $prm['details'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach($details as $k => $v){
|
||||
$query = "UPDATE nat_advice_fisik SET
|
||||
Nat_AdvicefisikM_AdviceFisikID = '{$v['Nat_AdvicefisikM_AdviceFisikID']}',
|
||||
Nat_AdvicefisikAdviceIna = '{$v['Nat_AdvicefisikAdviceIna']}',
|
||||
Nat_AdvicefisikAdviceEng = '{$v['Nat_AdvicefisikAdviceEng']}',
|
||||
Nat_AdvicefisikUserID = {$userid},
|
||||
Nat_AdvicefisikCreated = now(),
|
||||
Nat_AdvicefisikLastUpdated = now()
|
||||
WHERE Nat_AdvicefisikID = {$v['Nat_AdvicefisikID']}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
public function deletefisik()
|
||||
{
|
||||
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 m_advice_fisik SET
|
||||
M_AdviceFisikIsActive = 'N'
|
||||
WHERE
|
||||
M_AdviceFisikID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_advice_fisik delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update nat_advice_fisik SET
|
||||
Nat_AdvicefisikIsActive = 'N'
|
||||
WHERE
|
||||
Nat_AdvicefisikM_AdviceFisikID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_fisik 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 deleteadvice()
|
||||
{
|
||||
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 m_advice_fisik SET
|
||||
M_AdviceFisikIsActive = 'N'
|
||||
WHERE
|
||||
M_AdviceFisikID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_advice_fisik 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 searchfisik(){
|
||||
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_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = '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("nat_methode count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName 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("nat_methode rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchfisikbyname(){
|
||||
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_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = '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("nat_methode count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName 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("nat_methode rows",$this->db_onedev);
|
||||
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 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_test rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
863
application/controllers/v1/masterdata/Advicekelainan.php
Normal file
863
application/controllers/v1/masterdata/Advicekelainan.php
Normal file
@@ -0,0 +1,863 @@
|
||||
<?php
|
||||
|
||||
class Advicekelainan extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "ABNORMAL API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db_onedev = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupkelainanbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$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 mcu_kelainan
|
||||
WHERE
|
||||
Mcu_KelainanIsActive = 'Y' AND
|
||||
Mcu_KelainanName like '%{$name}%'
|
||||
GROUP BY Mcu_KelainanID) a";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$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("mcu_kelainan count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT mcu_kelainan.*,
|
||||
Mcu_KelainanID as id
|
||||
from mcu_kelainan
|
||||
WHERE
|
||||
Mcu_KelainanIsActive = 'Y' AND
|
||||
Mcu_KelainanName like '%{$name}%'
|
||||
GROUP BY Mcu_KelainanID
|
||||
ORDER BY Mcu_KelainanName ASC
|
||||
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("mcu_kelainan 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 lookupadvicebyid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$status = $prm['status'];
|
||||
$all = $prm['all'];
|
||||
$filter = '';
|
||||
if ($status != 'A') {
|
||||
$filter .= "AND status = '{$status}' ";
|
||||
} else {
|
||||
$filter .= "";
|
||||
}
|
||||
$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 *, IF(IFNULL(Nat_AdvicekelainanID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_kelainan ON Nat_AdviceID = Nat_AdvicekelainanNat_AdviceID AND Nat_AdvicekelainanMcu_KelainanID = $id AND Nat_AdvicekelainanIsActive = 'Y'
|
||||
LEFT JOIN mcu_kelainan ON Nat_AdvicekelainanMcu_KelainanID = Mcu_KelainanID AND Mcu_KelainanIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' GROUP BY Nat_AdviceID) a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select Nat_AdviceID as id,
|
||||
Nat_AdviceID,
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdvicekelainanID,
|
||||
Mcu_KelainanClasification,
|
||||
Mcu_KelainanName,
|
||||
Nat_AdvicekelainanMcu_KelainanID,
|
||||
Nat_AdvicekelainanNat_AdviceID,
|
||||
IF(IFNULL(Nat_AdvicekelainanID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_kelainan ON Nat_AdviceID = Nat_AdvicekelainanNat_AdviceID AND Nat_AdvicekelainanMcu_KelainanID = $id AND Nat_AdvicekelainanIsActive = 'Y'
|
||||
LEFT JOIN mcu_kelainan ON Nat_AdvicekelainanMcu_KelainanID = Mcu_KelainanID AND Mcu_KelainanIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y') a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter
|
||||
GROUP BY Nat_AdviceID
|
||||
ORDER BY Nat_AdviceID ASC
|
||||
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("nat_advice 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 listingadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'
|
||||
ORDER BY Nat_AdviceID ASC
|
||||
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("nat_advice 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 getsexreg()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query = " SELECT *
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT *
|
||||
FROM m_advice_fisiktype
|
||||
WHERE
|
||||
M_AdviceFisikTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['normalvaluetypees'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT *
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['flages'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['ageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['minageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['maxageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = "
|
||||
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
||||
UNION
|
||||
SELECT Nat_SexID, Nat_SexName
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_sexs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = "
|
||||
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
||||
UNION
|
||||
SELECT Nat_FlagID, Nat_FlagName
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['f_flags'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = "
|
||||
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
||||
UNION
|
||||
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
||||
UNION
|
||||
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function getstatus()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
|
||||
$query = "
|
||||
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
||||
UNION
|
||||
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
||||
UNION
|
||||
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
public function addnewkelainan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into mcu_kelainan(
|
||||
Mcu_KelainanClasification,
|
||||
Mcu_KelainanName,
|
||||
M_AdviceKelainanUserID,
|
||||
Mcu_KelainanCreated,
|
||||
Mcu_KelainanLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function editkelainan()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE mcu_kelainan SET
|
||||
Mcu_KelainanClasification = '{$prm['code']}',
|
||||
Mcu_KelainanName = '{$prm['name']}',
|
||||
M_AdviceKelainanUserID = {$userid}
|
||||
WHERE
|
||||
Mcu_KelainanID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
|
||||
if ($action) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function addnewadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$kelainanid = $prm['kelainanid'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into nat_advice(
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdviceUserID,
|
||||
Nat_AdviceCreated,
|
||||
Nat_AdviceLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$adviceina,
|
||||
$adviceeng,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function saveaddeditadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$kelainanid = $prm['kelainanid'];
|
||||
$adviceid = $prm['Nat_AdviceID'];
|
||||
$advicekelainanid = $prm['Nat_AdvicekelainanID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($status == 'Y') {
|
||||
$sql = "insert into nat_advice_kelainan(
|
||||
Nat_AdvicekelainanMcu_KelainanID,
|
||||
Nat_AdvicekelainanNat_AdviceID,
|
||||
Nat_AdvicekelainanUserID,
|
||||
Nat_AdvicekelainanCreated,
|
||||
Nat_AdvicekelainanLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$kelainanid,
|
||||
$adviceid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_kelainan insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE nat_advice_kelainan SET
|
||||
Nat_AdvicekelainanIsActive = 'N',
|
||||
Nat_AdvicekelainanUserID = ?,
|
||||
Nat_AdvicekelainanCreated = now(),
|
||||
Nat_AdvicekelainanLastUpdated = now()
|
||||
WHERE Nat_AdvicekelainanID = ?";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$userid,
|
||||
$advicekelainanid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_kelainan insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveeditsaran()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE nat_advice SET
|
||||
Nat_AdviceIna = '{$prm['ina']}',
|
||||
Nat_AdviceEng = '{$prm['eng']}',
|
||||
Nat_AdviceIsActive = '{$prm['status']}',
|
||||
Nat_AdviceUserID = {$userid}
|
||||
WHERE
|
||||
Nat_AdviceID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
|
||||
if ($action) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function savealladvice()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$details = $prm['details'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach ($details as $k => $v) {
|
||||
$query = "UPDATE nat_advice_kelainan SET
|
||||
Nat_AdvicekelainanMcu_KelainanID = '{$v['Nat_AdvicekelainanMcu_KelainanID']}',
|
||||
Nat_AdvicefisikAdviceIna = '{$v['Nat_AdvicefisikAdviceIna']}',
|
||||
Nat_AdvicefisikAdviceEng = '{$v['Nat_AdvicefisikAdviceEng']}',
|
||||
Nat_AdvicekelainanUserID = {$userid},
|
||||
Nat_AdvicekelainanCreated = now(),
|
||||
Nat_AdvicekelainanLastUpdated = now()
|
||||
WHERE Nat_AdvicekelainanID = {$v['Nat_AdvicekelainanID']}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
|
||||
if ($action) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function deletekelainan()
|
||||
{
|
||||
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 mcu_kelainan SET
|
||||
Mcu_KelainanIsActive = 'N'
|
||||
WHERE
|
||||
Mcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update nat_advice_kelainan SET
|
||||
Nat_AdvicekelainanIsActive = 'N'
|
||||
WHERE
|
||||
Nat_AdvicekelainanMcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_kelainan 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 deleteadvice()
|
||||
{
|
||||
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 mcu_kelainan SET
|
||||
Mcu_KelainanIsActive = 'N'
|
||||
WHERE
|
||||
Mcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan 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 searchkelainan()
|
||||
{
|
||||
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_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = '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("nat_methode count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName 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("nat_methode rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchkelainanbyname()
|
||||
{
|
||||
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_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = '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("nat_methode count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName 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("nat_methode rows", $this->db_onedev);
|
||||
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 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_test rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
523
application/controllers/v1/masterdata/Bahan.php
Normal file
523
application/controllers/v1/masterdata/Bahan.php
Normal file
@@ -0,0 +1,523 @@
|
||||
<?php
|
||||
|
||||
class Bahan extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "BAHAN API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
|
||||
function lookupsampletype(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select Nat_SampleTypeID as id,
|
||||
Nat_SampleTypeNat_BahanID as bahanid,
|
||||
Nat_SampleTypeCode as code,
|
||||
Nat_SampleTypeName as name,
|
||||
Nat_SampleTypeSuffix as suffix,
|
||||
'xxx' as action
|
||||
from nat_sampletype
|
||||
where
|
||||
Nat_SampleTypeNat_BahanID = {$id} AND Nat_SampleTypeIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db->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 lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_bahan
|
||||
where
|
||||
Nat_BahanIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select Nat_BahanID as id, Nat_BahanCode as code, Nat_BahanName as name, CONCAT('[ ',Nat_BahanCode,' ]',' ', Nat_BahanName) as description , 'xxx' as bahansampletype
|
||||
from nat_bahan
|
||||
where
|
||||
( Nat_BahanCode LIKE CONCAT('%','{$search}','%') OR
|
||||
Nat_BahanName LIKE CONCAT('%','{$search}','%')
|
||||
)AND
|
||||
Nat_BahanIsActive = 'Y' $limit";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("nat_bahan select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code_bahan = $prm['code'];
|
||||
$name_bahan = $prm['name'];
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanCode = '{$code_bahan}'";
|
||||
$exist_code = $this->db->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanName = '{$name_bahan}'";
|
||||
$exist_name = $this->db->query($query)->row()->exist;
|
||||
//echo $exist_name;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into nat_bahan(
|
||||
Nat_BahanCode,
|
||||
Nat_BahanName,
|
||||
Nat_BahanCreated,
|
||||
Nat_BahanLastUpdated
|
||||
)
|
||||
values( ?, ?, now(), now())";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan insert");
|
||||
exit;
|
||||
}
|
||||
$sql = "insert into t_bahan(
|
||||
T_BahanCode,
|
||||
T_BahanName,
|
||||
T_BahanCreated,
|
||||
T_BahanLastUpdated
|
||||
)
|
||||
values( ?, ?, now(), now())";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$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'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama 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 editbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_bahan = $prm['id'];
|
||||
$code_bahan = $prm['code'];
|
||||
$name_bahan = $prm['name'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanCode = '{$code_bahan}' AND Nat_BahanID <> {$id_bahan}";
|
||||
$exist_code = $this->db->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanName = '{$name_bahan}' AND Nat_BahanID <> {$id_bahan}";
|
||||
$exist_name = $this->db->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "update nat_bahan SET
|
||||
Nat_BahanCode = ?,
|
||||
Nat_BahanName = ?,
|
||||
Nat_BahanLastUpdated = now()
|
||||
where
|
||||
Nat_BahanID = ?
|
||||
";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan,
|
||||
$id_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan update");
|
||||
exit;
|
||||
}
|
||||
$sql = "update t_bahan SET
|
||||
T_BahanCode = ?,
|
||||
T_BahanName = ?,
|
||||
T_BahanLastUpdated = now()
|
||||
where
|
||||
T_BahanID = ?
|
||||
";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan,
|
||||
$id_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_bahan));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama 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 addnewsampletype()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$bahanid = $prm['bahanid'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$suffix = $prm['suffix'];
|
||||
//$agingonhold = $prm['agingonhold'];
|
||||
//$agingonholdtime = $prm['agingonholdtime'];
|
||||
// $sampleimgid = $prm['sampleimgid'];
|
||||
|
||||
|
||||
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeCode = '{$code}'";
|
||||
$exist_code = $this->db->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeName = '{$name}'";
|
||||
$exist_name = $this->db->query($query)->row()->exist;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into nat_sampletype(
|
||||
Nat_SampleTypeNat_BahanID,
|
||||
Nat_SampleTypeCode,
|
||||
Nat_SampleTypeName,
|
||||
Nat_SampleTypeSuffix,
|
||||
Nat_SampleTypeCreated,
|
||||
Nat_SampleTypeLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,now(),now())";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$bahanid,
|
||||
$code,
|
||||
$name,
|
||||
$suffix
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_sampletype insert");
|
||||
exit;
|
||||
}
|
||||
$sql = "insert into t_sampletype(
|
||||
T_SampleTypeT_BahanID,
|
||||
T_SampleTypeCode,
|
||||
T_SampleTypeName,
|
||||
T_SampleTypeSuffix,
|
||||
T_SampleTypeCreated,
|
||||
T_SampleTypeLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,now(),now())";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$bahanid,
|
||||
$code,
|
||||
$name,
|
||||
$suffix
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_sampletype insert");
|
||||
exit;
|
||||
}
|
||||
$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'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeCode = '{$code}' AND Nat_SampleTypeID <> {$prm['xid']}";
|
||||
$exist_code = $this->db->query($query)->row()->exist;
|
||||
//echo $query;
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeName = '{$name}' AND Nat_SampleTypeID <> {$prm['xid']}";
|
||||
$exist_name = $this->db->query($query)->row()->exist;
|
||||
//echo $query;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "UPDATE nat_sampletype SET Nat_SampleTypeCode = '{$code}', Nat_SampleTypeName = '{$name}', Nat_SampleTypeSuffix = '{$suffix}' WHERE Nat_SampleTypeID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
$sqllocal = "UPDATE t_sampletype SET T_SampleTypeCode = '{$code}', T_SampleTypeName = '{$name}', T_SampleTypeSuffix = '{$suffix}' WHERE T_SampleTypeID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$querylocal = $this->db->query($sqllocal);
|
||||
$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'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama 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 deletesampletype()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update nat_sampletype SET
|
||||
Nat_SampleTypeIsActive = 'N',
|
||||
Nat_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
Nat_SampleTypeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_sampletype delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update t_sampletype SET
|
||||
T_SampleTypeIsActive = 'N',
|
||||
T_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
T_SampleTypeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_sampletype 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 deletebahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update nat_bahan SET
|
||||
Nat_BahanIsActive = 'N',
|
||||
Nat_BahanLastUpdated = now()
|
||||
WHERE
|
||||
Nat_BahanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE nat_sampletype SET
|
||||
Nat_SampleTypeIsActive = 'N',
|
||||
Nat_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
Nat_SampleTypeNat_BahanID = ?
|
||||
";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_sampletype delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "UPDATE t_sampletype SET
|
||||
T_SampleTypeIsActive = 'N',
|
||||
T_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
T_SampleTypeNat_BahanID = ?
|
||||
";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_sampletype delete");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
754
application/controllers/v1/masterdata/Ekspose.php
Normal file
754
application/controllers/v1/masterdata/Ekspose.php
Normal file
@@ -0,0 +1,754 @@
|
||||
<?php
|
||||
class Ekspose extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage 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;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " Nat_TestCode LIKE CONCAT('{$search_code}','%') ";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " Nat_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (SELECT *
|
||||
FROM nat_test
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestID AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultID = 4
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
LEFT JOIN m_eksposi ON Nat_TestID = M_EksposiNat_TestID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
GROUP BY Nat_TestID) x
|
||||
";
|
||||
//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_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *, IFNULL(M_EksposiID,0) as eksposiid
|
||||
FROM nat_test
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestID AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultID = 4
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
LEFT JOIN m_eksposi ON Nat_TestID = M_EksposiNat_TestID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
GROUP BY Nat_TestID
|
||||
ORDER BY Nat_TestCode 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){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$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 Nat_TestTypeID as id, Nat_TestTypeName as name
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("id"=>"","name"=>"LAB"),array("id"=>"XRAY","name"=>"XRAY"), array("id"=>"USG","name"=>"USG"),array("id"=>"ELECTROMEDIS","name"=>"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 get_subsubgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name
|
||||
FROM nat_subsubgroup
|
||||
WHERE
|
||||
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupNat_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 nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_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("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_SampleTypeID as id, Nat_SampleTypeName as name
|
||||
FROM nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = 'Y'
|
||||
ORDER BY Nat_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("m_city 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"];
|
||||
$testid = $prm['id'];
|
||||
$expose = $prm['expose'];
|
||||
$tegangan = $prm['tegangan'];
|
||||
$arus = $prm['arus'];
|
||||
$waktu = $prm['waktu'];
|
||||
$mas = $prm['mas'];
|
||||
if($prm['eksposiid'] == 0){
|
||||
$sql = "insert into m_eksposi(
|
||||
M_EksposiNat_TestID,
|
||||
M_EksposiExpose,
|
||||
M_EksposiKV,
|
||||
M_EksposiMa,
|
||||
M_EksposiS,
|
||||
M_EksposiMaS,
|
||||
M_EksposiUserID,
|
||||
M_EksposiLastUpdated,
|
||||
M_EksposiCreated
|
||||
)
|
||||
values( ?,?,?,?,?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$expose,
|
||||
$tegangan,
|
||||
$arus,
|
||||
$waktu,
|
||||
$mas,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_eksposi insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
|
||||
//echo $query;
|
||||
$sql = "UPDATE m_eksposi SET M_EksposiExpose = '{$expose}', M_EksposiKV = '{$tegangan}',
|
||||
M_EksposiMa = '{$arus}',M_EksposiS = '{$waktu}',
|
||||
M_EksposiMaS = '{$mas}',
|
||||
M_EksposiUserID = '{$userid}' WHERE M_EksposiID = '{$prm['eksposiid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM nat_test
|
||||
WHERE Nat_TestCode = '{$prm['code']}' AND Nat_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['Nat_TestID'];
|
||||
|
||||
$query =" SELECT
|
||||
Nat_TestCode as code,
|
||||
Nat_TestName as name,
|
||||
Nat_TestShortName as shortname,
|
||||
Nat_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 subsubgroup,
|
||||
Nat_SubSubGroupID as subsubgroup_id,
|
||||
Nat_SubSubGroupName as subsubgroup_name,
|
||||
'' as type,
|
||||
Nat_TestNat_TestTypeID as type_id,
|
||||
Nat_TestTypeName as type_name,
|
||||
'' as unit,
|
||||
Nat_TestNat_UnitID as unit_id,
|
||||
Nat_UnitName as unit_name,
|
||||
'' as sample,
|
||||
Nat_TestIsNonLab as nonlab,
|
||||
Nat_TestNat_SampleTypeID as sample_id,
|
||||
Nat_SampleTypeName as sample_name,
|
||||
Nat_TestFontSize as fontsize,
|
||||
Nat_TestFontColor as fontcolor,
|
||||
Nat_TestIsBold as flagbold,
|
||||
Nat_TestIsItalic as flagitalic,
|
||||
Nat_TestFlagGluc as flaggluc,
|
||||
Nat_TestIsQuantitative as flagquantitative,
|
||||
Nat_TestIsDeltaCheck as deltacheck,
|
||||
Nat_TestIsResult as isresult,
|
||||
Nat_TestIsPrice as isprice,
|
||||
Nat_TestIsPrintResult as printresult,
|
||||
Nat_TestIsPrintNota as printnote,
|
||||
Nat_TestIsTrendAnalysis as trendanalysis,
|
||||
Nat_TestIsWorklist as isworklist,
|
||||
Nat_TestIsLongResult as islongresult,
|
||||
Nat_TestIsEkspertisi as isekspertisi,
|
||||
Nat_TestWorklistName as worklistname,
|
||||
Nat_TestFlagLow as flaglow,
|
||||
Nat_TestFlagHigh as flaghigh,
|
||||
'' as groupsprice,
|
||||
Nat_TestPriceSumToNat_TestID as selected_group_price,
|
||||
Nat_TestFlagMcu as selected_flag_mcu,
|
||||
IFNULL(M_EksposiID,0) as eksposiid,
|
||||
IFNULL(M_EksposiExpose,0) as expose,
|
||||
IFNULL(M_EksposiKV,0) as tegangan,
|
||||
IFNULL(M_EksposiMa,0) as arus,
|
||||
IFNULL(M_EksposiS,0) as waktu,
|
||||
IFNULL(M_EksposiMaS,0) as mas
|
||||
FROM nat_test
|
||||
JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
LEFT JOIN m_eksposi ON Nat_TestID = M_EksposiNat_TestID
|
||||
WHERE Nat_TestID = '{$id}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['xform'] = $this->db_onedev->query($query)->row_array();
|
||||
if($rows['xform']){
|
||||
if($rows['xform']['selected_flag_mcu'] == 'N')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'N','name'=>'Tidak ada');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'G')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Dengan perhitungan abnormal');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'A')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Sesuai hasil');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'C')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'C','name'=>'Berdasarkan SUBSUBGROUP');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'R')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'R','name'=>'Reaktif Tidak normal');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'P')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'P','name'=>'Positif Tidak normal');
|
||||
|
||||
$sevencode = substr($rows['xform']['code'],0,7);
|
||||
$sql = "SELECT 0 as id, '' as name
|
||||
UNION
|
||||
SELECT Nat_TestID as id, Nat_TestName as name FROM nat_test WHERE Nat_TestCode LIKE '{$sevencode}%'";
|
||||
$rows['xform']['groupsprice'] = $this->db_onedev->query($sql)->result_array();
|
||||
$selected_group_price = array();
|
||||
if($rows['xform']['groupsprice']){
|
||||
foreach($rows['xform']['groupsprice'] as $k =>$v){
|
||||
//echo $rows['xform']['selected_group_price'];echo '-';
|
||||
//echo $v['id'];echo '-';echo $rows['xform']['selected_group_price'];echo '&';
|
||||
if(intval($v['id']) == intval($rows['xform']['selected_group_price'])){
|
||||
//print_r($v);
|
||||
$selected_group_price = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows['xform']['selected_group_price'] = $selected_group_price;
|
||||
|
||||
$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']['subsubgroup'] = array('id'=>$rows['xform']['subsubgroup_id'],'name'=>$rows['xform']['subsubgroup_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']['subsubgroup_id']);
|
||||
unset($rows['xform']['sample_name']);
|
||||
unset($rows['xform']['unit_name']);
|
||||
unset($rows['xform']['group_name']);
|
||||
unset($rows['xform']['subgroup_name']);
|
||||
unset($rows['xform']['subsubgroup_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();
|
||||
|
||||
$sql = "SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name FROM nat_subsubgroup WHERE Nat_SubSubGroupSubGroupID = {$prm['Nat_SubGroupID']} AND Nat_SubSubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subsubgroups'] = $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_TestNat_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},
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
'{$codetoward}',
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM nat_test
|
||||
WHERE
|
||||
Nat_TestCode = '{$codefrom}' AND Nat_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;
|
||||
}
|
||||
}
|
||||
643
application/controllers/v1/masterdata/Groupresult.php
Normal file
643
application/controllers/v1/masterdata/Groupresult.php
Normal file
@@ -0,0 +1,643 @@
|
||||
<?php
|
||||
|
||||
class Groupresult extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "GROUP RESULT API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupdetailbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupresult = $prm['groupresult'];
|
||||
$detail = $prm['detail'];;
|
||||
$all = $prm['all'];
|
||||
$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 group_resultdetail
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultIsActive = 'Y'
|
||||
JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
Group_ResultName LIKE CONCAT('%','{$groupresult}','%') AND
|
||||
T_TestName LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultDetailIsActive = 'Y' GROUP BY Group_ResultDetailID) a";
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
$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("group_resultdetail count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Group_ResultDetailID as id,
|
||||
Group_ResultName,
|
||||
CONCAT('[',T_TestSasCode,'] ',T_TestName) T_TestName,
|
||||
group_resultdetail.*
|
||||
from group_resultdetail
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultIsActive = 'Y'
|
||||
JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
Group_ResultName LIKE CONCAT('%','{$groupresult}','%') AND
|
||||
T_TestName LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultDetailIsActive = 'Y'
|
||||
GROUP BY Group_ResultDetailID
|
||||
ORDER BY Group_ResultName ASC, T_TestName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("group_resultdetail 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 lookupdetailbyid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupresult = $prm['groupresult'];
|
||||
$detail = $prm['detail'];;
|
||||
$all = $prm['all'];
|
||||
$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 group_resultdetail
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultIsActive = 'Y'
|
||||
JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
($groupresult = 0 or ($groupresult > 0 and Group_ResultDetailGroup_ResultID = $groupresult)) AND
|
||||
T_TestName LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultDetailIsActive = 'Y' GROUP BY Group_ResultDetailID) a";
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
$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("group_resultdetail count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Group_ResultDetailID as id,
|
||||
Group_ResultName,
|
||||
CONCAT('[',T_TestSasCode,'] ',T_TestName) T_TestName,
|
||||
group_resultdetail.*
|
||||
from group_resultdetail
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultIsActive = 'Y'
|
||||
JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
($groupresult = 0 or ($groupresult > 0 and Group_ResultDetailGroup_ResultID = $groupresult)) AND
|
||||
T_TestName LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultDetailIsActive = 'Y'
|
||||
GROUP BY Group_ResultDetailID
|
||||
ORDER BY Group_ResultName ASC, T_TestName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("group_resultdetail 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 lookupgroupresultbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupresult = $prm['groupresult'];
|
||||
$detail = $prm['detail'];
|
||||
$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 group_result
|
||||
LEFT JOIN group_resultdetail ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultDetailIsActive = 'Y'
|
||||
LEFT JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
where
|
||||
Group_ResultName LIKE CONCAT('%','{$groupresult}','%') AND
|
||||
IFNULL(T_TestName,'') LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultIsActive = 'Y'
|
||||
GROUP BY Group_ResultID) a";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->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("group_result count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Group_ResultID as id,
|
||||
Group_ResultName as name,
|
||||
Group_ResultName as namex,
|
||||
IF(Group_ResultFlagPerTest = 'Y','Ya','Tidak') as ispertest,
|
||||
IF(Group_ResultFlagNonLab = 'Y','Ya','Tidak') as isnonlab,
|
||||
group_result.*
|
||||
from group_result
|
||||
LEFT JOIN group_resultdetail ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultDetailIsActive = 'Y'
|
||||
LEFT JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
where
|
||||
Group_ResultName LIKE CONCAT('%','{$groupresult}','%') AND
|
||||
IFNULL(T_TestName,'') LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultIsActive = 'Y'
|
||||
GROUP BY Group_ResultID
|
||||
ORDER BY Group_ResultName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("group_result 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 addnewgroupresult()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$ispertest = $prm['ispertest'];
|
||||
$isnonlab = $prm['isnonlab'];
|
||||
$sql = "insert into group_result(
|
||||
Group_ResultName,
|
||||
Group_ResultFlagPerTest,
|
||||
Group_ResultFlagNonLab
|
||||
)
|
||||
values( ?, ?, ?)";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$name,
|
||||
$ispertest,
|
||||
$isnonlab
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_result insert");
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db->insert_id();
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editgroupresult()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$ispertest = $prm['ispertest'];
|
||||
$isnonlab = $prm['isnonlab'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlcompany = "update group_result SET
|
||||
Group_ResultName = ?,
|
||||
Group_ResultFlagPerTest = ?,
|
||||
Group_ResultFlagNonLab = ?
|
||||
where
|
||||
Group_ResultID = ?
|
||||
";
|
||||
$querycompany = $this->db->query(
|
||||
$sqlcompany,
|
||||
array(
|
||||
$name,
|
||||
$ispertest,
|
||||
$isnonlab,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("group_result update");
|
||||
exit;
|
||||
}
|
||||
$result = array("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewdetail()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$groupresultid = $prm['groupresultid'];
|
||||
$testid = $prm['testid'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if ($groupresultid == 0 || $testid == 0) {
|
||||
$errors = array();
|
||||
if ($groupresultid == 0) {
|
||||
array_push($errors, array('field' => 'groupresult', 'msg' => 'Kelompok hasil dipilih dulu dong'));
|
||||
}
|
||||
if ($testid == 0) {
|
||||
array_push($errors, array('field' => 'test', 'msg' => 'Pemeriksaan dipilih dulu dong'));
|
||||
}
|
||||
$result = array("total" => -1, "errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
if ($prm['xid'] == 0) {
|
||||
$sql = "insert into group_resultdetail(
|
||||
Group_ResultDetailGroup_ResultID,
|
||||
Group_ResultDetailT_TestID)
|
||||
values(?,?)";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$groupresultid,
|
||||
$testid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_resultdetail insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE group_resultdetail SET Group_ResultDetailGroup_ResultID = '{$groupresultid}',
|
||||
Group_ResultDetailT_TestID = '{$testid}'
|
||||
WHERE Group_ResultDetailID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deletegroupresult()
|
||||
{
|
||||
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 group_result SET
|
||||
Group_ResultIsActive = 'N'
|
||||
WHERE
|
||||
Group_ResultID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_result delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update group_resultdetail SET
|
||||
Group_ResultDetailIsActive = 'N'
|
||||
WHERE
|
||||
Group_ResultDetailGroup_ResultID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_resultdetail 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 deletedetail()
|
||||
{
|
||||
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 group_resultdetail SET
|
||||
Group_ResultDetailIsActive = 'N'
|
||||
WHERE
|
||||
Group_ResultDetailID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_resultdetail 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 searchgroupresult()
|
||||
{
|
||||
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 group_result
|
||||
WHERE
|
||||
Group_ResultName like ?
|
||||
AND Group_ResultIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("group_result count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Group_ResultID, Group_ResultName
|
||||
FROM group_result
|
||||
WHERE
|
||||
Group_ResultName like ?
|
||||
AND Group_ResultIsActive = 'Y'
|
||||
ORDER BY Group_ResultName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("group_result rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchgroupresultbyname()
|
||||
{
|
||||
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 group_result
|
||||
WHERE
|
||||
Group_ResultName like ?
|
||||
AND Group_ResultIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("group_result count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Group_ResultID, Group_ResultName
|
||||
FROM group_result
|
||||
WHERE
|
||||
Group_ResultName like ?
|
||||
AND Group_ResultIsActive = 'Y'
|
||||
ORDER BY Group_ResultName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("group_result rows", $this->db);
|
||||
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->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);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT t_test.*, CONCAT('[',T_TestSasCode,'] ',T_TestName) as T_TestName
|
||||
FROM t_test
|
||||
WHERE
|
||||
CONCAT('[',T_TestCode,'] ',T_TestName) like ?
|
||||
AND T_TestIsActive = 'Y'
|
||||
ORDER BY T_TestName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->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);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
219
application/controllers/v1/masterdata/Methode.php
Normal file
219
application/controllers/v1/masterdata/Methode.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
class Methode extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$code = $prm["scode"];
|
||||
$nama = $prm["nama"];
|
||||
|
||||
// echo $nik;
|
||||
|
||||
$sql_where = "WHERE Nat_MethodeIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " Nat_MethodeName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
if ($code != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
if ($code == "xxx") {
|
||||
$sql_where .= " Nat_MethodeCode = Nat_MethodeOldCode ";
|
||||
$sql_param[] = "%$code%";
|
||||
} else {
|
||||
$sql_where .= " Nat_MethodeCode like ? ";
|
||||
$sql_param[] = "%$code%";
|
||||
}
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_StaffIsActive = 'Y' ";
|
||||
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_methode
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM nat_methode
|
||||
$sql_where
|
||||
ORDER BY Nat_MethodeCode ASC
|
||||
limit 0,$tot_count";
|
||||
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_methode($v['M_StaffID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['Nat_MethodePriority'] == '')
|
||||
$prm['Nat_MethodePriority'] = 0;
|
||||
|
||||
$query ="UPDATE nat_methode SET
|
||||
Nat_MethodeName = '{$prm['Nat_MethodeName']}',
|
||||
Nat_MethodeNameInResult = '{$prm['Nat_MethodeNameInResult']}',
|
||||
Nat_MethodeCode = '{$prm['Nat_MethodeCode']}',
|
||||
Nat_MethodePriority = '{$prm['Nat_MethodePriority']}',
|
||||
Nat_MethodeM_UserID = '{$userid}',
|
||||
Nat_MethodeLastUpdated = now()
|
||||
WHERE Nat_MethodeID = '{$prm['Nat_MethodeID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function newmethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
if($prm['Nat_MethodePriority'] == '')
|
||||
$prm['Nat_MethodePriority'] = 0;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO nat_methode (
|
||||
Nat_MethodeName,
|
||||
Nat_MethodeNameInResult,
|
||||
Nat_MethodeCode,
|
||||
Nat_MethodePriority,
|
||||
Nat_MethodeM_UserID,
|
||||
Nat_MethodeCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['Nat_MethodeName']}',
|
||||
'{$prm['Nat_MethodeNameInResult']}',
|
||||
'{$prm['Nat_MethodeCode']}',
|
||||
'{$prm['Nat_MethodePriority']}',
|
||||
'{$userid}',
|
||||
now()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function deletemethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE nat_methode SET
|
||||
Nat_MethodeIsActive = 'N'
|
||||
WHERE
|
||||
Nat_MethodeID = '{$prm['Nat_MethodeID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$query ="UPDATE nat_normalvalue SET
|
||||
Nat_NormalValueIsActive = 'N'
|
||||
WHERE
|
||||
Nat_NormalValueNat_MethodeID = '{$prm['Nat_MethodeID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$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 nat_methode
|
||||
WHERE Nat_MethodeCode = '{$prm['code']}' AND Nat_MethodeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_regional->query($query)->row()->countx;
|
||||
if($rst > 0)
|
||||
$rtn = 'Y';
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rtn,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
301
application/controllers/v1/masterdata/Natinstrumentmethode.php
Normal file
301
application/controllers/v1/masterdata/Natinstrumentmethode.php
Normal file
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
class Natinstrumentmethode extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "NatInstrumentMethode API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_one= $this->load->database("regional", true);
|
||||
}
|
||||
function list_instrument() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$search= "%" . $prm["search"] . "%";
|
||||
try {
|
||||
$sql = "select * from nat_instrument where Nat_InstrumentIsActive='Y' and Nat_InstrumentName like ? ORDER BY Nat_InstrumentCode ASC";
|
||||
$qry = $this->db_one->query($sql, array($search));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatInstrument List", $this->db_one);
|
||||
}
|
||||
}
|
||||
function list_test() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$search= "%" . $prm["search"] . "%";
|
||||
try {
|
||||
$sql = "select * from nat_test where Nat_TestIsResult = 'Y'
|
||||
and Nat_TestIsActive='Y' and Nat_TestName like ?";
|
||||
$qry = $this->db_one->query($sql, array($search));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatTest List", $this->db_one);
|
||||
}
|
||||
}
|
||||
function delete_instrument() {
|
||||
$param = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
try {
|
||||
$sql = "update nat_instrument
|
||||
set
|
||||
Nat_InstrumentIsActive = 'N'
|
||||
,Nat_InstrumentUserID = ?
|
||||
where
|
||||
Nat_InstrumentID= ?";
|
||||
|
||||
$id = $param["Nat_InstrumentID"];
|
||||
|
||||
$qry = $this->db_one->query($sql, array($userid,$id));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("Nat_Instrument save", $this->db_one);
|
||||
}
|
||||
}
|
||||
|
||||
function save_instrument() {
|
||||
$param = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($param["Nat_InstrumentID"] == 0 ) {
|
||||
//add
|
||||
try {
|
||||
$sql = "insert into nat_instrument( Nat_InstrumentCode, Nat_InstrumentName
|
||||
,Nat_InstrumentUserID)
|
||||
values (?, ?, ? )
|
||||
";
|
||||
$code= $param["Nat_InstrumentCode"];
|
||||
$name = $param["Nat_InstrumentName"];
|
||||
$qry = $this->db_one->query($sql, array($code, $name, $userid ));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$sql = "update nat_instrument
|
||||
set
|
||||
Nat_InstrumentCode = ?
|
||||
,Nat_InstrumentName = ?
|
||||
,Nat_InstrumentUserID = ?
|
||||
where
|
||||
Nat_InstrumentID= ?";
|
||||
|
||||
$id = $param["Nat_InstrumentID"];
|
||||
$code= $param["Nat_InstrumentCode"];
|
||||
$name = $param["Nat_InstrumentName"];
|
||||
|
||||
$qry = $this->db_one->query($sql, array($code, $name, $userid,
|
||||
$id));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("Nat_Instrument save", $this->db_one);
|
||||
}
|
||||
}
|
||||
}
|
||||
function save() {
|
||||
$param = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($param["M_InstrumentMethodeID"] == 0 ) {
|
||||
//add
|
||||
try {
|
||||
$sql = "insert into m_instrumentmethode(M_InstrumentMethodeNat_InstrumentID,
|
||||
M_InstrumentMethodeNat_MethodeID, M_InstrumentMethodeNat_TestID,
|
||||
M_InstrumentMethodeResultFormatSF, M_InstrumentMethodeResultFormatAboveSF,
|
||||
M_InstrumentMethodePriority,
|
||||
M_InstrumentMethodeUserID)
|
||||
values (?, ?, ?, ?, ?, ?, ? ) ";
|
||||
$instrumentID = $param["Nat_InstrumentID"];
|
||||
$methodeID= $param["Nat_MethodeID"];
|
||||
$testID= $param["Nat_TestID"];
|
||||
$resultFormatSF= $param["ResultFormatSF"];
|
||||
$resultFormatAboveSF= $param["ResultFormatAboveSF"];
|
||||
$priority = $param["Priority"];
|
||||
$sql_param = array($instrumentID, $methodeID, $testID,
|
||||
$resultFormatSF, $resultFormatAboveSF,
|
||||
$priority, $userid);
|
||||
|
||||
$qry = $this->db_one->query($sql, $sql_param );
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$sql = "update m_instrumentmethode set M_InstrumentMethodeNat_InstrumentID = ?, M_InstrumentMethodeNat_MethodeID =?,
|
||||
M_InstrumentMethodeNat_TestID =?, M_InstrumentMethodeResultFormatSF = ?,M_InstrumentMethodeResultFormatAboveSF = ? ,
|
||||
M_InstrumentMethodePriority = ? , M_InstrumentMethodeUserID = ?
|
||||
where M_InstrumentMethodeID = ? ";
|
||||
|
||||
$methodePxID = $param["M_InstrumentMethodeID"];
|
||||
$instrumentID = $param["Nat_InstrumentID"];
|
||||
$methodeID= $param["Nat_MethodeID"];
|
||||
$testID= $param["Nat_TestID"];
|
||||
$resultFormatSF= $param["ResultFormatSF"];
|
||||
$resultFormatAboveSF= $param["ResultFormatAboveSF"];
|
||||
$priority = $param["Priority"];
|
||||
if ($resultFormatSF == "") $resultFormatSF = "0.00";
|
||||
if ($resultFormatAboveSF == "") $resultFormatAboveSF = "0";
|
||||
|
||||
$sql_param = array($instrumentID, $methodeID, $testID, $resultFormatSF,
|
||||
$resultFormatAboveSF, $priority, $userID, $methodePxID);
|
||||
$qry = $this->db_one->query($sql,$sql_param );
|
||||
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
}
|
||||
}
|
||||
function list_methode() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$search= "%" . $prm["search"] . "%";
|
||||
try {
|
||||
$sql = "select * from nat_methode where Nat_MethodeIsActive='Y' and Nat_MethodeName like ?";
|
||||
$qry = $this->db_one->query($sql, array($search));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
}
|
||||
function list_methodepx() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$instrumentID = $prm["Nat_InstrumentID"] ;
|
||||
try {
|
||||
$sql = "select * , Nat_TestName, Nat_MethodeName
|
||||
from m_instrumentmethode
|
||||
join nat_test on Nat_TestID = M_InstrumentMethodeNat_TestID
|
||||
join nat_methode on Nat_MethodeID = M_InstrumentMethodeNat_MethodeID
|
||||
where M_InstrumentMethodeIsActive='Y'
|
||||
and M_InstrumentMethodeNat_InstrumentID = ?";
|
||||
$qry = $this->db_one->query($sql, array($instrumentID));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
}
|
||||
|
||||
function get_test_methode() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$id= $prm["Nat_TestID"] ;
|
||||
try {
|
||||
$sql = "select * from nat_test where Nat_TestID = ?";
|
||||
$qry = $this->db_one->query($sql, array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $test= $rows[0];
|
||||
|
||||
$id= $prm["Nat_MethodeID"] ;
|
||||
$sql = "select * from nat_methode where Nat_MethodeID= ?";
|
||||
$qry = $this->db_one->query($sql, array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $methode = $rows[0];
|
||||
|
||||
$result = array("status" => "OK" ,
|
||||
"data" => array("test" => $test , "methode" => $methode )
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$result = $this->sys_ok( array("status" => "ERR") );
|
||||
}
|
||||
} else {
|
||||
$result = $this->sys_ok( array("status" => "ERR") );
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("MethodePx delete", $this->db_one);
|
||||
}
|
||||
}
|
||||
function delete_methodepx() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$id= $prm["id"] ;
|
||||
try {
|
||||
$sql = "update
|
||||
m_instrumentmethode
|
||||
set M_InstrumentMethodeIsActive = 'N'
|
||||
where M_InstrumentMethodeID = ? ";
|
||||
$qry = $this->db_one->query($sql, array($id));
|
||||
if ($qry) {
|
||||
$result = array("records" => "");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("MethodePx delete", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("MethodePx delete", $this->db_one);
|
||||
}
|
||||
}
|
||||
}
|
||||
1355
application/controllers/v1/masterdata/Samplestation.php
Normal file
1355
application/controllers/v1/masterdata/Samplestation.php
Normal file
File diff suppressed because it is too large
Load Diff
277
application/controllers/v1/masterdata/Tbahan.php
Normal file
277
application/controllers/v1/masterdata/Tbahan.php
Normal file
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
|
||||
class Tbahan extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "SUB GROUP API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from t_bahan
|
||||
where
|
||||
T_BahanIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db->query($sql, $sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select T_BahanID as id,
|
||||
T_BahanCode as code,
|
||||
T_BahanName as name,
|
||||
T_BahanLangName as namelang,
|
||||
t_bahan.*
|
||||
from t_bahan
|
||||
where
|
||||
( T_BahanName LIKE CONCAT('%','{$search}','%') OR
|
||||
T_BahanCode LIKE CONCAT('%','{$search}','%')
|
||||
)AND
|
||||
T_BahanIsActive = 'Y'
|
||||
GROUP BY T_BahanID
|
||||
ORDER BY T_BahanID ASC $limit";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("t_bahan select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $total, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$namelang = $prm['namelang'];
|
||||
$code = $prm['code'];
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanCode = '{$code}'";
|
||||
$exist_code = $this->db->query($query)->row()->exist;
|
||||
if ($exist_code == 0) {
|
||||
$sql = "insert into t_bahan (
|
||||
T_BahanCode,
|
||||
T_BahanName,
|
||||
T_BahanLangName,
|
||||
T_BahanCreated,
|
||||
T_BahanLastUpdated
|
||||
)
|
||||
values( ?, ?, ?, now(), now())";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$namelang
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db->insert_id();
|
||||
} else {
|
||||
$errors = array();
|
||||
if ($exist_code != 0) {
|
||||
// array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
|
||||
$sql = "insert into t_bahan(
|
||||
T_BahanCode,
|
||||
T_BahanName,
|
||||
T_BahanLangName,
|
||||
T_BahanCreated,
|
||||
T_BahanLastUpdated
|
||||
)
|
||||
values( ?, ?, ?, now(), now())";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$namelang
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db->insert_id();
|
||||
}
|
||||
//$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
// $this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$namelang = $prm['namelang'];
|
||||
$code = $prm['code'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanCode = '{$code}' AND T_BahanID <> {$prm['id']}";
|
||||
$exist_code = $this->db->query($query)->row()->exist;
|
||||
if ($exist_code == 0) {
|
||||
$sqlcompany = "update t_bahan SET
|
||||
T_BahanCode = ?,
|
||||
T_BahanName = ?,
|
||||
T_BahanLangName = ?,
|
||||
T_BahanLastUpdated = now()
|
||||
where
|
||||
T_BahanID = ?
|
||||
";
|
||||
$querycompany = $this->db->query(
|
||||
$sqlcompany,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$namelang,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("t_bahan update");
|
||||
exit;
|
||||
}
|
||||
$result = array("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$errors = array();
|
||||
if ($exist_code != 0) {
|
||||
|
||||
$sqlcompany = "update t_bahan SET
|
||||
T_BahanCode = ?,
|
||||
T_BahanName = ?,
|
||||
T_BahanLangName = ?,
|
||||
T_BahanLastUpdated = now()
|
||||
where
|
||||
T_BahanID = ?
|
||||
";
|
||||
$querycompany = $this->db->query(
|
||||
$sqlcompany,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$namelang,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("t_bahan update");
|
||||
exit;
|
||||
}
|
||||
$result = array("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
// $result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
// $this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function deletebahan()
|
||||
{
|
||||
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 t_bahan SET
|
||||
T_BahanIsActive = 'N',
|
||||
T_BahanLastUpdated = now()
|
||||
WHERE
|
||||
T_BahanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan delete");
|
||||
exit;
|
||||
}
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
776
application/controllers/v1/masterdata/Test_v3.php
Normal file
776
application/controllers/v1/masterdata/Test_v3.php
Normal file
@@ -0,0 +1,776 @@
|
||||
<?php
|
||||
class Test_v3 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' ";
|
||||
$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
|
||||
$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
|
||||
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
|
||||
$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';
|
||||
|
||||
$sql = "SELECT T_TestID
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestSasCode = LEFT('{$prm['T_TestSasCode']}', LENGTH('{$prm['T_TestSasCode']}') - 2) ";
|
||||
$row_parent = $this->db_onedev->query($sql)->row();
|
||||
if($row_parent){
|
||||
$sql = "UPDATE t_test SET T_TestIsParent = 'Y' WHERE T_TestID = {$row_parent->T_TestID}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
1016
application/controllers/v1/masterdata/Testnas.php
Normal file
1016
application/controllers/v1/masterdata/Testnas.php
Normal file
File diff suppressed because it is too large
Load Diff
1012
application/controllers/v1/masterdata/Testnas.php--180320
Normal file
1012
application/controllers/v1/masterdata/Testnas.php--180320
Normal file
File diff suppressed because it is too large
Load Diff
1009
application/controllers/v1/masterdata/Testnas.php-beforepositif
Normal file
1009
application/controllers/v1/masterdata/Testnas.php-beforepositif
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,998 @@
|
||||
<?php
|
||||
class Testnas extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage 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;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " Nat_TestCode LIKE CONCAT('{$search_code}','%') ";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " Nat_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
";
|
||||
//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_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY Nat_TestCode 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){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$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 Nat_TestTypeID as id, Nat_TestTypeName as name
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("id"=>"","name"=>"LAB"),array("id"=>"XRAY","name"=>"XRAY"), array("id"=>"USG","name"=>"USG"),array("id"=>"ELECTROMEDIS","name"=>"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 get_subsubgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name
|
||||
FROM nat_subsubgroup
|
||||
WHERE
|
||||
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupNat_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 nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_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("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_SampleTypeID as id, Nat_SampleTypeName as name
|
||||
FROM nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = 'Y'
|
||||
ORDER BY Nat_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("m_city 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"];
|
||||
|
||||
$sampletype = 0;
|
||||
$unit = 0;
|
||||
if($prm['isresult'] == 'Y'){
|
||||
$sampletype = $prm['sample']['id'];
|
||||
$unit = $prm['unit']['id'];
|
||||
}
|
||||
|
||||
if($prm['fontsize'] == '')
|
||||
$prm['fontsize'] = 10;
|
||||
|
||||
$query ="INSERT INTO nat_test (
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SubSubGroupID,
|
||||
Nat_TestNat_TestTypeID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestNat_UnitID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
Nat_TestUserID,
|
||||
Nat_TestCreated,
|
||||
Nat_TestPriceSumToNat_TestID,
|
||||
Nat_TestFlagMcu
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['code']}',
|
||||
'{$prm['name']}',
|
||||
'{$prm['shortname']}',
|
||||
'{$prm['codebarcode']}',
|
||||
'{$prm['xgroup']['id']}',
|
||||
'{$prm['subgroup']['id']}',
|
||||
'{$prm['subsubgroup']['id']}',
|
||||
'{$prm['type']['id']}',
|
||||
'{$sampletype}',
|
||||
'{$unit}',
|
||||
'{$prm['fontsize']}',
|
||||
'{$prm['fontcolor']}',
|
||||
'{$prm['flagbold']}',
|
||||
'{$prm['flagitalic']}',
|
||||
'{$prm['flaggluc']}',
|
||||
'{$prm['flagquantitative']}',
|
||||
'{$prm['deltacheck']}',
|
||||
'{$prm['isresult']}',
|
||||
'{$prm['isprice']}',
|
||||
'{$prm['printresult']}',
|
||||
'{$prm['printnote']}',
|
||||
'{$prm['trendanalysis']}',
|
||||
'{$prm['isworklist']}',
|
||||
'{$prm['nonlab']['id']}',
|
||||
'{$prm['worklistname']}',
|
||||
'{$prm['flaglow']}',
|
||||
'{$prm['flaghigh']}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
'{$prm['selected_group_price']['id']}',
|
||||
'{$prm['Nat_TestFlagMcu']['id']}'
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_TestName = '{$prm['name']}',
|
||||
Nat_TestShortName = '{$prm['shortname']}',
|
||||
Nat_TestShortNameBarcode = '{$prm['codebarcode']}',
|
||||
Nat_TestNat_GroupID = '{$prm['xgroup']['id']}',
|
||||
Nat_TestNat_SubGroupID = '{$prm['subgroup']['id']}',
|
||||
Nat_TestNat_SubSubGroupID = '{$prm['subsubgroup']['id']}',
|
||||
Nat_TestNat_TestTypeID = '{$prm['type']['id']}',
|
||||
Nat_TestNat_SampleTypeID = '{$sampletype}',
|
||||
Nat_TestNat_UnitID = '{$unit}',
|
||||
Nat_TestFontSize = '{$prm['fontsize']}',
|
||||
Nat_TestFontColor = '{$prm['fontcolor']}',
|
||||
Nat_TestIsBold = '{$prm['flagbold']}',
|
||||
Nat_TestIsItalic = '{$prm['flagitalic']}',
|
||||
Nat_TestFlagGluc = '{$prm['flaggluc']}',
|
||||
Nat_TestIsQuantitative = '{$prm['flagquantitative']}',
|
||||
Nat_TestIsDeltaCheck = '{$prm['deltacheck']}',
|
||||
Nat_TestIsResult = '{$prm['isresult']}',
|
||||
Nat_TestIsPrice = '{$prm['isprice']}',
|
||||
Nat_TestIsPrintResult = '{$prm['printresult']}',
|
||||
Nat_TestIsPrintNota = '{$prm['printnote']}',
|
||||
Nat_TestIsTrendAnalysis = '{$prm['trendanalysis']}',
|
||||
Nat_TestIsWorklist = '{$prm['isworklist']}',
|
||||
Nat_TestIsNonLab = '{$prm['nonlab']['id']}',
|
||||
Nat_TestWorklistName = '{$prm['worklistname']}',
|
||||
Nat_TestFlagLow = '{$prm['flaglow']}',
|
||||
Nat_TestFlagHigh = '{$prm['flaghigh']}',
|
||||
Nat_TestUserID = '{$userid}',
|
||||
Nat_TestPriceSumToNat_TestID = '{$prm['selected_group_price']['id']}',
|
||||
Nat_TestFlagMcu = '{$prm['selected_flag_mcu']['id']}'
|
||||
";
|
||||
//echo $query;
|
||||
$savex = $this->db_onedev->query($query);
|
||||
if($prm['act'] == 'new'){
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT * FROM nat_test WHERE Nat_TestCode = '{$prm['code']}' AND Nat_TestIsActive = 'Y'";
|
||||
$last_id = $this->db_onedev->query($sql)->row()->Nat_TestID;
|
||||
}
|
||||
if($last_id ){
|
||||
if($prm['act'] == 'new' && ($prm['type']['id'] != 2 || $prm['type']['id'] != '2')){
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestNat_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
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['name']}',
|
||||
'{$prm['shortname']}',
|
||||
'{$prm['codebarcode']}',
|
||||
'{$prm['xgroup']['id']}',
|
||||
'{$prm['subgroup']['id']}',
|
||||
'{$sampletype}',
|
||||
'{$prm['fontsize']}',
|
||||
'{$prm['fontcolor']}',
|
||||
'{$prm['flagbold']}',
|
||||
'{$prm['flagitalic']}',
|
||||
'{$prm['flaggluc']}',
|
||||
'{$prm['flagquantitative']}',
|
||||
'{$prm['deltacheck']}',
|
||||
'{$prm['isresult']}',
|
||||
'{$prm['isprice']}',
|
||||
'{$prm['printresult']}',
|
||||
'{$prm['printnote']}',
|
||||
'{$prm['trendanalysis']}',
|
||||
'{$prm['isworklist']}',
|
||||
'{$prm['nonlab']['id']}',
|
||||
'{$prm['worklistname']}',
|
||||
'{$prm['flaglow']}',
|
||||
'{$prm['flaghigh']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$this->db_onedev->query($query);
|
||||
}else{
|
||||
$query = "UPDATE t_test SET
|
||||
T_TestName = '{$prm['name']}',
|
||||
T_TestShortName = '{$prm['shortname']}',
|
||||
T_TestShortNameBarcode = '{$prm['codebarcode']}',
|
||||
T_TestNat_GroupID = '{$prm['xgroup']['id']}',
|
||||
T_TestNat_SubGroupID = '{$prm['subgroup']['id']}',
|
||||
T_TestNat_SubSubGroupID = '{$prm['subsubgroup']['id']}',
|
||||
T_TestT_SampleTypeID = '{$sampletype}',
|
||||
T_TestFontSize = '{$prm['fontsize']}',
|
||||
T_TestFontColor = '{$prm['fontcolor']}',
|
||||
T_TestIsBold = '{$prm['flagbold']}',
|
||||
T_TestIsItalic = '{$prm['flagitalic']}',
|
||||
T_TestFlagGluc = '{$prm['flaggluc']}',
|
||||
T_TestIsQuantitative = '{$prm['flagquantitative']}',
|
||||
T_TestIsDeltaCheck = '{$prm['deltacheck']}',
|
||||
T_TestIsResult = '{$prm['isresult']}',
|
||||
T_TestIsPrintResult = '{$prm['printresult']}',
|
||||
T_TestIsPrintNota = '{$prm['printnote']}',
|
||||
T_TestIsTrendAnalysis = '{$prm['trendanalysis']}',
|
||||
T_TestIsWorklist = '{$prm['isworklist']}',
|
||||
T_TestIsNonLab = '{$prm['nonlab']['id']}',
|
||||
T_TestIsPrice = '{$prm['isprice']}',
|
||||
T_TestWorklistName = '{$prm['worklistname']}',
|
||||
T_TestFlagLow = '{$prm['flaglow']}',
|
||||
T_TestFlagHigh = '{$prm['flaghigh']}',
|
||||
T_TestUserID = '{$userid}'
|
||||
WHERE
|
||||
T_TestNat_TestID = {$last_id} AND T_TestIsActive = 'Y'
|
||||
";
|
||||
$this->db_onedev->query($query);
|
||||
if(intval($prm['type']['id']) == 1){
|
||||
$sql = "SELECT COUNT(*) as xcount FROM t_test WHERE T_TestCode = '{$prm['code']}' AND T_TestSasCode = '{$prm['code']}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$x_exist = $this->db_onedev->query($sql)->row()->xcount;
|
||||
if($x_exist == 0){
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestNat_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
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['name']}',
|
||||
'{$prm['shortname']}',
|
||||
'{$prm['codebarcode']}',
|
||||
'{$prm['xgroup']['id']}',
|
||||
'{$prm['subgroup']['id']}',
|
||||
'{$sampletype}',
|
||||
'{$prm['fontsize']}',
|
||||
'{$prm['fontcolor']}',
|
||||
'{$prm['flagbold']}',
|
||||
'{$prm['flagitalic']}',
|
||||
'{$prm['flaggluc']}',
|
||||
'{$prm['flagquantitative']}',
|
||||
'{$prm['deltacheck']}',
|
||||
'{$prm['isresult']}',
|
||||
'{$prm['isprice']}',
|
||||
'{$prm['printresult']}',
|
||||
'{$prm['printnote']}',
|
||||
'{$prm['trendanalysis']}',
|
||||
'{$prm['isworklist']}',
|
||||
'{$prm['nonlab']['id']}',
|
||||
'{$prm['worklistname']}',
|
||||
'{$prm['flaglow']}',
|
||||
'{$prm['flaghigh']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$this->db_onedev->query($query);
|
||||
//echo $query;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//echo $query;
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM nat_test WHERE Nat_TestID = {$last_id}";
|
||||
//echo $sql;
|
||||
$xdata_log = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode($xdata_log);
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
//$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $data_log_header,
|
||||
"id" => $last_id
|
||||
);
|
||||
$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 nat_test
|
||||
WHERE Nat_TestCode = '{$prm['code']}' AND Nat_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['Nat_TestID'];
|
||||
|
||||
$query =" SELECT
|
||||
Nat_TestCode as code,
|
||||
Nat_TestName as name,
|
||||
Nat_TestShortName as shortname,
|
||||
Nat_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 subsubgroup,
|
||||
Nat_SubSubGroupID as subsubgroup_id,
|
||||
Nat_SubSubGroupName as subsubgroup_name,
|
||||
'' as type,
|
||||
Nat_TestNat_TestTypeID as type_id,
|
||||
Nat_TestTypeName as type_name,
|
||||
'' as unit,
|
||||
Nat_TestNat_UnitID as unit_id,
|
||||
Nat_UnitName as unit_name,
|
||||
'' as sample,
|
||||
Nat_TestIsNonLab as nonlab,
|
||||
Nat_TestNat_SampleTypeID as sample_id,
|
||||
Nat_SampleTypeName as sample_name,
|
||||
Nat_TestFontSize as fontsize,
|
||||
Nat_TestFontColor as fontcolor,
|
||||
Nat_TestIsBold as flagbold,
|
||||
Nat_TestIsItalic as flagitalic,
|
||||
Nat_TestFlagGluc as flaggluc,
|
||||
Nat_TestIsQuantitative as flagquantitative,
|
||||
Nat_TestIsDeltaCheck as deltacheck,
|
||||
Nat_TestIsResult as isresult,
|
||||
Nat_TestIsPrice as isprice,
|
||||
Nat_TestIsPrintResult as printresult,
|
||||
Nat_TestIsPrintNota as printnote,
|
||||
Nat_TestIsTrendAnalysis as trendanalysis,
|
||||
Nat_TestIsWorklist as isworklist,
|
||||
Nat_TestWorklistName as worklistname,
|
||||
Nat_TestFlagLow as flaglow,
|
||||
Nat_TestFlagHigh as flaghigh,
|
||||
'' as groupsprice,
|
||||
Nat_TestPriceSumToNat_TestID as selected_group_price,
|
||||
Nat_TestFlagMcu as selected_flag_mcu
|
||||
FROM nat_test
|
||||
JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestID = '{$id}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['xform'] = $this->db_onedev->query($query)->row_array();
|
||||
if($rows['xform']){
|
||||
if($rows['xform']['selected_flag_mcu'] == 'N')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'N','name'=>'Tidak ada');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'G')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Dengan perhitungan abnormal');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'A')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Sesuai hasil');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'C')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'C','name'=>'Berdasarkan SUBSUBGROUP');
|
||||
|
||||
$sevencode = substr($rows['xform']['code'],0,7);
|
||||
$sql = "SELECT 0 as id, '' as name
|
||||
UNION
|
||||
SELECT Nat_TestID as id, Nat_TestName as name FROM nat_test WHERE Nat_TestCode LIKE '{$sevencode}%'";
|
||||
$rows['xform']['groupsprice'] = $this->db_onedev->query($sql)->result_array();
|
||||
$selected_group_price = array();
|
||||
if($rows['xform']['groupsprice']){
|
||||
foreach($rows['xform']['groupsprice'] as $k =>$v){
|
||||
//echo $rows['xform']['selected_group_price'];echo '-';
|
||||
//echo $v['id'];echo '-';echo $rows['xform']['selected_group_price'];echo '&';
|
||||
if(intval($v['id']) == intval($rows['xform']['selected_group_price'])){
|
||||
//print_r($v);
|
||||
$selected_group_price = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows['xform']['selected_group_price'] = $selected_group_price;
|
||||
|
||||
$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']['subsubgroup'] = array('id'=>$rows['xform']['subsubgroup_id'],'name'=>$rows['xform']['subsubgroup_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']['subsubgroup_id']);
|
||||
unset($rows['xform']['sample_name']);
|
||||
unset($rows['xform']['unit_name']);
|
||||
unset($rows['xform']['group_name']);
|
||||
unset($rows['xform']['subgroup_name']);
|
||||
unset($rows['xform']['subsubgroup_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();
|
||||
|
||||
$sql = "SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name FROM nat_subsubgroup WHERE Nat_SubSubGroupSubGroupID = {$prm['Nat_SubGroupID']} AND Nat_SubSubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subsubgroups'] = $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_TestNat_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},
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
'{$codetoward}',
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM nat_test
|
||||
WHERE
|
||||
Nat_TestCode = '{$codefrom}' AND Nat_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;
|
||||
}
|
||||
}
|
||||
999
application/controllers/v1/masterdata/Testnas_bkp.php
Normal file
999
application/controllers/v1/masterdata/Testnas_bkp.php
Normal file
@@ -0,0 +1,999 @@
|
||||
<?php
|
||||
class Testnas extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage 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;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " Nat_TestCode LIKE CONCAT('{$search_code}','%') ";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " Nat_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
";
|
||||
//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_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY Nat_TestCode 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){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$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 Nat_TestTypeID as id, Nat_TestTypeName as name
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("id"=>"","name"=>"LAB"),array("id"=>"XRAY","name"=>"XRAY"), array("id"=>"USG","name"=>"USG"),array("id"=>"ELECTROMEDIS","name"=>"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 get_subsubgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name
|
||||
FROM nat_subsubgroup
|
||||
WHERE
|
||||
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupNat_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 nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_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("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_SampleTypeID as id, Nat_SampleTypeName as name
|
||||
FROM nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = 'Y'
|
||||
ORDER BY Nat_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("m_city 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"];
|
||||
|
||||
$sampletype = 0;
|
||||
$unit = 0;
|
||||
if($prm['isresult'] == 'Y'){
|
||||
$sampletype = $prm['sample']['id'];
|
||||
$unit = $prm['unit']['id'];
|
||||
}
|
||||
|
||||
if($prm['fontsize'] == '')
|
||||
$prm['fontsize'] = 10;
|
||||
|
||||
if($prm['isprice'] == 'N')
|
||||
$prm['printnote'] = 'N';
|
||||
|
||||
$query ="INSERT INTO nat_test (
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SubSubGroupID,
|
||||
Nat_TestNat_TestTypeID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestNat_UnitID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
Nat_TestUserID,
|
||||
Nat_TestCreated,
|
||||
Nat_TestPriceSumToNat_TestID,
|
||||
Nat_TestFlagMcu
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['code']}',
|
||||
'{$prm['name']}',
|
||||
'{$prm['shortname']}',
|
||||
'{$prm['codebarcode']}',
|
||||
'{$prm['xgroup']['id']}',
|
||||
'{$prm['subgroup']['id']}',
|
||||
'{$prm['subsubgroup']['id']}',
|
||||
'{$prm['type']['id']}',
|
||||
'{$sampletype}',
|
||||
'{$unit}',
|
||||
'{$prm['fontsize']}',
|
||||
'{$prm['fontcolor']}',
|
||||
'{$prm['flagbold']}',
|
||||
'{$prm['flagitalic']}',
|
||||
'{$prm['flaggluc']}',
|
||||
'{$prm['flagquantitative']}',
|
||||
'{$prm['deltacheck']}',
|
||||
'{$prm['isresult']}',
|
||||
'{$prm['isprice']}',
|
||||
'{$prm['printresult']}',
|
||||
'{$prm['printnote']}',
|
||||
'{$prm['trendanalysis']}',
|
||||
'{$prm['isworklist']}',
|
||||
'{$prm['nonlab']['id']}',
|
||||
'{$prm['worklistname']}',
|
||||
'{$prm['flaglow']}',
|
||||
'{$prm['flaghigh']}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
'{$prm['selected_group_price']['id']}',
|
||||
'{$prm['Nat_TestFlagMcu']['id']}'
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_TestName = '{$prm['name']}',
|
||||
Nat_TestShortName = '{$prm['shortname']}',
|
||||
Nat_TestShortNameBarcode = '{$prm['codebarcode']}',
|
||||
Nat_TestNat_GroupID = '{$prm['xgroup']['id']}',
|
||||
Nat_TestNat_SubGroupID = '{$prm['subgroup']['id']}',
|
||||
Nat_TestNat_SubSubGroupID = '{$prm['subsubgroup']['id']}',
|
||||
Nat_TestNat_TestTypeID = '{$prm['type']['id']}',
|
||||
Nat_TestNat_SampleTypeID = '{$sampletype}',
|
||||
Nat_TestNat_UnitID = '{$unit}',
|
||||
Nat_TestFontSize = '{$prm['fontsize']}',
|
||||
Nat_TestFontColor = '{$prm['fontcolor']}',
|
||||
Nat_TestIsBold = '{$prm['flagbold']}',
|
||||
Nat_TestIsItalic = '{$prm['flagitalic']}',
|
||||
Nat_TestFlagGluc = '{$prm['flaggluc']}',
|
||||
Nat_TestIsQuantitative = '{$prm['flagquantitative']}',
|
||||
Nat_TestIsDeltaCheck = '{$prm['deltacheck']}',
|
||||
Nat_TestIsResult = '{$prm['isresult']}',
|
||||
Nat_TestIsPrice = '{$prm['isprice']}',
|
||||
Nat_TestIsPrintResult = '{$prm['printresult']}',
|
||||
Nat_TestIsPrintNota = '{$prm['printnote']}',
|
||||
Nat_TestIsTrendAnalysis = '{$prm['trendanalysis']}',
|
||||
Nat_TestIsWorklist = '{$prm['isworklist']}',
|
||||
Nat_TestIsNonLab = '{$prm['nonlab']['id']}',
|
||||
Nat_TestWorklistName = '{$prm['worklistname']}',
|
||||
Nat_TestFlagLow = '{$prm['flaglow']}',
|
||||
Nat_TestFlagHigh = '{$prm['flaghigh']}',
|
||||
Nat_TestUserID = '{$userid}',
|
||||
Nat_TestPriceSumToNat_TestID = '{$prm['selected_group_price']['id']}',
|
||||
Nat_TestFlagMcu = '{$prm['selected_flag_mcu']['id']}'
|
||||
";
|
||||
//echo $query;
|
||||
$savex = $this->db_onedev->query($query);
|
||||
if($prm['act'] == 'new'){
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT * FROM nat_test WHERE Nat_TestCode = '{$prm['code']}' AND Nat_TestIsActive = 'Y'";
|
||||
$last_id = $this->db_onedev->query($sql)->row()->Nat_TestID;
|
||||
}
|
||||
if($last_id ){
|
||||
if($prm['act'] == 'new' && ($prm['type']['id'] != 2 || $prm['type']['id'] != '2')){
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestNat_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
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['name']}',
|
||||
'{$prm['shortname']}',
|
||||
'{$prm['codebarcode']}',
|
||||
'{$prm['xgroup']['id']}',
|
||||
'{$prm['subgroup']['id']}',
|
||||
'{$sampletype}',
|
||||
'{$prm['fontsize']}',
|
||||
'{$prm['fontcolor']}',
|
||||
'{$prm['flagbold']}',
|
||||
'{$prm['flagitalic']}',
|
||||
'{$prm['flaggluc']}',
|
||||
'{$prm['flagquantitative']}',
|
||||
'{$prm['deltacheck']}',
|
||||
'{$prm['isresult']}',
|
||||
'{$prm['isprice']}',
|
||||
'{$prm['printresult']}',
|
||||
'{$prm['printnote']}',
|
||||
'{$prm['trendanalysis']}',
|
||||
'{$prm['isworklist']}',
|
||||
'{$prm['nonlab']['id']}',
|
||||
'{$prm['worklistname']}',
|
||||
'{$prm['flaglow']}',
|
||||
'{$prm['flaghigh']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$this->db_onedev->query($query);
|
||||
}else{
|
||||
$query = "UPDATE t_test SET
|
||||
T_TestName = '{$prm['name']}',
|
||||
T_TestShortName = '{$prm['shortname']}',
|
||||
T_TestShortNameBarcode = '{$prm['codebarcode']}',
|
||||
T_TestNat_GroupID = '{$prm['xgroup']['id']}',
|
||||
T_TestNat_SubGroupID = '{$prm['subgroup']['id']}',
|
||||
T_TestNat_SubSubGroupID = '{$prm['subsubgroup']['id']}',
|
||||
T_TestT_SampleTypeID = '{$sampletype}',
|
||||
T_TestFontSize = '{$prm['fontsize']}',
|
||||
T_TestFontColor = '{$prm['fontcolor']}',
|
||||
T_TestIsBold = '{$prm['flagbold']}',
|
||||
T_TestIsItalic = '{$prm['flagitalic']}',
|
||||
T_TestFlagGluc = '{$prm['flaggluc']}',
|
||||
T_TestIsQuantitative = '{$prm['flagquantitative']}',
|
||||
T_TestIsDeltaCheck = '{$prm['deltacheck']}',
|
||||
T_TestIsResult = '{$prm['isresult']}',
|
||||
T_TestIsPrintResult = '{$prm['printresult']}',
|
||||
T_TestIsTrendAnalysis = '{$prm['trendanalysis']}',
|
||||
T_TestIsWorklist = '{$prm['isworklist']}',
|
||||
T_TestIsNonLab = '{$prm['nonlab']['id']}',
|
||||
T_TestWorklistName = '{$prm['worklistname']}',
|
||||
T_TestFlagLow = '{$prm['flaglow']}',
|
||||
T_TestFlagHigh = '{$prm['flaghigh']}',
|
||||
T_TestUserID = '{$userid}'
|
||||
WHERE
|
||||
T_TestNat_TestID = {$last_id} AND T_TestIsActive = 'Y'
|
||||
";
|
||||
$this->db_onedev->query($query);
|
||||
if(intval($prm['type']['id']) == 1){
|
||||
$sql = "SELECT COUNT(*) as xcount FROM t_test WHERE T_TestCode = '{$prm['code']}' AND T_TestSasCode = '{$prm['code']}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$x_exist = $this->db_onedev->query($sql)->row()->xcount;
|
||||
if($x_exist == 0){
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestNat_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
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['name']}',
|
||||
'{$prm['shortname']}',
|
||||
'{$prm['codebarcode']}',
|
||||
'{$prm['xgroup']['id']}',
|
||||
'{$prm['subgroup']['id']}',
|
||||
'{$sampletype}',
|
||||
'{$prm['fontsize']}',
|
||||
'{$prm['fontcolor']}',
|
||||
'{$prm['flagbold']}',
|
||||
'{$prm['flagitalic']}',
|
||||
'{$prm['flaggluc']}',
|
||||
'{$prm['flagquantitative']}',
|
||||
'{$prm['deltacheck']}',
|
||||
'{$prm['isresult']}',
|
||||
'{$prm['isprice']}',
|
||||
'{$prm['printresult']}',
|
||||
'{$prm['printnote']}',
|
||||
'{$prm['trendanalysis']}',
|
||||
'{$prm['isworklist']}',
|
||||
'{$prm['nonlab']['id']}',
|
||||
'{$prm['worklistname']}',
|
||||
'{$prm['flaglow']}',
|
||||
'{$prm['flaghigh']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$this->db_onedev->query($query);
|
||||
//echo $query;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//echo $query;
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM nat_test WHERE Nat_TestID = {$last_id}";
|
||||
//echo $sql;
|
||||
$xdata_log = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode($xdata_log);
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
//$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $data_log_header,
|
||||
"id" => $last_id
|
||||
);
|
||||
$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 nat_test
|
||||
WHERE Nat_TestCode = '{$prm['code']}' AND Nat_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['Nat_TestID'];
|
||||
|
||||
$query =" SELECT
|
||||
Nat_TestCode as code,
|
||||
Nat_TestName as name,
|
||||
Nat_TestShortName as shortname,
|
||||
Nat_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 subsubgroup,
|
||||
Nat_SubSubGroupID as subsubgroup_id,
|
||||
Nat_SubSubGroupName as subsubgroup_name,
|
||||
'' as type,
|
||||
Nat_TestNat_TestTypeID as type_id,
|
||||
Nat_TestTypeName as type_name,
|
||||
'' as unit,
|
||||
Nat_TestNat_UnitID as unit_id,
|
||||
Nat_UnitName as unit_name,
|
||||
'' as sample,
|
||||
Nat_TestIsNonLab as nonlab,
|
||||
Nat_TestNat_SampleTypeID as sample_id,
|
||||
Nat_SampleTypeName as sample_name,
|
||||
Nat_TestFontSize as fontsize,
|
||||
Nat_TestFontColor as fontcolor,
|
||||
Nat_TestIsBold as flagbold,
|
||||
Nat_TestIsItalic as flagitalic,
|
||||
Nat_TestFlagGluc as flaggluc,
|
||||
Nat_TestIsQuantitative as flagquantitative,
|
||||
Nat_TestIsDeltaCheck as deltacheck,
|
||||
Nat_TestIsResult as isresult,
|
||||
Nat_TestIsPrice as isprice,
|
||||
Nat_TestIsPrintResult as printresult,
|
||||
Nat_TestIsPrintNota as printnote,
|
||||
Nat_TestIsTrendAnalysis as trendanalysis,
|
||||
Nat_TestIsWorklist as isworklist,
|
||||
Nat_TestWorklistName as worklistname,
|
||||
Nat_TestFlagLow as flaglow,
|
||||
Nat_TestFlagHigh as flaghigh,
|
||||
'' as groupsprice,
|
||||
Nat_TestPriceSumToNat_TestID as selected_group_price,
|
||||
Nat_TestFlagMcu as selected_flag_mcu
|
||||
FROM nat_test
|
||||
JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestID = '{$id}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['xform'] = $this->db_onedev->query($query)->row_array();
|
||||
if($rows['xform']){
|
||||
if($rows['xform']['selected_flag_mcu'] == 'N')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'N','name'=>'Tidak ada');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'G')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Dengan perhitungan abnormal');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'A')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Sesuai hasil');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'C')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'C','name'=>'Berdasarkan SUBSUBGROUP');
|
||||
|
||||
$sevencode = substr($rows['xform']['code'],0,7);
|
||||
$sql = "SELECT 0 as id, '' as name
|
||||
UNION
|
||||
SELECT Nat_TestID as id, Nat_TestName as name FROM nat_test WHERE Nat_TestCode LIKE '{$sevencode}%'";
|
||||
$rows['xform']['groupsprice'] = $this->db_onedev->query($sql)->result_array();
|
||||
$selected_group_price = array();
|
||||
if($rows['xform']['groupsprice']){
|
||||
foreach($rows['xform']['groupsprice'] as $k =>$v){
|
||||
//echo $rows['xform']['selected_group_price'];echo '-';
|
||||
//echo $v['id'];echo '-';echo $rows['xform']['selected_group_price'];echo '&';
|
||||
if(intval($v['id']) == intval($rows['xform']['selected_group_price'])){
|
||||
//print_r($v);
|
||||
$selected_group_price = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows['xform']['selected_group_price'] = $selected_group_price;
|
||||
|
||||
$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']['subsubgroup'] = array('id'=>$rows['xform']['subsubgroup_id'],'name'=>$rows['xform']['subsubgroup_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']['subsubgroup_id']);
|
||||
unset($rows['xform']['sample_name']);
|
||||
unset($rows['xform']['unit_name']);
|
||||
unset($rows['xform']['group_name']);
|
||||
unset($rows['xform']['subgroup_name']);
|
||||
unset($rows['xform']['subsubgroup_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();
|
||||
|
||||
$sql = "SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name FROM nat_subsubgroup WHERE Nat_SubSubGroupSubGroupID = {$prm['Nat_SubGroupID']} AND Nat_SubSubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subsubgroups'] = $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_TestNat_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},
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
'{$codetoward}',
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM nat_test
|
||||
WHERE
|
||||
Nat_TestCode = '{$codefrom}' AND Nat_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;
|
||||
}
|
||||
}
|
||||
1012
application/controllers/v1/masterdata/Testnas_old.php
Normal file
1012
application/controllers/v1/masterdata/Testnas_old.php
Normal file
File diff suppressed because it is too large
Load Diff
1009
application/controllers/v1/masterdata/Testnasv2.php
Normal file
1009
application/controllers/v1/masterdata/Testnasv2.php
Normal file
File diff suppressed because it is too large
Load Diff
304
application/controllers/v1/masterdata/Testsas.php
Normal file
304
application/controllers/v1/masterdata/Testsas.php
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
class Testsas extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage 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;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " ( T_TestSasCode LIKE CONCAT('{$search_code}','%') OR T_TestCode LIKE CONCAT('{$search_code}','%'))";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " T_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestCode ASC
|
||||
";
|
||||
//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_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *, if(T_TestParentT_TestID > 0 , fn_get_testname(T_TestParentT_TestID),'-') as parenttestname
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestSasCode 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){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//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 save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
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
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
304
application/controllers/v1/masterdata/Testsas_old.php
Normal file
304
application/controllers/v1/masterdata/Testsas_old.php
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
class Testsas extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage 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;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " ( T_TestSasCode LIKE CONCAT('{$search_code}','%') OR T_TestCode LIKE CONCAT('{$search_code}','%'))";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " T_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestCode ASC
|
||||
";
|
||||
//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_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *, if(T_TestParentT_TestID > 0 , fn_get_testname(T_TestParentT_TestID),'-') as parenttestname
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestSasCode 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){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//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 save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
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
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
304
application/controllers/v1/masterdata/Testsasv2.php
Normal file
304
application/controllers/v1/masterdata/Testsasv2.php
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
class Testsasv2 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage 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;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " ( T_TestSasCode LIKE CONCAT('{$search_code}','%') OR T_TestCode LIKE CONCAT('{$search_code}','%'))";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " T_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestCode ASC
|
||||
";
|
||||
//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_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *, if(T_TestParentT_TestID > 0 , fn_get_testname(T_TestParentT_TestID),'-') as parenttestname
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestSasCode 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){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//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 save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
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
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
910
application/controllers/v1/masterdata/Unit.php
Normal file
910
application/controllers/v1/masterdata/Unit.php
Normal file
@@ -0,0 +1,910 @@
|
||||
<?php
|
||||
|
||||
class Unit extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "UNIT API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("default", true);
|
||||
}
|
||||
|
||||
function lookupunitbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$unit = $prm['unit'];
|
||||
$all = $prm['all'];
|
||||
$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 nat_unit
|
||||
WHERE
|
||||
(Nat_UnitCode LIKE CONCAT('%','{$unit}','%') OR
|
||||
Nat_UnitName LIKE CONCAT('%','{$unit}','%')) AND
|
||||
Nat_UnitIsActive = 'Y' GROUP BY Nat_UnitID) a";
|
||||
// $total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
$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("nat_unit count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Nat_UnitID as id,
|
||||
Nat_UnitName as name,
|
||||
Nat_UnitCode as code,nat_unit.*
|
||||
from nat_unit
|
||||
WHERE
|
||||
(Nat_UnitCode LIKE CONCAT('%','{$unit}','%') OR
|
||||
Nat_UnitName LIKE CONCAT('%','{$unit}','%')) AND
|
||||
Nat_UnitIsActive = 'Y'
|
||||
GROUP BY Nat_UnitID
|
||||
ORDER BY Nat_UnitCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
// $sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql);
|
||||
// echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("nat_unit 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 lookupregionalbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$regional = $prm['regional'];
|
||||
$unit = $prm['unit'];
|
||||
$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 nat_group
|
||||
LEFT JOIN nat_unit ON Nat_GroupID = Nat_UnitNat_GroupID AND Nat_UnitIsActive = 'Y'
|
||||
where
|
||||
Nat_GroupName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(Nat_UnitName,'') LIKE CONCAT('%','{$unit}','%') AND
|
||||
Nat_GroupIsActive = 'Y'
|
||||
GROUP BY Nat_GroupID) a";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_regional->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("nat_group count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Nat_GroupID as id,
|
||||
Nat_GroupName as name,
|
||||
Nat_GroupName as namex,
|
||||
nat_group.*
|
||||
from nat_group
|
||||
LEFT JOIN nat_unit ON Nat_GroupID = Nat_UnitNat_GroupID AND Nat_UnitIsActive = 'Y'
|
||||
where
|
||||
Nat_GroupName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(Nat_UnitName,'') LIKE CONCAT('%','{$unit}','%') AND
|
||||
Nat_GroupIsActive = 'Y'
|
||||
GROUP BY Nat_GroupID
|
||||
ORDER BY Nat_GroupName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("nat_group 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 addnewregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$sql = "insert into nat_group(
|
||||
Nat_GroupName,
|
||||
Nat_GroupCreated,
|
||||
Nat_GroupLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$name
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_group insert");
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlcompany = "update nat_group SET
|
||||
Nat_GroupName = ?,
|
||||
Nat_GroupLastUpdated = now()
|
||||
where
|
||||
Nat_GroupID = ?
|
||||
";
|
||||
$querycompany = $this->db_regional->query($sqlcompany,
|
||||
array(
|
||||
$name,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("nat_group update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewunit()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$Nat_UnitCode = $prm['Nat_UnitCode'];
|
||||
$Nat_UnitName = $prm['Nat_UnitName'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_unit WHERE Nat_UnitIsActive = 'Y' AND Nat_UnitCode = '{$Nat_UnitCode}'";
|
||||
$exist_code = $this->db_regional->query($query)->row()->exist;
|
||||
if($exist_code == 0){
|
||||
$sql = "insert into nat_unit(
|
||||
Nat_UnitCode,
|
||||
Nat_UnitName,
|
||||
Nat_UnitLastUpdated,
|
||||
Nat_UnitCreated)
|
||||
values(?,?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$Nat_UnitCode,
|
||||
$Nat_UnitName)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_unit insert",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_regional->insert_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 nat_unit WHERE Nat_UnitIsActive = 'Y' AND Nat_UnitCode = '{$Nat_UnitCode}' AND Nat_UnitID <> {$prm['xid']}";
|
||||
//echo $query;
|
||||
$exist_code = $this->db_regional->query($query)->row()->exist;
|
||||
// echo $exist_code;
|
||||
if($exist_code == 0){
|
||||
$sql = "UPDATE nat_unit SET
|
||||
Nat_UnitCode = '{$Nat_UnitCode}',
|
||||
Nat_UnitName = '{$Nat_UnitName}'
|
||||
WHERE Nat_UnitID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$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 deleteregional()
|
||||
{
|
||||
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 nat_group SET
|
||||
Nat_GroupIsActive = 'N',
|
||||
Nat_GroupLastUpdated = now()
|
||||
WHERE
|
||||
Nat_GroupID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_group delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update nat_unit SET
|
||||
Nat_UnitIsActive = 'N',
|
||||
Nat_UnitLastUpdated = now()
|
||||
WHERE
|
||||
Nat_UnitNat_GroupID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_unit 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 deleteunit()
|
||||
{
|
||||
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 nat_unit SET
|
||||
Nat_UnitIsActive = 'N',
|
||||
Nat_UnitLastUpdated = now()
|
||||
WHERE
|
||||
Nat_UnitID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_unit 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 searchgroup(){
|
||||
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_group
|
||||
WHERE
|
||||
Nat_GroupName like ?
|
||||
AND Nat_GroupIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_group count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_GroupID, Nat_GroupName
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupName like ?
|
||||
AND Nat_GroupIsActive = 'Y'
|
||||
ORDER BY Nat_GroupName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_group rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchregionalbyname(){
|
||||
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_group
|
||||
WHERE
|
||||
Nat_GroupName like ?
|
||||
AND Nat_GroupIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_group count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_GroupID, Nat_GroupName
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupName like ?
|
||||
AND Nat_GroupIsActive = 'Y'
|
||||
ORDER BY Nat_GroupName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_group rows",$this->db_regional);
|
||||
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_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
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_regional->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_regional);
|
||||
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_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
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_regional->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_regional);
|
||||
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_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcompany(){
|
||||
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_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchmou(){
|
||||
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_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y'
|
||||
ORDER BY M_MouName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
// echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchdoctor(){
|
||||
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(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_doctor count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?
|
||||
ORDER BY M_DoctorName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_doctor rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function selectaddressdoctor(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query ="SELECT M_DoctorAddressID,
|
||||
CONCAT(M_DoctorAddressNote, ': ',M_DoctorAddressDescription) as M_DoctorAddressNote
|
||||
FROM
|
||||
m_doctoraddress
|
||||
WHERE M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = '{$id}'";
|
||||
//echo $query;
|
||||
$rows['addressdoctors'] = $this->db_regional->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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
1028
application/controllers/v1/masterdata/testmd/Testnas.php
Normal file
1028
application/controllers/v1/masterdata/testmd/Testnas.php
Normal file
File diff suppressed because it is too large
Load Diff
1027
application/controllers/v1/masterdata/testmd/Testnas.php--300425
Normal file
1027
application/controllers/v1/masterdata/testmd/Testnas.php--300425
Normal file
File diff suppressed because it is too large
Load Diff
331
application/controllers/v1/masterdata/testmd/Testsas.php
Normal file
331
application/controllers/v1/masterdata/testmd/Testsas.php
Normal file
@@ -0,0 +1,331 @@
|
||||
<?php
|
||||
class Testsas extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage 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;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " ( T_TestSasCode LIKE CONCAT('{$search_code}','%') OR T_TestCode LIKE CONCAT('{$search_code}','%'))";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " T_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestCode ASC
|
||||
";
|
||||
//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_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *, if(T_TestParentT_TestID > 0 , fn_get_testname(T_TestParentT_TestID),'-') as parenttestname
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestSasCode 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){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//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 save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
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
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function update_price(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "UPDATE t_test SET T_TestIsPrice = '{$prm['T_TestIsPrice']}',
|
||||
T_TestLastUpdatedUserID = {$userid},
|
||||
T_TestLastUpdated = NOW()
|
||||
WHERE T_TestID = {$prm['T_TestID']}";
|
||||
$query = $this->db_onedev->query($query);
|
||||
if(!$query){
|
||||
$this->sys_error_db("t_test update", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $prm,
|
||||
"status" => "OK"
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
304
application/controllers/v1/masterdata/testmd/Testsas.php--250425
Normal file
304
application/controllers/v1/masterdata/testmd/Testsas.php--250425
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
class Testsas extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage 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;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " ( T_TestSasCode LIKE CONCAT('{$search_code}','%') OR T_TestCode LIKE CONCAT('{$search_code}','%'))";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " T_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestCode ASC
|
||||
";
|
||||
//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_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *, if(T_TestParentT_TestID > 0 , fn_get_testname(T_TestParentT_TestID),'-') as parenttestname
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestSasCode 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){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//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 save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
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
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user