717 lines
25 KiB
PHP
717 lines
25 KiB
PHP
<?php
|
|
class Nonlabtemplatev2 extends MY_Controller
|
|
{
|
|
var $db;
|
|
public function index()
|
|
{
|
|
echo "NON LAN TEMPLATE API";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
function search()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$search = "";
|
|
if (isset($prm['search'])) {
|
|
$search = trim($prm["search"]);
|
|
if ($search != "") {
|
|
$search = '%' . $prm['search'] . '%';
|
|
} else {
|
|
$search = '%%';
|
|
}
|
|
}
|
|
|
|
$number_offset = 0;
|
|
$number_limit = 10;
|
|
if ($prm["current_page"] > 0) {
|
|
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
|
}
|
|
|
|
$sql_tot = "SELECT COUNT(*) as total
|
|
FROM nonlab_template
|
|
WHERE NonlabTemplateIsActive = 'Y'
|
|
AND (NonlabTemplateName LIKE ?)";
|
|
$qry_tot = $this->db->query($sql_tot, [$search]);
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($qry_tot) {
|
|
$tot_count = $qry_tot->result_array()[0]["total"];
|
|
$tot_page = ceil($tot_count / $number_limit);
|
|
} else {
|
|
$this->sys_error_db("nonlab template count", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT
|
|
NonlabTemplateID,
|
|
NonlabTemplateName,
|
|
NonlabTemplateFlagOther,
|
|
NonlabTemplateIsActive,
|
|
NonlabTemplateCreated,
|
|
NonlabTemplateLastUpdated
|
|
FROM nonlab_template
|
|
WHERE NonlabTemplateIsActive = 'Y'
|
|
AND (NonlabTemplateName LIKE ?)
|
|
ORDER BY NonlabTemplateID ASC
|
|
LIMIT ? OFFSET ?";
|
|
$qry = $this->db->query($sql, [$search, $number_limit, $number_offset]);
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select nonlab template", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$result = array(
|
|
"total_page" => $tot_page,
|
|
"total_filter" => $tot_count,
|
|
"records" => $rows
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function addnonlab()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$this->db->trans_begin();
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
|
|
$name = "";
|
|
if (isset($prm["name"])) {
|
|
$name = trim($prm["name"]);
|
|
}
|
|
$isfisik = "";
|
|
if (isset($prm["isfisik"])) {
|
|
$isfisik = trim($prm["isfisik"]);
|
|
}
|
|
|
|
$sql = "INSERT INTO nonlab_template(
|
|
NonlabTemplateName,
|
|
NonlabTemplateFlagOther,
|
|
NonlabTemplateCreated,
|
|
NonlabTemplateCreatedUserID,
|
|
NonlabTemplateLastUpdated,
|
|
NonlabTemplateLastUpdatedUserID
|
|
) VALUES(?,?,NOW(),?,NOW(),?)";
|
|
$qry = $this->db->query($sql, array(
|
|
$name,
|
|
$isfisik,
|
|
$userid,
|
|
$userid
|
|
));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
$this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
$result = array(
|
|
"total" => 1,
|
|
"affected_rows" => $this->db->affected_rows()
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function editnonlab()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$this->db->trans_begin();
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
|
|
$name = "";
|
|
if (isset($prm["name"])) {
|
|
$name = trim($prm["name"]);
|
|
}
|
|
$isfisik = "";
|
|
if (isset($prm["isfisik"])) {
|
|
$isfisik = trim($prm["isfisik"]);
|
|
}
|
|
$id = "";
|
|
if (isset($prm["id"])) {
|
|
$id = trim($prm["id"]);
|
|
}
|
|
|
|
$sql = "UPDATE nonlab_template
|
|
SET NonlabTemplateName = ?,
|
|
NonlabTemplateFlagOther = ?,
|
|
NonlabTemplateLastUpdated = NOW(),
|
|
NonlabTemplateLastUpdatedUserID = ?
|
|
WHERE NonlabTemplateID = ?";
|
|
$qry = $this->db->query($sql, array($name, $isfisik, $userid, $id));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
$this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
$result = array(
|
|
"total" => 1,
|
|
"affected_rows" => $this->db->affected_rows()
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function deletenonlab()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$this->db->trans_begin();
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
|
|
$id = "";
|
|
if (isset($prm["id"])) {
|
|
$id = trim($prm["id"]);
|
|
}
|
|
|
|
$sql = "UPDATE nonlab_template
|
|
SET NonlabTemplateIsActive = 'N',
|
|
NonlabTemplateDelete = NOW(),
|
|
NonlabTemplateDeleteUserID = ?
|
|
WHERE NonlabTemplateID = ?";
|
|
$qry = $this->db->query($sql, array($userid, $id));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
$this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
$result = array(
|
|
"total" => 1,
|
|
"affected_rows" => $this->db->affected_rows()
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function searchdetail()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$search = "";
|
|
if (isset($prm['search'])) {
|
|
$search = trim($prm["search"]);
|
|
if ($search != "") {
|
|
$search = '%' . $prm['search'] . '%';
|
|
} else {
|
|
$search = '%%';
|
|
}
|
|
}
|
|
|
|
$nonlabID = $prm["nonlabID"];
|
|
|
|
$number_offset = 0;
|
|
$number_limit = 10;
|
|
if ($prm["current_page"] > 0) {
|
|
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
|
}
|
|
|
|
$sql_total = "SELECT COUNT(*) as total
|
|
FROM nonlab_template_detail
|
|
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
|
AND NonlabTemplateDetailIsActive = 'Y'
|
|
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)";
|
|
$qry_total = $this->db->query($sql_total, [$nonlabID, $search, $search]);
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($qry_total) {
|
|
$tot_count = $qry_total->result_array()[0]["total"];
|
|
$tot_page = ceil($tot_count / $number_limit);
|
|
} else {
|
|
$this->sys_error_db("nonlab template detail count", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT
|
|
NonlabTemplateDetailID,
|
|
NonlabTemplateDetailNonlabTemplateID,
|
|
NonlabTemplateDetailCode,
|
|
NonlabTemplateDetailName,
|
|
NonlabTemplateDetaiNat_UnitID,
|
|
NonlabTemplateDetailFlagActive,
|
|
NonlabTemplateDetaiM_LangID,
|
|
NonlabTemplateDetailIsActive
|
|
FROM nonlab_template_detail
|
|
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
|
AND NonlabTemplateDetailIsActive = 'Y'
|
|
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)
|
|
limit ? offset ?";
|
|
$qry = $this->db->query($sql, [$nonlabID, $search, $search, $number_limit, $number_offset]);
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select nonlab template detail", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$result = array(
|
|
"total_page" => $tot_page,
|
|
"total_filter" => $tot_count,
|
|
"records" => $rows
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function adddetail()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$this->db->trans_begin();
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
|
|
$nonlabid = intval($prm["nonlabid"]);
|
|
|
|
if ($nonlabid === 0) {
|
|
$this->sys_error("Anda belum memilih nonlab template, silahkan pilih nonlab template dulu");
|
|
exit;
|
|
}
|
|
|
|
$name = "";
|
|
if (isset($prm["name"])) {
|
|
$name = trim($prm["name"]);
|
|
}
|
|
$code = "";
|
|
if (isset($prm["code"])) {
|
|
$code = trim($prm["code"]);
|
|
}
|
|
// $nonlabid = "";
|
|
// if (isset($prm["nonlabid"])) {
|
|
// $nonlabid = trim($prm["nonlabid"]);
|
|
// }
|
|
|
|
$sql = "INSERT INTO nonlab_template_detail(
|
|
NonlabTemplateDetailNonlabTemplateID,
|
|
NonlabTemplateDetailCode,
|
|
NonlabTemplateDetailName,
|
|
NonlabTemplateDetailCreated,
|
|
NonlabTemplateDetailCreatedUserID,
|
|
NonlabTemplateDetailLastUpdated,
|
|
NonlabTemplateDetailLastUpdatedUserID
|
|
) VALUES(?,?,?,NOW(),?,NOW(),?)";
|
|
$qry = $this->db->query($sql, array(
|
|
$nonlabid,
|
|
$code,
|
|
$name,
|
|
$userid,
|
|
$userid
|
|
));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
$this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
$result = array(
|
|
"total" => 1,
|
|
"affected_rows" => $this->db->affected_rows()
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function deletedetail()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$this->db->trans_begin();
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
|
|
$id = "";
|
|
if (isset($prm["id"])) {
|
|
$id = trim($prm["id"]);
|
|
}
|
|
|
|
$sql = "UPDATE nonlab_template_detail
|
|
SET NonlabTemplateDetailIsActive = 'N',
|
|
NonlabTemplateDetailDelete = NOW(),
|
|
NonlabTemplateDetailDeleteUserID = ?
|
|
WHERE NonlabTemplateDetailID = ?";
|
|
$qry = $this->db->query($sql, array($userid, $id));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
$this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
$result = array(
|
|
"total" => 1,
|
|
"affected_rows" => $this->db->affected_rows()
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function saveeditflag()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$this->db->trans_begin();
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
|
|
$flagstatus = $prm['flagstatus'];
|
|
$templatedetailid = $prm['templatedetailid'];
|
|
|
|
if ($flagstatus == "Y") {
|
|
$sql = "UPDATE nonlab_template_detail
|
|
SET NonlabTemplateDetailFlagActive = 'Y',
|
|
NonlabTemplateDetailLastUpdated = NOW(),
|
|
NonlabTemplateDetailLastUpdatedUserID = ?
|
|
WHERE NonlabTemplateDetailID = ?";
|
|
$qry = $this->db->query($sql, array(
|
|
$userid,
|
|
$templatedetailid
|
|
));
|
|
|
|
|
|
// echo $this->db->last_query();
|
|
// exit;
|
|
if (!$qry) {
|
|
$this->sys_error_db("nonlab template detail avtive", $this->db);
|
|
exit;
|
|
}
|
|
$this->db->trans_commit();
|
|
$result = array("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
} else {
|
|
$sql = "UPDATE nonlab_template_detail
|
|
SET NonlabTemplateDetailFlagActive = 'N',
|
|
NonlabTemplateDetailLastUpdated = NOW(),
|
|
NonlabTemplateDetailLastUpdatedUserID = ?
|
|
WHERE NonlabTemplateDetailID = ?";
|
|
$qry = $this->db->query($sql, array(
|
|
$userid,
|
|
$templatedetailid
|
|
));
|
|
|
|
// echo $this->db->last_query();
|
|
// exit;
|
|
if (!$qry) {
|
|
$this->sys_error_db("nonlab template detail no avtive", $this->db);
|
|
exit;
|
|
}
|
|
$this->db->trans_commit();
|
|
$result = array("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function editdetail()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$this->db->trans_begin();
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
|
|
$name = "";
|
|
if (isset($prm["name"])) {
|
|
$name = trim($prm["name"]);
|
|
}
|
|
$code = "";
|
|
if (isset($prm["code"])) {
|
|
$code = trim($prm["code"]);
|
|
}
|
|
$id = "";
|
|
if (isset($prm["id"])) {
|
|
$id = trim($prm["id"]);
|
|
}
|
|
|
|
$sql = "UPDATE nonlab_template_detail SET
|
|
NonlabTemplateDetailCode = ?,
|
|
NonlabTemplateDetailName = ?,
|
|
NonlabTemplateDetailLastUpdated = NOW(),
|
|
NonlabTemplateDetailLastUpdatedUserID = ?
|
|
WHERE NonlabTemplateDetailID = ?";
|
|
$qry = $this->db->query($sql, array($code, $name, $userid, $id));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
$this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
$result = array(
|
|
"total" => 1,
|
|
"affected_rows" => $this->db->affected_rows()
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function lookuptest()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$search = "";
|
|
if (isset($prm["search"])) {
|
|
$search = trim($prm["search"]);
|
|
if ($search != "") {
|
|
$search = "%" . $prm["search"] . "%";
|
|
} else {
|
|
$search = "%%";
|
|
}
|
|
}
|
|
|
|
$nonlabtemplate_id = 0;
|
|
if (isset($prm['nonlabtemplate_id'])) {
|
|
$nonlabtemplate_id = trim($prm["nonlabtemplate_id"]);
|
|
}
|
|
$status = $prm['status'];
|
|
$filter = '';
|
|
if ($status == 'Y') {
|
|
$filter .= "AND ntm.NonlabTemplateMappingNonlabTemplateID IS NOT NULL ";
|
|
} else {
|
|
if ($status == 'N') {
|
|
$filter .= "AND ntm.NonlabTemplateMappingNonlabTemplateID IS NULL ";
|
|
} else {
|
|
$filter .= "";
|
|
}
|
|
}
|
|
|
|
$number_offset = 0;
|
|
$number_limit = 10;
|
|
if ($prm["current_page"] > 0) {
|
|
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
|
}
|
|
|
|
$sql_dasar = "SELECT
|
|
n.Nat_TestID,
|
|
IF(ntm.NonlabTemplateMappingNonlabTemplateID IS NULL, 'N', 'Y') AS status,
|
|
ntm.NonlabTemplateMappingNat_TestID,
|
|
n.Nat_TestCode,
|
|
n.Nat_TestName,
|
|
n.Nat_TestShortName
|
|
FROM nat_test as n
|
|
LEFT JOIN nonlab_template_mapping as ntm ON n.Nat_TestID = ntm.NonlabTemplateMappingNat_TestID
|
|
AND ntm.NonlabTemplateMappingIsActive = 'Y'
|
|
LEFT JOIN nonlab_template as nt ON ntm.NonlabTemplateMappingNonlabTemplateID = nt.NonlabTemplateID
|
|
AND nt.NonlabTemplateIsActive = 'Y'
|
|
WHERE n.Nat_TestIsActive = 'Y'
|
|
AND n.Nat_TestIsNonLab <> ''
|
|
AND n.Nat_TestIsResult = 'Y'
|
|
AND (n.Nat_TestCode LIKE '{$search}' OR n.Nat_TestName LIKE '{$search}')
|
|
AND (nt.NonlabTemplateID = {$nonlabtemplate_id} OR nt.NonlabTemplateID IS NULL)
|
|
$filter";
|
|
|
|
$qry_filter = "SELECT COUNT(*) as total FROM ($sql_dasar) as x";
|
|
|
|
$qry_filter = $this->db->query($qry_filter);
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($qry_filter) {
|
|
$tot_count = $qry_filter->result_array()[0]["total"];
|
|
$tot_page = ceil($tot_count / $number_limit);
|
|
} else {
|
|
$this->sys_error_db("test count error", $this->db);
|
|
}
|
|
|
|
$sql = $sql_dasar . " ORDER BY n.Nat_TestCode LIMIT $number_limit OFFSET $number_offset";
|
|
|
|
$qry = $this->db->query($sql);
|
|
// echo $this->db->last_query();
|
|
// exit;
|
|
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("test select error", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$result = array(
|
|
"total" => $tot_page,
|
|
"total_filter" => count($rows),
|
|
"records" => $rows,
|
|
"sql" => $this->db->last_query()
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function saveedittestmap()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
$nonlabtemplate_id = 0;
|
|
if (isset($prm['nonlabtemplate_id'])) {
|
|
$nonlabtemplate_id = trim($prm["nonlabtemplate_id"]);
|
|
}
|
|
$test_id = 0;
|
|
if (isset($prm['test_id'])) {
|
|
$test_id = trim($prm["test_id"]);
|
|
}
|
|
|
|
$status = $prm["status"];
|
|
|
|
$sql = "SELECT NonlabTemplateMappingID,
|
|
NonlabTemplateMappingNonlabTemplateID,
|
|
NonlabTemplateMappingNat_TestID
|
|
FROM nonlab_template_mapping
|
|
WHERE NonlabTemplateMappingNonlabTemplateID = ?
|
|
AND NonlabTemplateMappingNat_TestID = ?";
|
|
$qry = $this->db->query($sql, [$nonlabtemplate_id, $test_id]);
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("nonlab template error", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$nonlabtemplatemapid = $rows[0]["NonlabTemplateMappingID"];
|
|
$sql_update = "UPDATE nonlab_template_mapping SET
|
|
NonlabTemplateMappingLastUpdated = NOW(),
|
|
NonlabTemplateMappingLastUpdatedUserID = ?,
|
|
NonlabTemplateMappingDeleted = NOW(),
|
|
NonlabTemplateMappingIsActive = ?
|
|
WHERE NonlabTemplateMappingID = ?";
|
|
$qry_update = $this->db->query($sql_update, [$userid, $status, $nonlabtemplatemapid]);
|
|
if (!$qry_update) {
|
|
$this->sys_error_db("map test update", $this->db);
|
|
exit;
|
|
}
|
|
} else {
|
|
$sql_insert = "INSERT INTO nonlab_template_mapping(
|
|
NonlabTemplateMappingNonlabTemplateID,
|
|
NonlabTemplateMappingNat_TestID,
|
|
NonlabTemplateMappingCreated,
|
|
NonlabTemplateMappingCreatedUserID,
|
|
NonlabTemplateMappingIsActive) VALUES(?,?,NOW(),?,'Y')";
|
|
$qry_insert = $this->db->query($sql_insert, [$nonlabtemplate_id, $test_id, $userid]);
|
|
if (!$qry_insert) {
|
|
$this->sys_error_db("nonlab_template_mapping test insert", $this->db);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
$result = array(
|
|
"total" => 1,
|
|
"affected_rows" => $this->db->affected_rows()
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
}
|