Initial import
This commit is contained in:
39
application/controllers/chart/Qr_polos.php
Normal file
39
application/controllers/chart/Qr_polos.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
class Qr_polos extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function pcr($nolab)
|
||||
{
|
||||
$img_qrcode = $this->post("http://localhost/charts/qrtext.php", $nolab);
|
||||
header("Content-type: image/png");
|
||||
echo $img_qrcode;
|
||||
exit;
|
||||
}
|
||||
public function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/text',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
|
||||
if (curl_error($ch) != "") {
|
||||
return "ERROR Accessing QrCode : " . curl_error($ch) . "\n";
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
430
application/controllers/chart/The_qr.php
Normal file
430
application/controllers/chart/The_qr.php
Normal file
@@ -0,0 +1,430 @@
|
||||
<?php
|
||||
class The_qr extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function get_one_row($sql, $param = false)
|
||||
{
|
||||
if ($param) {
|
||||
$qry = $this->db->query($sql, $param);
|
||||
} else {
|
||||
$qry = $this->db->query($sql);
|
||||
}
|
||||
if (!$qry) {
|
||||
return ["status" => -1];
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
return ["status" => 0];
|
||||
}
|
||||
return ["status" => 1, "data" => $rows[0]];
|
||||
}
|
||||
public function get_rows($sql, $param = false)
|
||||
{
|
||||
if ($param) {
|
||||
$qry = $this->db->query($sql, $param);
|
||||
} else {
|
||||
$qry = $this->db->query($sql);
|
||||
}
|
||||
if (!$qry) {
|
||||
return ["status" => -1];
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
return ["status" => 0];
|
||||
}
|
||||
return ["status" => 1, "data" => $rows];
|
||||
}
|
||||
public function v1($orderHeaderID, $date = "")
|
||||
{
|
||||
$sql = "call sp_rpt_t_hasil2(?,'admin')";
|
||||
$rs = $this->get_rows($sql, [$orderHeaderID]);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
if ($rs["status"] == -1) {
|
||||
echo "Error : sp_rpt | " . $this->db->error()["message"];
|
||||
exit();
|
||||
}
|
||||
if ($rs["status"] == 0) {
|
||||
echo "Error : No Order found.";
|
||||
exit();
|
||||
}
|
||||
$rows = $rs["data"];
|
||||
$r = $rows[0];
|
||||
|
||||
$msg = <<<EOF
|
||||
{$r["T_OrderHeaderLabNumber"]}
|
||||
{$r["M_PatientName"]}
|
||||
EOF;
|
||||
$msg = trim($msg);
|
||||
$msg .= "\n";
|
||||
foreach ($rows as $r) {
|
||||
$msg .=
|
||||
$r["T_TestNameAA"] .
|
||||
" : " .
|
||||
str_replace("</br>", "", $r["T_OrderDetailResult"]) .
|
||||
"\n";
|
||||
}
|
||||
$img_qrcode = $this->post("http://localhost/charts/qrtext.php", $msg);
|
||||
header("Content-type: image/png");
|
||||
echo $img_qrcode;
|
||||
exit();
|
||||
}
|
||||
public function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/text",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
|
||||
if (curl_error($ch) != "") {
|
||||
return "ERROR Accessing QrCode : " . curl_error($ch) . "\n";
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
public function post_gz($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
$zdata = gzdeflate($data, 9);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $zdata);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/octet",
|
||||
"Content-Length: " . strlen($zdata),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
|
||||
if (curl_error($ch) != "") {
|
||||
return "ERROR Accessing QrCode : " . curl_error($ch) . "\n";
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
public function post_debug($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/text",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
|
||||
if (curl_error($ch) != "") {
|
||||
return "ERROR Accessing QrCode : " . curl_error($ch) . "\n";
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
public function v2($orderHeaderID, $date = "")
|
||||
{
|
||||
$this->load->library("Jwt");
|
||||
$sql = "call sp_rpt_t_hasil2(?,'admin')";
|
||||
$rs = $this->get_rows($sql, [$orderHeaderID]);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
if ($rs["status"] == -1) {
|
||||
echo "Error : sp_rpt | " . $this->db->error()["message"];
|
||||
exit();
|
||||
}
|
||||
if ($rs["status"] == 0) {
|
||||
echo "Error : No Order found.";
|
||||
exit();
|
||||
}
|
||||
$rows = $rs["data"];
|
||||
$secretToken = "--!!Super!!Suket#@!1231456";
|
||||
$j_result = json_encode($rows);
|
||||
$jwtToken = JWT::encode($j_result, $secretToken);
|
||||
|
||||
$rst = $this->post(
|
||||
"https://result.pramita.co.id/one-api/verify/shortener",
|
||||
$jwtToken
|
||||
);
|
||||
$j_rst = json_decode($rst, true);
|
||||
if (json_last_error_msg() != "No error") {
|
||||
echo "Error Json Token : " . json_last_error_msg();
|
||||
exit();
|
||||
}
|
||||
$url = $j_rst["url"];
|
||||
$img_qrcode = $this->post("http://localhost/charts/qrtext.php", $url);
|
||||
header("Content-type: image/png");
|
||||
echo $img_qrcode;
|
||||
exit();
|
||||
}
|
||||
|
||||
public function v3_old($orderHeaderID, $date = "")
|
||||
{
|
||||
$this->load->library("Jwt");
|
||||
$sql = "call sp_rpt_t_hasil2(?,'admin')";
|
||||
$rs = $this->get_rows($sql, [$orderHeaderID]);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
if ($rs["status"] == -1) {
|
||||
echo "Error : sp_rpt | " . $this->db->error()["message"];
|
||||
exit();
|
||||
}
|
||||
if ($rs["status"] == 0) {
|
||||
echo "Error : No Order found.";
|
||||
exit();
|
||||
}
|
||||
$rows = $rs["data"];
|
||||
$secretToken = "--!!Super!!Suket#@!1231456";
|
||||
$j_result = json_encode($rows);
|
||||
$jwtToken = JWT::encode($j_result, $secretToken);
|
||||
|
||||
$rst = $this->post(
|
||||
"https://result.pramita.co.id/one-api/verify/shortener_v2",
|
||||
$jwtToken
|
||||
);
|
||||
$j_rst = json_decode($rst, true);
|
||||
if (json_last_error_msg() != "No error") {
|
||||
echo "Error Json Token : " . json_last_error_msg();
|
||||
exit();
|
||||
}
|
||||
$url = $j_rst["url"];
|
||||
$img_qrcode = $this->post("http://localhost/charts/qrtext.php", $url);
|
||||
header("Content-type: image/png");
|
||||
echo $img_qrcode;
|
||||
exit();
|
||||
}
|
||||
public function v3_dual($orderHeaderID, $date = "")
|
||||
{
|
||||
$this->load->library("Jwt");
|
||||
$sql = "call sp_rpt_t_hasil2(?,'admin')";
|
||||
$rs = $this->get_rows($sql, [$orderHeaderID]);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
if ($rs["status"] == -1) {
|
||||
echo "Error : sp_rpt | " . $this->db->error()["message"];
|
||||
exit();
|
||||
}
|
||||
if ($rs["status"] == 0) {
|
||||
echo "Error : No Order found.";
|
||||
exit();
|
||||
}
|
||||
$rows = $rs["data"];
|
||||
$sql = "select count(*) tot
|
||||
from t_orderheaderaddon
|
||||
where T_OrderHeaderAddOnIsActive = 'Y'
|
||||
and T_OrderHeaderAddOnSecondM_LangID = 2
|
||||
and T_OrderHeaderAddOnT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
echo "Error : " . $this->db->error()["message"];
|
||||
exit();
|
||||
}
|
||||
$xrows = $qry->result_array();
|
||||
$flag_have_en = "N";
|
||||
if ($xrows[0]["tot"] > 0) {
|
||||
$flag_have_en = "Y";
|
||||
$sql = "call sp_rpt_t_hasil_eng(?,'admin')";
|
||||
$rs = $this->get_rows($sql, [$orderHeaderID]);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
if ($rs["status"] == -1) {
|
||||
echo "Error : sp_rpt | " . $this->db->error()["message"];
|
||||
exit();
|
||||
}
|
||||
$rows_en = $rs["data"];
|
||||
$result_en = [];
|
||||
$test_en = [];
|
||||
|
||||
foreach ($rows_en as $r) {
|
||||
list($dob_en, $age_en) = explode(
|
||||
"/",
|
||||
$r["T_OrderHeaderM_PatientAge"]
|
||||
);
|
||||
$age_en = trim($age_en);
|
||||
$sex_en = $r["M_SexName"];
|
||||
$name_en = $r["M_PatientName"];
|
||||
$testID = $r["T_TestID"];
|
||||
$result_en[$testID] = $r["T_OrderDetailResult"];
|
||||
$test_en[$testID] = $r["T_TestNameAA"];
|
||||
}
|
||||
}
|
||||
foreach ($rows as $idx => $r) {
|
||||
$rows[$idx]["HaveEnglish"] = $flag_have_en;
|
||||
$testID = $r["T_TestID"];
|
||||
if ($flag_have_en == "Y") {
|
||||
$rows[$idx]["M_PatientName_en"] = $name_en;
|
||||
$rows[$idx]["Umur_en"] = $age_en . " / " . $sex_en;
|
||||
$rows[$idx]["T_OrderDetailResult_en"] = $result_en[$testID];
|
||||
$rows[$idx]["T_TestNameAA_en"] = $test_en[$testID];
|
||||
} else {
|
||||
$rows[$idx]["Umur_en"] = "";
|
||||
$rows[$idx]["T_OrderDetailResult_en"] = "";
|
||||
$rows[$idx]["T_TestNameAA_en"] = "";
|
||||
$rows[$idx]["M_PatientName_en"] = "";
|
||||
}
|
||||
}
|
||||
|
||||
$secretToken = "--!!Super!!Suket#@!1231456";
|
||||
$j_result = json_encode($rows);
|
||||
if (json_last_error_msg() != "No error") {
|
||||
echo "Error Json Token : " . json_last_error_msg();
|
||||
exit();
|
||||
}
|
||||
$jwtToken = JWT::encode($j_result, $secretToken);
|
||||
$rst = $this->post_gz(
|
||||
"https://result.pramita.co.id/one-api/verify/shortener_v2_gz",
|
||||
$jwtToken
|
||||
);
|
||||
$j_rst = json_decode($rst, true);
|
||||
if (json_last_error_msg() != "No error") {
|
||||
echo "Error Json Token : " . json_last_error_msg();
|
||||
exit();
|
||||
}
|
||||
$url = $j_rst["url"];
|
||||
$img_qrcode = $this->post("http://localhost/charts/qrtext.php", $url);
|
||||
header("Content-type: image/png");
|
||||
echo $img_qrcode;
|
||||
exit();
|
||||
}
|
||||
public function v3($orderHeaerID, $date = "") {
|
||||
$this->v3_dual($orderHeaerID,$date);
|
||||
}
|
||||
public function v3_en($orderHeaderID, $date = "")
|
||||
{
|
||||
$this->load->library("Jwt");
|
||||
$sql = "call sp_rpt_t_hasil_eng(?,'admin')";
|
||||
$rs = $this->get_rows($sql, [$orderHeaderID]);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
if ($rs["status"] == -1) {
|
||||
echo "Error : sp_rpt | " . $this->db->error()["message"];
|
||||
exit();
|
||||
}
|
||||
if ($rs["status"] == 0) {
|
||||
echo "Error : No Order found.";
|
||||
exit();
|
||||
}
|
||||
$rows = $rs["data"];
|
||||
$secretToken = "--!!Super!!Suket#@!1231456";
|
||||
$j_result = json_encode($rows);
|
||||
if (json_last_error_msg() != "No error") {
|
||||
echo "Error Json Token : " . json_last_error_msg();
|
||||
exit();
|
||||
}
|
||||
$jwtToken = JWT::encode($j_result, $secretToken);
|
||||
$rst = $this->post_gz(
|
||||
"https://result.pramita.co.id/one-api/verify/shortener_v2_gz",
|
||||
$jwtToken
|
||||
);
|
||||
$j_rst = json_decode($rst, true);
|
||||
if (json_last_error_msg() != "No error") {
|
||||
echo "Error Json Token : " . json_last_error_msg();
|
||||
exit();
|
||||
}
|
||||
$url = $j_rst["url"];
|
||||
$img_qrcode = $this->post("http://localhost/charts/qrtext.php", $url);
|
||||
header("Content-type: image/png");
|
||||
echo $img_qrcode;
|
||||
exit();
|
||||
}
|
||||
|
||||
public function v3_show($orderHeaderID, $date = "")
|
||||
{
|
||||
$this->load->library("Jwt");
|
||||
$sql = "call sp_rpt_t_hasil2(?,'admin')";
|
||||
$rs = $this->get_rows($sql, [$orderHeaderID]);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
print_r($rs);
|
||||
}
|
||||
public function v3_show_en($orderHeaderID, $date = "")
|
||||
{
|
||||
$this->load->library("Jwt");
|
||||
$sql = "call sp_rpt_t_hasil_eng(?,'admin')";
|
||||
$rs = $this->get_rows($sql, [$orderHeaderID]);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
print_r($rs);
|
||||
}
|
||||
public function v3_before_dual($orderHeaderID, $date = "")
|
||||
{
|
||||
$this->load->library("Jwt");
|
||||
$sql = "call sp_rpt_t_hasil2(?,'admin')";
|
||||
$rs = $this->get_rows($sql, [$orderHeaderID]);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
if ($rs["status"] == -1) {
|
||||
echo "Error : sp_rpt | " . $this->db->error()["message"];
|
||||
exit();
|
||||
}
|
||||
if ($rs["status"] == 0) {
|
||||
echo "Error : No Order found.";
|
||||
exit();
|
||||
}
|
||||
$rows = $rs["data"];
|
||||
$secretToken = "--!!Super!!Suket#@!1231456";
|
||||
$j_result = json_encode($rows);
|
||||
if (json_last_error_msg() != "No error") {
|
||||
echo "Error Json Token : " . json_last_error_msg();
|
||||
exit();
|
||||
}
|
||||
$jwtToken = JWT::encode($j_result, $secretToken);
|
||||
$rst = $this->post_gz(
|
||||
"https://result.pramita.co.id/one-api/verify/shortener_v2_gz",
|
||||
$jwtToken
|
||||
);
|
||||
$j_rst = json_decode($rst, true);
|
||||
if (json_last_error_msg() != "No error") {
|
||||
echo "Error Json Token : " . json_last_error_msg();
|
||||
exit();
|
||||
}
|
||||
$url = $j_rst["url"];
|
||||
$img_qrcode = $this->post("http://localhost/charts/qrtext.php", $url);
|
||||
header("Content-type: image/png");
|
||||
echo $img_qrcode;
|
||||
exit();
|
||||
}
|
||||
|
||||
public function v3b($orderHeaderID, $date = "")
|
||||
{
|
||||
$this->load->library("Jwt");
|
||||
$sql = "call sp_rpt_t_hasil2(?,'admin')";
|
||||
$rs = $this->get_rows($sql, [$orderHeaderID]);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
if ($rs["status"] == -1) {
|
||||
echo "Error : sp_rpt | " . $this->db->error()["message"];
|
||||
exit();
|
||||
}
|
||||
if ($rs["status"] == 0) {
|
||||
echo "Error : No Order found.";
|
||||
exit();
|
||||
}
|
||||
$rows = $rs["data"];
|
||||
$secretToken = "--!!Super!!Suket#@!1231456";
|
||||
$j_result = json_encode($rows);
|
||||
$jwtToken = JWT::encode($j_result, $secretToken);
|
||||
if (json_last_error_msg() != "No error") {
|
||||
echo "Error Encode Json Token : " . json_last_error_msg();
|
||||
exit();
|
||||
}
|
||||
echo strlen($jwtToken) . "\n";
|
||||
$rst = $this->post(
|
||||
"https://result.pramita.co.id/one-api/verify/shortener_v2",
|
||||
$jwtToken
|
||||
);
|
||||
echo $rst;
|
||||
$j_rst = json_decode($rst, true);
|
||||
if (json_last_error_msg() != "No error") {
|
||||
echo "Error Json Token : " . json_last_error_msg();
|
||||
exit();
|
||||
}
|
||||
exit();
|
||||
$url = $j_rst["url"];
|
||||
$img_qrcode = $this->post("http://localhost/charts/qrtext.php", $url);
|
||||
header("Content-type: image/png");
|
||||
echo $img_qrcode;
|
||||
exit();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user