877 lines
31 KiB
Plaintext
877 lines
31 KiB
Plaintext
<?php
|
|
|
|
class Mcu_chartgenerator extends MY_Controller
|
|
{
|
|
var $url_renderer;
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->url_renderer = "http://localhost:3030/chart";
|
|
}
|
|
|
|
function get_graph_image($id){
|
|
$sql = "SELECT *
|
|
FROM mcu_image_grafik
|
|
WHERE
|
|
Mcu_ImageGrafikID = ?";
|
|
$qry = $this->db->query($sql,[$id]);
|
|
$data_graph = $qry->row_array();
|
|
|
|
$option = json_decode($data_graph['Mcu_ImageGrafikJsonRender'],true);
|
|
//print_r($option);
|
|
|
|
$config = ["config" => $option];
|
|
$j_param = json_encode($config);
|
|
header("Content-Type: image/png");
|
|
echo $this->post($this->url_renderer, $j_param);
|
|
|
|
}
|
|
|
|
function render_graph_global($id){
|
|
$graph_global = [];
|
|
$sql = "SELECT *
|
|
FROM mcu_image_grafik
|
|
WHERE
|
|
Mcu_ImageGrafikGroupMenu = 'GLOBAL' AND Mcu_ImageGrafikIsActive = 'Y'";
|
|
$qry = $this->db->query($sql);
|
|
$data_graph = $qry->result_array();
|
|
$option_not_found = [
|
|
"title" => [
|
|
"text" => "Kelainan Global (10 Terbesar)",
|
|
"show" => true
|
|
],
|
|
"graphic" => [
|
|
"elements" => [
|
|
[
|
|
"type" => "text",
|
|
"left" => "center",
|
|
"top" => "middle",
|
|
"style" => [
|
|
"text" => "Data tidak ditemukan",
|
|
"fontSize" => 18,
|
|
"color" => "#42aaf5"
|
|
]
|
|
]
|
|
]
|
|
]
|
|
];
|
|
$option = [
|
|
'title' => [
|
|
"text" => "Kelainan Global (10 Terbesar)",
|
|
"show" => true,
|
|
'left' => 'center'
|
|
],
|
|
'dataset' => [
|
|
'source' => []
|
|
],
|
|
'grid' => ['containLabel' => true],
|
|
'xAxis' => ['name' => 'persen'],
|
|
'yAxis' => ['type' => 'category'],
|
|
'series' => [
|
|
[
|
|
'type' => 'bar',
|
|
'encode' => [
|
|
'x' => 'persen',
|
|
'y' => 'kelainan'
|
|
]
|
|
]
|
|
]
|
|
];
|
|
|
|
$datasource = [];
|
|
|
|
|
|
$sql = "SELECT *
|
|
FROM mcu_mapping_kelainangroupsummary
|
|
JOIN mcu_kelainangroupsummary ON Mcu_Mapping_KeliananGroupSummaryMcu_KelainanGroupSummaryID = Mcu_KelainanGroupSummaryID
|
|
WHERE
|
|
Mcu_Mapping_KeliananGroupSummaryMgm_McuID = ? AND Mcu_Mapping_KeliananGroupSummaryIsActive = 'Y'";
|
|
$qry = $this->db->query($sql, [$id]);
|
|
$datas = $qry->result_array();
|
|
//echo $this->db->last_query();
|
|
foreach ($datas as $key => $value) {
|
|
$sql = "CALL sp_get_data_graph_summary_report_xtotal(?,?)";
|
|
//echo $sql;
|
|
$query = $this->db->query($sql,[
|
|
$id,
|
|
$value['Mcu_KelainanGroupSummaryID']
|
|
]);
|
|
//echo $this->db->last_query();
|
|
if ($query)
|
|
{
|
|
$rst = $query->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
|
|
$total_peserta = 0;
|
|
$total = 0;
|
|
if($rst){
|
|
foreach ($rst as $k => $v) {
|
|
$total_peserta = $total_peserta + $v['total_peserta'];
|
|
$total = $total + $v['total'];
|
|
}
|
|
|
|
$percentase = ($total/$total_peserta) * 100;
|
|
$percentase = round($percentase,2);
|
|
//echo $percentase;
|
|
}
|
|
|
|
$datasource[] = [$percentase,$value['Mcu_KelainanGroupSummaryName']];
|
|
// print_r($datasource);
|
|
}
|
|
}
|
|
// print_r($datasource);
|
|
$option['dataset']['source'] = $datasource;
|
|
//echo json_encode($option);
|
|
|
|
if(count($data_graph) == 0){
|
|
$sql = "INSERT INTO mcu_image_grafik(
|
|
Mcu_ImageGrafikMgm_McuID,
|
|
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
|
Mcu_ImageGrafikGroupMenu,
|
|
Mcu_ImageGrafikName,
|
|
Mcu_ImageGrafikType,
|
|
Mcu_ImageGrafikUseRest,
|
|
Mcu_ImageGrafikRestLabel,
|
|
Mcu_ImageGrafikJsonRender,
|
|
Mcu_ImageGrafikJsonNotFound,
|
|
Mcu_ImageGrafikCreated
|
|
)
|
|
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
|
$qry = $this->db->query($sql,[
|
|
$id,
|
|
0,
|
|
'GLOBAL',
|
|
"Kelainan Global ( 10 Besar )",
|
|
'bar ',
|
|
'Y',
|
|
'Normal',
|
|
json_encode($option),
|
|
json_encode($option_not_found)
|
|
]);
|
|
}else{
|
|
$sql = "UPDATE mcu_image_grafik SET
|
|
Mcu_ImageGrafikJsonRender = ?
|
|
WHERE
|
|
Mcu_ImageGrafikID = ?";
|
|
$qry = $this->db->query($sql,[
|
|
json_encode($option),
|
|
$data_graph[0]['Mcu_ImageGrafikID']
|
|
]);
|
|
}
|
|
|
|
//echo json_encode($option);
|
|
return true;
|
|
}
|
|
|
|
function render_graph_image($id){
|
|
$sql = "SELECT *
|
|
FROM mcu_image_grafik
|
|
WHERE
|
|
Mcu_ImageGrafikID = ?";
|
|
$qry = $this->db->query($sql,[$id]);
|
|
$data_graph = $qry->row_array();
|
|
|
|
$datas = [];
|
|
$typeResult = "";
|
|
if($data_graph['Mcu_ImageGrafikGroupMenu'] == 'PESERTA' && intval($data_graph['Mcu_ImageGrafikMcu_KelainanGroupSummaryID']) == 1){
|
|
$sql = "SELECT
|
|
COUNT(distinct(T_OrderHeaderID)) as peserta,
|
|
COUNT( distinct(Mcu_PreregisterPatientsM_PatientID)) as total
|
|
FROM mcu_preregister_patients
|
|
LEFT JOIN t_orderheader ON Mcu_PreregisterPatientsT_OrderHeaderID = T_OrderHeaderID AND
|
|
T_OrderHeaderIsActive = 'Y'
|
|
WHERE
|
|
Mcu_PreregisterPatientsMgm_McuID = ? AND
|
|
Mcu_PreregisterPatientsIsActive = 'Y'";
|
|
|
|
$qry = $this->db->query($sql, [$data_graph['Mcu_ImageGrafikMgm_McuID']]);
|
|
//echo $this->db->last_query();
|
|
$data_peserta = $qry->row_array();
|
|
|
|
$peserta = $data_peserta['peserta'];
|
|
$total = $data_peserta['total'];
|
|
$belummcu = $total - $peserta;
|
|
$datas[] = array('value' => $peserta ,'name' => $peserta." : Sudah MCU");
|
|
$datas[] = array('value' => $belummcu ,'name' => $belummcu.' : Belum MCU');
|
|
}
|
|
|
|
if($data_graph['Mcu_ImageGrafikGroupMenu'] == 'PESERTA' && intval($data_graph['Mcu_ImageGrafikMcu_KelainanGroupSummaryID']) == 2){
|
|
$sql = "SELECT IF(M_PatientGender = 'male','Laki-laki','Perempuan') as M_PatientGender,
|
|
COUNT(T_OrderHeaderID) as Jumlah
|
|
FROM t_orderheader
|
|
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND M_PatientIsActive = 'Y'
|
|
WHERE T_OrderHeaderMgm_McuID = ? AND T_OrderHeaderIsActive = 'Y'
|
|
GROUP BY M_PatientGender";
|
|
|
|
$qry = $this->db->query($sql, [$data_graph['Mcu_ImageGrafikMgm_McuID']]);
|
|
//echo $this->db->last_query();
|
|
$data_peserta = $qry->result_array();
|
|
foreach ($data_peserta as $key => $vx) {
|
|
$datas[] = array(
|
|
"value" => $vx["Jumlah"],
|
|
"name" => $vx['Jumlah']." : ".$vx["M_PatientGender"]
|
|
);
|
|
}
|
|
//print_r($datas);
|
|
}
|
|
|
|
if($data_graph['Mcu_ImageGrafikGroupMenu'] == 'PESERTA' && intval($data_graph['Mcu_ImageGrafikMcu_KelainanGroupSummaryID']) == 3){
|
|
$sql = "SELECT
|
|
CASE
|
|
WHEN LEFT(T_OrderHeaderM_PatientAge,2) < '30' THEN '< 30 tahun'
|
|
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '30' AND left(T_OrderHeaderM_PatientAge,2) < '40' THEN '30 - 40 tahun'
|
|
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '40' AND left(T_OrderHeaderM_PatientAge,2) < '50' THEN '40 - < 50 tahun'
|
|
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '50' THEN '4. > 50 tahun' ELSE ''
|
|
END AS umur,
|
|
COUNT(T_OrderHeaderID) as total
|
|
FROM t_orderheader
|
|
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND M_PatientIsActive = 'Y'
|
|
WHERE t_orderheaderMgm_McuID = ? AND T_OrderHeaderIsActive = 'Y'
|
|
GROUP BY
|
|
CASE
|
|
WHEN LEFT(T_OrderHeaderM_PatientAge,2) < '30' THEN '< 30 tahun'
|
|
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '30' AND left(T_OrderHeaderM_PatientAge,2) < '40' THEN '30 - 40 tahun'
|
|
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '40' AND left(T_OrderHeaderM_PatientAge,2) < '50' THEN '40 - 50 tahun'
|
|
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '50' THEN '> 50 tahun' ELSE ''
|
|
END
|
|
ORDER BY umur";
|
|
|
|
$qry = $this->db->query($sql, [$data_graph['Mcu_ImageGrafikMgm_McuID']]);
|
|
//echo $this->db->last_query();
|
|
$data_peserta = $qry->result_array();
|
|
foreach ($data_peserta as $key => $vx) {
|
|
$datas[] = array(
|
|
"value" => $vx["total"],
|
|
"name" => $vx['total']." : ".$vx["umur"]
|
|
);
|
|
}
|
|
//print_r($datas);
|
|
}
|
|
$typeResult = "";
|
|
$data_axis = [];
|
|
$nodata = false;
|
|
$option_pie_normal = "";
|
|
if($data_graph['Mcu_ImageGrafikGroupMenu'] == 'SUMMARY'){
|
|
$sql = "CALL sp_get_data_graph_summary_report(?,?)";
|
|
//echo $sql;
|
|
$query = $this->db->query($sql,[
|
|
$data_graph['Mcu_ImageGrafikMgm_McuID'],
|
|
$data_graph['Mcu_ImageGrafikMcu_KelainanGroupSummaryID']
|
|
]);
|
|
//echo $this->db->last_query();
|
|
if ($query)
|
|
{
|
|
$rst = $query->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
//print_r($rst);
|
|
$total_all = 0;
|
|
$total = 0;
|
|
if($rst){
|
|
foreach ($rst as $key => $value) {
|
|
$typeResult = $value['type'];
|
|
$total_all = floatval($value['total_peserta']);
|
|
$total = floatval($total) + floatval($value["total"]);
|
|
if($value["kelainan"] != 'No Data'){
|
|
$datas[] = array(
|
|
"value" => $value["total"],
|
|
"name" => $value["total"]." : ".$this->splitString($value["kelainan"])
|
|
);
|
|
$data_axis[] = $this->splitString($value["kelainan"]);
|
|
}else{
|
|
$nodata = true;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
if($data_graph['Mcu_ImageGrafikType'] == 'pie' && $data_graph['Mcu_ImageGrafikUseRest'] == 'Y'){
|
|
$total_rest = $total_all - $total;
|
|
$xname = $total_rest." : ".$data_graph['Mcu_ImageGrafikRestLabel'];
|
|
|
|
$datas[] = array("value" => $total_rest, "name" => $xname);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
//echo count($datas) ;
|
|
//echo $data_graph['Mcu_ImageGrafikName'];
|
|
|
|
if(count($datas) > 0){
|
|
|
|
$option = json_decode($data_graph['Mcu_ImageGrafikJson'], true);
|
|
$option['title']['text'] = $data_graph['Mcu_ImageGrafikName'];
|
|
|
|
if($data_graph['Mcu_ImageGrafikType'] == 'bar' ){
|
|
$option['series'][0]['name'] = $data_graph['Mcu_ImageGrafikName'];
|
|
$option['series'][0]['data'] = $datas;
|
|
$option['xAxis']['data'] = $data_axis;
|
|
}else{
|
|
$option['series']['name'] = $data_graph['Mcu_ImageGrafikName'];
|
|
$option['series']['data'] = $datas;
|
|
}
|
|
|
|
if($nodata){
|
|
$option = [
|
|
"title" => [
|
|
"text" => $data_graph['Mcu_ImageGrafikName'],
|
|
'subtext' => '',
|
|
"show" => true,
|
|
'left' => 'center'
|
|
],
|
|
"tooltip" => [
|
|
"trigger" => "item"
|
|
],
|
|
"legend" => [
|
|
"top" => "5%",
|
|
"left" => "center",
|
|
"show" => false
|
|
],
|
|
"series" => [
|
|
[
|
|
"name" => $data_graph['Mcu_ImageGrafikName'],
|
|
"type" => "pie",
|
|
"radius" => ["40%", "70%"],
|
|
"avoidLabelOverlap" => false,
|
|
"label" => [
|
|
"show" => true,
|
|
"position" => "center"
|
|
],
|
|
"emphasis" => [
|
|
"label" => [
|
|
"show" => true,
|
|
"fontSize" => 40,
|
|
"fontWeight" => "bold"
|
|
]
|
|
],
|
|
"labelLine" => [
|
|
"show" => true
|
|
],
|
|
"data" => [
|
|
['value' => 0,'name' => $data_graph['Mcu_ImageGrafikRestLabel']]
|
|
]
|
|
|
|
]
|
|
]
|
|
];
|
|
}
|
|
//print_r($option);
|
|
//echo json_encode($option);
|
|
}else{
|
|
$option = json_decode($data_graph['Mcu_ImageGrafikJsonNotFound'], true);
|
|
$option['title']['text'] = $data_graph['Mcu_ImageGrafikName'];
|
|
//$option = json_decode($data_graph['Mcu_ImageGrafikJsonNotFound']);
|
|
}
|
|
|
|
|
|
$sql = "UPDATE mcu_image_grafik
|
|
SET
|
|
Mcu_ImageGrafikJsonRender = ?,
|
|
Mcu_ImageGrafikGroupResult = ?
|
|
WHERE
|
|
Mcu_ImageGrafikID = ?";
|
|
$qry = $this->db->query($sql,[
|
|
json_encode($option),
|
|
$typeResult,
|
|
$id
|
|
]);
|
|
|
|
//echo json_encode($option);
|
|
return true;
|
|
|
|
}
|
|
|
|
function gengraph_global(){
|
|
$prm = $this->sys_input;
|
|
$id = $prm["Mgm_McuID"];
|
|
$this->render_graph_global($id);
|
|
$result = array(
|
|
"status" => "OK"
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
|
|
}
|
|
|
|
function generate_graph(){
|
|
$prm = $this->sys_input;
|
|
$id = $prm["Mgm_McuID"];
|
|
$this->render_graph_all($id);
|
|
}
|
|
|
|
function render_graph_all($id){
|
|
$def_gen = $this->generate_default_graph($id);
|
|
if($def_gen){
|
|
$sql = "SELECT *
|
|
FROM mcu_image_grafik
|
|
WHERE
|
|
Mcu_ImageGrafikMgm_McuID = ? AND Mcu_ImageGrafikIsActive = 'Y'";
|
|
$qry = $this->db->query($sql,[$id]);
|
|
$datas = $qry->result_array();
|
|
if($datas){
|
|
foreach ($datas as $key => $value) {
|
|
$this->render_graph_image($value['Mcu_ImageGrafikID']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$result = array(
|
|
"status" => "OK"
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function generate_default_graph($id)
|
|
{
|
|
$title = "";
|
|
$param_not_found = [
|
|
"title" => [
|
|
"text" => $title,
|
|
'subtext' => '',
|
|
"show" => true,
|
|
'left' => 'center'
|
|
],
|
|
"graphic" => [
|
|
"elements" => [
|
|
[
|
|
"type" => "text",
|
|
"left" => "center",
|
|
"top" => "middle",
|
|
"style" => [
|
|
"text" => "Data tidak ditemukan",
|
|
"fontSize" => 18,
|
|
"color" => "#42aaf5"
|
|
]
|
|
]
|
|
]
|
|
]
|
|
];
|
|
|
|
$param = array(
|
|
'title' => array(
|
|
"text" => $title,
|
|
'subtext' => '',
|
|
"show" => true,
|
|
'left' => 'center'
|
|
),
|
|
'tooltip' => array(
|
|
'trigger' => 'item'
|
|
),
|
|
'legend' => array(
|
|
'orient' => 'vertical',
|
|
'left' => 'left',
|
|
'show' => false
|
|
),
|
|
'series' => array(
|
|
'name' => 'Access From',
|
|
'type' => 'pie',
|
|
'radius' => ['40%', '70%'],
|
|
'labelLine' => [
|
|
'length' => 30
|
|
],
|
|
'data' => []
|
|
)
|
|
);
|
|
|
|
$option_not_found = [
|
|
"title" => [
|
|
"text" => $title,
|
|
'subtext' => '',
|
|
"show" => true,
|
|
'left' => 'center'
|
|
],
|
|
"graphic" => [
|
|
"elements" => [
|
|
[
|
|
"type" => "text",
|
|
"left" => "center",
|
|
"top" => "middle",
|
|
"style" => [
|
|
"text" => "Data tidak ditemukan",
|
|
"fontSize" => 18,
|
|
"color" => "#42aaf5"
|
|
]
|
|
]
|
|
]
|
|
]
|
|
];
|
|
|
|
$option = [
|
|
"title" => [
|
|
"text" => $title,
|
|
'subtext' => '',
|
|
"show" => true,
|
|
'left' => 'center'
|
|
],
|
|
"dataset" => [
|
|
"source" => []
|
|
],
|
|
"grid" => [
|
|
"containLabel" => true
|
|
],
|
|
"xAxis" => [
|
|
"data" => [],
|
|
"type" => "category",
|
|
/*"axisLabel" => [
|
|
"interval" => 0,
|
|
"rotate" => 20
|
|
]*/
|
|
"axisLabel" => [
|
|
"interval" => 0,
|
|
"width" => 80,
|
|
"rotate" => 20
|
|
]
|
|
],
|
|
"yAxis" => [
|
|
"type" => "value",
|
|
"name" => "",
|
|
"nameTextStyle" => [
|
|
"align" => "right"
|
|
],
|
|
"nameGap" => 20
|
|
],
|
|
"visualMap" => [
|
|
"orient" => "horizontal",
|
|
"left" => "center",
|
|
"min" => 0,
|
|
"max" => count($data),
|
|
"dimension" => 0,
|
|
"show" => false,
|
|
"inRange" => [
|
|
"color" => ["#42aaf5", "#00eaf2", "#035bff"]
|
|
]
|
|
],
|
|
"series" => [
|
|
[
|
|
"label" => [
|
|
"position" => "inside",
|
|
"show" => true,
|
|
"formatter" => "{@[1]}"
|
|
],
|
|
"type" => "bar",
|
|
"encode" => [
|
|
"x" => "kelainan",
|
|
"y" => "jumlah"
|
|
]
|
|
]
|
|
],
|
|
"tooltip" => [
|
|
"trigger" => "axis",
|
|
"axisPointer" => [
|
|
"type" => "shadow"
|
|
]
|
|
],
|
|
];
|
|
|
|
|
|
$title = "Peserta MCU";
|
|
$sql = "INSERT INTO mcu_image_grafik(
|
|
Mcu_ImageGrafikMgm_McuID,
|
|
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
|
Mcu_ImageGrafikGroupMenu,
|
|
Mcu_ImageGrafikName,
|
|
Mcu_ImageGrafikType,
|
|
Mcu_ImageGrafikUseRest,
|
|
Mcu_ImageGrafikRestLabel,
|
|
Mcu_ImageGrafikJson,
|
|
Mcu_ImageGrafikJsonNotFound,
|
|
Mcu_ImageGrafikCreated
|
|
)
|
|
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
|
$qry = $this->db->query($sql,[
|
|
$id,
|
|
1,
|
|
'PESERTA',
|
|
"Peserta MCU",
|
|
'pie',
|
|
'Y',
|
|
'Normal',
|
|
json_encode($param),
|
|
json_encode($param_not_found)
|
|
]);
|
|
|
|
$sql = "INSERT INTO mcu_image_grafik(
|
|
Mcu_ImageGrafikMgm_McuID,
|
|
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
|
Mcu_ImageGrafikGroupMenu,
|
|
Mcu_ImageGrafikName,
|
|
Mcu_ImageGrafikType,
|
|
Mcu_ImageGrafikUseRest,
|
|
Mcu_ImageGrafikRestLabel,
|
|
Mcu_ImageGrafikJson,
|
|
Mcu_ImageGrafikJsonNotFound,
|
|
Mcu_ImageGrafikCreated
|
|
)
|
|
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
|
$qry = $this->db->query($sql,[
|
|
$id,
|
|
1,
|
|
'PESERTA',
|
|
"Peserta MCU",
|
|
'bar',
|
|
'Y',
|
|
'Normal',
|
|
json_encode($option),
|
|
json_encode($option_not_found)
|
|
]);
|
|
|
|
$title = "Peserta MCU Berdasarkan Jenis Kelamin";
|
|
$sql = "INSERT INTO mcu_image_grafik(
|
|
Mcu_ImageGrafikMgm_McuID,
|
|
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
|
Mcu_ImageGrafikGroupMenu,
|
|
Mcu_ImageGrafikName,
|
|
Mcu_ImageGrafikType,
|
|
Mcu_ImageGrafikUseRest,
|
|
Mcu_ImageGrafikRestLabel,
|
|
Mcu_ImageGrafikJson,
|
|
Mcu_ImageGrafikJsonNotFound,
|
|
Mcu_ImageGrafikCreated
|
|
)
|
|
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
|
$qry = $this->db->query($sql,[
|
|
$id,
|
|
2,
|
|
'PESERTA',
|
|
"Peserta MCU Berdasarkan Jenis Kelamin",
|
|
'pie',
|
|
'Y',
|
|
'Normal',
|
|
json_encode($param),
|
|
json_encode($param_not_found)
|
|
]);
|
|
|
|
$sql = "INSERT INTO mcu_image_grafik(
|
|
Mcu_ImageGrafikMgm_McuID,
|
|
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
|
Mcu_ImageGrafikGroupMenu,
|
|
Mcu_ImageGrafikName,
|
|
Mcu_ImageGrafikType,
|
|
Mcu_ImageGrafikUseRest,
|
|
Mcu_ImageGrafikRestLabel,
|
|
Mcu_ImageGrafikJson,
|
|
Mcu_ImageGrafikJsonNotFound,
|
|
Mcu_ImageGrafikCreated
|
|
)
|
|
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
|
$qry = $this->db->query($sql,[
|
|
$id,
|
|
2,
|
|
'PESERTA',
|
|
"Peserta MCU Berdasarkan Jenis Kelamin",
|
|
'bar',
|
|
'Y',
|
|
'Normal',
|
|
json_encode($option),
|
|
json_encode($option_not_found)
|
|
]);
|
|
|
|
$title = "Peserta MCU Berdasarkan Umur";
|
|
$sql = "INSERT INTO mcu_image_grafik(
|
|
Mcu_ImageGrafikMgm_McuID,
|
|
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
|
Mcu_ImageGrafikGroupMenu,
|
|
Mcu_ImageGrafikName,
|
|
Mcu_ImageGrafikType,
|
|
Mcu_ImageGrafikUseRest,
|
|
Mcu_ImageGrafikRestLabel,
|
|
Mcu_ImageGrafikJson,
|
|
Mcu_ImageGrafikJsonNotFound,
|
|
Mcu_ImageGrafikCreated
|
|
)
|
|
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
|
$qry = $this->db->query($sql,[
|
|
$id,
|
|
3,
|
|
'PESERTA',
|
|
"Peserta MCU Berdasarkan Umur",
|
|
'pie',
|
|
'Y',
|
|
'Normal',
|
|
json_encode($param),
|
|
json_encode($param_not_found)
|
|
]);
|
|
|
|
$sql = "INSERT INTO mcu_image_grafik(
|
|
Mcu_ImageGrafikMgm_McuID,
|
|
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
|
Mcu_ImageGrafikGroupMenu,
|
|
Mcu_ImageGrafikName,
|
|
Mcu_ImageGrafikType,
|
|
Mcu_ImageGrafikUseRest,
|
|
Mcu_ImageGrafikRestLabel,
|
|
Mcu_ImageGrafikJson,
|
|
Mcu_ImageGrafikJsonNotFound,
|
|
Mcu_ImageGrafikCreated
|
|
)
|
|
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
|
$qry = $this->db->query($sql,[
|
|
$id,
|
|
3,
|
|
'PESERTA',
|
|
"Peserta MCU Berdasarkan Umur",
|
|
'bar',
|
|
'Y',
|
|
'Normal',
|
|
json_encode($option),
|
|
json_encode($option_not_found)
|
|
]);
|
|
|
|
$sql = "SELECT *
|
|
FROM mcu_kelainangroupsummary
|
|
WHERE
|
|
Mcu_KelainanGroupSummaryIsActive = 'Y'";
|
|
$qry = $this->db->query($sql);
|
|
$rows = $qry->result_array();
|
|
if($rows){
|
|
foreach ($rows as $key => $value) {
|
|
$title = $value['Mcu_KelainanGroupSummaryName'];
|
|
$sql = "INSERT INTO mcu_image_grafik(
|
|
Mcu_ImageGrafikMgm_McuID,
|
|
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
|
Mcu_ImageGrafikGroupMenu,
|
|
Mcu_ImageGrafikName,
|
|
Mcu_ImageGrafikType,
|
|
Mcu_ImageGrafikUseRest,
|
|
Mcu_ImageGrafikRestLabel,
|
|
Mcu_ImageGrafikJson,
|
|
Mcu_ImageGrafikJsonNotFound,
|
|
Mcu_ImageGrafikCreated
|
|
)
|
|
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
|
$qry = $this->db->query($sql,[
|
|
$id,
|
|
$value['Mcu_KelainanGroupSummaryID'],
|
|
'SUMMARY',
|
|
$value['Mcu_KelainanGroupSummaryName'],
|
|
'pie',
|
|
'Y',
|
|
'Normal',
|
|
json_encode($param),
|
|
json_encode($param_not_found)
|
|
]);
|
|
|
|
$sql = "INSERT INTO mcu_image_grafik(
|
|
Mcu_ImageGrafikMgm_McuID,
|
|
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
|
Mcu_ImageGrafikGroupMenu,
|
|
Mcu_ImageGrafikName,
|
|
Mcu_ImageGrafikType,
|
|
Mcu_ImageGrafikUseRest,
|
|
Mcu_ImageGrafikRestLabel,
|
|
Mcu_ImageGrafikJson,
|
|
Mcu_ImageGrafikJsonNotFound,
|
|
Mcu_ImageGrafikCreated
|
|
)
|
|
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
|
$qry = $this->db->query($sql,[
|
|
$id,
|
|
$value['Mcu_KelainanGroupSummaryID'],
|
|
'SUMMARY',
|
|
$value['Mcu_KelainanGroupSummaryName'],
|
|
'bar',
|
|
'Y',
|
|
'Normal',
|
|
json_encode($option),
|
|
json_encode($option_not_found)
|
|
]);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
//echo "selesai default render";
|
|
}
|
|
|
|
function render($type, $id)
|
|
{
|
|
switch ($type) {
|
|
case "mcu001":
|
|
$this->mcu001($id);
|
|
break;
|
|
|
|
case "mcu002":
|
|
$this->mcu002($id);
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
function splitString($string, $wordsPerLine = 2)
|
|
{
|
|
$words = explode(' ', $string);
|
|
$lines = [];
|
|
for ($i = 0; $i < count($words); $i += $wordsPerLine) {
|
|
$lines[] = implode(' ', array_slice($words, $i, $wordsPerLine));
|
|
}
|
|
return implode("\n", $lines);
|
|
}
|
|
|
|
function check_error($qry, $stage)
|
|
{
|
|
if (!$qry) {
|
|
$errMsg = $stage . "<br/>" . $this->db->error()["messge"];
|
|
print_r($errMsg);
|
|
$this->chart_error($errMsg);
|
|
}
|
|
}
|
|
|
|
function chart_error($msg)
|
|
{
|
|
$param = array(
|
|
'title' => array(
|
|
'show' => true,
|
|
'textStyle' => array(
|
|
'color' => 'grey',
|
|
'fontSize' => 20
|
|
),
|
|
'text' => $msg,
|
|
'left' => 'center',
|
|
'top' => 'center'
|
|
),
|
|
'xAxis' => array(
|
|
'show' => false
|
|
),
|
|
'yAxis' => array(
|
|
'show' => false
|
|
),
|
|
'series' => array()
|
|
);
|
|
header("Content-Type: image/png");
|
|
$config = ["config" => $param];
|
|
$j_param = json_encode($config);
|
|
echo $this->post($this->url_renderer, $j_param);
|
|
exit;
|
|
}
|
|
|
|
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, j120);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
"Content-Type: application/json",
|
|
"Content-Length: " . strlen($data),
|
|
]);
|
|
$result = curl_exec($ch);
|
|
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;
|
|
}
|
|
}
|