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; } }