<?php 
defined('BASEPATH') OR exit('No direct script access allowed');

class c_template_akta_mil extends CI_Controller {

	function index(){
        if($this->session->userdata('is_logged_in')==FALSE){
        redirect('login');
        }       
    	$this->load->view('dashboard', FALSE);
    }

	function penetapan_majelis_hakim_mil(){
        if($this->session->userdata('is_logged_in')==FALSE){
        redirect('login');
        }       

        $data['enc']=$this->uri->segment('3');
        $data['jpen']=$this->uri->segment('5');
        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }   

        $this->load->model('generate_template/m_template_mil','template');
        $this->load->model('penetapan/add_majelis_m');
    	$data['penandatangan']=$this->template->getDataPN();

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2'); 
        $template=$this->template2->getDataDocumentTemplate('1','12','20','1','');
        $i=0;
        $jumdata=count($template->result());
        foreach ($template->result() as $template){
            if ($jumdata=='1'){
                $judul['0']=$template->namatemplate;
                $jnsperkara=$template->jnsperkara;
            }else{
                if ($i=='0'){
                    $judul=$template->namatemplate;
                    $judul=explode("Voluntair",$judul);
                    $jnsperkara=$template->jnsperkara;
                }
            }
        }

        $perkara_id=$this->encrypt->decode(base64_decode($data['enc']));
        $data['perkara'] = $this->add_majelis_m->get_no_perkara($perkara_id);
        $data['idalurperkara'] = $this->tanggalhelper->getIDAlurPerkara($perkara_id);
        $list = array('0'=>'Pilih Nama Hakim');
        $res = $this->add_majelis_m->get_data_hakim_aktif();
        foreach ($res as $row){
            $list[$row['id']] = $row['nama_gelar'];
        };
        $data['data_hakim']=$list;
        $data['tanggal_pelimpahan'] = $this->add_majelis_m->get_tanggal_pelimpahan($perkara_id);
        $data['data_majelis'] = $this->add_majelis_m->get_data_majelis($perkara_id);
        $data['data_majelis_detail'] = $this->add_majelis_m->get_data_majelis_detail($perkara_id);
        $data['idperkara']=$this->encrypt->decode(base64_decode($data['enc']));


        $data['judul']=$judul['0'];
        $data['jnsperkara']=$jnsperkara;
    	$this->load->view('generate_template/popup_penetapan_mil', $data, FALSE);
    }

    function cetak_penetapan_mil(){
        if($this->session->userdata('is_logged_in')==FALSE){
        redirect('login');
        }       

        $jpen = $this->uri->segment('3');
        $data['enc']=$this->input->post('enc',TRUE);
        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }  

        $pembuat=$this->input->post('ditetapkanoleh',TRUE);
        if(!is_numeric($pembuat) OR !intval($pembuat)>0){
            show_404();
            exit();
        }   

    	$this->load->model('generate_template/m_template_mil','template');
    	$data['dataTemplate'] = $this->template->getDataPenetapanHakimMil($idperkara,$pembuat);
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        if($jpen==1){
            $data['template']=$this->template2->getDataDocumentTemplate('120','12','20','1','');    
        }elseif($jpen==2) {
            $data['template']=$this->template2->getDataDocumentTemplate('120','12','30','1','');    
        }else{
            $data['template']=$this->template2->getDataDocumentTemplate('120','12','80','1','');    
        }              
        
    	$this->load->view('generate_template/cetak_penetapan_mil',$data,FALSE);
    }

    function penetapan_tabtera(){
        if($this->session->userdata('is_logged_in')==FALSE){
        redirect('login');
        }       

        $segment = $this->uri->segment_array();
        $data['enc']=$this->uri->segment('3');
        $data['jpen']=$this->uri->segment('5');
        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }

        $this->load->model('generate_template/m_template_mil','template');
        $this->load->model('penetapan/add_majelis_m');
        $data['penandatangan']=$this->template->getDataPN();
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('120','12','30','1','');
        $i=0;
        foreach ($template->result() as $template){
            if (count($template)=='1'){
                $judul['0']=$template->namatemplate;
                $jnsperkara=$template->jnsperkara;
            }else{
                if ($i=='0'){
                    $judul=$template->namatemplate;
                    $judul=explode("",$judul);
                    $jnsperkara=$template->jnsperkara;
                }
            }
        }

        if($data['jpen']==1){
            $perkara_id=$this->encrypt->decode(base64_decode($data['enc']));
            $data['perkara'] = $this->add_majelis_m->get_no_perkara($perkara_id);
            $data['idalurperkara'] = $this->tanggalhelper->getIDAlurPerkara($perkara_id);
            $data['tanggal_pelimpahan'] = $this->add_majelis_m->get_tanggal_pelimpahan($perkara_id);
            $data['data_majelis'] = $this->add_majelis_m->get_data_majelis($perkara_id);
            $data['data_majelis_detail'] = $this->add_majelis_m->get_data_majelis_detail($perkara_id);            
        }elseif($data['jpen']==2){
            $this->load->model('penetapan/add_panitera_m');
            $perkara_id=$this->encrypt->decode(base64_decode($data['enc']));
            //$data['enc'] = $this->nativesession->get_flash_session('enc');
            $data['perkara'] = $this->add_majelis_m->get_no_perkara($perkara_id);
            $data['idalurperkara'] = $this->tanggalhelper->getIDAlurPerkara($perkara_id);
            $data['tanggal_pelimpahan'] = $this->add_majelis_m->get_tanggal_pelimpahan($perkara_id);
            $data['data_penetapan'] = $this->add_panitera_m->get_data_penetapan($perkara_id);
            $data['data_panitera_detail'] = $this->add_panitera_m->get_data_panitera_detail($perkara_id);
        }

        $data['judul']=$judul['0'];
        $data['jnsperkara']=$jnsperkara;
        $this->load->view('generate_template/popup_penetapan_mil', $data, FALSE);
    }


    function cetak_sidang_pertama_mil(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }       

        $data['enc']=$this->uri->segment('3');
        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }   
        
        $this->load->model('generate_template/m_template_mil','template');
        $data['dataTemplate'] = $this->template->getDataPenetapanHakimMil($idperkara,'64');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $data['template']=$this->template2->getDataDocumentTemplate('120','12','80','1','');
        $this->load->view('generate_template/cetak_penetapan_mil',$data,FALSE);
    }

    function cetak_akta_apa(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }       

        $data['enc']=$this->uri->segment('3');
        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }   
        
        $this->load->model('generate_template/m_template_mil','template');
        $data['dataTemplate'] = $this->template->getDataPenetapanHakimMil($idperkara,'64');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $data['template']=$this->template2->getDataDocumentTemplate('120','16','240','1','');
        $this->load->view('generate_template/cetak_akta_mil',$data,FALSE);
    }

    function cetak_akta_permohonan_banding_mil(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }       

        $data['enc']=$this->uri->segment('3');
        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }   
        
        $this->load->model('generate_template/m_template_mil','template');
        $data['dataTemplate'] = $this->template->getDataPenetapanHakimMil($idperkara,'64');
        $data['dataTemplate2'] = $this->template->getDataPemohonBanding($idperkara);
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $data['template']=$this->template2->getDataDocumentTemplate('120','16','240','12','');
        $this->load->view('generate_template/cetak_akta_mil',$data,FALSE);
    }

}
?>