Initial import
This commit is contained in:
@@ -0,0 +1,709 @@
|
||||
<?php
|
||||
class Conclusion extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "NON LAB CONCLUSION API";
|
||||
}
|
||||
|
||||
public 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_conclusion
|
||||
WHERE NonlabConclusionIsActive = 'Y'
|
||||
AND (NonlabConclusionName 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 conclusion count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT NonlabConclusionID,
|
||||
NonlabConclusionName,
|
||||
NonlabConclusionIsActive,
|
||||
NonlabConclusionCreated,
|
||||
NonlabConclusionCreatedUserID
|
||||
FROM nonlab_conclusion
|
||||
WHERE NonlabConclusionIsActive = 'Y'
|
||||
AND (NonlabConclusionName LIKE ?)
|
||||
ORDER BY NonlabConclusionID 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 conclusion", $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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO nonlab_conclusion(
|
||||
NonlabConclusionName,
|
||||
NonlabConclusionIsActive,
|
||||
NonlabConclusionCreated,
|
||||
NonlabConclusionCreatedUserID,
|
||||
NonlabConclusionLastUpdated,
|
||||
NonlabConclusionLastUpdatedUserID) VALUES(?,'Y',NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_conclusion
|
||||
SET NonlabConclusionName = ?,
|
||||
NonlabConclusionLastUpdated = NOW(),
|
||||
NonlabConclusionLastUpdatedUserID = ?
|
||||
WHERE NonlabConclusionID = ?";
|
||||
$qry = $this->db->query($sql, array($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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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_conclusion
|
||||
SET NonlabConclusionIsActive = 'N',
|
||||
NonlabConclusionDelete = NOW(),
|
||||
NonlabConclusionDeleteUserID = ?
|
||||
WHERE NonlabConclusionID = ?";
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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_conclusion_detail
|
||||
WHERE NonlabConclusionDetailNonlabConclusionID = ?
|
||||
AND NonlabConclusionDetailIsActive = 'Y'
|
||||
AND (NonlabConclusionDetailCode LIKE ? OR NonlabConclusionDetailName 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 conclusion detail count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT NonlabConclusionDetailID,
|
||||
NonlabConclusionDetailNonlabConclusionID,
|
||||
NonlabConclusionDetailCode,
|
||||
NonlabConclusionDetailName,
|
||||
NonlabConclusionDetailIsNormal,
|
||||
NonlabConclusionDetailFlagActive,
|
||||
NonlabConclusionDetaiM_LangID,
|
||||
NonlabConclusionDetailIsActive,
|
||||
NonlabConclusionDetailCreated
|
||||
FROM nonlab_conclusion_detail
|
||||
WHERE NonlabConclusionDetailNonlabConclusionID = ?
|
||||
AND NonlabConclusionDetailIsActive = 'Y'
|
||||
AND (NonlabConclusionDetailCode LIKE ? OR NonlabConclusionDetailName 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 conclusion 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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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'];
|
||||
|
||||
$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"]);
|
||||
}
|
||||
$isnormal = "";
|
||||
if (isset($prm["isnormal"])) {
|
||||
$isnormal = trim($prm["isnormal"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO nonlab_conclusion_detail(
|
||||
NonlabConclusionDetailNonlabConclusionID,
|
||||
NonlabConclusionDetailCode,
|
||||
NonlabConclusionDetailName,
|
||||
NonlabConclusionDetailIsNormal,
|
||||
NonlabConclusionDetailIsActive,
|
||||
NonlabConclusionDetailCreated,
|
||||
NonlabConclusionDetailCreatedUserID,
|
||||
NonlabConclusionDetailLastUpdated,
|
||||
NonlabConclusionDetailLastUpdatedUserID) VALUES(?,?,?,?,'Y',NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$nonlabid,
|
||||
$code,
|
||||
$name,
|
||||
$isnormal,
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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"]);
|
||||
}
|
||||
$isnormal = "";
|
||||
if (isset($prm["isnormal"])) {
|
||||
$isnormal = trim($prm["isnormal"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_conclusion_detail SET
|
||||
NonlabConclusionDetailCode = ?,
|
||||
NonlabConclusionDetailName = ?,
|
||||
NonlabConclusionDetailIsNormal = ?,
|
||||
NonlabConclusionDetailLastUpdated = NOW(),
|
||||
NonlabConclusionDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabConclusionDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($code, $name, $isnormal, $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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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'];
|
||||
$conclusionid = $prm['conclusionid'];
|
||||
|
||||
if ($flagstatus == "Y") {
|
||||
$sql = "UPDATE nonlab_conclusion_detail
|
||||
SET NonlabConclusionDetailFlagActive = 'Y',
|
||||
NonlabConclusionDetailLastUpdated = NOW(),
|
||||
NonlabConclusionDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabConclusionDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$conclusionid
|
||||
));
|
||||
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab conclusion 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_conclusion_detail
|
||||
SET NonlabConclusionDetailFlagActive = 'N',
|
||||
NonlabConclusionDetailLastUpdated = NOW(),
|
||||
NonlabConclusionDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabConclusionDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$conclusionid
|
||||
));
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab conclusion 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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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_conclusion_detail
|
||||
SET NonlabConclusionDetailIsActive = 'N',
|
||||
NonlabConclusionDetailDelete = NOW(),
|
||||
NonlabConclusionDetailDeleteUserID = ?
|
||||
WHERE NonlabConclusionDetailID = ?";
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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 = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$conclusionid = 0;
|
||||
if (isset($prm['conclusionid'])) {
|
||||
$conclusionid = trim($prm["conclusionid"]);
|
||||
}
|
||||
$status = $prm['status'];
|
||||
$filter = '';
|
||||
if ($status == 'Y') {
|
||||
$filter .= "AND ncm.NonlabConclusionMappingNonlabConclusionID IS NOT NULL ";
|
||||
} else {
|
||||
if ($status == 'N') {
|
||||
$filter .= "AND ncm.NonlabConclusionMappingNonlabConclusionID 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(ncm.NonlabConclusionMappingNonlabConclusionID IS NULL, 'N', 'Y') AS status,
|
||||
ncm.NonlabConclusionMappingNat_TestID,
|
||||
n.Nat_TestCode,
|
||||
n.Nat_TestName,
|
||||
n.Nat_TestShortName
|
||||
FROM
|
||||
nat_test AS n
|
||||
LEFT JOIN
|
||||
nonlab_conclusion_mapping AS ncm
|
||||
ON n.Nat_TestID = ncm.NonlabConclusionMappingNat_TestID
|
||||
AND ncm.NonlabConclusionMappingIsActive = 'Y'
|
||||
LEFT JOIN
|
||||
nonlab_conclusion AS nc
|
||||
ON ncm.NonlabConclusionMappingNonlabConclusionID = nc.NonlabConclusionID
|
||||
AND NonlabConclusionIsActive = '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 (nc.NonlabConclusionID = {$conclusionid} OR nc.NonlabConclusionID 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);
|
||||
}
|
||||
}
|
||||
|
||||
public function saveedittestmap()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$conclusionid = 0;
|
||||
if (isset($prm['conclusionid'])) {
|
||||
$conclusionid = trim($prm["conclusionid"]);
|
||||
}
|
||||
$test_id = 0;
|
||||
if (isset($prm['test_id'])) {
|
||||
$test_id = trim($prm["test_id"]);
|
||||
}
|
||||
|
||||
$status = $prm["status"];
|
||||
|
||||
$sql = "SELECT NonlabConclusionMappingID,
|
||||
NonlabConclusionMappingNonlabConclusionID,
|
||||
NonlabConclusionMappingNat_TestID
|
||||
FROM nonlab_conclusion_mapping
|
||||
WHERE NonlabConclusionMappingNonlabConclusionID = ?
|
||||
AND NonlabConclusionMappingNat_TestID = ?";
|
||||
$qry = $this->db->query($sql, [$conclusionid, $test_id]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$nonlabconclusionmapid = $rows[0]["NonlabConclusionMappingID"];
|
||||
$sql_update = "UPDATE nonlab_conclusion_mapping SET
|
||||
NonlabConclusionMappingLastUpdated = NOW(),
|
||||
NonlabConclusionMappingLastUpdatedUserID = ?,
|
||||
NonlabConclusionMappingDeleted = NOW(),
|
||||
NonlabConclusionMappingIsActive = ?
|
||||
WHERE NonlabConclusionMappingID = ?";
|
||||
$qry_update = $this->db->query($sql_update, [$userid, $status, $nonlabconclusionmapid]);
|
||||
if (!$qry_update) {
|
||||
$this->sys_error_db("map test update", $this->db);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql_insert = "INSERT INTO nonlab_conclusion_mapping(
|
||||
NonlabConclusionMappingNonlabConclusionID,
|
||||
NonlabConclusionMappingNat_TestID,
|
||||
NonlabConclusionMappingCreated,
|
||||
NonlabConclusionMappingCreatedUserID,
|
||||
NonlabConclusionMappingIsActive) VALUES(?,?,NOW(),?,'Y')";
|
||||
$qry_insert = $this->db->query($sql_insert, [$conclusionid, $test_id, $userid]);
|
||||
if (!$qry_insert) {
|
||||
$this->sys_error_db("nonlab_conclusion_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user