116 lines
3.4 KiB
PHP
116 lines
3.4 KiB
PHP
<?php
|
|
|
|
class Qr_result extends MY_Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
echo ".: Qr Result Dual :.";
|
|
}
|
|
function dual($nolab)
|
|
{
|
|
$sql = "select T_OrderHeaderLabNumber,
|
|
T_OrderHeaderLabNumberExt, T_OrderHeaderID,
|
|
JSON_UNQUOTE(
|
|
JSON_EXTRACT(fn_get_patient_atribute(T_OrderHeaderM_PatientID), '$.patient_fullname')) as Patient
|
|
from
|
|
t_orderheader
|
|
where ( T_OrderHeaderLabNumber = ? or T_OrderHeaderLabNumberExt = ? ) ";
|
|
$qry = $this->db->query($sql, [$nolab,$nolab]);
|
|
if (!$qry) {
|
|
echo json_encode([
|
|
"status" => "ERR",
|
|
"message" => print_r($this->db->error(), true),
|
|
]);
|
|
exit();
|
|
}
|
|
$rows = $qry->result_array();
|
|
if (count($rows) == 0) {
|
|
echo $this->db->last_query();
|
|
echo "No record";
|
|
exit();
|
|
}
|
|
$orderHeaderID = $rows[0]["T_OrderHeaderID"];
|
|
$sql = "select count(*) xtot
|
|
from
|
|
t_orderheaderaddon
|
|
where T_OrderHeaderAddOnT_OrderHeaderID=? and T_OrderHeaderAddOnSecondM_LangID = 2";
|
|
|
|
$qry = $this->db->query($sql, [$orderHeaderID]);
|
|
if (!$qry) {
|
|
echo json_encode([
|
|
"status" => "ERR",
|
|
"message" => print_r($this->db->error(), true),
|
|
]);
|
|
exit();
|
|
}
|
|
$xrows = $qry->result_array();
|
|
$flag_have_en = true;
|
|
if (count($xrows) == 0) {
|
|
$flag_have_en = false;
|
|
}
|
|
foreach($rows as $idx => $r) {
|
|
unset($rows[$idx]["T_OrderHeaderID"]);
|
|
$rows[$idx]["English"] = $flag_have_en ? "Requested" : "Not Requested";
|
|
}
|
|
$this->print_table_style();
|
|
$this->print_table($rows, array_keys($rows[0]));
|
|
echo "<br/>";
|
|
$url_barcode = "/one-api/chart/the_qr/v3_dual/$orderHeaderID/" . date("Y-m-dHis");
|
|
echo "<div style='margin-left:15%'> <image src='$url_barcode' style='width:350px'/> </div>";
|
|
if ($flag_have_en) {
|
|
echo "Call sp_rpt_t_hasil_eng($orderHeaderID,'admin'), hasil :<br/>\n";
|
|
$sql = "call sp_rpt_t_hasil_eng(?,'admin')";
|
|
$qry = $this->db->query($sql,[$orderHeaderID]);
|
|
if (!$qry) {
|
|
echo json_encode([
|
|
"status" => "ERR",
|
|
"message" => print_r($this->db->error(), true),
|
|
]);
|
|
exit();
|
|
}
|
|
$rows = $qry->result_array();
|
|
print_r($rows);
|
|
}
|
|
}
|
|
|
|
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)
|
|
{
|
|
$this->print_table_style();
|
|
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>";
|
|
}
|
|
}
|