update generate qr report
This commit is contained in:
@@ -123,7 +123,8 @@ class Uploadqrreport extends MY_Controller
|
||||
|
||||
// $url = "http://10.9.10.38:8899/xgw/upload";
|
||||
$url = $endpoint_url . "upload";
|
||||
$token = "aW5pIHRva2VuIGJ1YXQgdXBsb2FkIGlibCBxciByZXBvcnQ=";
|
||||
// $token = "aW5pIHRva2VuIGJ1YXQgdXBsb2FkIGlibCBxciByZXBvcnQ=";
|
||||
$token = "secure-token-libCBxciByZXBvcnQ=";
|
||||
|
||||
if (empty($data)) {
|
||||
echo json_encode([
|
||||
|
||||
615
application/controllers/tools/Audiometry_chart.php
Normal file
615
application/controllers/tools/Audiometry_chart.php
Normal file
@@ -0,0 +1,615 @@
|
||||
<?php
|
||||
|
||||
class Audiometry_chart extends MY_Controller
|
||||
{
|
||||
var $url_renderer;
|
||||
var $url_audio_new;
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url_renderer = "http://localhost:3030/chart";
|
||||
$this->url_audio_new = "http://localhost/xcharts/audio_metry.php";
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function v01($id)
|
||||
{
|
||||
|
||||
$icon_shape_url = array(
|
||||
'image://https://cpone.aplikasi.web.id/icon/red_circle.png',
|
||||
'image://https://cpone.aplikasi.web.id/icon/red_star.png',
|
||||
'image://https://cpone.aplikasi.web.id/icon/four_star_blue.png',
|
||||
'image://https://cpone.aplikasi.web.id/icon/blue_plus.png',
|
||||
);
|
||||
|
||||
$sql = "SELECT
|
||||
So_ResultEntryDetailID as trx_id,
|
||||
NonlabTemplateDetailCode as code,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailID as template_detail_id,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailName as result_label,
|
||||
IFNULL(So_ResultEntryDetailResult, 0) as result_value,
|
||||
So_ResultEntryDetailFlagPrint as flag_print,
|
||||
So_ResultEntryDetailResult as result_value_before,
|
||||
NonlabTemplateDetailIsResult as isResult,
|
||||
CASE
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AR%' AND NonlabTemplateDetailIsResult='Y' THEN 'AR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AL%' AND NonlabTemplateDetailIsResult='Y' THEN 'AL'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BR%' AND NonlabTemplateDetailIsResult='Y' THEN 'BR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BL%' AND NonlabTemplateDetailIsResult='Y' THEN 'BL'
|
||||
ELSE 'N'
|
||||
END as type,
|
||||
GROUP_CONCAT(CASE
|
||||
WHEN So_ResultEntryDetailResult IS NULL THEN 0
|
||||
WHEN TRIM(So_ResultEntryDetailResult) = '' THEN 0
|
||||
WHEN So_ResultEntryDetailResult REGEXP '^[0-9]+$' THEN So_ResultEntryDetailResult
|
||||
ELSE 0
|
||||
END ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID) as value
|
||||
FROM so_resultentrydetail
|
||||
JOIN nonlab_template_detail ON So_ResultEntryDetailNonlab_TemplateDetailID = NonlabTemplateDetailID
|
||||
AND NonlabTemplateDetaiM_LangID = 1
|
||||
WHERE
|
||||
So_ResultEntryDetailSo_ResultEntryID = '{$id}' AND So_ResultEntryDetailisActive = 'Y'
|
||||
GROUP BY type
|
||||
ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID
|
||||
";
|
||||
//echo $sql;
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
if (!$qry) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$acR = array();
|
||||
$acL = array();
|
||||
$bcR = array();
|
||||
$bcL = array();
|
||||
$dtls = $qry->result_array();
|
||||
foreach ($dtls as $key => $v) {
|
||||
if ($v['type'] == 'AR') {
|
||||
$acR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acR); $i++) {
|
||||
if (intval($acR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acR)) {
|
||||
$acR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'AL') {
|
||||
$acL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acL); $i++) {
|
||||
if (intval($acL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acL)) {
|
||||
$acL = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BR') {
|
||||
$bcR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcR); $i++) {
|
||||
if (intval($bcR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcR)) {
|
||||
$bcR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BL') {
|
||||
$bcL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcL); $i++) {
|
||||
if (intval($bcL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcL)) {
|
||||
$bcL = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
$param = array(
|
||||
|
||||
'tooltip' => array(
|
||||
"show" => true,
|
||||
'trigger' => 'item'
|
||||
),
|
||||
'color' => [
|
||||
"#ff0000",
|
||||
"#00ff00",
|
||||
"#0000ff",
|
||||
"#00ffff",
|
||||
],
|
||||
'xAxis' => [
|
||||
"name" => "Frequency in hertz (Hz)",
|
||||
"nameLocation" => "center",
|
||||
"nameGap" => 30,
|
||||
"showGrid" => true,
|
||||
"type" => "category",
|
||||
"data" => [250, 500, 1000, 2000, 3000, 4000, 6000, 8000],
|
||||
"forceLabelIsEnabled" => true,
|
||||
"labelCount" => 8,
|
||||
"splitLine" => [
|
||||
"show" => true,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'yAxis' => [
|
||||
"name" => "Hearing treshold level (dB)",
|
||||
"nameLocation" => "middle",
|
||||
"nameGap" => 30,
|
||||
"type" => "value",
|
||||
"inverse" => true,
|
||||
"min" => 0,
|
||||
"max" => 120,
|
||||
"interval" => 10,
|
||||
"splitLine" => [
|
||||
"interval" => 0,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'legend' => array(
|
||||
'top' => 'bottom',
|
||||
'left' => 'center',
|
||||
'orient' => 'horizontal'
|
||||
),
|
||||
'series' => array(
|
||||
array(
|
||||
"name" => "1 Right Ear",
|
||||
// "symbol" => "image://https://cpone.aplikasi.web.id/icon/red_circle.png",
|
||||
"symbol" => "circle",
|
||||
"showSymbol" => true,
|
||||
"symbolSize" => 10,
|
||||
"data" => [5, 25, 20, 25, 20, 15, 20, 25],
|
||||
// "data" => $acR,
|
||||
"type" => "line",
|
||||
"stackStrategy" => "all",
|
||||
"lineStyle" => array(
|
||||
"color" => 'red',
|
||||
"width" => 3,
|
||||
"type" => 'solid'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'red',
|
||||
"borderWidth" => 3,
|
||||
"borderColor" => '#EE6666',
|
||||
)
|
||||
),
|
||||
[
|
||||
"name" => "2 BC Right",
|
||||
// "symbol" => "image://https://cpone.aplikasi.web.id/icon/red_circle.png",
|
||||
"symbol" => "triangle",
|
||||
// "showSymbol" => true,
|
||||
// "data" => [],
|
||||
"data" => $bcR,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'red',
|
||||
"width" => 3,
|
||||
"type" => 'dashed'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'red'
|
||||
)
|
||||
],
|
||||
[
|
||||
"name" => "3 Left Ear",
|
||||
// "symbol" => $icon_shape_url[2],
|
||||
"symbol" => "diamond",
|
||||
// "showSymbol" => true,
|
||||
// "data" => [30, 30, 25, 25, 30, 20, 30, 30],
|
||||
"data" => $acL,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'blue',
|
||||
"width" => 3,
|
||||
"type" => 'solid'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'blue'
|
||||
)
|
||||
],
|
||||
[
|
||||
"name" => "4 BC Left ",
|
||||
// "symbol" => $icon_shape_url[3],
|
||||
"symbol" => "rect",
|
||||
// "showSymbol" => true,
|
||||
"data" => $bcL,
|
||||
// "data" => [],
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'blue',
|
||||
"width" => 3,
|
||||
"type" => 'dashed'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'blue',
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
// 3. encapsulate in config attribute and json encode
|
||||
// print_r($param);
|
||||
$config = ["config" => $param];
|
||||
$j_param = json_encode($config);
|
||||
header("Content-Type: image/png");
|
||||
// 4. post to chart renderer
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
}
|
||||
function v02($id)
|
||||
{
|
||||
|
||||
$icon_shape_url = array(
|
||||
'image://https://cpone.aplikasi.web.id/icon/red_circle.png',
|
||||
'image://https://cpone.aplikasi.web.id/icon/red_star.png',
|
||||
'image://https://cpone.aplikasi.web.id/icon/four_star_blue.png',
|
||||
'image://https://cpone.aplikasi.web.id/icon/blue_plus.png',
|
||||
);
|
||||
|
||||
$sql = "SELECT
|
||||
So_ResultEntryDetailID as trx_id,
|
||||
NonlabTemplateDetailCode as code,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailID as template_detail_id,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailName as result_label,
|
||||
IFNULL(So_ResultEntryDetailResult, 0) as result_value,
|
||||
So_ResultEntryDetailFlagPrint as flag_print,
|
||||
So_ResultEntryDetailResult as result_value_before,
|
||||
NonlabTemplateDetailIsResult as isResult,
|
||||
CASE
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AR%' AND NonlabTemplateDetailIsResult='Y' THEN 'AR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AL%' AND NonlabTemplateDetailIsResult='Y' THEN 'AL'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BR%' AND NonlabTemplateDetailIsResult='Y' THEN 'BR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BL%' AND NonlabTemplateDetailIsResult='Y' THEN 'BL'
|
||||
ELSE 'N'
|
||||
END as type,
|
||||
GROUP_CONCAT(CASE
|
||||
WHEN So_ResultEntryDetailResult IS NULL THEN 0
|
||||
WHEN TRIM(So_ResultEntryDetailResult) = '' THEN 0
|
||||
WHEN So_ResultEntryDetailResult REGEXP '^[0-9]+$' THEN So_ResultEntryDetailResult
|
||||
ELSE 0
|
||||
END ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID) as value
|
||||
FROM so_resultentrydetail
|
||||
JOIN nonlab_template_detail ON So_ResultEntryDetailNonlab_TemplateDetailID = NonlabTemplateDetailID
|
||||
AND NonlabTemplateDetaiM_LangID = 1
|
||||
WHERE
|
||||
So_ResultEntryDetailSo_ResultEntryID = '{$id}' AND So_ResultEntryDetailisActive = 'Y'
|
||||
GROUP BY type
|
||||
ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID
|
||||
";
|
||||
//echo $sql;
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
if (!$qry) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$acR = array();
|
||||
$acL = array();
|
||||
$bcR = array();
|
||||
$bcL = array();
|
||||
$dtls = $qry->result_array();
|
||||
foreach ($dtls as $key => $v) {
|
||||
if ($v['type'] == 'AR') {
|
||||
$acR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acR); $i++) {
|
||||
if (intval($acR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acR)) {
|
||||
$acR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'AL') {
|
||||
$acL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acL); $i++) {
|
||||
if (intval($acL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acL)) {
|
||||
$acL = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BR') {
|
||||
$bcR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcR); $i++) {
|
||||
if (intval($bcR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcR)) {
|
||||
$bcR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BL') {
|
||||
$bcL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcL); $i++) {
|
||||
if (intval($bcL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcL)) {
|
||||
$bcL = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
$param = array(
|
||||
'tooltip' => array(
|
||||
'trigger' => 'item'
|
||||
),
|
||||
// 'color' => [
|
||||
// "#ff0000",
|
||||
// "#00ff00",
|
||||
// "#0000ff",
|
||||
// "#00ffff",
|
||||
// ],
|
||||
'xAxis' => [
|
||||
"name" => "Frequency in hertz (Hz)",
|
||||
"nameLocation" => "center",
|
||||
"nameGap" => 30,
|
||||
"type" => "category",
|
||||
"data" => [250, 500, 1000, 2000, 3000, 4000, 6000, 8000],
|
||||
"splitLine" => [
|
||||
"show" => true,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'yAxis' => [
|
||||
"name" => "Hearing threshold level (dB)",
|
||||
"nameLocation" => "middle",
|
||||
"nameGap" => 30,
|
||||
"type" => "value",
|
||||
"inverse" => true,
|
||||
"min" => 0,
|
||||
"max" => 120,
|
||||
"interval" => 10,
|
||||
"splitLine" => [
|
||||
"show" => true,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'legend' => array(
|
||||
'top' => 'bottom',
|
||||
'left' => 'center',
|
||||
'orient' => 'horizontal'
|
||||
),
|
||||
'series' => array(
|
||||
[
|
||||
"name" => "1 Right Ear",
|
||||
"symbol" => "circle", // Gunakan simbol default untuk tes
|
||||
"showSymbol" => true,
|
||||
"showAllSymbol" => true,
|
||||
"symbolSize" => 10,
|
||||
"data" => $acR,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'red',
|
||||
"width" => 3,
|
||||
"type" => 'solid'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'red',
|
||||
)
|
||||
],
|
||||
array(
|
||||
"name" => "2 BC Right",
|
||||
"symbol" => "triangle",
|
||||
"showSymbol" => true,
|
||||
"symbolSize" => 10,
|
||||
"data" => $bcR,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'red',
|
||||
"width" => 3,
|
||||
"type" => 'dashed'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'red'
|
||||
)
|
||||
),
|
||||
array(
|
||||
"name" => "3 Left Ear",
|
||||
"symbol" => "diamond",
|
||||
"showSymbol" => true,
|
||||
"symbolSize" => 10,
|
||||
"data" => $acL,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'blue',
|
||||
"width" => 3,
|
||||
"type" => 'solid'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'blue'
|
||||
)
|
||||
),
|
||||
array(
|
||||
"name" => "4 BC Left",
|
||||
"symbol" => "rect",
|
||||
"showSymbol" => true,
|
||||
"symbolSize" => 10,
|
||||
"data" => $bcL,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'blue',
|
||||
"width" => 3,
|
||||
"type" => 'dashed'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'blue'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// 3. encapsulate in config attribute and json encode
|
||||
// print_r($param);
|
||||
$config = ["config" => $param];
|
||||
$j_param = json_encode($config);
|
||||
header("Content-Type: image/jpeg");
|
||||
// 4. post to chart renderer
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
}
|
||||
|
||||
function v03($id)
|
||||
{
|
||||
$sql = "SELECT
|
||||
So_ResultEntryDetailID as trx_id,
|
||||
NonlabTemplateDetailCode as code,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailID as template_detail_id,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailName as result_label,
|
||||
IFNULL(So_ResultEntryDetailResult, 0) as result_value,
|
||||
So_ResultEntryDetailFlagPrint as flag_print,
|
||||
So_ResultEntryDetailResult as result_value_before,
|
||||
NonlabTemplateDetailIsResult as isResult,
|
||||
CASE
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AR%' AND NonlabTemplateDetailIsResult='Y' THEN 'AR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AL%' AND NonlabTemplateDetailIsResult='Y' THEN 'AL'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BR%' AND NonlabTemplateDetailIsResult='Y' THEN 'BR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BL%' AND NonlabTemplateDetailIsResult='Y' THEN 'BL'
|
||||
ELSE 'N'
|
||||
END as type,
|
||||
GROUP_CONCAT(CASE
|
||||
WHEN So_ResultEntryDetailResult IS NULL THEN 0
|
||||
WHEN TRIM(So_ResultEntryDetailResult) = '' THEN 0
|
||||
WHEN So_ResultEntryDetailResult REGEXP '^[0-9]+$' THEN So_ResultEntryDetailResult
|
||||
ELSE 0
|
||||
END ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID) as value
|
||||
FROM so_resultentrydetail
|
||||
JOIN nonlab_template_detail ON So_ResultEntryDetailNonlab_TemplateDetailID = NonlabTemplateDetailID
|
||||
AND NonlabTemplateDetaiM_LangID = 1
|
||||
WHERE
|
||||
So_ResultEntryDetailSo_ResultEntryID = '{$id}' AND So_ResultEntryDetailisActive = 'Y'
|
||||
GROUP BY type
|
||||
ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
if (!$qry) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$acR = array();
|
||||
$acL = array();
|
||||
$bcR = array();
|
||||
$bcL = array();
|
||||
$dtls = $qry->result_array();
|
||||
|
||||
foreach ($dtls as $key => $v) {
|
||||
if ($v['type'] == 'AR') {
|
||||
$acR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acR); $i++) {
|
||||
if (intval($acR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acR)) {
|
||||
$acR = ["-", "-", "-", "-", "-", "-", "-", "-"];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'AL') {
|
||||
$acL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acL); $i++) {
|
||||
if (intval($acL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acL)) {
|
||||
$acL = ["-", "-", "-", "-", "-", "-", "-", "-"];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BR') {
|
||||
$bcR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcR); $i++) {
|
||||
if (intval($bcR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcR)) {
|
||||
$bcR = ["-", "-", "-", "-", "-", "-", "-", "-"];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BL') {
|
||||
$bcL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcL); $i++) {
|
||||
if (intval($bcL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcL)) {
|
||||
$bcL = ["-", "-", "-", "-", "-", "-", "-", "-"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$param = array(
|
||||
"right_ear" => $acR,
|
||||
"left_ear" => $acL,
|
||||
"bc_right" => $bcR,
|
||||
"bc_left" => $bcL
|
||||
);
|
||||
|
||||
$j_param = json_encode($param);
|
||||
// print_r($j_param);
|
||||
header("Content-Type: image/jpeg");
|
||||
echo $this->post($this->url_audio_new, $j_param);
|
||||
}
|
||||
|
||||
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, 20);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
print_r($result);
|
||||
if (curl_errno($ch) > 0) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => curl_error($ch),
|
||||
];
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode != 200) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => "Http Response : $httpCode",
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class Generateqrreport
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$CI = & get_instance();
|
||||
$CI = &get_instance();
|
||||
$this->db_smartone = $CI->load->database("default", true);
|
||||
$this->db_onedev = $CI->load->database("default", true);
|
||||
|
||||
@@ -229,7 +229,8 @@ class Generateqrreport
|
||||
|
||||
// verifyURL = URL langsung ke PDF: {base}/{uuid}.pdf
|
||||
// Golang akan upload PDF ke path ini di dedicated server
|
||||
$verifyURL = rtrim($params['verifyBaseURL'], '/') . '/' . str_replace('-', '', $uuid) . '.pdf';
|
||||
|
||||
$verifyURL = rtrim($params['verifyBaseURL'], '/') . '/' . $uuid;
|
||||
$groupResultID = (int)($params['groupResultID'] ?? 0);
|
||||
$testID = (int)($params['testID'] ?? 0);
|
||||
$groupResultName = $params['groupResultName'];
|
||||
@@ -406,8 +407,12 @@ class Generateqrreport
|
||||
$uuid = $this->_normalizeUUID($uuid);
|
||||
|
||||
if (!$this->_validateUUIDFormat($uuid)) {
|
||||
return ['success' => false, 'retry_count' => 0, 'is_permanent' => false,
|
||||
'message' => 'Format UUID tidak valid.'];
|
||||
return [
|
||||
'success' => false,
|
||||
'retry_count' => 0,
|
||||
'is_permanent' => false,
|
||||
'message' => 'Format UUID tidak valid.'
|
||||
];
|
||||
}
|
||||
|
||||
$qrRow = $this->db_smartone
|
||||
@@ -417,8 +422,12 @@ class Generateqrreport
|
||||
->row_array();
|
||||
|
||||
if (!$qrRow) {
|
||||
return ['success' => false, 'retry_count' => 0, 'is_permanent' => false,
|
||||
'message' => 'UUID tidak ditemukan.'];
|
||||
return [
|
||||
'success' => false,
|
||||
'retry_count' => 0,
|
||||
'is_permanent' => false,
|
||||
'message' => 'UUID tidak ditemukan.'
|
||||
];
|
||||
}
|
||||
|
||||
$newRetryCount = (int)$qrRow['QR_PrintOutRetryCount'] + 1;
|
||||
@@ -427,18 +436,18 @@ class Generateqrreport
|
||||
|
||||
$this->db_smartone->where('QR_PrintOutUUID', $uuid)
|
||||
->update('qr_printout', [
|
||||
'QR_PrintOutRetryCount' => $newRetryCount,
|
||||
'QR_PrintOutLastRetryAt' => date('Y-m-d H:i:s'),
|
||||
'QR_PrintOutUploadStatus' => $newStatus,
|
||||
]);
|
||||
'QR_PrintOutRetryCount' => $newRetryCount,
|
||||
'QR_PrintOutLastRetryAt' => date('Y-m-d H:i:s'),
|
||||
'QR_PrintOutUploadStatus' => $newStatus,
|
||||
]);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'retry_count' => $newRetryCount,
|
||||
'is_permanent' => $isPermanent,
|
||||
'message' => $isPermanent
|
||||
? "Retry count mencapai {$newRetryCount}. Status menjadi 'failed_permanent'. Upload otomatis dihentikan."
|
||||
: "Retry count: {$newRetryCount}/3. Akan dicoba kembali.",
|
||||
? "Retry count mencapai {$newRetryCount}. Status menjadi 'failed_permanent'. Upload otomatis dihentikan."
|
||||
: "Retry count: {$newRetryCount}/3. Akan dicoba kembali.",
|
||||
];
|
||||
}
|
||||
|
||||
@@ -476,12 +485,12 @@ class Generateqrreport
|
||||
|
||||
$this->db_smartone->where('QR_PrintOutUUID', $uuid)
|
||||
->update('qr_printout', [
|
||||
'QR_PrintOutUploadStatus' => 'pending',
|
||||
'QR_PrintOutRetryCount' => 0,
|
||||
'QR_PrintOutLastRetryAt' => null,
|
||||
'QR_PrintOutUploadedAt' => null,
|
||||
'QR_PrintOutTempFilePath' => '', // harus diisi ulang via saveTempPDF()
|
||||
]);
|
||||
'QR_PrintOutUploadStatus' => 'pending',
|
||||
'QR_PrintOutRetryCount' => 0,
|
||||
'QR_PrintOutLastRetryAt' => null,
|
||||
'QR_PrintOutUploadedAt' => null,
|
||||
'QR_PrintOutTempFilePath' => '', // harus diisi ulang via saveTempPDF()
|
||||
]);
|
||||
|
||||
if ($this->db_smartone->affected_rows() === 0) {
|
||||
return ['success' => false, 'message' => 'Gagal update database.'];
|
||||
@@ -493,7 +502,7 @@ class Generateqrreport
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Konfirmasi bahwa Golang berhasil upload PDF ke dedicated server.
|
||||
@@ -530,9 +539,9 @@ class Generateqrreport
|
||||
|
||||
$this->db_smartone->where('QR_PrintOutUUID', $uuid)
|
||||
->update('qr_printout', [
|
||||
'QR_PrintOutUploadStatus' => 'uploaded',
|
||||
'QR_PrintOutUploadedAt' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
'QR_PrintOutUploadStatus' => 'uploaded',
|
||||
'QR_PrintOutUploadedAt' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
if ($this->db_smartone->affected_rows() === 0) {
|
||||
return ['success' => false, 'message' => 'Gagal update database.'];
|
||||
@@ -554,9 +563,9 @@ class Generateqrreport
|
||||
$uuid = $this->_normalizeUUID($uuid);
|
||||
$this->db_smartone->where('QR_PrintOutUUID', $uuid)
|
||||
->update('qr_printout', [
|
||||
'QR_PrintOutUploadStatus' => 'failed_permanent',
|
||||
'QR_PrintOutRetryCount' => 3,
|
||||
]);
|
||||
'QR_PrintOutUploadStatus' => 'failed_permanent',
|
||||
'QR_PrintOutRetryCount' => 3,
|
||||
]);
|
||||
return $this->db_smartone->affected_rows() > 0;
|
||||
}
|
||||
|
||||
@@ -595,8 +604,12 @@ class Generateqrreport
|
||||
$uuid = $this->_normalizeUUID($uuid);
|
||||
|
||||
if (!$this->_validateUUIDFormat($uuid)) {
|
||||
return ['success' => false, 'report_url' => null, 'qr_info' => null,
|
||||
'message' => 'Format UUID tidak valid.'];
|
||||
return [
|
||||
'success' => false,
|
||||
'report_url' => null,
|
||||
'qr_info' => null,
|
||||
'message' => 'Format UUID tidak valid.'
|
||||
];
|
||||
}
|
||||
|
||||
$qrRow = $this->db_smartone
|
||||
@@ -606,8 +619,12 @@ class Generateqrreport
|
||||
->row_array();
|
||||
|
||||
if (!$qrRow) {
|
||||
return ['success' => false, 'report_url' => null, 'qr_info' => null,
|
||||
'message' => 'QR Code tidak ditemukan atau sudah tidak aktif.'];
|
||||
return [
|
||||
'success' => false,
|
||||
'report_url' => null,
|
||||
'qr_info' => null,
|
||||
'message' => 'QR Code tidak ditemukan atau sudah tidak aktif.'
|
||||
];
|
||||
}
|
||||
|
||||
// verifyURL = URL langsung ke PDF, hanya valid jika sudah ter-upload
|
||||
@@ -638,8 +655,7 @@ class Generateqrreport
|
||||
$result = mysqli_use_result($dbc);
|
||||
if (get_class($result) == 'mysqli_stmt') {
|
||||
mysqli_stmt_free_result($result);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
unset($result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user