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

class c_template_putusan_perdata extends CI_Controller {

	function index() {
        show_404();
    }

    function popup_putusan_perdata(){
        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_perdata','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('1','15','210','','putusan perdata');
        $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;
                }
            }
        }
        if(($alurPerkara>'0') and ($alurPerkara<'3')){
            $data['judul']="PUTUSAN PERDATA"; //override
        }else{
            $data['judul']="PUTUSAN PERDATA BANTAHAN"; //override
        }
        
        $data['jnsperkara']=$jnsperkara;
        $data['idperkara']=$idperkara;
        $data['alurPerkara']=$alurPerkara;
        $this->load->view('generate_template/popup_putusan_perdata', $data, FALSE);
    }

    function popup_putusan_verzet(){
        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_perdata','template');

        
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('1','15','210','','putusan perdata');
        $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 VERZET"; //override
        $data['jnsperkara']=$jnsperkara;
        $data['idperkara']=$idperkara;
        //$data['alurPerkara']=$alurPerkara;
        $this->load->view('generate_template/popup_putusan_verzet', $data, FALSE);
    }

    function cetak_putusan_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();
        }
        $jenisTemplate =$segment[4];
        if(!is_numeric($jenisTemplate) OR !intval($jenisTemplate)>0){
             show_404();
             exit();
        }
        $this->load->model('generate_template/m_template_putusan_perdata','template');
        $data['data_template'] = $this->template->get_data_putusan_pdt($idperkara);
        $data['data_turutTergugat'] = $this->template->getTurutTergugat($idperkara);
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        if($jenisTemplate==1){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','1','');
        } else if ($jenisTemplate==2){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','2','');
        } else if ($jenisTemplate==3){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','3','');
        } else if ($jenisTemplate==4){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','4','');
        } else if ($jenisTemplate==5){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','5','');
        } else if ($jenisTemplate==6){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','6','');
        } else if ($jenisTemplate==7){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','7','');
        } else if ($jenisTemplate==8){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','8','');
        } else if ($jenisTemplate==9){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','9','');
        }  else if ($jenisTemplate==10){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','10','');
        } else if ($jenisTemplate==11){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','11','');
        } else if ($jenisTemplate==12){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','12','');
        } else if ($jenisTemplate==13){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','13','');
        } else if ($jenisTemplate==14){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','14','');
        } else if ($jenisTemplate==15){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','15','');
        } else if ($jenisTemplate==16){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','16','');
        } else if ($jenisTemplate==17){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','17','');
        } else if ($jenisTemplate==18){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','18','');
        } else if ($jenisTemplate==19){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','19','');
        }else{
            show_404();
            exit();
        }
        $this->load->view('generate_template/cetak_putusan_perdata',$data,FALSE);
    }

    function cetak_putusan_verzet(){
        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();
        }
        $jenisTemplate =$segment[4];
        if(!is_numeric($jenisTemplate) OR !intval($jenisTemplate)>0){
             show_404();
             exit();
        }
        $this->load->model('generate_template/m_template_putusan_perdata','template');
        $data['data_template'] = $this->template->get_data_putusan_pdt($idperkara);
        
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        if ($jenisTemplate==6){
            $data['template']=$this->template2->getDataDocumentTemplate('1','15','210','6','');

        }else{
            show_404();
            exit();
        }
        $this->load->view('generate_template/cetak_putusan_perdata',$data,FALSE);
    }

    function popup_putusan_perdata_s(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }       
        $data['enc']=$this->uri->segment('3');

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('1','15','210','','putusan perdata');
        $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']="DRAFT PUTUSAN AKHIR"; 
        $data['jnsperkara']='PERKARA GUGATAN SEDERHANA';

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

    function cetak_putusan_pdt_s(){
        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();
        }
        $jenisTemplate =$segment[4];
        if(!is_numeric($jenisTemplate) OR !intval($jenisTemplate)>0){
             show_404();
             exit();
        }
        $this->load->model('generate_template/m_template_putusan_perdata','template');
        $data['data_template'] = $this->template->get_data_putusan_pdt_s($idperkara);
    
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        if($jenisTemplate==1){
            $data['template']=$this->template2->getDataDocumentTemplate('8','15','210','1','');
        }elseif($jenisTemplate==2){
            $data['template']=$this->template2->getDataDocumentTemplate('8','15','210','2','');
        }
        $this->load->view('generate_template/cetak_putusan_perdata_s',$data,FALSE);
    }

    function popup_putusan_perdata_keberatan(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }       
        $data['enc']=$this->uri->segment('3');

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('1','15','210','','putusan perdata');
        $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 PERDATA SEDERHANA KEBERATAN"; 
        $data['jnsperkara']=$jnsperkara;

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

    function cetak_putusan_pdt_keberatan(){
        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();
        }
        $jenisTemplate =$segment[4];
        if(!is_numeric($jenisTemplate) OR !intval($jenisTemplate)>0){
             show_404();
             exit();
        }
        $this->load->model('generate_template/m_template_putusan_perdata','template');
        $data['data_template'] = $this->template->get_data_putusan_pdt_keberatan($idperkara);
    
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        if($jenisTemplate==1){
            $data['template']=$this->template2->getDataDocumentTemplate('8','15','210','1','');
        }elseif($jenisTemplate==2){
            $data['template']=$this->template2->getDataDocumentTemplate('8','15','210','2','');
        }
        $this->load->view('generate_template/cetak_putusan_perdata_keberatan',$data,FALSE);
    }

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

        $data['enc']=$this->uri->segment('3');

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('6','15','210','','phi');
        $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(" - ",$judul);
                    $jnsperkara=$template->jnsperkara;
                }
            }
        }

        $data['judul']=$judul['0'];
        //$data['judul']="RELAAS PANGGILAN KEPADA PENGGUGAT"; //override
        $data['jnsperkara']=$jnsperkara;

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

    function cetak_putusan_pdt_phi(){
        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();
        }   
        $data['jenisTemplate']=$segment[4];
        if(!is_numeric($data['jenisTemplate']) OR !intval($data['jenisTemplate'])>0){
            show_404();
            exit();
        }   

        $this->load->model('generate_template/m_template_putusan_perdata','template');
        $data['data_template'] = $this->template->get_data_putusan_pdt($idperkara);
        $data['dataPN'] = $this->template->getDataPN();

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        if($data['jenisTemplate']==1){
            $data['template']=$this->template2->getDataDocumentTemplate('6','15','210','45','');
        } else if ($data['jenisTemplate']==2){
            $data['template']=$this->template2->getDataDocumentTemplate('6','15','210','46','');
        } else if ($data['jenisTemplate']==3){
            $data['template']=$this->template2->getDataDocumentTemplate('6','15','210','47','');
        } else if ($data['jenisTemplate']==4){
            $data['template']=$this->template2->getDataDocumentTemplate('6','15','210','48','');
        } else if ($data['jenisTemplate']==5){
            $data['template']=$this->template2->getDataDocumentTemplate('6','15','210','49','');
        } else if ($data['jenisTemplate']==6){
            $data['template']=$this->template2->getDataDocumentTemplate('6','15','210','50','');
        }else if ($data['jenisTemplate']==7){
            $data['template']=$this->template2->getDataDocumentTemplate('6','15','210','51','');
        }else if ($data['jenisTemplate']==8){
            $data['template']=$this->template2->getDataDocumentTemplate('6','15','210','52','');
        }else if ($data['jenisTemplate']==9){
            $data['template']=$this->template2->getDataDocumentTemplate('6','15','210','53','');
        }else if ($data['jenisTemplate']==10){
            $data['template']=$this->template2->getDataDocumentTemplate('6','15','210','54','');
        }else if ($data['jenisTemplate']==11){
            $data['template']=$this->template2->getDataDocumentTemplate('6','15','210','55','');
        }else if ($data['jenisTemplate']==12){
            $data['template']=$this->template2->getDataDocumentTemplate('6','15','210','56','');
        }else{
            show_404();
            exit();
        }
        $this->load->view('generate_template/cetak_putusan_perdata_phi',$data,FALSE);
    }

    function popup_putusan_pdt_pailit() {
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }   
        $data['enc']=$this->uri->segment('3');

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('3','15','210','','pailit voluntair');
        $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['judul']="RELAAS PANGGILAN KEPADA PENGGUGAT"; //override
        $data['jnsperkara']=$jnsperkara;

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

    }

    function cetak_putusan_pdt_pailit(){
        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();
        }   
        $data['jenisTemplate']=$segment[4];
        if(!is_numeric($data['jenisTemplate']) OR !intval($data['jenisTemplate'])>0){
            show_404();
            exit();
        }   

        $this->load->model('generate_template/m_template_putusan_perdata','template');
        $data['data_template'] = $this->template->get_data_putusan_pdt($idperkara);
        $data['dataPN'] = $this->template->getDataPN();

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        if($data['jenisTemplate']==1){
            $data['template']=$this->template2->getDataDocumentTemplate('3','15','210','20','');
        } else if ($data['jenisTemplate']==2){
            $data['template']=$this->template2->getDataDocumentTemplate('3','15','210','21','');
        } else if ($data['jenisTemplate']==3){
            $data['template']=$this->template2->getDataDocumentTemplate('3','15','210','22','');
        } else if ($data['jenisTemplate']==4){
            $data['template']=$this->template2->getDataDocumentTemplate('3','15','210','23','');
        } else if ($data['jenisTemplate']==5){
            $data['template']=$this->template2->getDataDocumentTemplate('3','15','210','26','');
        } else if ($data['jenisTemplate']==6){
            $data['template']=$this->template2->getDataDocumentTemplate('3','15','210','27','');
        }else if ($data['jenisTemplate']==7){
            $data['template']=$this->template2->getDataDocumentTemplate('4','15','210','28','');
        }else if ($data['jenisTemplate']==8){
            $data['template']=$this->template2->getDataDocumentTemplate('4','15','210','29','');
        }else{
            show_404();
            exit();
        }

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

    function popup_putusan_pdt_pkpu() {
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }  
        $data['enc']=$this->uri->segment('3');

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('4','15','210','','homologasi');
        $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['judul']="RELAAS PANGGILAN KEPADA PENGGUGAT"; //override
        $data['jnsperkara']=$jnsperkara;

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

    }

    function cetak_putusan_pdt_pkpu(){
        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();
        }
        $data['jenisTemplate']=$segment[4];
        if(!is_numeric($data['jenisTemplate']) OR !intval($data['jenisTemplate'])>0){
             show_404();
             exit();
        }

        $this->load->model('generate_template/m_template_putusan_perdata','template');
        $data['data_template'] = $this->template->get_data_putusan_pdt($idperkara);
        $data['dataPN'] = $this->template->getDataPN();

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        if($data['jenisTemplate']==1){
            $data['template']=$this->template2->getDataDocumentTemplate('4','15','210','28','');
        } else if ($data['jenisTemplate']==2){
            $data['template']=$this->template2->getDataDocumentTemplate('4','15','210','29','');
        } else if ($data['jenisTemplate']==3){
            $data['template']=$this->template2->getDataDocumentTemplate('4','15','210','30','');
        } else if ($data['jenisTemplate']==4){
            $data['template']=$this->template2->getDataDocumentTemplate('4','15','210','31','');
        } else if ($data['jenisTemplate']==5){
            $data['template']=$this->template2->getDataDocumentTemplate('4','15','210','32','');
        } else if ($data['jenisTemplate']==6){
            $data['template']=$this->template2->getDataDocumentTemplate('4','15','210','33','');
        } else if ($data['jenisTemplate']==7){
            $data['template']=$this->template2->getDataDocumentTemplate('4','15','210','34','');
        } else if ($data['jenisTemplate']==8){
            $data['template']=$this->template2->getDataDocumentTemplate('4','15','210','35','');
        }else if ($data['jenisTemplate']==9){
            $data['template']=$this->template2->getDataDocumentTemplate('4','15','210','36','');
        }else{
            show_404();
            exit();
        }
        $this->load->view('generate_template/cetak_putusan_perdata_pkpu',$data,FALSE);
    }

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

        $data['enc']=$this->uri->segment('3');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('5','15','210','38','');
        $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("Kabul",$judul);
                    $jnsperkara=$template->jnsperkara;
                }
            }
        }

        $data['judul']=$judul['0'];
        //$data['judul']="RELAAS PANGGILAN KEPADA PENGGUGAT"; //override
        $data['jnsperkara']=$jnsperkara;

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

    function cetak_putusan_pdt_hki(){
        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();
        }
        $data['jenisTemplate']=$segment[4];
        if(!is_numeric($data['jenisTemplate']) OR !intval($data['jenisTemplate'])>0){
            show_404();
            exit();
        }
        $data['jenisGugatanHKI']=$segment[5];

        $this->load->model('generate_template/m_template_putusan_perdata','template');
        $data['data_template'] = $this->template->get_data_putusan_pdt($idperkara);
        $data['dataPN'] = $this->template->getDataPN();

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

}
