Initial import
This commit is contained in:
240
application/controllers/fix/Mobile_report.php
Normal file
240
application/controllers/fix/Mobile_report.php
Normal file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
class Mobile_report extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo ".: Mobile Report Check :.";
|
||||
}
|
||||
function info($nolab) {
|
||||
$sql = "select T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderLabNumberExt, T_OrderHeaderID,
|
||||
T_OnlineOrderID, T_OnlineOrderT_OrderID,
|
||||
T_OnlineTxOrgID, max(Result_ProcessToOfficeLastUpdated) maxDate ,
|
||||
max(T_OrderHeaderAddonReadyPrintDate) maxPrintDate,
|
||||
pbUploadExecuted,
|
||||
T_OrderHeaderM_PatientID
|
||||
from t_onlineorder
|
||||
join t_onlinetx on T_OnlineOrderT_OnlineTxID = T_OnlineTxID
|
||||
and T_OnlineOrderIsActive = 'Y'
|
||||
and T_OnlineTxIsActive = 'Y'
|
||||
and T_OnlineOrderUploaded is not null
|
||||
join t_orderheader
|
||||
on T_OnlineOrderT_OrderHeaderID = T_OrderHeaderID
|
||||
and date(T_OrderHeaderDate) >= '2021-12-13'
|
||||
and T_OrderHeaderLabNumber = ?
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
join pb_upload
|
||||
on pbUploadCode = 'RESULT'
|
||||
join result_processtooffice on
|
||||
Result_ProcessToOfficeT_OrderHeaderID = T_OrderHeaderID
|
||||
and Result_ProcessToOfficeIsActive = 'Y'
|
||||
group by T_OrderHeaderID
|
||||
"; $qry = $this->db->query($sql,[$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;
|
||||
}
|
||||
$maxDate = $rows[0]["maxDate"];
|
||||
|
||||
$this->print_table_style();
|
||||
$this->print_table($rows,array_keys($rows[0]));
|
||||
if (count($rows)>0) {
|
||||
$res = $this->get_report($rows[0]["T_OrderHeaderID"]);
|
||||
if(count($res) > 0 ) {
|
||||
$encDate= bin2hex($maxDate);
|
||||
$url_fix = "/one-api/fix/mobile_report/force/" . $encDate . "/$nolab";
|
||||
|
||||
echo "<br/><button onClick=\"document.location.href='$url_fix'\">Force Upload</button>";
|
||||
}
|
||||
}
|
||||
}
|
||||
function force($encDate,$nolab) {
|
||||
$maxDate = hex2bin($encDate);
|
||||
$newMax = date("Y-m-d H:i:s", strtotime($maxDate . " - 1 hour"));
|
||||
$sql = "update pb_upload set pbUploadExecuted = ? where pbUploadCode ='RESULT'";
|
||||
$qry = $this->db->query($sql,[$newMax]);
|
||||
if(!$qry){
|
||||
echo "ERR : " . $this->db->error()["message"];
|
||||
exit;
|
||||
}
|
||||
header("Location: /one-api/fix/mobile_report/info/$nolab");
|
||||
}
|
||||
function get_report($headerID)
|
||||
{
|
||||
$sql = "select distinct
|
||||
Group_ResultID,Group_ResultName,
|
||||
Group_ResultFlagNonLab,IFNULL(T_EmailNonLabUrl,'-') EmailNonLabUrl,
|
||||
IF(T_EmailNonLabUrl IS NULL AND Group_ResultFlagNonLab = 'Y',' [Belum Pilih Format Hasil]','') temail
|
||||
from
|
||||
t_orderdetail
|
||||
join group_resultdetail
|
||||
on Group_ResultDetailT_TestID = T_OrderDetailT_TestID
|
||||
and T_OrderDetailIsActive = 'Y' and Group_ResultDetailIsActive = 'Y'
|
||||
and T_OrderDetailT_OrderHeaderID = ?
|
||||
join group_result
|
||||
on Group_ResultDetailGroup_ResultID = Group_ResultID
|
||||
and Group_ResultIsActive = 'Y'
|
||||
LEFT JOIN t_email_nonlab ON T_EmailNonLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_EmailNonLabType LIKE CONCAT('%',REPLACE(Group_ResultName, 'Elektromedik', 'electromedis'),'%')
|
||||
group by Group_ResultID";
|
||||
$qry = $this->db->query($sql, [$headerID]);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} Error Ger Report : " .
|
||||
$this->db->error()["message"] .
|
||||
"|\n" .
|
||||
$this->db->last_query() .
|
||||
" \n";
|
||||
return [];
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$ts = "&ts=" . date("Ymdhis");
|
||||
$id = $headerID;
|
||||
$result = [];
|
||||
|
||||
foreach ($rows as $r) {
|
||||
$xname = $r["Group_ResultName"];
|
||||
$name = $this->escape_fname($xname);
|
||||
$gid = $r["Group_ResultID"];
|
||||
$temail = $r["temail"];
|
||||
$isnonlab = $r["Group_ResultFlagNonLab"];
|
||||
$emailnonlaburl = str_replace(" ", "", $r["EmailNonLabUrl"]);
|
||||
if (strpos($emailnonlaburl, "fisik") > 0) {
|
||||
continue;
|
||||
}
|
||||
$report = "";
|
||||
switch ($gid) {
|
||||
case 1:
|
||||
$report =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_test_email.rptdesign&__format=pdf&username=admin&PID=" .
|
||||
$id .
|
||||
$ts;
|
||||
break;
|
||||
case 2:
|
||||
$report =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_hasil_papsmear_email.rptdesign&__format=pdf&username=admin&PID=" .
|
||||
$id .
|
||||
$ts;
|
||||
break;
|
||||
case 3:
|
||||
$report =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_hasil_fna_email.rptdesign&__format=pdf&username=admin&PID=" .
|
||||
$id .
|
||||
$ts;
|
||||
break;
|
||||
case 4:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 5:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 6:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 7:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 8:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 9:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 10:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 11:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 12:
|
||||
$report =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_hasil_lcprep_email.rptdesign&__format=pdf&username=admin&PID=" .
|
||||
$id .
|
||||
$ts;
|
||||
break;
|
||||
case 13:
|
||||
$report =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_test_mikro_email.rptdesign&__format=pdf&username=admin&PID=" .
|
||||
$id .
|
||||
$ts;
|
||||
break;
|
||||
case 14:
|
||||
$report =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_hasil_cytologi_email.rptdesign&__format=pdf&username=admin&PID=" .
|
||||
$id .
|
||||
$ts;
|
||||
break;
|
||||
case 15:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 16:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 17:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
}
|
||||
$result[] = ["Group_ResultName" => $xname, "url_rpt" => $report];
|
||||
}
|
||||
$this->print_table($result,array_keys($result[0]));
|
||||
return $result;
|
||||
}
|
||||
|
||||
function escape_fname($xname)
|
||||
{
|
||||
$find = [" ", "&", '\r\n', '\n', "+", ","];
|
||||
$xname = str_replace($find, "-", $xname);
|
||||
|
||||
//delete and replace rest of special chars
|
||||
$find = ["/[^a-zA-Z0-9\-<>]/", "/[\-]+/", "/<[^>]*>/"];
|
||||
$repl = ["", "-", ""];
|
||||
$xname = preg_replace($find, $repl, $xname);
|
||||
return $xname;
|
||||
}
|
||||
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>";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user