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

class c_template_putusan_tun extends CI_Controller {

	function index() {
        show_404();
    }

    function popup_putusan_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']));
        
        $this->load->model('generate_template/m_template_putusan_tun','template');
        $dataAlur = $this->template->getAlurPerkara($idperkara);
        foreach ($dataAlur->result() as $dataAlur) {
            $alurPerkara = $dataAlur->alur_perkara_id;
        }
        
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('9','15','210','3','');
        $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']="PUTUSAN AKHIR";
        $data['jnsperkara']=$jnsperkara;
        $data['idperkara']=$idperkara;
        $data['alurPerkara']=$alurPerkara;
        $this->load->view('generate_template/popup_putusan_tun', $data, FALSE);
    }


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

        $segment = $this->uri->segment_array();
        $data['enc']=$this->uri->segment('3');
        $jenisTemplate=$this->uri->segment('4');
        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
             show_404();
             exit();
        }
        $jenisTemplate =$segment[4];
        if(!is_numeric($jenisTemplate) OR !intval($jenisTemplate)>0){
             show_404();
             exit();
        }
        $this->load->model('generate_template/m_template_putusan_tun','template');
        $data['dataPN'] = $this->template->get_data_pn($idperkara);
        $data['dataPihak1']=$this->template->get_data_pihak($idperkara,1);
        $data['dataPengacaraPihak1']=$this->template->get_data_pengacara($idperkara,1);
        $data['dataPihak2']=$this->template->get_data_pihak($idperkara,2);
        $data['dataPengacaraPihak2']=$this->template->get_data_pengacara($idperkara,2);
        $data['dataPihak3']=$this->template->get_data_pihak($idperkara,3);
        $data['dataPengacaraPihak3']=$this->template->get_data_pengacara($idperkara,3);
        $data['dataPihak4']=$this->template->get_data_pihak($idperkara,4);
        $data['dataSaksi']=$this->template->get_data_pihak($idperkara,5);
        $data['dataPerkara']=$this->template->get_data_perkara($idperkara);
        $data['dataPutusan']=$this->template->get_data_putusan($idperkara);
        $data['dataBiayaPerkara']=$this->template->get_biaya_perkara($idperkara);
        $data['dataPenetapan']=$this->template->get_data_penetapan($idperkara);
        $data['dataPenetapanPersiapan']=$this->template->getPenetapanPersiapan($idperkara);
        $data['dataDismissal']=$this->template->get_data_dismissal($idperkara);
        $data['dataCabut']=$this->template->get_data_cabut($idperkara);
        $data['dataPersiapan']=$this->template->get_data_persiapan($idperkara);

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        if($jenisTemplate==1){
            $data['template']=$this->template2->getDataDocumentTemplate('9','15','210','1','');
        } else if ($jenisTemplate==2){
            $data['template']=$this->template2->getDataDocumentTemplate('9','15','210','2','');
        } else if ($jenisTemplate==3){
            $data['template']=$this->template2->getDataDocumentTemplate('9','15','210','3','');
        } else if ($jenisTemplate==4){
            $data['template']=$this->template2->getDataDocumentTemplate('9','15','210','4','');
        } else if ($jenisTemplate==5){
            $data['template']=$this->template2->getDataDocumentTemplate('9','15','210','5','');
        } else{
            show_404();
            exit();
        }
        $this->load->view('generate_template/cetak_putusan_tun',$data,FALSE);
    }

   
    function cetak_putusan_sela(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }
        $segment = $this->uri->segment_array();
        $data['enc']=$this->uri->segment(3);
        $data['jenisTemplate']=$this->uri->segment(4);
        $data['encPutusanSela']=$this->uri->segment(5);
        $jenisTemplate=$data['jenisTemplate'];

        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        $idPutusanSela=$this->encrypt->decode(base64_decode($data['encPutusanSela']));
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2'); 

        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
             show_404();
             exit();
        }
        $this->load->model('generate_template/m_template_putusan_tun','template');
        $data['dataPN'] = $this->template->get_data_pn($idperkara);
        $data['dataPihak1']=$this->template->get_data_pihak($idperkara,1);
        $data['dataPengacaraPihak1']=$this->template->get_data_pengacara($idperkara,1);
        $data['dataPihak2']=$this->template->get_data_pihak($idperkara,2);
        $data['dataPengacaraPihak2']=$this->template->get_data_pengacara($idperkara,2);
        $data['dataPihak3']=$this->template->get_data_pihak($idperkara,3);
        $data['dataPengacaraPihak3']=$this->template->get_data_pengacara($idperkara,3);
        $data['dataPihak4']=$this->template->get_data_pihak($idperkara,4);
        $data['dataSaksi']=$this->template->get_data_pihak($idperkara,5);
        $data['dataPerkara']=$this->template->get_data_perkara($idperkara);
        $data['dataPutusan']=$this->template->get_data_putusan($idperkara);
        $data['dataBiayaPerkara']=$this->template->get_biaya_perkara($idperkara);
        $data['dataPenetapan']=$this->template->get_data_penetapan($idperkara);
        $data['dataPenetapanPersiapan']=$this->template->getPenetapanPersiapan($idperkara);
        $data['dataDismissal']=$this->template->get_data_dismissal($idperkara);
        $data['dataCabut']=$this->template->get_data_cabut($idperkara);
        $data['dataPersiapan']=$this->template->get_data_persiapan($idperkara);

        if ($jenisTemplate=='pencabutan_gugatan_dikabulkan'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','1','');
        } else if ($jenisTemplate=='pencabutan_gugatan_ditolak'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','2','');
        } else if($jenisTemplate=='ktun_dikabulkan'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','3','');
        } else if ($jenisTemplate=='ktun_ditolak'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','4','');
        } else if ($jenisTemplate=='penetapan_intervensi_dikabulkan'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','5','');
        } else if ($jenisTemplate=='penetapan_intervensi_ditolak'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','6','');
        } else if ($jenisTemplate=='gugatan_tidak_dapat_diterima'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','7','');
        } else{
            show_404();
            exit();
        }

        $this->load->view('generate_template/cetak_putusan_sela_tun',$data,FALSE);
    }
}