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

class c_template_pen_tun extends CI_Controller {

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

	function penetapan_majelis_hakim_tun(){
        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_tun','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['enc1'] = $data['enc'];
        $data['enc'] = $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_tun', $data, FALSE);
    }

    function cetak_penetapan_majelis_hakim_tun(){
        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();
        }  
        $filenya="peradilan_tun/Gugatan/Penetapan/penetapan_MH.rtf"
        $pembuat=$this->input->post('ditetapkanoleh',TRUE);
        if(!is_numeric($pembuat) OR !intval($pembuat)>0){
            show_404();
            exit();
        }   
        $data_id= array(
                    'source_file'=>$filenya,
                    'perkara_id'=>$idperkara,
                    'pembuat'=>$pembuat);   
                            
        $this->load->model('generate_template/var_template','var_template');
        $this->var_template->kirim_variabel($data_id);
    	// $this->load->model('generate_template/m_template_penetapan_tun','template');
    	// $data['dataTemplate'] = $this->template->getDataPenetapanHakimMil($idperkara,$pembuat);
     //    //print_r($this->template->getDataPenetapanHakimMil($idperkara,$pembuat));
     //    $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
     //    $data['jenisGugatan']='1';             
     //    $data['template']=$this->template2->getDataDocumentTemplate('120','12','20','1','');
    	// $this->load->view('generate_template/cetak_penetapan_mil_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('120','12','20','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);
    }
}
?>