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

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

    function popup_akta_banding(){	
		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_banding_agama','template');
		$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);
		$data['listPembuatAkta'] = $this->template->pembuatAkta($idperkara);
	
		if($data['idakta']==1){
			foreach ($data['listPihakBanding']->result() as $row) {			
	            $data['tglpermohonan'] = $row->tglPemberitahuan;        	
	            $data['tglpermohonanindo'] = $this->templatehelper->convertKeTglIndo($row->tglPemberitahuan);
	        }
	    }elseif($data['idakta']==2){
	    	foreach ($data['listPihak']->result() as $row) {			
	            $data['tglpermohonan'] = $row->tglmemori;        	
	            $data['tglpermohonanindo'] = $this->templatehelper->convertKeTglIndo($row->tglmemori);
	        }
	    }elseif($data['idakta']==3){
	    	foreach ($data['listPihak']->result() as $row) {			
	            $data['tglpermohonan'] = $row->tglkontramemori;        	
	            $data['tglpermohonanindo'] = $this->templatehelper->convertKeTglIndo($row->tglkontramemori);
	        }
	    }elseif($data['idakta']==4){
	    	foreach ($data['listPihakBanding']->result() as $row) {			
	            $data['tglpermohonan'] = $row->tanggal_cabut;        	
	            $data['tglpermohonanindo'] = $this->templatehelper->convertKeTglIndo($row->tanggal_cabut);
	        }
	    }

	    if($data['pihakasal']==1){
	    	$data['template']=$this->template->getDataDocumentTemplate('15','20','300','1','');			
	    }elseif($data['pihakasal']==2){
	    	$data['template']=$this->template->getDataDocumentTemplate('15','20','300','1','');		
	    }elseif($data['pihakasal']==3){
	    	$data['template']=$this->template->getDataDocumentTemplate('15','20','300','1','');
	    }	    		
		
		$this->load->view('generate_template/peradilan_agama/popup_akta_banding',$data,FALSE);
	}

	function cetak_akta_banding(){
		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('idterdakwa',TRUE);
	    $idterdakwa=$this->encrypt->decode(base64_decode($data['idterdakwa']));	    
		$data['penandatangan'] = $this->input->post('penandaT',TRUE);
        $penandatangan=$this->encrypt->decode(base64_decode($data['penandatangan']));        
        $data['tglBanding'] = $this->input->post('inputpemberitahuan',TRUE);        
        $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();
		}
		$data['tglpermohonan'] = $this->input->post('inputpemberitahuan',TRUE);
		$this->load->model('generate_template/peradilan_agama/m_template_akta_banding_agama','template');

		$data['dataPerkara'] = $this->template->getDataPerkara($idperkara);
        $data['dataPN'] = $this->template->getDataPN($idperkara);
        $data['tanggalPutus'] = $this->template->getTanggalPutusan($idperkara);
        $data['infopembanding'] = $this->template->infoPembanding($idperkara,$idterdakwa);        
        $data['infoallpembanding'] = $this->template->infoAllPembanding($idperkara);            
        $data['infoallterbanding'] = $this->template->infoAllTerbanding($idperkara);
        $data['infoKuasaPihak'] = $this->template->infoKuasaPihak($idperkara,$penasihat); 
        $data['infoPihak'] = $this->template->infoPihak($idperkara,$idterdakwa);       
		
		if(($data['jenisAkta']==1)||($data['jenisAkta']==3)||($data['jenisAkta']==5)){
        	$data['template']=$this->template->getDataDocumentTemplate('15','20','300','1','');
		}elseif(($data['jenisAkta']==2)||($data['jenisAkta']==4)||($data['jenisAkta']==6)){
        	$data['template']=$this->template->getDataDocumentTemplate('15','20','300','2','');
		}elseif(($data['jenisAkta']==7)||($data['jenisAkta']==8)||($data['jenisAkta']==9)) {
        	$data['template']=$this->template->getDataDocumentTemplate('15','20','300','3','');
		}elseif(($data['jenisAkta']==10)||($data['jenisAkta']==11)||($data['jenisAkta']==12)){
        	$data['template']=$this->template->getDataDocumentTemplate('15','20','300','4','');
		}elseif(($data['jenisAkta']==13)||($data['jenisAkta']==14)||($data['jenisAkta']==15)){
        	$data['template']=$this->template->getDataDocumentTemplate('15','20','310','1','');
		}elseif(($data['jenisAkta']==16)||($data['jenisAkta']==17)||($data['jenisAkta']==18)){
        	$data['template']=$this->template->getDataDocumentTemplate('15','20','330','1','');
		}elseif(($data['jenisAkta']==19)||($data['jenisAkta']==20)||($data['jenisAkta']==21)){
        	$data['template']=$this->template->getDataDocumentTemplate('15','20','391','1','');
		}elseif(($data['jenisAkta']==22)||($data['jenisAkta']==23)||($data['jenisAkta']==24)){
        	$data['template']=$this->template->getDataDocumentTemplate('15','20','391','2','');
		}else{
			show_404();
		}
        $this->load->view('generate_template/peradilan_agama/cetak_akta_banding',$data,FALSE);
	}

	function popup_relaas_banding(){
		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_banding_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['listTglBanding'] = $this->template->infoTglBandingAll($idperkara);
		$data['listTglMemori'] = $this->template->infoTglTerimaMemori($idperkara);
		$data['listTglKontraMemori'] = $this->template->infoTglTerimaKontraMemori($idperkara);				
		$data['listPT'] = $this->template->infoPT();
		$data['listPN'] = $this->template->infoPN();
		$data['ttdKetua'] = $this->template->ttdKetua();
		$data['listBiayaPemberitahuan'] = $this->template->listBiayaPemberitahuan($idperkara);	
		$data['listPembuatAkta'] = $this->template->pembuatAkta();	

		$data['infotglpemberitahuan'] = $this->template->getTanggalPemberitahuanBanding($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_banding;
				$data['tglpemberitahuanindo'] = $this->templatehelper->convertKeTglIndo($row->penyerahan_memori_banding);       	
			}
			if($data['jenisrelas']==3){
				$data['tglpemberitahuan'] = $row->penyerahan_kontra_banding;
				$data['tglpemberitahuanindo'] = $this->templatehelper->convertKeTglIndo($row->penyerahan_kontra_banding);       	
			}
			if($data['jenisrelas']==4){
				$data['tglpemberitahuan'] = $row->pemberitahuan_inzage;
				$data['tglpemberitahuanindo'] = $this->templatehelper->convertKeTglIndo($row->pemberitahuan_inzage);       	
			}
			if($data['jenisrelas']==5){
				$data['tglpemberitahuan'] = $row->pemberitahuan_putusan_banding;
				$data['tglpemberitahuanindo'] = $this->templatehelper->convertKeTglIndo($row->pemberitahuan_putusan_banding);       	
			}
		}

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

	function cetak_relaas_banding(){
		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 'siji';
             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('tglBanding',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_banding_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->infoAllPembanding($idperkara);            
        $data['infoallterbanding'] = $this->template->infoAllTerbanding($idperkara);
        $data['infoKuasaPihak'] = $this->template->infoKuasaPihak($idperkara,$penasihat);
        $data['cetakJurusita'] = $this->template->cetakJurusita($idjurusita);
        if($data['jenisAkta']>=1 && $data['jenisAkta']<=12){		                
        	$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 OR $data['jenisAkta']==31 OR $data['jenisAkta']==32 OR $data['jenisAkta']==33){
        	$data['cetakNamaPN'] = $this->template->cetakNamaPN($idPengadilan);        	
        }
        
		if(($data['jenisAkta']==1)||($data['jenisAkta']==3)||($data['jenisAkta']==5)){			
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','301','201','');
		}elseif(($data['jenisAkta']==2)||($data['jenisAkta']==4)||($data['jenisAkta']==6)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','301','202','');
		}elseif(($data['jenisAkta']==31)||($data['jenisAkta']==32)||($data['jenisAkta']==33)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','301','203','');
		}elseif(($data['jenisAkta']==7)||($data['jenisAkta']==9)||($data['jenisAkta']==11)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','301','203','');
		}elseif(($data['jenisAkta']==8)||($data['jenisAkta']==10)||($data['jenisAkta']==12)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','320','202','');
		}elseif(($data['jenisAkta']==13)||($data['jenisAkta']==19)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','340','201','');
		}elseif($data['jenisAkta']==16){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','340','202','');
		}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','20','340','204','');
		}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','201','');
		}elseif(($data['jenisAkta']==22)||($data['jenisAkta']==25)||($data['jenisAkta']==28)){
	        $data['template']=$this->template->getDataDocumentTemplate('15','20','360','1','');
		}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{
			show_404();
		}

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

}