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

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

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

	function cetak_template(){
        $data['jenisTemplate'] = $this->input->post('jenisAkta',TRUE);     
        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']));
        
        $encpihak = $this->input->post('pihak',TRUE);
        $idpihak=$this->encrypt->decode(base64_decode($encpihak));
        
        $data['jenisrelaas'] = $this->input->post('jenisrelaas',TRUE);
        $this->load->model('generate_template/m_template_tun_peninjauan_kembali','template');
		$this->load->model('generate_template/m_template_ambil_identitas_template','template2');
        $data['datapemohonallpk'] = $this->template->getAllPemohon($idperkara);
        $data['datatermohonallpk'] = $this->template->getAllTermohon($idperkara);
        if($data['jenisrelaas']==1){
            $data['datapemohonpk'] = $this->template->infoPemohonPK($idperkara,$idpemohon);
            $data['datatermohonpk'] = $this->template->infoTermohonPK($idperkara,$idpihak);
            $idpemohon = $idpihak;
        }elseif($data['jenisrelaas']==2){
            $data['datapemohonpk'] = $this->template->infoAllPihak($idperkara,$idpemohon);
            $data['datatermohonpk'] = $this->template->infoAllPihak($idperkara,$idpihak);
        }elseif($data['jenisrelaas']==3){
            $data['dataperkarapk'] = $this->template->getDataPK($idperkara);
            $data['datatermohonpk'] = $this->template->infoAllPihak($idperkara,$idpihak);
            $idpemohon = $idpihak;
        }
       
        //Cetak Template Akta Permohonan PK
		$templates1=array("1","2","3","4","20","21","22","23","24","25");
		if (in_array($data['jenisTemplate'],$templates1)){
			$data['dataTemplate'] = $this->template->cetak_akta_peninjauan_kembali($idperkara,$idpembuatakta,$idput,$idpemohon);
			if($data['jenisTemplate']==1){
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','1','');
			}elseif($data['jenisTemplate']==2){
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','2','');
			}elseif ($data['jenisTemplate']==3) {            
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','3','');
			}elseif ($data['jenisTemplate']==4) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','4','');
			}elseif ($data['jenisTemplate']==20) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','5','');
			}elseif($data['jenisTemplate']==21){
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','6','');
			}elseif($data['jenisTemplate']==22){
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','7','');
			}elseif ($data['jenisTemplate']==23) {            
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','8','');
			}elseif ($data['jenisTemplate']==24) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','9','');
			}elseif ($data['jenisTemplate']==25) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','10','');
			}
			$this->load->view('generate_template/cetak_tun_akta_permintaan_peninjauan_kembali',$data,FALSE);
        }

		$templates2=array("5","6","7","8","9","10","11","12","13","14","15","16","17","18","19");
		if (in_array($data['jenisTemplate'],$templates2)){
			//CetakTemplate Pemberitahuan Permintaan PK
			$data['dataTemplate'] = $this->template->cetak_peninjauan_kembali($idperkara,$idpembuatakta,$idput,$idpemohon);            
			$data['datapihakpemberitahuan'] = $this->template->getDataPemberitahuan($idperkara,$idpihak);        
			if($data['jenisTemplate']==5) {            
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','520','1','');
			}elseif ($data['jenisTemplate']==6) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','520','3','');
			}elseif ($data['jenisTemplate']==7) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','520','2','');
			}elseif ($data['jenisTemplate']==8) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','520','4','');
			}elseif ($data['jenisTemplate']==9) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','520','5','');
			}
			//Cetak Template Pemberitahuan Kentra Memori PK
			elseif ($data['jenisTemplate']==10) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','540','1','');
			}elseif ($data['jenisTemplate']==11) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','540','2','');
			}elseif ($data['jenisTemplate']==12) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','540','3','');
			}elseif ($data['jenisTemplate']==13) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','540','4','');
			}elseif ($data['jenisTemplate']==14) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','540','5','');
			
			//Cetak Template Pemberitahuan Putusan
			}elseif ($data['jenisTemplate']==15) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','571','1','');
			}elseif ($data['jenisTemplate']==16) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','571','2','');
			}elseif ($data['jenisTemplate']==17) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','571','3','');
			}elseif ($data['jenisTemplate']==18) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','571','4','');
			}elseif ($data['jenisTemplate']==19) {
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','571','5','');
			}
			$this->load->view('generate_template/cetak_tun_pemberitahuan_peninjauan_kembali',$data,FALSE);  
		}
    }

	function popup_tun_akta_permintaan_pk(){
        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');                
        $data['encpemohon']=$this->uri->segment('5');
        $idpemohon=$this->encrypt->decode(base64_decode($data['encpemohon']));

        $data['jenisakta']=$this->uri->segment('6');
        $this->load->model('generate_template/m_template_tun_peninjauan_kembali','template');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');

        $data['datapemohon'] = $this->template->getListPemohon($idperkara,$idpemohon);
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['info_penadatangan']=$this->template->getDataPejabat();
        $info=$this->template->getInfo($idperkara,$idpemohon);
        $data['info_datapk']=$this->template->getDataPK($idperkara);
        
        if($info != ''){
            $data['namapihak'] = '';
            if($info->num_rows>0){
                foreach ($info->result() as $row) {                                                                    
                    if($row->pihak_diwakili=='Y'){
                        $diwakili=TRUE;
                        $data['namapihak'] .= "</br>Diwakili oleh: ".$this->templatehelper->standradnaming($row->pemohon_nama);
                    }else{
                        $diwakili=FALSE;
                        $data['namapihak'] .= $this->templatehelper->standradnaming($row->pihak_nama);
                    }
                }
            }
        }
        if($data['jenisakta']==1){
            if($data['pihakasal']==1 AND $diwakili==FALSE){
                $data['jenistemplate'] = 1;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','1','');}
            elseif($data['pihakasal']==1 AND $diwakili==TRUE){
				$data['jenistemplate'] = 2;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','2','');}
            elseif($data['pihakasal']==2 AND $diwakili==FALSE){
                $data['jenistemplate'] = 3;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','3','');}
            elseif($data['pihakasal']==2 AND $diwakili==TRUE){
                $data['jenistemplate'] = 4;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','4','');}
            elseif($data['pihakasal']==3 AND $diwakili==FALSE){
                $data['jenistemplate'] = 20;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','5','');}
		}
        if($data['jenisakta']==2){
            if($data['pihakasal']==1 AND $diwakili==FALSE){
                $data['jenistemplate'] = 21;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','6','');}
            elseif($data['pihakasal']==1 AND $diwakili==TRUE){
                $data['jenistemplate'] = 22;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','7','');}
            elseif($data['pihakasal']==2 AND $diwakili==FALSE){
                $data['jenistemplate'] = 23;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','8','');}
            elseif($data['pihakasal']==2 AND $diwakili==TRUE){
                $data['jenistemplate'] = 24;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','9','');}
            elseif($data['pihakasal']==3 AND $diwakili==FALSE){
                $data['jenistemplate'] = 25;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','510','10','');}
		}
        $this->load->view('generate_template/popup_tun_akta_permintaan_peninjauan_kembali', $data, FALSE);
    }


	function popup_tun_pemberitahuan_pk(){
        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){
            echo 'id perkara';
            show_404();
            exit();
        }
        $pihakasal=$this->uri->segment('4');
        $idpihakasal=$this->encrypt->decode(base64_decode($pihakasal));              
        if(!is_numeric($idpihakasal) OR !intval($idpihakasal)>0){
            echo 'id ne pihak asal';
            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){
            echo 'id ne pihak';
            show_404();
            exit();
        }
        $jenisrelaas = $this->uri->segment('6');

        $this->load->model('generate_template/m_template_tun_peninjauan_kembali','template');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');
        $data['datapemohon'] = $this->template->getInfoPihak($idperkara,$idpihak);
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['info_penadatangan']=$this->template->getDataPejabat();
        $data['info']=$this->template->getInfoPihak($idperkara,$idpihak);
        $data['info_datapk']=$this->template->getDataPK($idperkara);
        $data['infopemohonpkall']=$this->template->getPihakPemohonPK($idperkara);
        $data['infoPenerimaanKontra']=$this->template->getPihakKontraPK($idperkara);

        if($data['info'] != ''){
            $data['namapihak'] = '';
            if($data['info']->num_rows>0){
                foreach ($data['info']->result() as $row) { 
                    if($jenisrelaas==1){
                        $data['tglPemberitahuanPk'] = $row->pemberitahuan_pk;
                        $data['tglPemberitahuanPkIndo'] = $this->templatehelper->convertKeTglIndo($row->pemberitahuan_pk);
                    }elseif($jenisrelaas==2){
                        $data['tglPemberitahuanPk'] = $row->penyerahan_kontra_pk;
                        $data['tglPemberitahuanPkIndo'] = $this->templatehelper->convertKeTglIndo($row->penyerahan_kontra_pk);
                    }elseif($jenisrelaas==3){
                        $data['tglPemberitahuanPk'] = $row->pemberitahuan_putusan_pk;
                        $data['tglPemberitahuanPkIndo'] = $this->templatehelper->convertKeTglIndo($row->pemberitahuan_putusan_pk);
                    }                   
                    $diwakili = FALSE;
                    $data['namapihak'] .= $this->templatehelper->standradnaming($row->pihak_nama);
                    if($row->diwakili=='Y'){
                        $diwakili = TRUE;
                        $data['encpihak']=base64_encode($this->encrypt->encode($row->pihak_id));
                        $data['namapihak'] .= "</br>Diwakili oleh: ".$this->templatehelper->standradnaming($row->pemohon_nama);
                    }
                }
            }
        }
        if ($jenisrelaas==1){
            if($idpihakasal==1 AND $diwakili==FALSE){
                $data['jenistemplate'] = 5;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','520','1','');}
            elseif($idpihakasal==1 AND $diwakili==TRUE){
                $data['jenistemplate'] = 6;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','520','3','');}
            elseif($idpihakasal==2 AND $diwakili==FALSE){
                $data['jenistemplate'] = 7;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','520','2','');}
            elseif($idpihakasal==2 AND $diwakili==TRUE){
                $data['jenistemplate'] = 8;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','520','4','');}
            elseif($idpihakasal==3 AND $diwakili==FALSE){
                $data['jenistemplate'] = 9;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','520','5','');}
		}
        if($jenisrelaas==2){
            if($idpihakasal==1 AND $diwakili==FALSE){
                $data['jenistemplate'] = 10;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','540','1','');}
            elseif($idpihakasal==1 AND $diwakili==TRUE){
                $data['jenistemplate'] = 11;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','540','2','');}
            elseif($idpihakasal==2 AND $diwakili==FALSE){
                $data['jenistemplate'] = 12;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','540','3','');}
            elseif($idpihakasal==2 AND $diwakili==TRUE){
                $data['jenistemplate'] = 13;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','540','4','');}
            elseif($idpihakasal==3 AND $diwakili==FALSE){
                $data['jenistemplate'] = 14;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','540','5','');}
		}
        if($jenisrelaas==3){
            if($idpihakasal==1 AND $diwakili==FALSE){
                $data['jenistemplate'] = 15;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','571','1','');}
            elseif($idpihakasal==1 AND $diwakili==TRUE){
                $data['jenistemplate'] = 16;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','571','2','');}
            elseif($idpihakasal==2 AND $diwakili==FALSE){
                $data['jenistemplate'] = 17;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','571','3','');}
            elseif($idpihakasal==2 AND $diwakili==TRUE){
                $data['jenistemplate'] = 18;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','571','4','');}
            elseif($idpihakasal==3 AND $diwakili==FALSE){
                $data['jenistemplate'] = 19;
				$data['template']=$this->template2->getDataDocumentTemplate('9','40','571','5','');}
		}
        $data['jenisrelaas'] = $jenisrelaas;
        $this->load->view('generate_template/popup_tun_pemberitahuan_peninjauan_kembali', $data, FALSE);
    }
}
/* End of file c_template_tun_peninjauan_kembali.php */
/* Location: ./application/controllers/c_template_tun_peninjauan_kembali.php */