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

class c_template_penetapan_perdata extends CI_Controller {

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

	function penetapan_majelis_hakim_pdt(){
        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_penetapan_pdt','template');
    	$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;
                }
            }
        }
        $data['judul']=$judul['0'];
        $data['jnsperkara']=$jnsperkara;
        $filenya = 'peradilan_umum/pidana/penetapan/2_4_PEN_MAJELIS_HAKIM.rtf';
        //$data['judul']="RELAAS PANGGILAN KEPADA PENGGUGAT"; //override
        $data_id=array( 'source_file'=>$filenya,
                        'perkara_id'=>$idperkara 
                      );   
                                    
        // $this->session->set_userdata('data_id',$data_id);
        $this->load->model('generate_template/var_template','var_template');
        $this->var_template->kirim_variabel($data_id);
    	// $this->load->view('generate_template/popup_penetapan_perdata_hakim', $data, FALSE);
    }

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

        $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_penetapan_pdt','template');
    	$data['dataTemplate'] = $this->template->getDataPenetapanHakim($idperkara,$pembuat);
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $data['jenisGugatan']='1';             
        $data['template']=$this->template2->getDataDocumentTemplate('1','12','20','1','');
    	$this->load->view('generate_template/cetak_penetapan_perdata_majelis_hakim',$data,FALSE);
    }

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

        $segment = $this->uri->segment_array();
        $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_penetapan_pdt_pp','template');
        $data['penandatangan']=$this->template->getDataPN();

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('1','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;
                }
            }
        }

        $data['judul']=$judul['0'];
        //$data['judul']="RELAAS PANGGILAN KEPADA PENGGUGAT"; //override
        $data['jnsperkara']=$jnsperkara;
        $this->load->view('generate_template/popup_penetapan_perdata_pp', $data, FALSE);
    }

    function cetak_penetapan_panitera_pdt(){
        if($this->session->userdata('is_logged_in')==FALSE){
        redirect('login');
        }       
        $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_penetapan_pdt_pp','template');
        $data['data_pp'] = $this->template->getdata_pp($idperkara);
        $data['data_template'] = $this->template->get_data_penetapan_pp($idperkara,$pembuat);
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $data['template']=$this->template2->getDataDocumentTemplate('1','12','30','1','');
        $this->load->view('generate_template/cetak_penetapan_perdata_pp',$data,FALSE);
    }

    function cetak_sidang_pertama_pdt(){
        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_penetapan_pdt_sidang_pertama','template');
        $data['data_template'] = $this->template->get_data_penetapan_sidang_pertama($idperkara);
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $data['template']=$this->template2->getDataDocumentTemplate('1','12','80','1','');
        $this->load->view('generate_template/cetak_penetapan_perdata_sidang_pertama',$data,FALSE);
    }

    function cetak_penetapan_dismissal_pdt(){
        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_penetapan_pdt','template');
        $data['getDataPerkara'] = $this->template->getDataPerkara($idperkara);
        $data['getDataPN'] = $this->template->getDataPN();
        $data['getTglPts'] = $this->template->getTglPts($idperkara);
        $data['getHakim'] = $this->template->getHakim($idperkara);
        $data['getPanitera'] = $this->template->getPanitera($idperkara);
        $data['cetakPihakP'] = $this->template->getCetakPihakPenggugat($idperkara);
        $data['cetakPihakT'] = $this->template->getCetakPihakTergugat($idperkara);
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $data['template']=$this->template2->getDataDocumentTemplate('8','15','214','1','');
        $this->load->view('generate_template/cetak_penetapan_dismissal',$data,FALSE);
    }

    function cetak_penetapan_gugur_pdt(){
        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_penetapan_pdt','template');
        $data['getDataPerkara'] = $this->template->getDataPerkara($idperkara);
        $data['getDataPN'] = $this->template->getDataPN();
        $data['getTglPts'] = $this->template->getTglPts($idperkara);
        $data['getHakim'] = $this->template->getHakim($idperkara);
        $data['getPanitera'] = $this->template->getPanitera($idperkara);
        $data['cetakPihakP'] = $this->template->getCetakPihakPenggugat($idperkara);
        $data['cetakPihakT'] = $this->template->getCetakPihakTergugat($idperkara);
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $data['template']=$this->template2->getDataDocumentTemplate('8','15','212','1','');
        $this->load->view('generate_template/cetak_penetapan_gugur_gs',$data,FALSE);
    }
}
?>