diff --git a/application/controllers/chart/The_qr.php b/application/controllers/chart/The_qr.php index 2e3fa293..4a797df0 100644 --- a/application/controllers/chart/The_qr.php +++ b/application/controllers/chart/The_qr.php @@ -5,7 +5,7 @@ class The_qr extends MY_Controller { parent::__construct(); } - public function get_one_row($sql, $param=false) + public function get_one_row($sql, $param = false) { if ($param) { $qry = $this->db->query($sql, $param); @@ -19,9 +19,9 @@ class The_qr extends MY_Controller if (count($rows) == 0) { return array("status" => 0); } - return array("status" => 1 , "data" => $rows[0]); + return array("status" => 1, "data" => $rows[0]); } - public function get_rows($sql, $param=false) + public function get_rows($sql, $param = false) { if ($param) { $qry = $this->db->query($sql, $param); @@ -35,7 +35,7 @@ class The_qr extends MY_Controller if (count($rows) == 0) { return array("status" => 0); } - return array("status" => 1 , "data" => $rows); + return array("status" => 1, "data" => $rows); } public function v1($orderHeaderID, $date = "") { @@ -52,11 +52,10 @@ class The_qr extends MY_Controller } $rows = $rs["data"]; $r = $rows[0]; - $msg =<<get_one_row($sql, array($orderHeaderID)); + if ($rs["status"] == -1) { + echo "Error : qr_printout | " . $this->db->error()["message"]; + exit; + } + if ($rs["status"] == 0) { + echo "Error : No QR Printout found."; + exit; + } + + $reportUrl = $rs["data"]["QR_PrintOutReportURL"]; + $img_qrcode = $this->post("http://localhost/charts/qrtext.php", $reportUrl); + header("Content-type: image/png"); + echo $img_qrcode; + exit; + } + public function v3_nonlab($resultEntryID) + { + $sql = " SELECT + qp.QR_PrintOutReportURL + FROM one_lab.so_resultentry se + JOIN one_lab.t_orderheader oh + ON oh.T_OrderHeaderID = se.SO_ResultEntryT_OrderHeaderID + AND oh.T_OrderHeaderIsActive = 'Y' + JOIN one_lab.qr_printout qp + ON qp.QR_PrintOutT_OrderHeaderID = oh.T_OrderHeaderID + AND qp.QR_PrintOutIsActive = 1 + WHERE se.SO_ResultEntryID = ? + ORDER BY qp.QR_PrintOutID DESC + LIMIT 1"; + $rs = $this->get_one_row($sql, array($resultEntryID)); + if ($rs["status"] == -1) { + echo "Error : qr_printout | " . $this->db->error()["message"]; + exit; + } + if ($rs["status"] == 0) { + echo "Error : No QR Printout found."; + exit; + } + + $reportUrl = $rs["data"]["QR_PrintOutReportURL"]; + $img_qrcode = $this->post("http://localhost/charts/qrtext.php", $reportUrl); + header("Content-type: image/png"); + echo $img_qrcode; + exit; + } }