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

class c_template_tun_akta_permintaan_kasasi2 extends CI_Controller {
    public function index(){
        if($this->session->userdata('is_logged_in')==FALSE){
        redirect('login');
        }       

        $this->load->view('dashboard', FALSE);
    }



    function cetak_template(){
        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();
        }
        $data['idpembuatakta'] = $this->input->post('pembuat',TRUE);
        $idpembuatakta=$this->encrypt->decode(base64_decode($data['idpembuatakta']));
        if(!is_numeric($idpembuatakta) OR !intval($idpembuatakta)>0){
            show_404();
            exit();
        }
        $data['idput'] = $this->input->post('putusan',TRUE);
        $idput=$this->encrypt->decode(base64_decode($data['idput']));
        if(!is_numeric($idput) OR !intval($idput)>0){
            show_404();
            exit();
        }

        $data['encpemohon'] = $this->input->post('encpemohon',TRUE);
        $idpemohon=$this->encrypt->decode(base64_decode($data['encpemohon']));
        if(!is_numeric($idpemohon) OR !intval($idpemohon)>0){
            show_404();
            exit();
        }
        $encpihak = $this->input->post('encpihak',TRUE);
        if(!empty($encpihak)){
            $idpihak=$this->encrypt->decode(base64_decode($encpihak));
            if(!is_numeric($idpihak) OR !intval($idpihak)>0){
                show_404();
                exit();
            }
            
        }
        $data['jenisTemplate'] = $this->input->post('jenisAkta',TRUE); 
        //echo $data['jenisTemplate']; 
        $this->load->model('generate_template/m_template_tun_akta_permintaan_kasasi','template');
        $data['datapihakpenggugat'] = $this->template->getPihakPenggugat($idperkara);
        $data['datapihaktergugat'] = $this->template->getPihakTergugat($idperkara);
        //$data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
        // echo $data['jenisTemplate'] ;
        // exit();
        //Cetak Template Akta Permohonan Kasasi
        if($data['jenisTemplate']==1){
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','410','1','');
            $this->load->view('generate_template/cetak_tun_akta_permintaan_kasasi',$data,FALSE);
        }if($data['jenisTemplate']==2){
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','410','3','');
            $this->load->view('generate_template/cetak_tun_akta_permintaan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==4) {            
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','410','4','');
            $this->load->view('generate_template/cetak_tun_akta_permintaan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==3) {
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','410','2','');
            $this->load->view('generate_template/cetak_tun_akta_permintaan_kasasi',$data,FALSE);
        
        //CetakTemplate Pemberitahuan Akta Kasasi
        }elseif ($data['jenisTemplate']==5) {
            //== Load Penggugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','420','1','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==6) {
            //== Load Tergugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','420','3','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==7) {
            //== Load Kuasa Hukum Penggugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','420','2','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==8) {
            //== Load Kuasa Hukum Tergugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','420','4','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==9) {
            //== Load Intervensi
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','420','5','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        
        //Cetak Template Pemberitahuan Memori Kasasi
        }elseif ($data['jenisTemplate']==10) {
            //== Load Penggugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','430','1','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==12) {
            //== Load Kuasa Hukum Penggugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','430','2','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==11) {
            //== Load Tergugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','430','3','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==13) {
            //== Load Kuasa Hukum Tergugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','430','4','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==14) {
            //== Load Intervensi
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','430','5','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);

        //Cetak Template Pemberitahuan Kentra Memori Kasasi
        }elseif ($data['jenisTemplate']==15) {
            //== Load Penggugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','460','1','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==17) {
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','460','3','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==16) {
            //== Load Kuasa Hukum Penggugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','460','2','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==18) {
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','460','4','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==19) {
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','460','5','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE); 
        
        //Cetak Template Pemberitahuan Inzage
        }elseif ($data['jenisTemplate']==20) {
            //== Load Penggugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','461','1','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==21) {
            //== Load Tergugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','461','3','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==22) {
            //== Load Kuasa Hukum Penggugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','461','2','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==23) {
            //== Load Kuasa hukum Tergugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','461','4','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==24) {
            //== Load Intervensi
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','461','5','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE); 
        
        //Cetak Template Pemberitahuan Putusan
        }elseif ($data['jenisTemplate']==25) {
            //Load Penggugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','500','1','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==26) {
            //Load Tergugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','500','3','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==27) {
            //Load Kuasa Hukum Penggugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','500','2','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==28) {
            //Load Kuasa Hukum Tergugat
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi2($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','500','4','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==29) {
            //Load Kuasa Hukum Intervensi
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','20','500','5','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);  
    
        //Cetak Template Pencabutan Permohonan Kasasi
        }elseif ($data['jenisTemplate']==30) {
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','410','8','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==31) {
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','410','9','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==32) {
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','410','10','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==33) {
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','30','410','11','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==34) {
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','20','410','12','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);  
        //Load TMF
        }elseif ($data['jenisTemplate']==35) {
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','20','410','5','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
        }elseif ($data['jenisTemplate']==36) {
            $data['dataTemplate'] = $this->template->cetak_permintaan_kasasi($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);
            $data['template']=$this->template->getDataDocumentTemplate('9','20','410','6','');
            $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE); 
        }else{
            show_404();
            exit();
        }
    }

    function popup_tun_akta_permintaan_kasasi(){
        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();
        }
        $data['pihakasal']=$this->uri->segment('4');        
        if(!is_numeric($data['pihakasal']) OR !intval($data['pihakasal'])>0){
            show_404();
            exit();
        }
        $data['encpemohon']=$this->uri->segment('5');
        $idpemohon=$this->encrypt->decode(base64_decode($data['encpemohon']));
        if(!is_numeric($idpemohon) OR !intval($idpemohon)>0){
            show_404();
            exit();
        }

        $this->load->model('generate_template/m_template_tun_akta_permintaan_kasasi','template');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['info_penadatangan']=$this->template->getDataPejabat();
        $info=$this->template->getInfo($idperkara,$idpemohon);
        $data['info_datakasasi']=$this->template->getDataKasasi($idperkara);
        $data['template']=$this->template2->getDataDocumentTemplate('9','30','410','1','');
        if($info != ''){
            $data['namapihak'] = '';
            if($info->num_rows>0){
                foreach ($info->result() as $row) {                                
                    $diwakili = FALSE;
                    $data['namapihak'] .= $this->templatehelper->standradnaming($row->pihak_nama);
                    if($row->diwakili=='Y'){
                        $diwakili = TRUE;
                        $data['namapihak'] .= "</br>Diwakili oleh: ".$this->templatehelper->standradnaming($row->pemohon_nama);
                    }
                }
            }
        }
        if($data['pihakasal']==1 AND $diwakili==FALSE)
            $data['jenistemplate'] = 1;
        elseif($data['pihakasal']==1 AND $diwakili==TRUE)
            $data['jenistemplate'] = 3;
        elseif($data['pihakasal']==2 AND $diwakili==FALSE)
            $data['jenistemplate'] = 2;
        elseif($data['pihakasal']==2 AND $diwakili==TRUE)
            $data['jenistemplate'] = 4;
        elseif($data['pihakasal']==3)
            $data['jenistemplate'] = 5;
        $this->load->view('generate_template/popup_tun_akta_permintaan_kasasi', $data, FALSE);
    }
    
    function popup_tun_pemberitahuan_kasasi(){
        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();
        }
        $data['pihakasal']=$this->uri->segment('4');        
        if(!is_numeric($data['pihakasal']) OR !intval($data['pihakasal'])>0){
            show_404();
            exit();
        }
        $data['encpihak']=$this->uri->segment('5');
        $idpihak=$this->encrypt->decode(base64_decode($data['encpihak']));
        if(!is_numeric($idpihak) OR !intval($idpihak)>0){
            show_404();
            exit();
        }

        $data['encpemohon']=$this->uri->segment('5');        

        $this->load->model('generate_template/m_template_tun_akta_permintaan_kasasi','template');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');
        $data['datapemohon'] = $this->template->getListpihak($idperkara,$idpihak);
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['info_penadatangan']=$this->template->getDataPejabat();
        $info=$this->template->getInfoPihak($idperkara,$idpihak);
        $data['info_datakasasi']=$this->template->getDataKasasi($idperkara);
        $data['template']=$this->template2->getDataDocumentTemplate('9','30','420','1','');
        if($info != ''){
            $data['namapihak'] = '';
            if($info->num_rows>0){
                foreach ($info->result() as $row) {                                
                    $diwakili = FALSE;
                    $data['namapihak'] .= $this->templatehelper->standradnaming($row->pihak_nama);
                    if($row->diwakili=='Y'){
                        $diwakili = TRUE;
                        $data['encpihak']=base64_encode($this->encrypt->encode($row->pemohon_id));
                        $data['namapihak'] .= "</br>Diwakili oleh: ".$this->templatehelper->standradnaming($row->pemohon_nama);
                    }
                }
            }
        }
        $tglrelaaskasasi=$this->template->getTglKasasi($idperkara,$idpihak);
        if($tglrelaaskasasi!=''){
            if($tglrelaaskasasi->num_rows>0){
                foreach ($tglrelaaskasasi->result() as $row) {
                    $data['tglpemberitahuan'] = $this->templatehelper->convertKeTglIndo($row->pemberitahuan_kasasi);                    
                }
            }
        }
        if($data['pihakasal']==1 AND $diwakili==FALSE)
            $data['jenistemplate'] = 5;
        elseif($data['pihakasal']==1 AND $diwakili==TRUE)
            $data['jenistemplate'] = 7;
        elseif($data['pihakasal']==2 AND $diwakili==FALSE)
            $data['jenistemplate'] = 6;
        elseif($data['pihakasal']==2 AND $diwakili==TRUE)
            $data['jenistemplate'] = 8;
        elseif($data['pihakasal']==3)
            $data['jenistemplate'] = 9;
        
        $this->load->view('generate_template/popup_tun_pemberitahuan_kasasi', $data, FALSE);
    }

    function popup_tun_pemberitahuan_memori_kasasi(){
        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();
        }
        $data['pihakasal']=$this->uri->segment('4');        
        if(!is_numeric($data['pihakasal']) OR !intval($data['pihakasal'])>0){
            show_404();
            exit();
        }
        $data['encpihak']=$this->uri->segment('5');
        $idpihak=$this->encrypt->decode(base64_decode($data['encpihak']));
        if(!is_numeric($idpihak) OR !intval($idpihak)>0){
            show_404();
            exit();
        }

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

        $this->load->model('generate_template/m_template_tun_akta_permintaan_kasasi','template');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');
        $data['datapemohon'] = $this->template->getListpihak($idperkara,$idpihak);
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['info_penadatangan']=$this->template->getDataPejabat();
        $info=$this->template->getInfoPihak($idperkara,$idpihak);
        $data['info_datakasasi']=$this->template->getDataKasasi($idperkara);
        $data['template']=$this->template2->getDataDocumentTemplate('9','30','430','1','');
        if($info != ''){
            $data['namapihak'] = '';
            if($info->num_rows>0){
                foreach ($info->result() as $row) {                                
                    $diwakili = FALSE;
                    $data['namapihak'] .= $this->templatehelper->standradnaming($row->pihak_nama);
                    if($row->diwakili=='Y'){
                        $diwakili = TRUE;
                        $data['encpihak']=base64_encode($this->encrypt->encode($row->pemohon_id));
                        $data['namapihak'] .= "</br>Diwakili oleh: ".$this->templatehelper->standradnaming($row->pemohon_nama);
                    }
                }
            }
        }
        $tglrelaaskasasi=$this->template->getTglKasasi($idperkara,$idpihak);
        if($tglrelaaskasasi!=''){
            if($tglrelaaskasasi->num_rows>0){
                foreach ($tglrelaaskasasi->result() as $row) {
                    $data['tglpemberitahuan'] = $this->templatehelper->convertKeTglIndo($row->penyerahan_memori_kasasi);                    
                }
            }
        }
        if($data['pihakasal']==1 AND $diwakili==FALSE)
            $data['jenistemplate'] = 10;
        elseif($data['pihakasal']==1 AND $diwakili==TRUE)
            $data['jenistemplate'] = 12;
        elseif($data['pihakasal']==2 AND $diwakili==FALSE)
            $data['jenistemplate'] = 11;
        elseif($data['pihakasal']==2 AND $diwakili==TRUE)
            $data['jenistemplate'] = 13;
        elseif($data['pihakasal']==3 )
            $data['jenistemplate'] = 14;
        $this->load->view('generate_template/popup_tun_pemberitahuan_memori_kasasi', $data, FALSE);
    }


function popup_tun_pemberitahuan_kontra_memori_kasasi(){
        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();
        }
        $data['pihakasal']=$this->uri->segment('4');        
        if(!is_numeric($data['pihakasal']) OR !intval($data['pihakasal'])>0){
            show_404();
            exit();
        }
        $data['encpihak']=$this->uri->segment('5');
        $idpihak=$this->encrypt->decode(base64_decode($data['encpihak']));
        if(!is_numeric($idpihak) OR !intval($idpihak)>0){
            show_404();
            exit();
        }

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

        $this->load->model('generate_template/m_template_tun_akta_permintaan_kasasi','template');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');
        $data['datapemohon'] = $this->template->getListpihak($idperkara,$idpihak);
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['info_penadatangan']=$this->template->getDataPejabat();
        $info=$this->template->getInfoPihak($idperkara,$idpihak);
        $data['info_datakasasi']=$this->template->getDataKasasi($idperkara);
        $data['template']=$this->template2->getDataDocumentTemplate('9','30','460','1','');
        if($info != ''){
            $data['namapihak'] = '';
            if($info->num_rows>0){
                foreach ($info->result() as $row) {                                
                    $diwakili = FALSE;
                    $data['namapihak'] .= $this->templatehelper->standradnaming($row->pihak_nama);
                    if($row->diwakili=='Y'){
                        $diwakili = TRUE;
                        $data['encpihak']=base64_encode($this->encrypt->encode($row->pemohon_id));
                        $data['namapihak'] .= "</br>Diwakili oleh: ".$this->templatehelper->standradnaming($row->pemohon_nama);
                    }
                }
            }
        }
         $tglrelaaskasasi=$this->template->getTglKasasi($idperkara,$idpihak);
        if($tglrelaaskasasi!=''){
            if($tglrelaaskasasi->num_rows>0){
                foreach ($tglrelaaskasasi->result() as $row) {
                    $data['tglpemberitahuan'] = $this->templatehelper->convertKeTglIndo($row->penyerahan_kontra_kasasi);                    
                }
            }
        }
        if($data['pihakasal']==1 AND $diwakili==FALSE)
            $data['jenistemplate'] = 15;
        elseif($data['pihakasal']==1 AND $diwakili==TRUE)
            $data['jenistemplate'] = 17;
        elseif($data['pihakasal']==2 AND $diwakili==FALSE)
            $data['jenistemplate'] = 16;
        elseif($data['pihakasal']==2 AND $diwakili==TRUE)
            $data['jenistemplate'] = 18;
        elseif($data['pihakasal']==3 )
            $data['jenistemplate'] = 19;
        $this->load->view('generate_template/popup_tun_pemberitahuan_kontra_memori_kasasi', $data, FALSE);
    }


function popup_tun_inzage_kasasi(){

        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();
        }
        $data['pihakasal']=$this->uri->segment('4');        
        if(!is_numeric($data['pihakasal']) OR !intval($data['pihakasal'])>0){
            show_404();
            exit();
        }
        $data['encpihak']=$this->uri->segment('5');
        $idpihak=$this->encrypt->decode(base64_decode($data['encpihak']));
        if(!is_numeric($idpihak) OR !intval($idpihak)>0){
            show_404();
            exit();
        }

        // $data['encpemohon']=$this->uri->segment('5');
        // $idpemohon=$this->encrypt->decode(base64_decode($data['encpemohon']));
        // if(!is_numeric($idpemohon) OR !intval($idpemohon)>0){
        //     show_404();
        //     exit();
        // }
        // echo $idpihak;
        // exit();
        $this->load->model('generate_template/m_template_tun_akta_permintaan_kasasi','template');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');
        $data['datapemohon'] = $this->template->getListpihak($idperkara,$idpihak);
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['info_penadatangan']=$this->template->getDataPejabat();
        $info=$this->template->getInfoPihak($idperkara,$idpihak);
        $data['info_datakasasi']=$this->template->getDataKasasi($idperkara);
        $data['template']=$this->template2->getDataDocumentTemplate('9','30','461','1','');
        if($info != ''){
            $data['namapihak'] = '';
            if($info->num_rows>0){
                foreach ($info->result() as $row) {                                
                    $diwakili = FALSE;
                    $data['namapihak'] .= $this->templatehelper->standradnaming($row->pihak_nama);
                    if($row->diwakili=='Y'){
                        $diwakili = TRUE;
                        $data['encpihak']=base64_encode($this->encrypt->encode($row->pemohon_id));
                        $data['namapihak'] .= "</br>Diwakili oleh: ".$this->templatehelper->standradnaming($row->pemohon_nama);
                    }
                }
            }
        }
        $tglrelaaskasasi=$this->template->getTglKasasi($idperkara,$idpihak);
        if($tglrelaaskasasi!=''){
            if($tglrelaaskasasi->num_rows>0){
                foreach ($tglrelaaskasasi->result() as $row) {
                    $data['tglpemberitahuan'] = $this->templatehelper->convertKeTglIndo($row->pemberitahuan_inzage_kasasi);                   
                }
            }
        }


        if($data['pihakasal']==1 AND $diwakili==FALSE){
            $data['jenistemplate'] = 20;
        }elseif($data['pihakasal']==1 AND $diwakili==TRUE){
            $data['jenistemplate'] = 22;
        }elseif($data['pihakasal']==2 AND $diwakili==FALSE){
            $data['jenistemplate'] = 21;
        }elseif($data['pihakasal']==2 AND $diwakili==TRUE){
            $data['jenistemplate'] = 23;
        }elseif($data['pihakasal']==3 ){
            $data['jenistemplate'] = 24;
        }
        $this->load->view('generate_template/popup_tun_pemberitahuan_inzage', $data, FALSE);
    }


function popup_tun_pemberitahuan_put_kasasi(){
        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();
        }
        $data['pihakasal']=$this->uri->segment('4');        
        if(!is_numeric($data['pihakasal']) OR !intval($data['pihakasal'])>0){
            show_404();
            exit();
        }
        $data['encpihak']=$this->uri->segment('5');
        $idpihak=$this->encrypt->decode(base64_decode($data['encpihak']));
        if(!is_numeric($idpihak) OR !intval($idpihak)>0){
            show_404();
            exit();
        }

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

        $this->load->model('generate_template/m_template_tun_akta_permintaan_kasasi','template');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');
        $data['datapemohon'] = $this->template->getListpihak($idperkara,$idpihak);
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['info_penadatangan']=$this->template->getDataPejabat();
        $info=$this->template->getInfoPihak($idperkara,$idpihak);
        $data['info_datakasasi']=$this->template->getDataKasasi($idperkara);
        $data['template']=$this->template2->getDataDocumentTemplate('9','30','500','1','');
        if($info != ''){
            $data['namapihak'] = '';
            if($info->num_rows>0){
                foreach ($info->result() as $row) {                                
                    $diwakili = FALSE;
                    $data['namapihak'] .= $this->templatehelper->standradnaming($row->pihak_nama);
                    if($row->diwakili=='Y'){
                        $diwakili = TRUE;
                        $data['encpihak']=base64_encode($this->encrypt->encode($row->pemohon_id));
                        $data['namapihak'] .= "</br>Diwakili oleh: ".$this->templatehelper->standradnaming($row->pemohon_nama);
                    }
                }
            }
        }
        $tglrelaaskasasi=$this->template->getTglKasasi($idperkara,$idpihak);
        if($tglrelaaskasasi!=''){
            if($tglrelaaskasasi->num_rows>0){
                foreach ($tglrelaaskasasi->result() as $row) {
                    $data['tglpemberitahuan'] = $this->templatehelper->convertKeTglIndo($row->pemberitahuan_putusan_kasasi);                   
                }
            }
        }
        if($data['pihakasal']==1 AND $diwakili==FALSE)
            $data['jenistemplate'] = 25;
        elseif($data['pihakasal']==1 AND $diwakili==TRUE)
            $data['jenistemplate'] = 26;
        elseif($data['pihakasal']==2 AND $diwakili==FALSE)
            $data['jenistemplate'] = 27;
        elseif($data['pihakasal']==2 AND $diwakili==TRUE)
            $data['jenistemplate'] = 28;
        elseif($data['pihakasal']==3 )
            $data['jenistemplate'] = 29;
        $this->load->view('generate_template/popup_tun_pemberitahuan_put_kasasi', $data, FALSE);
    }


function popup_tun_akta_akta_cabut_kasasi(){
        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();
        }
        $data['pihakasal']=$this->uri->segment('4');        
        if(!is_numeric($data['pihakasal']) OR !intval($data['pihakasal'])>0){
            show_404();
            exit();
        }
        $data['encpihak']=$this->uri->segment('5');
        $idpihak=$this->encrypt->decode(base64_decode($data['encpihak']));
        if(!is_numeric($idpihak) OR !intval($idpihak)>0){
            show_404();
            exit();
        }

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

        $this->load->model('generate_template/m_template_tun_akta_permintaan_kasasi','template');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');
        $data['datapemohon'] = $this->template->getListpihak($idperkara,$idpihak);
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['info_penadatangan']=$this->template->getDataPejabat();
        $info=$this->template->getInfoPihak($idperkara,$idpihak);
        $data['info_datakasasi']=$this->template->getDataKasasi($idperkara);
        $data['template']=$this->template2->getDataDocumentTemplate('9','30','410','8','');
        if($info != ''){
            $data['namapihak'] = '';
            if($info->num_rows>0){
                foreach ($info->result() as $row) {                                
                    $diwakili = FALSE;
                    $data['namapihak'] .= $this->templatehelper->standradnaming($row->pihak_nama);
                    if($row->diwakili=='Y'){
                        $diwakili = TRUE;
                        $data['encpihak']=base64_encode($this->encrypt->encode($row->pemohon_id));
                        $data['namapihak'] .= "</br>Diwakili oleh: ".$this->templatehelper->standradnaming($row->pemohon_nama);
                    }
                }
            }
        }
        if($data['pihakasal']==1 AND $diwakili==FALSE)
            $data['jenistemplate'] = 30;
        elseif($data['pihakasal']==1 AND $diwakili==TRUE)
            $data['jenistemplate'] = 31;
        elseif($data['pihakasal']==2 AND $diwakili==FALSE)
            $data['jenistemplate'] = 32;
        elseif($data['pihakasal']==2 AND $diwakili==TRUE)
            $data['jenistemplate'] = 33;
        elseif($data['pihakasal']==3)
            $data['jenistemplate'] = 34;
        $this->load->view('generate_template/popup_tun_akta_cabut_kasasi', $data, FALSE);
    }

function cetak_penetapan_tmf(){
        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_tun_akta_permintaan_kasasi','template');
        $data['dataTemplate'] = $this->template->cetak_pemberitahuan_pk($idperkara,$pembuat);
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $data['jenisGugatan']='1';             
        $data['template']=$this->template2->getDataDocumentTemplate('9','30','410','5','');
        $this->load->view('generate_template/cetak_tun_pemberitahuan_kasasi',$data,FALSE);
    }



}
