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

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

    function popup_akta_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();
		}
		$data['idakta'] = $this->uri->segment('6');		
		$this->load->model('generate_template/peradilan_agama/m_template_akta_kasasi_agama','template');
		$data['dataPutusan']=$this->template->getDataPutusan($idperkara);
		$data['listPembuatAkta'] = $this->template->pembuatAkta($idperkara);
		$info=$this->template->getInfo($idperkara,$idpemohon);
		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);
                    }
                }
            }
        }

		/*$data['blangko_akta_banding'] = $this->template->blangko_akta_banding();
		$data['listPihakBanding'] = $this->template->getDataPihakBanding($idperkara,$idpemohon);
		$data['listPihak'] = $this->template->getDataPihak($idperkara,$idpemohon);
		$data['listTerdakwa'] = $this->template->getDataTerdakwa($idperkara,$idpemohon);
		$data['listKuasaP'] = $this->template->infoKuasaPenggugat($idperkara,$idpemohon);
		$data['listKuasaT'] = $this->template->infoKuasaTergugat($idperkara,$idpemohon);
		$data['listKuasaInter'] = $this->template->infoKuasaIntervensi($idperkara,$idpemohon);
		$data['listPenuntut'] = $this->template->getDataTerdakwa($idperkara,$idpemohon);
				
		if($data['idakta']==1){
			foreach ($data['listPihakBanding']->result() as $row) {			
	            $data['tglpermohonan'] = $row->tglPemberitahuan;        	
	            $data['tglpermohonanindo'] = $this->templatehelper->convertKeTglIndo($row->tglPemberitahuan);
	        }
	    }*/
	    if($data['pihakasal']==1){
	    	$data['template']=$this->template->getDataDocumentTemplate('15','30','410','1','');			
	    }elseif($data['pihakasal']==2){
	    	$data['template']=$this->template->getDataDocumentTemplate('15','30','410','1','');		
	    }elseif($data['pihakasal']==3){
	    	$data['template']=$this->template->getDataDocumentTemplate('15','30','410','1','');
	    }	    		
		
		$this->load->view('generate_template/peradilan_agama/popup_akta_kasasi',$data,FALSE);
	}

	function cetak_akta_kasasi(){
		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){
             echo 'idperkara';
             show_404();
             exit();
        }           
        $encpemohon = $this->input->post('encpemohon',TRUE);
        $idpemohon=$this->encrypt->decode(base64_decode($encpemohon));
        if(!is_numeric($idpemohon) OR !intval($idpemohon)>0){
             echo 'idpemohon';
             show_404();
             exit();
        }
		       
		$data['jenisAkta'] = $this->input->post('jenisAkta',TRUE);
		if(empty($data['jenisAkta']) OR intval($data['jenisAkta'])<1){
			echo 'idakta';
			show_404();
		}
		
		$encputusan = $this->input->post('putusan',TRUE);
		$idputusan=$this->encrypt->decode(base64_decode($encputusan));
		if(empty($idputusan) OR intval($idputusan)<1){
			echo 'idputusan';
			show_404();
		}
		$data['penandatangan'] = $this->input->post('penandaT',TRUE);
        $penandatangan=$this->encrypt->decode(base64_decode($data['penandatangan']));
		/*echo $idperkara.' - '.$idpemohon.' - '.$idputusan.' - '.$penandatangan;
		exit();*/
		$this->load->model('generate_template/peradilan_agama/m_template_akta_kasasi_agama','template');
		$data['dataPN'] = $this->template->getDataPN($idperkara);        
		$data['dataTemplate'] = $this->template->cetak_AktaPermohonanKasasi($idperkara,$penandatangan,$idpemohon,$idputusan);
		
		if(($data['jenisAkta']==1)||($data['jenisAkta']==3)||($data['jenisAkta']==5)){
        	$data['template']=$this->template->getDataDocumentTemplate('15','30','410','1','');
		}elseif(($data['jenisAkta']==2)||($data['jenisAkta']==4)||($data['jenisAkta']==6)){
        	$data['template']=$this->template->getDataDocumentTemplate('15','30','410','2','');
		}elseif(($data['jenisAkta']==7)||($data['jenisAkta']==8)||($data['jenisAkta']==9)) {
        	$data['template']=$this->template->getDataDocumentTemplate('15','30','410','3','');
		}elseif(($data['jenisAkta']==10)||($data['jenisAkta']==11)||($data['jenisAkta']==12)){
        	$data['template']=$this->template->getDataDocumentTemplate('15','30','410','4','');
		}else{
			show_404();
		}
        $this->load->view('generate_template/peradilan_agama/cetak_akta_kasasi',$data,FALSE);
	}

	function popup_relaas_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['jenisrelas']=$this->uri->segment('6');
		$data['current_date'] = date('d/m/Y');

		$this->load->model('generate_template/peradilan_agama/m_template_akta_kasasi_agama','template');
		$data['listTerdakwa'] = $this->template->getDataTerdakwa($idperkara,$idpihak);
		$data['listKuasaP'] = $this->template->getKuasaPenggugat($idperkara,$idpihak);
		$data['listKuasaT'] = $this->template->getKuasaTergugat($idperkara,$idpihak);
		$data['listKuasaInter'] = $this->template->getKuasaIntervensi($idperkara,$idpihak);		
		$data['listPenuntut'] = $this->template->getInfoPihak($idperkara,$idpihak);									
		$data['listJurusita'] = $this->template->getAllJurusita($idperkara);		
		$data['listTglKasasi'] = $this->template->infoTglKasasiAll($idperkara);
		$data['listTglMemori'] = $this->template->infoTglTerimaMemori($idperkara);
		$data['listTglKontraMemori'] = $this->template->infoTglTerimaKontraMemori($idperkara);
		$data['dataPutusan']=$this->template->getDataPutusan($idperkara);
		
		//$data['dataTemplate'] = $this->template->cetak_AktaPermohonanKasasi($idperkara,$penandatangan,$idpihak,$idputusan);		
		//$data['listPT'] = $this->template->infoPT();
		$data['listPN'] = $this->template->infoPN();
		$data['ttdKetua'] = $this->template->ttdKetua();
		$data['listBiayaPemberitahuan'] = $this->template->listBiayaPemberitahuan($idperkara);		

		$data['infotglpemberitahuan'] = $this->template->getTanggalPemberitahuanKasasi($idperkara,$idpihak);
		foreach ($data['infotglpemberitahuan']->result() as $row) {
			if($data['jenisrelas']==1){
				$data['tglpemberitahuan'] = $row->pemberitahuan;
				$data['tglpemberitahuanindo'] = $this->templatehelper->convertKeTglIndo($row->pemberitahuan);       	
			}
			if($data['jenisrelas']==2){
				$data['tglpemberitahuan'] = $row->penyerahan_memori_kasasi;
				$data['tglpemberitahuanindo'] = $this->templatehelper->convertKeTglIndo($row->penyerahan_memori_kasasi);       	
			}
			if($data['jenisrelas']==3){
				$data['tglpemberitahuan'] = $row->penyerahan_kontra_kasasi;
				$data['tglpemberitahuanindo'] = $this->templatehelper->convertKeTglIndo($row->penyerahan_kontra_kasasi);       	
			}
			if($data['jenisrelas']==5){
				$data['tglpemberitahuan'] = $row->pemberitahuan_putusan_kasasi;
				$data['tglpemberitahuanindo'] = $this->templatehelper->convertKeTglIndo($row->pemberitahuan_putusan_kasasi);       	
			}
		}

		
        $data['judul']='';
        $data['jnsperkara']='Gugatan';
        
        $idalurperkara = $this->tanggalhelper->getIDAlurPerkara($idperkara);       
        if($data['jenisrelas']==1){
        	$data['judul'] = "PEMBERITAHUAN PERNYATAAN KASASI";
        }elseif($data['jenisrelas']==2){
        	$data['judul'] = "PEMBERITAHUAN DAN PENYERAHAN MEMORI KASASI";
        }elseif($data['jenisrelas']==3){
        	$data['judul'] = "PEMBERITAHUAN DAN PENYERAHAN KONTRA MEMORI KASASI";
        }elseif($data['jenisrelas']==4){
        	$data['judul'] = "RELAAS PEMBERITAHUAN INZAGE";
        }elseif($data['jenisrelas']==5){
        	$data['judul'] = "RELAAS PEMBERITAHUAN PUTUSAN KASASI";
        }else{
        	$data['judul'] = "RELAAS PEMBERITAHUAN";
        }
		$this->load->view('generate_template/peradilan_agama/popup_relaas_kasasi',$data,FALSE);
	}

	function cetak_relaas_kasasi(){
		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['idterdakwa'] = $this->input->post('terdakwa',TRUE);
	    $idterdakwa=$this->encrypt->decode(base64_decode($data['idterdakwa']));					
		$data['idjurusita'] = $this->input->post('jurusita',TRUE);
	    $idjurusita=$this->encrypt->decode(base64_decode($data['idjurusita']));				                       
        $data['penasihat'] = $this->input->post('idpenasihat',TRUE);
        $penasihat=$this->encrypt->decode(base64_decode($data['penasihat']));		
		$data['jenisAkta'] = $this->input->post('jenisAkta',TRUE);
		
		if(empty($data['jenisAkta']) OR intval($data['jenisAkta'])<1){
			show_404();
			exit();
		}				      
		$idPengadilan = $this->input->post('namaPN',TRUE);	
		$data['tgldelegasi'] = $this->tanggalhelper->convertToMysqlDate($this->input->post('tglPanggil',TRUE));
		        
        $idbanding = $this->encrypt->decode(base64_decode($this->input->post('tglKasasi',TRUE)));
    
        $idpenandatangan = $this->input->post('penandaT',TRUE);   
        $data['idpenandatangan'] = $this->encrypt->decode(base64_decode($idpenandatangan));    
		$data['tglpemberitahuan'] = $this->input->post('tglpemberitahuan',TRUE);
		$data['tglPenerimaan'] = $this->input->post('tglPenerimaan',TRUE);		
		$data['biayapemberitahuan'] = $this->input->post('biayapemberitahuan',TRUE);

		$this->load->model('generate_template/peradilan_agama/m_template_akta_kasasi_agama','template');
		
		$data['dataPerkara'] = $this->template->getDataPerkara($idperkara);
        $data['dataPN'] = $this->template->getDataPN($idperkara);
        $data['tanggalPutus'] = $this->template->getTanggalPutusan($idperkara);
        $data['infoPihak'] = $this->template->infoPihak($idperkara,$idterdakwa);
        //$data['infoallpembanding'] = $this->template->infoAllPemohon($idperkara);            
        //$data['infoallterbanding'] = $this->template->infoAllTermohon($idperkara);
        $data['infoKuasaPihak'] = $this->template->infoKuasaPihak($idperkara,$penasihat);
        $data['cetakJurusita'] = $this->template->cetakJurusita($idjurusita);
        
        if($data['jenisAkta']>=1 && $data['jenisAkta']<=20){		                
        	$data['cetaktglbanding'] = $this->template->cetaktglbanding($idbanding);
        }        	
        if($data['jenisAkta']==7 OR $data['jenisAkta']==9 OR $data['jenisAkta']==11 OR $data['jenisAkta']==15 OR $data['jenisAkta']==18 OR $data['jenisAkta']==21){
        	$data['cetakNamaPN'] = $this->template->cetakNamaPN($idPengadilan);        	
        }

        $data['infoKasasiTerhadap'] ='';
		if(($data['jenisAkta']==1)||($data['jenisAkta']==3)||($data['jenisAkta']==5)){	
			$encputusan = $this->input->post('putusan',TRUE);
			$idputusan=$this->encrypt->decode(base64_decode($encputusan));
			if(empty($idputusan) OR intval($idputusan)<1){
				show_404();
				exit();
			}
			$data['infoKasasiTerhadap'] = $this->template->getKasasiTerhadap($idputusan,$idperkara);
	        $data['template']=$this->template->getDataDocumentTemplate('15','30','420','201','');
		}elseif(($data['jenisAkta']==2)||($data['jenisAkta']==4)||($data['jenisAkta']==6)){
			$encputusan = $this->input->post('putusan',TRUE);
			$idputusan=$this->encrypt->decode(base64_decode($encputusan));
			if(empty($idputusan) OR intval($idputusan)<1){
				show_404();
				exit();
			}
			$data['infoKasasiTerhadap'] = $this->template->getKasasiTerhadap($idputusan,$idperkara);
	        $data['template']=$this->template->getDataDocumentTemplate('15','30','420','201','');
		}elseif(($data['jenisAkta']==7)||($data['jenisAkta']==9)||($data['jenisAkta']==11)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','320','201','');
		
		}elseif(($data['jenisAkta']==8)||($data['jenisAkta']==10)||($data['jenisAkta']==12)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','30','440','201','');
		}elseif(($data['jenisAkta']==13)||($data['jenisAkta']==19)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','30','460','201','');
		}elseif($data['jenisAkta']==16){
	        $data['template']=$this->template->getDataDocumentTemplate('15','30','460','201','');
		}elseif(($data['jenisAkta']==15)||($data['jenisAkta']==18)||($data['jenisAkta']==21)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','340','203','');
		}elseif(($data['jenisAkta']==14)||($data['jenisAkta']==17)||($data['jenisAkta']==20)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','40','460','201','');
		}elseif(($data['jenisAkta']==23)||($data['jenisAkta']==29)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','350','201','');
		}elseif($data['jenisAkta']==26){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','350','202','');
		}elseif($data['jenisAkta']==25){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','350','203','');
		}elseif(($data['jenisAkta']==22)||($data['jenisAkta']==28)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','350','204','');
		}elseif(($data['jenisAkta']==24)||($data['jenisAkta']==30)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','350','205','');
		}elseif($data['jenisAkta']==27){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','350','206','');
		}else if(($data['jenisAkta']==37)||($data['jenisAkta']==38)){	
			$encputusan = $this->input->post('putusan',TRUE);
			$idputusan=$this->encrypt->decode(base64_decode($encputusan));
			if(empty($idputusan) OR intval($idputusan)<1){
				show_404();
				exit();
			}
			$data['infoKasasiTerhadap'] = $this->template->getKasasiTerhadap($idputusan,$idperkara);
	        $data['template']=$this->template->getDataDocumentTemplate('15','30','490','201','');
		}else{
			show_404();
		}
		
		$this->load->view('generate_template/peradilan_agama/cetak_relaas_kasasi',$data,FALSE);
	}
}