Files
BE_CPONE/application/controllers/process/Check_verif.php
2026-04-27 10:26:26 +07:00

127 lines
4.3 KiB
PHP

<?php
class Check_verif extends MY_Controller
{
function __construct()
{
parent::__construct();
}
function do($nolab, $px)
{
$nolab = "%" . $nolab;
$sql = "select T_OrderHeaderID,T_OrderHeaderLabNumber,T_OrderHeaderDate
from t_orderheader where T_OrderHeaderLabNumber like ?";
$qry = $this->db->query($sql, [$nolab]);
if (!$qry) {
echo "<h3> Error t_orderheader : " .
$this->db->error()["message"] .
"</h3>";
exit();
}
$rows = $qry->result_array();
if (count($rows) == 0) {
echo "<h3> Order not found $nolab</h3>";
exit();
}
$orderID = [];
foreach ($rows as $idx => $r) {
$orderID[] = $r["T_OrderHeaderID"];
unset($rows[$idx]["T_OrderHeaderID"]);
}
$this->print_table_style();
$this->print_table($rows, array_keys($rows[0]));
$sids = implode(",", $orderID);
$sql = "select T_OrderHeaderLabNumber, T_OrderDetailID,T_OrderDetailT_TestName,
T_OrderDetailID,T_OrderDetailResult,T_OrderDetailVerUserID, T_OrderDetailVerDate,T_OrderHeaderID
from
t_orderdetail
join t_orderheader on T_OrderDetailT_OrderHeaderID in ({$sids})
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
and T_OrderDetailIsActive = 'Y'
order by T_OrderHeaderLabNumber";
$qry = $this->db->query($sql);
if (!$qry) {
echo "<h3> Error Get Order Detail : " .
$this->db->error()["message"] .
"|" .
$this->db->last_query() .
"</h3>";
exit();
}
$rows = $qry->result_array();
$rows = array_filter($rows, function ($d) use ($px) {
return preg_match("/{$px}*/", $d["T_OrderDetailT_TestName"]) == 1;
});
$sql = "select * from auto_verif where AutoVerifT_OrderDetailID = ?";
foreach ($rows as $idx => $r) {
echo "<h4> {$r["T_OrderHeaderLabNumber"]} | {$r["T_OrderDetailT_TestName"]} | {$r["T_OrderDetailVerUserID"]} | {$r["T_OrderDetailVerDate"]} AutoVerif :</h4> \n";
$qry = $this->db->query($sql, [$r["T_OrderDetailID"]]);
if (!$qry) {
echo "<h3> Error Get Auto Verif : " .
$this->db->error()["message"] .
"</h3>";
exit();
}
$drows = $qry->result_array();
foreach ($drows as $didx => $xr) {
unset($drows[$didx]["AutoVerifAmrIsOk"]);
unset($drows[$didx]["AutoVerifAmrNote"]);
}
$this->print_table($drows, array_keys($drows[0]));
$url =
"http://localhost/one-api/process/auto_verif_valid/info_verif/" .
$r["T_OrderDetailID"];
$info = file_get_contents($url);
$ainfo = json_decode($info, true);
echo "<pre>INFO: [{$r["T_OrderDetailID"]}] \n";
print_r($ainfo);
echo "</pre>";
if ($info["image"] != "") {
$url_img = $ainfo["image"];
echo "<img src='{$url_img}'>";
}
$url_status =
"http://localhost/one-api/process/auto_verif_valid/status/" .
$r["T_OrderHeaderID"];
$status = file_get_contents($url_status);
$astatus = json_decode($status, true);
echo "<pre>STATUS: $url_status \n";
print_r($astatus);
echo "<pre>";
}
}
public function print_table_style()
{
echo "
<style>
th, td {
padding: 15px;
text-align: left;
}
tr:nth-child(even) {background-color: #f2f2f2;}
table {
border: solid 1px ;
min-width:600px;
}
</style>
";
}
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>";
}
}