| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /wamp/www/simbada_2018/application/libraries/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
* Class build report for report menu
*/
class Report_builder
{
var $CI = null;
var $is_skpd;
var $is_bud;
var $is_ppkd;
var $is_ppkdbud;
var $is_ppkskpd;
var $is_bt;
var $is_bk;
function __construct()
{
$CI = & get_instance();
/*
skpd : id_skpd != 0
bud : id_skpd = 0
ppkd : ppkd = [1,2]
ppkdterima : ppkd = 1
ppkdkeluar : ppkd = 2
ppkdbud : id_skpd = 0 + ppkd = [1,2]
ppkskpd : id_skpd != 0 + role = 1
bt : id_skpd != 0 + role = 2
bk : id_skpd != 0 + role = 3
*/
$this->is_skpd = $CI->id_skpd !==0;
$this->is_bud = $CI->id_skpd === 0;
$this->is_ppkd = in_array($CI->ppkd, array(1, 2));
$this->is_ppkdterima = $this->is_skpd && $CI->ppkd === 1;
$this->is_ppkdkeluar = $this->is_skpd && $CI->ppkd === 2;
$this->is_ppkdbud = $CI->id_skpd === 0 && $this->is_ppkd;
$this->is_ppkskpd = $CI->id_skpd !==0 && $CI->roles === 1;
$this->is_bt = $CI->id_skpd !==0 && $CI->roles === 2;
$this->is_bk = $CI->id_skpd !==0 && $CI->roles === 3;
}
function merge_xml(&$simplexml_to, &$simplexml_from)
{
// selain elemen REPORT di tambahkan jika id nya belum ada di tujuan
// khusus untuk elemen REPORT, jika id sudah ada, maka elemen di tujuan ditimpa
foreach ($simplexml_from->children() as $simplexml_child)
{
// cek apakah id elemen asal sudah ada di tujuan
$found = false;
$id_from = (string) $simplexml_child->attributes()->id;
foreach($simplexml_to->children() as $child){
$id_to = (string) $child->attributes()->id;
if ($id_to == '') continue; // elemen tidak punya id, misal elemen DATE, SELECT
if ($id_from == $id_to) {
$found = true;
if ($child->getName() == 'REPORT'){
// hapus children dari elemen
$remove = array();
foreach($child->children() as $grand_children){
$remove[] = $grand_children;
}
foreach($remove as $item){
unset($item[0]);
}
// ganti atribut dengan atribut tujuan
$remove = array();
foreach($child->attributes() as $attr){
$remove[] = $attr;
}
foreach($remove as $item){
unset($item[0]);
}
foreach ($simplexml_child->attributes() as $attr_key => $attr_value)
{
$child->addAttribute($attr_key, $attr_value);
}
}
$simplexml_temp = $child;
break;
}
}
// jika elemen id belum ada di tujuan, tambahkan elemen
if (!$found){
$simplexml_temp = $simplexml_to->addChild($simplexml_child->getName(), (string) $simplexml_child);
foreach ($simplexml_child->attributes() as $attr_key => $attr_value)
{
$simplexml_temp->addAttribute($attr_key, $attr_value);
}
}
$this->merge_xml($simplexml_temp, $simplexml_child);
}
}
function get_html_menu($laporan, $laporan_custom, $laporan_temp)
{
$xml_path = FCPATH.'assets/fr/fr3/';
$xml = $xml_path.$laporan;
$xml_custom = $xml_path.$laporan_custom;
$xml_merge = $xml_path.$laporan_temp;
if (file_exists($xml)){
$doc = simplexml_load_file($xml);
}
else {
throw new Exception($xml . " does not exist");
}
if (file_exists($xml_custom)){
$doc_custom = simplexml_load_file($xml_custom);
// jika ada laporan custom, tambahkan ke laporan
$this->merge_xml($doc, $doc_custom);
}
$doc->asXML($xml_merge);
$len_tipe = count($doc->TIPE);
$html = '';
for ($tp=0; $tp<$len_tipe; $tp++){
if((string)$doc->TIPE[$tp]['caption'] !== 'STANDAR'){
$html .= '<li><span class="folder">'.$doc->TIPE[$tp]['caption'].'</span>';
$html .= '<ul>';
}
$len_area = count($doc->TIPE[$tp]->AREA);
for ($ar=0; $ar<$len_area; $ar++){
if((string)$doc->TIPE[$tp]->AREA[$ar]['caption'] !== 'SEMUA'){
$html .= '<li><span class="folder">'.$doc->TIPE[$tp]->AREA[$ar]['caption'].'</span>';
$html .= '<ul>';
}
$len_group = count($doc->TIPE[$tp]->AREA[$ar]->GROUP);
for ($i=0; $i<$len_group; $i++)
{
$hide = $doc->TIPE[$tp]->AREA[$ar]->GROUP[$i]['hide'];
$show_only = $doc->TIPE[$tp]->AREA[$ar]->GROUP[$i]['showonly'];
if ($hide == 1) continue;
if ($show_only != ''){
$akses_arr = explode(",", $show_only);
$show = FALSE;
foreach($akses_arr as $akses){
switch (strtoupper($akses)){
case 'SKPD' : if ($this->is_skpd) $show = TRUE; break;
case 'BUD' : if ($this->is_bud) $show = TRUE; break;
case 'PPKD' : if ($this->is_ppkd) $show = TRUE; break;
case 'PPKDTERIMA' : if ($this->is_ppkdterima) $show = TRUE; break;
case 'PPKDKELUAR' : if ($this->is_ppkdkeluar) $show = TRUE; break;
case 'PPKDBUD' : if ($this->is_ppkdbud) $show = TRUE; break;
case 'PPKSKPD' : if ($this->is_ppkskpd) $show = TRUE; break;
case 'BT' : if ($this->is_bt) $show = TRUE; break;
case 'BK' : if ($this->is_bk) $show = TRUE; break;
}
}
if (!$show) continue;
}
$html .= '<li><span class="folder">'.$doc->TIPE[$tp]->AREA[$ar]->GROUP[$i]['caption'].'</span>';
$html .= '<ul>';
$len_report = count($doc->TIPE[$tp]->AREA[$ar]->GROUP[$i]->REPORT);
for ($j=0; $j<$len_report; $j++)
{
$hide = $doc->TIPE[$tp]->AREA[$ar]->GROUP[$i]->REPORT[$j]['hide'];
$show_only = $doc->TIPE[$tp]->AREA[$ar]->GROUP[$i]->REPORT[$j]['showonly'];
if ($hide == 1) continue;
if ($show_only != ''){
$akses_arr = explode(",", $show_only);
$show = FALSE;
foreach($akses_arr as $akses){
switch (strtoupper($akses)){
case 'SKPD' : if ($this->is_skpd) $show = TRUE; break;
case 'BUD' : if ($this->is_bud) $show = TRUE; break;
case 'PPKD' : if ($this->is_ppkd) $show = TRUE; break;
case 'PPKDTERIMA' : if ($this->is_ppkdterima) $show = TRUE; break;
case 'PPKDKELUAR' : if ($this->is_ppkdkeluar) $show = TRUE; break;
case 'PPKDBUD' : if ($this->is_ppkdbud) $show = TRUE; break;
case 'PPKSKPD' : if ($this->is_ppkskpd) $show = TRUE; break;
case 'BT' : if ($this->is_bt) $show = TRUE; break;
case 'BK' : if ($this->is_bk) $show = TRUE; break;
}
}
if (!$show) continue;
}
$show_dialog = $doc->TIPE[$tp]->AREA[$ar]->GROUP[$i]->REPORT[$j]['showfilter'];
$html .= '<li><span class="file"><a href="#" class="preview" data-tipe="'.$tp.'" data-area="'.$ar.'" data-group="'.$i.'" data-unit="'.$j.'" data-show="'.$show_dialog.'" >';
$html .= $doc->TIPE[$tp]->AREA[$ar]->GROUP[$i]->REPORT[$j]['caption'].'</a></span></li>';
}
$html .= '</ul>';
$html .= '</li>';
}
if((string)$doc->TIPE[$tp]->AREA[$ar]['caption'] !== 'SEMUA'){
$html .= '</ul>';
$html .= '</li>';
}
}
if((string)$doc->TIPE[$tp]['caption'] !== 'STANDAR'){
$html .= '</ul>';
$html .= '</li>';
}
}
return $html;
}
}