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

class c_template_tun_akta_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/m_template_tun_akta_banding','template');				
		$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);
	        }
	    }
	    if($data['pihakasal']==1){
	    	$data['template']=$this->template->getDataDocumentTemplate('9','20','290','2','');			
	    }elseif($data['pihakasal']==2){
	    	$data['template']=$this->template->getDataDocumentTemplate('9','20','290','4','');		
	    }elseif($data['pihakasal']==3){
	    	$data['template']=$this->template->getDataDocumentTemplate('9','20','290','6','');
	    }	    		
		
		$this->load->view('generate_template/popup_tun_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/m_template_tun_akta_banding','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);        
		
		if($data['jenisAkta']==1){
        	$data['template']=$this->template->getDataDocumentTemplate('9','20','290','2','');
		}elseif($data['jenisAkta']==2){
        	$data['template']=$this->template->getDataDocumentTemplate('9','20','290','3','');
		}elseif($data['jenisAkta']==3){
        	$data['template']=$this->template->getDataDocumentTemplate('9','20','290','4','');
		}elseif($data['jenisAkta']==4){
        	$data['template']=$this->template->getDataDocumentTemplate('9','20','290','5','');
		}elseif($data['jenisAkta']==5){
        	$data['template']=$this->template->getDataDocumentTemplate('9','20','290','6','');
		}elseif($data['jenisAkta']==6){
        	$data['template']=$this->template->getDataDocumentTemplate('9','20','290','7','');
		}else{
			show_404();
		}
        $this->load->view('generate_template/cetak_tun_akta_banding',$data,FALSE);
	}

	function popup_cabut_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();
		}				

		$this->load->model('generate_template/m_template_tun_akta_banding','template');		
		$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);
		foreach ($data['listPihakBanding']->result() as $row) {
			$data['tglcabut'] = $row->tanggal_cabut;
			$data['tglcabutindo'] = $this->templatehelper->convertKeTglIndo($row->tanggal_cabut);
			$data['tglbanding'] = $row->tglPemberitahuan;
		}
		if($data['pihakasal']==1){
	    	$data['template']=$this->template->getDataDocumentTemplate('9','20','290','8','');			
	    }elseif($data['pihakasal']==2){
	    	$data['template']=$this->template->getDataDocumentTemplate('9','20','290','10','');			
	    }elseif($data['pihakasal']==3){
	    	$data['template']=$this->template->getDataDocumentTemplate('9','20','290','12','');			
	    }		
        
		$this->load->view('generate_template/popup_tun_akta_pencabutan_banding',$data,FALSE);
	} 	
	function cetak_cabut_banding(){
		if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        } 
        $idperkara=$this->encrypt->decode(base64_decode($this->input->post('enc',TRUE)));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
             show_404();
             exit();
        }
        $data['penandatangan'] = $this->input->post('penandaT',TRUE);	    	            
        $idterdakwa=$this->encrypt->decode(base64_decode($this->input->post('terdakwa',TRUE)));								
        $penasihat=$this->encrypt->decode(base64_decode($this->input->post('idpenasihat',TRUE)));		
        
		$data['jenisAkta'] = $this->input->post('jenisAkta',TRUE);
		if(empty($data['jenisAkta']) OR intval($data['jenisAkta'])<1){
			show_404();
		} 
		$data['tglsurat'] = $this->tanggalhelper->convertToMysqlDate($this->input->post('tglsurat',TRUE));		
		$data['nomorsurat'] = $this->input->post('nomorsurat',TRUE);
		$data['tglcabut'] = $this->input->post('tglcabut',TRUE);
		$data['tglbanding'] = $this->input->post('tglbanding',TRUE);
		$data['idakta'] = $this->input->post('idakta',TRUE);

		$this->load->model('generate_template/m_template_tun_akta_banding','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);     	
		
		if($data['jenisAkta']==7){
			$data['template']=$this->template->getDataDocumentTemplate('9','20','290','8','');
		}elseif($data['jenisAkta']==8){
			$data['template']=$this->template->getDataDocumentTemplate('9','20','290','9','');
		}elseif($data['jenisAkta']==9){
		    $data['template']=$this->template->getDataDocumentTemplate('9','20','290','10','');
		}elseif($data['jenisAkta']==10){
		    $data['template']=$this->template->getDataDocumentTemplate('9','20','290','11','');
		}elseif($data['jenisAkta']==11){
		    $data['template']=$this->template->getDataDocumentTemplate('9','20','290','12','');
		}elseif($data['jenisAkta']==12){
		    $data['template']=$this->template->getDataDocumentTemplate('9','20','290','13','');
		}else{
			show_404();
		}

		$this->load->view('generate_template/cetak_tun_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');

		$this->load->model('generate_template/m_template_tun_akta_banding','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['listPembuatAkta'] = $this->template->pembuatAkta($idperkara);		
		$data['listTglBanding'] = $this->template->infoTglBandingAll($idperkara);
		$data['listTglMemori'] = $this->template->infoTglTerimaMemori($idperkara);
		$data['listTglKontraMemori'] = $this->template->infoTglTerimaKontraMemori($idperkara);				

		$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']='';
        
        $idalurperkara = $this->tanggalhelper->getIDAlurPerkara($idperkara);
        if($idalurperkara==9){
        	$data['jnsperkara'] = "TUN";
        }
        if($data['jenisrelas']==1){
        	$data['judul'] = "SURAT PEMBERITAHUAN PERNYATAAN BANDING";
        }elseif($data['jenisrelas']==2){
        	$data['judul'] = "RELAAS PENYERAHAN MEMORI BANDING";
        }elseif($data['jenisrelas']==3){
        	$data['judul'] = "RELAAS 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/popup_tun_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['penandatangan'] = $this->input->post('penandaT',TRUE);
        $penandatangan=$this->encrypt->decode(base64_decode($data['penandatangan']));                        
        $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();
		}				      
        $data['tglBanding'] = $this->input->post('tglBanding',TRUE);
		$data['tglpemberitahuan'] = $this->input->post('tglpemberitahuan',TRUE);

		$this->load->model('generate_template/m_template_tun_akta_banding','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);		

		if($data['jenisAkta']==1){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','300','1','');
		}elseif($data['jenisAkta']==2){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','300','2','');
		}elseif($data['jenisAkta']==3){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','300','3','');
		}elseif($data['jenisAkta']==4){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','300','4','');
		}elseif($data['jenisAkta']==5){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','300','3','');
		}elseif($data['jenisAkta']==6){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','300','4','');
		}elseif($data['jenisAkta']==7){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','320','1','');
		}elseif($data['jenisAkta']==8){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','320','2','');
		}elseif($data['jenisAkta']==9){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','320','3','');
		}elseif($data['jenisAkta']==10){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','320','4','');
		}elseif($data['jenisAkta']==11){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','320','3','');
		}elseif($data['jenisAkta']==12){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','320','4','');
		}elseif($data['jenisAkta']==13){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','340','1','');
		}elseif($data['jenisAkta']==14){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','340','2','');
		}elseif($data['jenisAkta']==15){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','340','3','');
		}elseif($data['jenisAkta']==16){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','340','4','');
		}elseif($data['jenisAkta']==17){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','340','3','');
		}elseif($data['jenisAkta']==18){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','340','4','');
		}elseif($data['jenisAkta']==19){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','360','1','');
		}elseif($data['jenisAkta']==20){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','360','2','');
		}elseif($data['jenisAkta']==21){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','360','3','');
		}elseif($data['jenisAkta']==22){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','360','4','');
		}elseif($data['jenisAkta']==23){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','360','3','');
		}elseif($data['jenisAkta']==24){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','360','4','');
		}elseif($data['jenisAkta']==25){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','400','1','');
		}elseif($data['jenisAkta']==26){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','400','2','');
		}elseif($data['jenisAkta']==27){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','400','3','');
		}elseif($data['jenisAkta']==28){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','400','4','');
		}elseif($data['jenisAkta']==29){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','400','3','');
		}elseif($data['jenisAkta']==30){
	        $data['template']=$this->template->getDataDocumentTemplate('9','20','400','4','');
		}else{
			show_404();
		}

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

}