Initial import
This commit is contained in:
495
application/controllers/process/Auto_verif_valid.php
Normal file
495
application/controllers/process/Auto_verif_valid.php
Normal file
@@ -0,0 +1,495 @@
|
||||
<?php
|
||||
class Auto_verif_valid extends MY_Controller
|
||||
{
|
||||
function cors()
|
||||
{
|
||||
global $_SERVER;
|
||||
if (isset($_SERVER["HTTP_ORIGIN"])) {
|
||||
header("Access-Control-Allow-Origin: " . $_SERVER["HTTP_ORIGIN"]);
|
||||
} else {
|
||||
header("Access-Control-Allow-Origin: */*");
|
||||
}
|
||||
header("Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS");
|
||||
header(
|
||||
"Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization"
|
||||
);
|
||||
if (
|
||||
isset($_SERVER["REQUEST_METHOD"]) &&
|
||||
$_SERVER["REQUEST_METHOD"] == "OPTIONS"
|
||||
) {
|
||||
http_response_code(200);
|
||||
echo json_encode("OK");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
function extract_image($inp, $debug = "")
|
||||
{
|
||||
$mapimg = file_get_contents("http://localhost" . $inp);
|
||||
if ($debug != "") {
|
||||
echo "<br/>";
|
||||
echo $mapimg;
|
||||
}
|
||||
if (strpos($mapimg, "<img src=\"") > -1) {
|
||||
$mapimg = substr($mapimg, strpos($mapimg, "<img src=\"") + 10);
|
||||
$mapimg = substr($mapimg, 0, strpos($mapimg, "\""));
|
||||
$mapimg = "/charts/" . htmlspecialchars_decode($mapimg);
|
||||
return $mapimg;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
function info_valid($detailID)
|
||||
{
|
||||
$this->cors();
|
||||
|
||||
$sql = "select auto_valid_v2.*, autoVerifImage
|
||||
from auto_valid_v2
|
||||
join auto_verif_v2 on AutoValidT_OrderDetailID = AutoVerifT_OrderDetailID
|
||||
and AutoValidT_OrderDetailID = ?";
|
||||
$qry = $this->db->query($sql, [$detailID]);
|
||||
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0) {
|
||||
//AutoValid V2
|
||||
$r = $rows[0];
|
||||
$note = $this->print_table_style();
|
||||
$xrows = [];
|
||||
$isStatusOk = true;
|
||||
if ($r["AutoValidAutoVerifIsOK"] == "Y") {
|
||||
$xrows[] = "Auto Verif terpenuhi. <i>" . "</i>";
|
||||
} else {
|
||||
$xrows[] = "Auto Verif tidak terpenuhi. <i>" . "</i>";
|
||||
$isStatusOk = $isStatusOk && false;
|
||||
}
|
||||
if ($isStatusOk) {
|
||||
if ($r["AutoValidIsInReviewRange"] == "Y") {
|
||||
$xrows[] =
|
||||
"Masuk dalam review range. <i>" .
|
||||
$r["AutoValidInReviewRangeNote"] .
|
||||
"</i>";
|
||||
$isStatusOk = $isStatusOk && false;
|
||||
} else {
|
||||
$xrows[] =
|
||||
"Tidak masuk dalam review range. <i>" .
|
||||
$r["AutoValidInReviewRangeNote"] .
|
||||
"</i>";
|
||||
}
|
||||
}
|
||||
if ($isStatusOk) {
|
||||
if ($r["AutoValidIsInconsistencyOK"] == "N") {
|
||||
$xrows[] =
|
||||
"Inkonsistensi rule tidak terpenuhi. <i>" .
|
||||
$r["AutoValidInconsistencyNote"] .
|
||||
"</i>";
|
||||
$isStatusOk = $isStatusOk && false;
|
||||
} else {
|
||||
$xrows[] =
|
||||
"Inkonsistensi rule terpenuhi. <i>" .
|
||||
$r["AutoValidInconsistencyNote"] .
|
||||
"</i>";
|
||||
}
|
||||
}
|
||||
if ($isStatusOk) {
|
||||
if ($r["AutoValidIsDeltacheckOK"] == "N") {
|
||||
$xrows[] =
|
||||
"Delta check tidak terpenuhi. <i>" .
|
||||
$r["AutoValidDeltaCheckNote"] .
|
||||
"</i>";
|
||||
$isStatusOk = $isStatusOk && false;
|
||||
} else {
|
||||
$xrows[] =
|
||||
"Delta check terpenuhi. <i>" .
|
||||
$r["AutoValidDeltaCheckNote"] .
|
||||
"</i>";
|
||||
}
|
||||
}
|
||||
if ($isStatusOk) {
|
||||
if ($r["AutoValidReflexTestIsOK"] == "N") {
|
||||
$xrows[] =
|
||||
"Reflex Test tidak terpenuhi. <i>" .
|
||||
$r["AutoValidReflexTestNote"] .
|
||||
"</i>";
|
||||
$isStatusOk = $isStatusOk && false;
|
||||
} else {
|
||||
$xrows[] =
|
||||
"Reflex Test terpenuhi. <i>" .
|
||||
str_ireplace(
|
||||
"|",
|
||||
"<br/>",
|
||||
$r["AutoValidReflexTestNote"]
|
||||
) .
|
||||
"</i>";
|
||||
}
|
||||
}
|
||||
$note = $this->print_table_style();
|
||||
$note .= $this->print_table_one_column($xrows);
|
||||
if (false) {
|
||||
echo "Img : " . $r["autoVerifImage"];
|
||||
echo "<br/><br/>extract : " .
|
||||
$this->extract_image($r["autoVerifImage"], "1");
|
||||
}
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"note" => $note, //$r["AutoVerifDeltaCheckNote"],
|
||||
"raw_image" => $r["autoVerifImage"],
|
||||
"image" => $this->extract_image($r["autoVerifImage"]),
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$sql = "select auto_valid.*,
|
||||
AutoVerifTrendAnalysisImage
|
||||
from auto_valid
|
||||
join auto_verif on AutoValidT_OrderDetailID =?
|
||||
and AutoValidT_OrderDetailID = AutoVerifT_OrderDetailID";
|
||||
$qry = $this->db->query($sql, [$detailID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Informasi Auto Valid tidak ada",
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$r = $rows[0];
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"note" => $r["AutoValidNote"],
|
||||
"raw_image" => $r["AutoVerifTrendAnalysisImage"],
|
||||
"image" => $this->extract_image($r["AutoVerifTrendAnalysisImage"]),
|
||||
]);
|
||||
}
|
||||
function info_verif($detailID, $debug = "")
|
||||
{
|
||||
$this->cors();
|
||||
|
||||
$sql = "select * from auto_verif_v2 where AutoVerifT_OrderDetailID = ?";
|
||||
$qry = $this->db->query($sql, [$detailID]);
|
||||
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0) {
|
||||
//AutoVerif V2
|
||||
$r = $rows[0];
|
||||
$note = $this->print_table_style();
|
||||
$xrows = [];
|
||||
$isStatusOk = true;
|
||||
if ($r["autoVerifIsPanicValue"] == "Y") {
|
||||
$xrows[] =
|
||||
"Ada Panic Value. <i>" .
|
||||
$r["autoVerifPanicValueNote"] .
|
||||
"</i>";
|
||||
$isStatusOk = $isStatusOk && false;
|
||||
} else {
|
||||
$xrows[] =
|
||||
"Tidak ada Panic Value. <i>" .
|
||||
$r["autoVerifPanicValueNote"] .
|
||||
"</i>";
|
||||
}
|
||||
if ($isStatusOk) {
|
||||
if ($r["autoVerifIsPreAnalityc"] == "Y") {
|
||||
$xrows[] =
|
||||
"Ada ketidaksesuaian. <i>" .
|
||||
$r["autoVerifPreAnalitycNote"] .
|
||||
"</i>";
|
||||
$isStatusOk = $isStatusOk && false;
|
||||
} else {
|
||||
$xrows[] =
|
||||
"Tidak ada ketidaksesuaian persyaratan preanalitik. <i>" .
|
||||
$r["autoVerifPreAnalitycNote"] .
|
||||
"</i>";
|
||||
}
|
||||
}
|
||||
if ($isStatusOk) {
|
||||
if ($r["autoVerifIsInAmr"] == "N") {
|
||||
$xrows[] =
|
||||
"Tidak masuk dalam range AMR. <i>" .
|
||||
$r["autoVerifAmrNote"] .
|
||||
"</i>";
|
||||
$isStatusOk = $isStatusOk && false;
|
||||
} else {
|
||||
$xrows[] =
|
||||
"Masuk dalam range AMR. <i>" .
|
||||
$r["autoVerifAmrNote"] .
|
||||
"</i>";
|
||||
}
|
||||
}
|
||||
if ($isStatusOk) {
|
||||
if ($r["autoVerifIsUjiTrendOK"] == "N") {
|
||||
$xrows[] =
|
||||
"Rata-rata harian tidak masuk dalam rentang AON. <i>" .
|
||||
$r["autoVerifUjiTrendNote"] .
|
||||
"</i>";
|
||||
$isStatusOk = $isStatusOk && false;
|
||||
} else {
|
||||
$xrows[] =
|
||||
"Rata-rata harian masuk dalam rentang AON. <i>" .
|
||||
$r["autoVerifUjiTrendNote"] .
|
||||
"</i>";
|
||||
}
|
||||
}
|
||||
$note = $this->print_table_style();
|
||||
$note .= $this->print_table_one_column($xrows);
|
||||
if ($debug != "") {
|
||||
echo "Img : " . $r["autoVerifImage"];
|
||||
echo "<br/><br/>extract : " .
|
||||
$this->extract_image($r["autoVerifImage"], "1");
|
||||
}
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"note" => $note, //$r["AutoVerifDeltaCheckNote"],
|
||||
"raw_image" => $r["autoVerifImage"],
|
||||
"image" => $this->extract_image($r["autoVerifImage"]),
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
|
||||
$sql = "select * from auto_verif where AutoVerifT_OrderDetailID = ?";
|
||||
$qry = $this->db->query($sql, [$detailID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Informasi Auto Verif tidak ada",
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$r = $rows[0];
|
||||
if ($debug != "") {
|
||||
print_r($r);
|
||||
}
|
||||
$note = "";
|
||||
if ($r["AutoVerifHaveReq"] == "Y") {
|
||||
$note =
|
||||
"<font color='brown'>*</font>) Ada Requirement checklist. <br/>";
|
||||
} else {
|
||||
$note =
|
||||
"<font color='brown'>*</font>) Tidak ada Requirement checklist. <br/>";
|
||||
}
|
||||
if ($r["AutoVerifReviewRangeIsOK"] != "Y") {
|
||||
if ($note != "") {
|
||||
$note .= "<br/>";
|
||||
}
|
||||
$note .=
|
||||
"<font color='brown'>*</font>) Review Range tidak terpenuhi. <br/>";
|
||||
} else {
|
||||
if ($note != "") {
|
||||
$note .= "<br/>";
|
||||
}
|
||||
$note .=
|
||||
"<font color='brown'>*</font>) Review Range terpenuhi. <br/>";
|
||||
}
|
||||
$note .= $r["AutoVerifTrendAnalysisNote"];
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"note" => $note, //$r["AutoVerifDeltaCheckNote"],
|
||||
"raw_image" => $r["AutoVerifTrendAnalysisImage"],
|
||||
"image" => $this->extract_image($r["AutoVerifTrendAnalysisImage"]),
|
||||
]);
|
||||
}
|
||||
function status($orderHeaderID)
|
||||
{
|
||||
$this->cors();
|
||||
$sql = "select auto_verif_v2.* from auto_verif_v2
|
||||
join t_orderdetail on AutoVerifT_OrderDetailID = T_OrderDetailID
|
||||
and T_OrderDetailT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$result = ["autoVerif" => [], "autoValid" => []];
|
||||
if (count($rows) > 0) {
|
||||
// auto Verif v2
|
||||
foreach ($rows as $r) {
|
||||
if (
|
||||
$r["autoVerifIsPanicValue"] == "N" &&
|
||||
$r["autoVerifIsPreAnalityc"] == "N" &&
|
||||
$r["autoVerifIsInAmr"] == "Y" &&
|
||||
$r["autoVerifIsUjiTrendOK"] == "Y"
|
||||
) {
|
||||
$result["autoVerif"][] = [
|
||||
"id" => $r["AutoVerifT_OrderDetailID"],
|
||||
"status" => true,
|
||||
];
|
||||
} else {
|
||||
$result["autoVerif"][] = [
|
||||
"id" => $r["AutoVerifT_OrderDetailID"],
|
||||
"status" => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sql = "select auto_verif.* from auto_verif
|
||||
join t_orderdetail on AutoVerifT_OrderDetailID = T_OrderDetailID
|
||||
and T_OrderDetailT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
if (
|
||||
$r["AutoVerifHaveReq"] == "N" &&
|
||||
//$r["AutoVerifDeltaCheckStatus"] == "Y" &&
|
||||
$r["AutoVerifReviewRangeIsOK"] == "Y" &&
|
||||
$r["AutoVerifTrendAnalysisStatus"] == "Y"
|
||||
) {
|
||||
$result["autoVerif"][] = [
|
||||
"id" => $r["AutoVerifT_OrderDetailID"],
|
||||
"status" => true,
|
||||
];
|
||||
} else {
|
||||
$result["autoVerif"][] = [
|
||||
"id" => $r["AutoVerifT_OrderDetailID"],
|
||||
"status" => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "select auto_valid_v2.* from auto_valid_v2
|
||||
join t_orderdetail on AutoValidT_OrderDetailID = T_OrderDetailID
|
||||
and T_OrderDetailT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0) {
|
||||
// auto valid v2
|
||||
foreach ($rows as $r) {
|
||||
if (
|
||||
$r["AutoValidAutoVerifIsOK"] == "Y" &&
|
||||
$r["AutoValidIsInReviewRange"] == "N" &&
|
||||
$r["AutoValidIsInconsistencyOK"] == "Y" &&
|
||||
$r["AutoValidReflexTestIsOK"] == "Y" &&
|
||||
$r["AutoValidIsDeltacheckOK"] == "Y"
|
||||
) {
|
||||
$result["autoValid"][] = [
|
||||
"id" => $r["AutoValidT_OrderDetailID"],
|
||||
"status" => true,
|
||||
];
|
||||
} else {
|
||||
$result["autoValid"][] = [
|
||||
"id" => $r["AutoValidT_OrderDetailID"],
|
||||
"status" => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sql = "select auto_valid.* from auto_valid
|
||||
join t_orderdetail on AutoValidT_OrderDetailID = T_OrderDetailID
|
||||
and T_OrderDetailT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
if (
|
||||
$r["AutoValidHaveReq"] == "N" &&
|
||||
$r["AutoValidIsOk"] == "Y"
|
||||
) {
|
||||
$result["autoValid"][] = [
|
||||
"id" => $r["AutoValidT_OrderDetailID"],
|
||||
"status" => true,
|
||||
];
|
||||
} else {
|
||||
$result["autoValid"][] = [
|
||||
"id" => $r["AutoValidT_OrderDetailID"],
|
||||
"status" => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode(["status" => "OK", "data" => $result]);
|
||||
}
|
||||
function print_table_style()
|
||||
{
|
||||
return "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table_one_column($rows)
|
||||
{
|
||||
$rst = "<table>";
|
||||
foreach ($rows as $r) {
|
||||
$rst .= "<tr>";
|
||||
$rst .= "<td>" . $r . "</td>";
|
||||
$rst .= "</tr>";
|
||||
}
|
||||
$rst .= "</table>";
|
||||
return $rst;
|
||||
}
|
||||
public function print_table($rows, $keys)
|
||||
{
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user