1751 lines
60 KiB
PHP
1751 lines
60 KiB
PHP
<?php
|
|
|
|
class Control extends MY_Controller
|
|
{
|
|
var $db_regional;
|
|
public function index()
|
|
{
|
|
echo "CONTROL API";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_regional = $this->load->database("regional", true);
|
|
}
|
|
function lookupqcbyid(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$controlid = $prm['controlid'];
|
|
$instrumentid = $prm['instrumentid'];
|
|
$px = $prm['px'];
|
|
$all = $prm['all'];
|
|
$limit = '';
|
|
if($all == 'N'){
|
|
$limit = ' LIMIT 10';
|
|
}
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
if($instrumentid > 0){
|
|
$sql = "select COUNT(*) as total
|
|
FROM(SELECT *
|
|
from nat_qc
|
|
JOIN nat_qc_control ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcControlIsActive = 'Y'
|
|
JOIN nat_test ON Nat_TestID = Nat_QcNat_TestID
|
|
WHERE
|
|
Nat_TestName LIKE CONCAT('%','{$px}','%') AND
|
|
Nat_QcNat_QcControlID = $controlid AND Nat_QcNat_InstrumentID = $instrumentid AND
|
|
Nat_QcIsActive = 'Y' GROUP BY Nat_QcID) a";
|
|
// $total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
|
$query = $this->db_regional->query($sql);
|
|
//echo $this->db_regional->last_query();
|
|
}else{
|
|
$sql = "select COUNT(*) as total
|
|
FROM(SELECT *
|
|
from nat_qc
|
|
JOIN nat_qc_control ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcControlIsActive = 'Y'
|
|
JOIN nat_test ON Nat_TestID = Nat_QcNat_TestID
|
|
WHERE
|
|
Nat_TestName LIKE CONCAT('%','{$px}','%') AND
|
|
Nat_QcNat_QcControlID = $controlid AND
|
|
Nat_QcIsActive = 'Y' GROUP BY Nat_QcID) 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_qc count", $this->db_regional);
|
|
exit;
|
|
}
|
|
if($instrumentid > 0){
|
|
$sql = "select Nat_QcID as id,
|
|
Nat_QcControlID,
|
|
Nat_QcControlName,
|
|
Nat_QcControlNat_QcLevelID,
|
|
Nat_QcLevelName,
|
|
Nat_QcControlLotNumber,
|
|
Nat_QcControlExpired,
|
|
DATE_FORMAT(Nat_QcControlExpired,'%d-%m-%Y') as expdate,
|
|
Nat_TestID,
|
|
Nat_TestName,
|
|
nat_qc.*,
|
|
Nat_QcMean as Nat_QcMeanOld,
|
|
Nat_QcSd as Nat_QcSdOld,
|
|
Nat_QcTea as Nat_QcTeaOld,
|
|
Nat_InstrumentID,
|
|
Nat_InstrumentName
|
|
from nat_qc
|
|
JOIN nat_qc_control ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcControlIsActive = 'Y'
|
|
JOIN nat_test ON Nat_TestID = Nat_QcNat_TestID
|
|
JOIN nat_instrument ON Nat_InstrumentID = Nat_QcNat_InstrumentID
|
|
JOIN nat_qc_level ON Nat_QcLevelID = Nat_QcControlNat_QcLevelID
|
|
WHERE
|
|
Nat_TestName LIKE CONCAT('%','{$px}','%') AND
|
|
Nat_QcNat_QcControlID = $controlid AND Nat_QcNat_InstrumentID = $instrumentid AND
|
|
Nat_QcIsActive = 'Y'
|
|
GROUP BY Nat_QcID
|
|
ORDER BY Nat_TestName 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_qc select");
|
|
exit;
|
|
}
|
|
}else{
|
|
$sql = "select Nat_QcID as id,
|
|
Nat_QcControlID,
|
|
Nat_QcControlName,
|
|
Nat_QcControlNat_QcLevelID,
|
|
Nat_QcLevelName,
|
|
Nat_QcControlLotNumber,
|
|
Nat_QcControlExpired,
|
|
DATE_FORMAT(Nat_QcControlExpired,'%d-%m-%Y') as expdate,
|
|
Nat_TestID,
|
|
Nat_TestName,
|
|
nat_qc.*,
|
|
Nat_QcMean as Nat_QcMeanOld,
|
|
Nat_QcSd as Nat_QcSdOld,
|
|
Nat_QcTea as Nat_QcTeaOld,
|
|
Nat_InstrumentID,
|
|
Nat_InstrumentName
|
|
from nat_qc
|
|
JOIN nat_qc_control ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcControlIsActive = 'Y'
|
|
JOIN nat_test ON Nat_TestID = Nat_QcNat_TestID
|
|
JOIN nat_instrument ON Nat_InstrumentID = Nat_QcNat_InstrumentID
|
|
JOIN nat_qc_level ON Nat_QcLevelID = Nat_QcControlNat_QcLevelID
|
|
WHERE
|
|
Nat_TestName LIKE CONCAT('%','{$px}','%') AND
|
|
Nat_QcNat_QcControlID = $controlid AND
|
|
Nat_QcIsActive = 'Y'
|
|
GROUP BY Nat_QcID
|
|
ORDER BY Nat_TestName 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_qc 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 lookupqcbyname(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$control = $prm['control'];
|
|
$qc = $prm['qc'];
|
|
$instrument = $prm['instrument'];
|
|
$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_qc
|
|
JOIN nat_qc_control ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcControlIsActive = 'Y'
|
|
LEFT JOIN nat_instrument ON Nat_InstrumentID = Nat_QcNat_InstrumentID
|
|
LEFT JOIN nat_test ON Nat_TestID = Nat_QcNat_TestID
|
|
where
|
|
Nat_QcControlName LIKE CONCAT('%','{$control}','%') AND
|
|
IFNULL(Nat_InstrumentName,'') LIKE CONCAT('%','{$instrument}','%') AND
|
|
IFNULL(Nat_TestName,'') LIKE CONCAT('%','{$qc}','%') AND
|
|
Nat_QcIsActive = 'Y' GROUP BY Nat_QcID) 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_qc count", $this->db_regional);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_QcID as id,
|
|
Nat_QcControlID,
|
|
Nat_QcControlName,
|
|
Nat_QcControlNat_QcLevelID,
|
|
Nat_QcLevelName,
|
|
Nat_QcControlLotNumber,
|
|
Nat_QcControlExpired,
|
|
DATE_FORMAT(Nat_QcControlExpired,'%d-%m-%Y') as expdate,
|
|
Nat_TestID,
|
|
Nat_TestName,
|
|
nat_qc.*,
|
|
Nat_QcMean as Nat_QcMeanOld,
|
|
Nat_QcSd as Nat_QcSdOld,
|
|
Nat_QcTea as Nat_QcTeaOld,
|
|
Nat_InstrumentID,
|
|
Nat_InstrumentName
|
|
from nat_qc
|
|
JOIN nat_qc_control ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcControlIsActive = 'Y'
|
|
JOIN nat_test ON Nat_TestID = Nat_QcNat_TestID
|
|
JOIN nat_instrument ON Nat_InstrumentID = Nat_QcNat_InstrumentID
|
|
JOIN nat_qc_level ON Nat_QcLevelID = Nat_QcControlNat_QcLevelID
|
|
where
|
|
Nat_QcControlName LIKE CONCAT('%','{$control}','%') AND
|
|
IFNULL(Nat_InstrumentName,'') LIKE CONCAT('%','{$instrument}','%') AND
|
|
IFNULL(Nat_TestName,'') LIKE CONCAT('%','{$qc}','%') AND
|
|
Nat_QcIsActive = 'Y'
|
|
GROUP BY Nat_QcID
|
|
ORDER BY Nat_QcControlName ASC, Nat_InstrumentName ASC, Nat_TestName 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_qc 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 lookupbyid()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$control = $prm['control'];
|
|
$instrument = $prm['instrument'];
|
|
$qc = $prm['qc'];
|
|
$id = $prm['id'];
|
|
$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_qc_control
|
|
JOIN nat_qc_level ON Nat_QcLevelID = Nat_QcControlNat_QcLevelID
|
|
LEFT JOIN nat_qc ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcIsActive = 'Y'
|
|
LEFT JOIN nat_instrument ON Nat_InstrumentID = Nat_QcNat_InstrumentID
|
|
LEFT JOIN nat_test ON Nat_TestID = Nat_QcNat_TestID
|
|
where
|
|
Nat_QcControlName LIKE CONCAT('%','{$control}','%') AND
|
|
Nat_QcControlID = $id AND
|
|
Nat_QcControlIsActive = 'Y'
|
|
GROUP BY Nat_QcControlID) 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_qc_control count", $this->db_regional);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_QcControlID as id,
|
|
Nat_QcControlName as name,
|
|
Nat_QcControlName as namex,
|
|
Nat_QcLevelID,
|
|
Nat_QcLevelName,
|
|
nat_qc_control.*,
|
|
DATE_FORMAT(Nat_QcControlExpired,'%d-%m-%Y') as expdate
|
|
from nat_qc_control
|
|
JOIN nat_qc_level ON Nat_QcLevelID = Nat_QcControlNat_QcLevelID
|
|
LEFT JOIN nat_qc ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcIsActive = 'Y'
|
|
LEFT JOIN nat_instrument ON Nat_InstrumentID = Nat_QcNat_InstrumentID
|
|
LEFT JOIN nat_test ON Nat_TestID = Nat_QcNat_TestID
|
|
where
|
|
Nat_QcControlName LIKE CONCAT('%','{$control}','%') AND
|
|
Nat_QcControlID = $id AND
|
|
Nat_QcControlIsActive = 'Y'
|
|
GROUP BY Nat_QcControlID
|
|
ORDER BY Nat_QcControlName 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_qc_control 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 lookupcontrolbyname()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$control = $prm['control'];
|
|
$instrument = $prm['instrument'];
|
|
$qc = $prm['qc'];
|
|
$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_qc_control
|
|
JOIN nat_qc_level ON Nat_QcLevelID = Nat_QcControlNat_QcLevelID
|
|
LEFT JOIN nat_qc ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcIsActive = 'Y'
|
|
LEFT JOIN nat_instrument ON Nat_InstrumentID = Nat_QcNat_InstrumentID
|
|
LEFT JOIN nat_test ON Nat_TestID = Nat_QcNat_TestID
|
|
where
|
|
Nat_QcControlName LIKE CONCAT('%','{$control}','%') AND
|
|
IFNULL(Nat_InstrumentName,'') LIKE CONCAT('%','{$instrument}','%') AND
|
|
IFNULL(Nat_TestName,'') LIKE CONCAT('%','{$qc}','%') AND
|
|
Nat_QcControlIsActive = 'Y'
|
|
GROUP BY Nat_QcControlID) 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_qc_control count", $this->db_regional);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_QcControlID as id,
|
|
Nat_QcControlName as name,
|
|
Nat_QcControlName as namex,
|
|
Nat_QcLevelID,
|
|
Nat_QcLevelName,
|
|
nat_qc_control.*,
|
|
DATE_FORMAT(Nat_QcControlExpired,'%d-%m-%Y') as expdate
|
|
from nat_qc_control
|
|
JOIN nat_qc_level ON Nat_QcLevelID = Nat_QcControlNat_QcLevelID
|
|
LEFT JOIN nat_qc ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcIsActive = 'Y'
|
|
LEFT JOIN nat_instrument ON Nat_InstrumentID = Nat_QcNat_InstrumentID
|
|
LEFT JOIN nat_test ON Nat_TestID = Nat_QcNat_TestID
|
|
where
|
|
Nat_QcControlName LIKE CONCAT('%','{$control}','%') AND
|
|
IFNULL(Nat_InstrumentName,'') LIKE CONCAT('%','{$instrument}','%') AND
|
|
IFNULL(Nat_TestName,'') LIKE CONCAT('%','{$qc}','%') AND
|
|
Nat_QcControlIsActive = 'Y'
|
|
GROUP BY Nat_QcControlID
|
|
ORDER BY Nat_QcControlName 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_qc_control 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 lookupinstrumentbyid(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$instrument = $prm['instrument'];;
|
|
$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_qc
|
|
JOIN nat_qc_control ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcControlIsActive = 'Y'
|
|
JOIN nat_instrument ON Nat_InstrumentID = Nat_QcNat_InstrumentID
|
|
WHERE
|
|
Nat_QcIsActive = 'Y' AND Nat_InstrumentName LIKE CONCAT('%','{$instrument}','%') AND
|
|
Nat_QcNat_QcControlID = $id
|
|
GROUP BY Nat_QcNat_QcControlID,Nat_QcNat_InstrumentID) 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_qc count", $this->db_regional);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_QcID as id,
|
|
Nat_InstrumentName as name,
|
|
Nat_QcControlID,
|
|
Nat_QcControlName,
|
|
Nat_QcControlNat_QcLevelID,
|
|
Nat_QcLevelName,
|
|
Nat_QcControlLotNumber,
|
|
Nat_QcControlExpired,
|
|
DATE_FORMAT(Nat_QcControlExpired,'%d-%m-%Y') as expdate,
|
|
Nat_InstrumentID,
|
|
Nat_InstrumentCode,
|
|
Nat_InstrumentName,
|
|
nat_qc.*,
|
|
Nat_QcInstrumentQcCode as Nat_QcInstrumentQcCodeOld
|
|
from nat_qc
|
|
JOIN nat_qc_control ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcControlIsActive = 'Y'
|
|
JOIN nat_instrument ON Nat_InstrumentID = Nat_QcNat_InstrumentID
|
|
JOIN nat_qc_level ON Nat_QcLevelID = Nat_QcControlNat_QcLevelID
|
|
WHERE
|
|
Nat_QcIsActive = 'Y' AND Nat_InstrumentName LIKE CONCAT('%','{$instrument}','%') AND
|
|
Nat_QcNat_QcControlID = $id
|
|
GROUP BY Nat_QcNat_QcControlID,Nat_QcNat_InstrumentID
|
|
ORDER BY Nat_QcControlName ASC, Nat_InstrumentName 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_qc 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 lookupinstrumentbyname(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$control = $prm['control'];
|
|
$qc = $prm['qc'];
|
|
$instrument = $prm['instrument'];
|
|
$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_qc
|
|
JOIN nat_qc_control ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcControlIsActive = 'Y'
|
|
JOIN nat_instrument ON Nat_InstrumentID = Nat_QcNat_InstrumentID
|
|
LEFT JOIN nat_test ON Nat_TestID = Nat_QcNat_TestID
|
|
WHERE
|
|
Nat_QcControlName LIKE CONCAT('%','{$control}','%') AND
|
|
IFNULL(Nat_InstrumentName,'') LIKE CONCAT('%','{$instrument}','%') AND
|
|
IFNULL(Nat_TestName,'') LIKE CONCAT('%','{$qc}','%') AND
|
|
Nat_QcIsActive = 'Y' GROUP BY Nat_QcNat_QcControlID,Nat_QcNat_InstrumentID) 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_qc count", $this->db_regional);
|
|
exit;
|
|
}
|
|
|
|
$sql = "select Nat_QcID as id,
|
|
Nat_InstrumentName as name,
|
|
Nat_QcControlID,
|
|
Nat_QcControlName,
|
|
Nat_QcControlNat_QcLevelID,
|
|
Nat_QcLevelName,
|
|
Nat_QcControlLotNumber,
|
|
Nat_QcControlExpired,
|
|
DATE_FORMAT(Nat_QcControlExpired,'%d-%m-%Y') as expdate,
|
|
Nat_InstrumentID,
|
|
Nat_InstrumentCode,
|
|
Nat_InstrumentName,
|
|
nat_qc.*,
|
|
Nat_QcInstrumentQcCode as Nat_QcInstrumentQcCodeOld
|
|
from nat_qc
|
|
JOIN nat_qc_control ON Nat_QcNat_QcControlID = Nat_QcControlID AND Nat_QcControlIsActive = 'Y'
|
|
JOIN nat_instrument ON Nat_InstrumentID = Nat_QcNat_InstrumentID
|
|
LEFT JOIN nat_test ON Nat_TestID = Nat_QcNat_TestID
|
|
JOIN nat_qc_level ON Nat_QcLevelID = Nat_QcControlNat_QcLevelID
|
|
WHERE
|
|
Nat_QcControlName LIKE CONCAT('%','{$control}','%') AND
|
|
IFNULL(Nat_InstrumentName,'') LIKE CONCAT('%','{$instrument}','%') AND
|
|
IFNULL(Nat_TestName,'') LIKE CONCAT('%','{$qc}','%') AND
|
|
Nat_QcIsActive = 'Y'
|
|
GROUP BY Nat_QcNat_QcControlID,Nat_QcNat_InstrumentID
|
|
ORDER BY Nat_QcControlName ASC, Nat_InstrumentName 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_qc 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 addnewcontrol()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$name = $prm['name'];
|
|
$level = $prm['level'];
|
|
$lotnumber = $prm['lotnumber'];
|
|
$exp = $prm['exp'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query = "SELECT COUNT(*) as exist FROM nat_qc_control WHERE Nat_QcControlIsActive = 'Y'
|
|
AND Nat_QcControlName = '{$name}' AND Nat_QcControlNat_QcLevelID = '{$level}'
|
|
AND Nat_QcControlLotNumber = '{$lotnumber}' AND Nat_QcControlExpired = '{$exp}'";
|
|
$exist_name = $this->db_regional->query($query)->row()->exist;
|
|
if($exist_name == 0){
|
|
$sql = "insert into nat_qc_control(
|
|
Nat_QcControlName,
|
|
Nat_QcControlNat_QcLevelID,
|
|
Nat_QcControlLotNumber,
|
|
Nat_QcControlExpired,
|
|
Nat_QcControlUserID,
|
|
Nat_QcControlCreated,
|
|
Nat_QcControlLastUpdated
|
|
)
|
|
values( ?, ?,?,?, ?, now(), now())";
|
|
$query = $this->db_regional->query($sql,
|
|
array(
|
|
$name,
|
|
$level,
|
|
$lotnumber,
|
|
$exp,
|
|
$userid
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_qc_control 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();
|
|
}else{
|
|
$errors = array();
|
|
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 editcontrol()
|
|
{
|
|
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'];
|
|
$level = $prm['level'];
|
|
$lotnumber = $prm['lotnumber'];
|
|
$exp = $prm['exp'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query = "SELECT COUNT(*) as exist FROM nat_qc_control WHERE Nat_QcControlIsActive = 'Y'
|
|
AND Nat_QcControlName = '{$name}' AND Nat_QcControlNat_QcLevelID = '{$level}'
|
|
AND Nat_QcControlLotNumber = '{$lotnumber}' AND Nat_QcControlExpired = '{$exp}' AND Nat_QcControlID <> '{$id}' ";
|
|
$exist_name = $this->db_regional->query($query)->row()->exist;
|
|
if($exist_name == 0){
|
|
$sqlcompany = "update nat_qc_control SET
|
|
Nat_QcControlName = ?,
|
|
Nat_QcControlNat_QcLevelID= ?,
|
|
Nat_QcControlLotNumber= ?,
|
|
Nat_QcControlExpired = ?,
|
|
Nat_QcControlUserID = ?,
|
|
Nat_QcControlLastUpdated = now()
|
|
where
|
|
Nat_QcControlID = ?
|
|
";
|
|
$querycompany = $this->db_regional->query($sqlcompany,
|
|
array(
|
|
$name,
|
|
$level,
|
|
$lotnumber,
|
|
$exp,
|
|
$userid,
|
|
$id
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$querycompany) {
|
|
$this->sys_error_db("nat_qc_control update");
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => $id));
|
|
$this->sys_ok($result);
|
|
}else{
|
|
$errors = array();
|
|
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 addnewinstrument()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$controlid = $prm['controlid'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach($prm['instruments'] as $k=>$v){
|
|
$instrumentid = $v['Nat_InstrumentID'];
|
|
$query = "INSERT INTO nat_qc (
|
|
Nat_QcNat_QcControlID,
|
|
Nat_QcNat_InstrumentID,
|
|
Nat_QcUserID,
|
|
Nat_QcCreated,
|
|
Nat_QcLastUpdated
|
|
)
|
|
VALUES(
|
|
?,?,?,now(),now()
|
|
)";
|
|
$insert_new_test = $this->db_regional->query($query,array(
|
|
$controlid,
|
|
$v['Nat_InstrumentID'],
|
|
$userid
|
|
));
|
|
|
|
|
|
}
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_qc_control 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 saveallinstrument()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$controlid = $prm['controlid'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach($prm['instruments'] as $k=>$v){
|
|
$instrumentid = $v['Nat_InstrumentID'];
|
|
if($v['Nat_QcInstrumentQcCode'] !== $v['Nat_QcInstrumentQcCodeOld']){
|
|
$query = "UPDATE nat_qc SET
|
|
Nat_QcInstrumentQcCode = ?,
|
|
Nat_QcUserID = ?,
|
|
Nat_QcLastUpdated = now()
|
|
WHERE Nat_QcNat_QcControlID = ? AND Nat_QcNat_InstrumentID = ?";
|
|
$insert_new_test = $this->db_regional->query($query,array(
|
|
$v['Nat_QcInstrumentQcCode'],
|
|
$userid,
|
|
$controlid,
|
|
$instrumentid
|
|
));
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_qc_control 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 addnewqc()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$controlid = $prm['controlid'];
|
|
$instrumentid = $prm['instrumentid'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach($prm['tests'] as $k=>$v){
|
|
$testid = $v['Nat_TestID'];
|
|
$query = "INSERT INTO nat_qc (
|
|
Nat_QcNat_QcControlID,
|
|
Nat_QcNat_InstrumentID,
|
|
Nat_QcNat_TestID,
|
|
Nat_QcUserID,
|
|
Nat_QcCreated,
|
|
Nat_QcLastUpdated
|
|
)
|
|
VALUES(
|
|
?,?,?,?,now(),now()
|
|
)";
|
|
$insert_new_test = $this->db_regional->query($query,array(
|
|
$controlid,
|
|
$instrumentid,
|
|
$testid,
|
|
$userid
|
|
));
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_qc_control insert");
|
|
exit;
|
|
}
|
|
|
|
}
|
|
$queryupdate = "UPDATE nat_qc SET
|
|
Nat_QcIsActive = 'N',
|
|
Nat_QcUserID = ?,
|
|
Nat_QcLastUpdated = now()
|
|
WHERE Nat_QcNat_QcControlID = ? AND Nat_QcNat_InstrumentID = ? AND Nat_QcNat_TestID IS NULL";
|
|
$update_test = $this->db_regional->query($queryupdate,array(
|
|
$userid,
|
|
$controlid,
|
|
$instrumentid
|
|
|
|
));
|
|
if (!$queryupdate) {
|
|
$this->sys_error_db("nat_qc_control insert");
|
|
exit;
|
|
} //echo $query;
|
|
|
|
$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 saveallqc()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$controlid = $prm['controlid'];
|
|
$instrumentid = $prm['instrumentid'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach($prm['tests'] as $k=>$v){
|
|
$instrumentid = $v['Nat_InstrumentID'];
|
|
if($v['Nat_QcMean'] !== $v['Nat_QcMeanOld'] || $v['Nat_QcSd'] !== $v['Nat_QcSdOld'] || $v['Nat_QcTea'] !== $v['Nat_QcTeaOld']){
|
|
$query = "UPDATE nat_qc SET
|
|
Nat_QcMean = ?,
|
|
Nat_QcSd = ?,
|
|
Nat_QcTea = ?,
|
|
Nat_QcUserID = ?,
|
|
Nat_QcLastUpdated = now()
|
|
WHERE Nat_QcID = ?";
|
|
$insert_new_test = $this->db_regional->query($query,array(
|
|
$v['Nat_QcMean'],
|
|
$v['Nat_QcSd'],
|
|
$v['Nat_QcTea'],
|
|
$userid,
|
|
$v['Nat_QcID']
|
|
));
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_qc_control 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 oldaddnewqc()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$controlid = $prm['controlid'];
|
|
$name = $prm['name'];
|
|
$description = $prm['description'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
if($controlid == 0){
|
|
$errors = array();
|
|
if($controlid == 0){
|
|
array_push($errors,array('field'=>'control','msg'=>'Kategori dipilih dulu dong'));
|
|
}
|
|
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
|
$this->sys_ok($result);
|
|
}else{
|
|
if($prm['xid'] == 0){
|
|
$query = "SELECT COUNT(*) as exist FROM nat_qc WHERE Nat_QcIsActive = 'Y' AND Nat_QcName = '{$name}'";
|
|
$exist_code = $this->db_regional->query($query)->row()->exist;
|
|
if($exist_code == 0){
|
|
$sql = "insert into nat_qc(
|
|
Nat_QcNat_QcControlID,
|
|
Nat_QcName,
|
|
Nat_QcDescription,
|
|
Nat_QcUserID,
|
|
Nat_QcLastUpdate,
|
|
Nat_QcCreated)
|
|
values(?,?,?,?,now(),now())";
|
|
$query = $this->db_regional->query($sql,
|
|
array(
|
|
$controlid,
|
|
$name,
|
|
$description,
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_qc 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'=>'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_qc WHERE Nat_QcIsActive = 'Y' AND Nat_QcName = '{$name}' AND Nat_QcID <> {$prm['xid']}";
|
|
//echo $query;
|
|
$exist_code = $this->db_regional->query($query)->row()->exist;
|
|
// echo $exist_code;
|
|
if($exist_code == 0){
|
|
$sql = "UPDATE nat_qc SET Nat_QcNat_QcControlID = '{$controlid}',
|
|
Nat_QcName = '{$name}',
|
|
Nat_QcDescription = '{$description}',
|
|
Nat_QcUserID = '{$userid}'
|
|
WHERE Nat_QcID = '{$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'=>'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 deletecontrol()
|
|
{
|
|
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_qc_control SET
|
|
Nat_QcControlIsActive = 'N',
|
|
Nat_QcControlLastUpdated = now()
|
|
WHERE
|
|
Nat_QcControlID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_regional->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_qc_control delete");
|
|
exit;
|
|
}
|
|
$sql = "update nat_qc SET
|
|
Nat_QcIsActive = 'N',
|
|
Nat_QcLastUpdated = now()
|
|
WHERE
|
|
Nat_QcNat_QcControlID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_regional->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_qc 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 deleteinstrument()
|
|
{
|
|
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_qc SET
|
|
Nat_QcIsActive = 'N',
|
|
Nat_QcUserID = ?,
|
|
Nat_QcLastUpdated = now()
|
|
WHERE
|
|
Nat_QcNat_InstrumentID = ? AND Nat_QcNat_QcControlID = ?";
|
|
|
|
$query = $this->db_regional->query($sql,
|
|
array(
|
|
$userid,
|
|
$prm['instrumentid'],
|
|
$prm['controlid']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_qc 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 deleteqc()
|
|
{
|
|
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_qc SET
|
|
Nat_QcIsActive = 'N',
|
|
Nat_QcUserID = $userid,
|
|
Nat_QcLastUpdated = now()
|
|
WHERE
|
|
Nat_QcID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_regional->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("nat_qc 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 searchinstrument(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$controlid = $prm['controlid'];
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
$s_ids = "0";
|
|
foreach($prm['instruments'] as $k=>$v) {
|
|
$s_ids .= "," . $v["Nat_InstrumentID"];
|
|
}
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM nat_instrument
|
|
WHERE
|
|
Nat_InstrumentName like ? AND Nat_InstrumentID not in (
|
|
select Nat_QcNat_InstrumentID from nat_qc where Nat_QcNat_QcControlID = $controlid and Nat_QcIsActive = 'Y'
|
|
|
|
union select Nat_InstrumentID FROM
|
|
nat_instrument
|
|
WHERE Nat_InstrumentID IN ($s_ids))
|
|
AND Nat_InstrumentIsActive = '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_qc_control count",$this->db_regional);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT Nat_InstrumentID, Nat_InstrumentName
|
|
FROM nat_instrument
|
|
WHERE
|
|
Nat_InstrumentName like ? AND Nat_InstrumentID not in (
|
|
select Nat_QcNat_InstrumentID from nat_qc where Nat_QcNat_QcControlID = $controlid and Nat_QcIsActive = 'Y'
|
|
|
|
union select Nat_InstrumentID FROM
|
|
nat_instrument
|
|
WHERE Nat_InstrumentID IN ($s_ids))
|
|
AND Nat_InstrumentIsActive = 'Y'
|
|
ORDER BY Nat_InstrumentName 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_qc_control rows",$this->db_regional);
|
|
exit;
|
|
}
|
|
}
|
|
function searchcontrolbyname(){
|
|
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_qc_control
|
|
WHERE
|
|
Nat_QcControlName like ?
|
|
AND Nat_QcControlIsActive = '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_qc_control count",$this->db_regional);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT Nat_QcControlID, Nat_QcControlName
|
|
FROM nat_qc_control
|
|
WHERE
|
|
Nat_QcControlName like ?
|
|
AND Nat_QcControlIsActive = 'Y'
|
|
ORDER BY Nat_QcControlName 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_qc_control 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 searchtest(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$controlid = $prm['controlid'];
|
|
$instrumentid = $prm['instrumentid'];
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
$s_ids = "0";
|
|
foreach($prm['tests'] as $k=>$v) {
|
|
$s_ids .= "," . $v["Nat_TestID"];
|
|
}
|
|
// echo $s_ids;
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total FROM
|
|
( SELECT * FROM nat_test
|
|
JOIN m_instrumentmethode ON M_InstrumentMethodeNat_TestID = Nat_TestID AND M_InstrumentMethodeIsActive = 'Y'
|
|
WHERE
|
|
Nat_TestName like ?
|
|
AND M_InstrumentMethodeNat_InstrumentID = '{$instrumentid}'
|
|
AND Nat_TestID not in (
|
|
select IFNULL(Nat_QcNat_TestID,0) from nat_qc
|
|
where Nat_QcNat_QcControlID = $controlid
|
|
and Nat_QcNat_InstrumentID = $instrumentid
|
|
and Nat_QcIsActive = 'Y'
|
|
|
|
union select Nat_TestID FROM
|
|
nat_test
|
|
WHERE Nat_TestID IN ($s_ids))
|
|
AND Nat_TestIsActive = 'Y' GROUP BY Nat_TestID) a
|
|
";
|
|
$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 nat_test
|
|
JOIN m_instrumentmethode ON M_InstrumentMethodeNat_TestID = Nat_TestID AND M_InstrumentMethodeIsActive = 'Y'
|
|
WHERE
|
|
Nat_TestName like ?
|
|
AND M_InstrumentMethodeNat_InstrumentID = '{$instrumentid}'
|
|
AND Nat_TestID not in (
|
|
select IFNULL(Nat_QcNat_TestID,0) from nat_qc
|
|
where Nat_QcNat_QcControlID = $controlid
|
|
and Nat_QcNat_InstrumentID = $instrumentid
|
|
and Nat_QcIsActive = 'Y'
|
|
|
|
union select Nat_TestID FROM
|
|
nat_test
|
|
WHERE Nat_TestID IN ($s_ids))
|
|
ORDER BY Nat_TestName 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 selectlevel(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$rows = [];
|
|
$query ="SELECT *
|
|
FROM
|
|
nat_qc_level
|
|
WHERE Nat_QcLevelIsActive = 'Y'";
|
|
//echo $query;
|
|
$rows['levels'] = $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);
|
|
}
|
|
|
|
}
|
|
function selectdescriptiondoctor(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$rows = [];
|
|
$query ="SELECT M_DoctorDescriptionID,
|
|
CONCAT(M_DoctorDescriptionNote, ': ',M_DoctorDescriptionDescription) as M_DoctorDescriptionNote
|
|
FROM
|
|
m_doctordescription
|
|
WHERE M_DoctorDescriptionIsActive = 'Y' AND M_DoctorDescriptionM_DoctorID = '{$id}'";
|
|
//echo $query;
|
|
$rows['descriptiondoctors'] = $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);
|
|
}
|
|
|
|
}
|
|
} |