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

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

	function popup_akta_banding_mil(){	
		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_pidana_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['listTerdakwaKontra'] = $this->template->getTerdakwaKontraMemori($idperkara);
		$data['listKuasa'] = $this->template->getDataPembanding($idperkara);
		$data['listKuasaKontra'] = $this->template->getPHKontraMemoriBanding($idperkara);
		$data['listPenuntut'] = $this->template->getDataJaksa($idperkara,$idpemohon);
		$data['listPenuntutKontra'] = $this->template->getJaksaKontraBanding($idperkara);
		$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);
	        }
	    }
	    		
	
        $data['template']=$this->template->getDataDocumentTemplate('111','20','290','','permintaan banding');
		$this->load->view('generate_template/popup_akta_pidana_banding_mil',$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['bandingMelalui'] = $this->input->post('bandingMelalui',TRUE);
        $data['penasihat'] = $this->input->post('idpenasihat',TRUE);
        $penasihat=$this->encrypt->decode(base64_decode($data['penasihat']));
		$data['penuntut'] = $this->input->post('idpenuntut',TRUE);
        $penuntut=$this->encrypt->decode(base64_decode($data['penuntut']));
		$data['jenisAkta'] = $this->input->post('jenisAkta',TRUE);
		if(empty($data['jenisAkta']) OR intval($data['jenisAkta'])<1){
			show_404();
		}

		$this->load->model('generate_template/m_template_pidana_akta_banding','template');

		$data['dataPerkara'] = $this->template->getDataPerkara($idperkara);
        $data['dataPN'] = $this->template->getDataPN($idperkara);
        $data['tanggalPutus'] = $this->template->getTanggalPutusan($idperkara);        
        $data['cetakDataTerdakwa'] = $this->template->getDataTerdakwaBanding($idperkara,$idterdakwa);
        $data['cetakDataBanding'] = $this->template->getDataPembanding($idperkara);
        $data['cetakpartiesbanding'] = $this->template->getDataBandingParties($idperkara,$penasihat);
        $data['cetakDataJPU'] = $this->template->cetakDataJaksa($idperkara);
        $data['cetakDataPUKontra'] = $this->template->cetakJaksaKontra($idperkara);
		
		if($data['jenisAkta']==1){
        	$data['template']=$this->template->getDataDocumentTemplate('111','20','290','601','');
		}elseif($data['jenisAkta']==2){
        	$data['template']=$this->template->getDataDocumentTemplate('111','20','290','602','');
		}elseif($data['jenisAkta']==3){
        	$data['template']=$this->template->getDataDocumentTemplate('111','20','290','603','');
		}elseif($data['jenisAkta']==4){
        	$data['template']=$this->template->getDataDocumentTemplate('111','20','290','604','');
		}elseif($data['jenisAkta']==5){
        	$data['template']=$this->template->getDataDocumentTemplate('111','20','310','609','');
		}elseif($data['jenisAkta']==6){
        	$data['template']=$this->template->getDataDocumentTemplate('111','20','310','610','');
		}elseif($data['jenisAkta']==7){
        	$data['template']=$this->template->getDataDocumentTemplate('111','20','310','611','');
		}elseif($data['jenisAkta']==8){
        	$data['template']=$this->template->getDataDocumentTemplate('111','20','310','612','');
		}elseif($data['jenisAkta']==9){
        	$data['template']=$this->template->getDataDocumentTemplate('111','20','330','613','');
		}elseif($data['jenisAkta']==10){
        	$data['template']=$this->template->getDataDocumentTemplate('111','20','330','614','');
		}elseif($data['jenisAkta']==11){
        	$data['template']=$this->template->getDataDocumentTemplate('111','20','330','615','');
		}elseif($data['jenisAkta']==12){
        	$data['template']=$this->template->getDataDocumentTemplate('111','20','330','616','');
		}else{
			show_404();
		}
        $this->load->view('generate_template/cetak_akta_pidana_banding',$data,FALSE);
	}

	function popup_cabut_banding_mil(){
		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_pidana_akta_banding','template');		
		$data['listPihakBanding'] = $this->template->getDataPihakBanding($idperkara,$idpemohon);		
		$data['listTerdakwa'] = $this->template->getDataTerdakwa($idperkara,$idpemohon);
		$data['listKuasa'] = $this->template->getDataPembanding($idperkara);
		$data['listPenuntut'] = $this->template->getDataJaksa($idperkara,$idpemohon);
		$data['listPembuatAkta'] = $this->template->pembuatAkta($idperkara);
		foreach ($data['listPihakBanding']->result() as $row) {
			$data['tglcabut'] = $row->tanggal_cabut;
			$data['tglbanding'] = $row->tglPemberitahuan;
		}		
        $data['template']=$this->template->getDataDocumentTemplate('111','20','290','','pencabutan banding');
		$this->load->view('generate_template/popup_akta_pidana_pencabutan_banding_mil',$data,FALSE);
	} 	
	function cetak_cabut_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['bandingMelalui'] = $this->input->post('bandingMelalui',TRUE);
        $data['penasihat'] = $this->input->post('idpenasihat',TRUE);
        $penasihat=$this->encrypt->decode(base64_decode($data['penasihat']));
		$data['penuntut'] = $this->input->post('idpenuntut',TRUE);
        $penuntut=$this->encrypt->decode(base64_decode($data['penuntut']));
		$data['jenisAkta'] = $this->input->post('jenisAkta',TRUE);
		if(empty($data['jenisAkta']) OR intval($data['jenisAkta'])<1){
			show_404();
		} 
		$data['tglcabut'] = $this->input->post('tglcabut',TRUE);
		$data['tglbanding'] = $this->input->post('tglbanding',TRUE);
		$this->load->model('generate_template/m_template_pidana_akta_banding','template');		
		$data['dataPerkara'] = $this->template->getDataPerkara($idperkara);
        $data['dataPN'] = $this->template->getDataPN($idperkara);
        $data['tanggalPutus'] = $this->template->getTanggalPutusan($idperkara);        
        $data['cetakDataTerdakwa'] = $this->template->getDataTerdakwaBanding($idperkara,$idterdakwa);
        $data['cetakDataBanding'] = $this->template->getDataPembanding($idperkara);
        $data['cetakpartiesbanding'] = $this->template->getDataBandingParties($idperkara,$penasihat);
        $data['cetakDataJPU'] = $this->template->cetakDataJaksa($idperkara);
		$data['cetakTanggalCabut'] = $this->template->getTanggalCabutBanding($idperkara);        	
		
		if($data['jenisAkta']==1){
			$data['template']=$this->template->getDataDocumentTemplate('111','20','290','605','');
		}elseif($data['jenisAkta']==2){
			$data['template']=$this->template->getDataDocumentTemplate('111','20','290','606','');
		}elseif($data['jenisAkta']==3){
		    $data['template']=$this->template->getDataDocumentTemplate('111','20','290','607','');
		}elseif($data['jenisAkta']==4){
		    $data['template']=$this->template->getDataDocumentTemplate('111','20','290','608','');
		}else{
			show_404();
		}

		$this->load->view('generate_template/cetak_akta_pidana_pencabutan_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_pidana_akta_banding','template');
		$data['listTerdakwa'] = $this->template->getDataTerdakwa($idperkara,$idpihak);
		$data['listKuasa'] = $this->template->getDataPembanding($idperkara);
		$data['listPenuntut'] = $this->template->getInfoPihak($idperkara,$idpihak);		
		$data['listJurusita'] = $this->template->getAllJurusita($idperkara);							
		$data['listPembuatAkta'] = $this->template->pembuatAkta($idperkara);
		$data['listPembanding'] = $this->template->getPihakPembanding($idperkara);
		$data['listTerbanding'] = $this->template->getPihakTerbanding($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<100){
        	$data['jnsperkara'] = "PERDATA";
        }else{
        	$data['jnsperkara'] = "PIDANA";
        }
        if($data['jenisrelas']==1){
        	$data['judul'] = "RELAAS 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_relaas_pidana_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){
             show_404();
             exit();
        }
        $data['idjurusita'] = $this->input->post('jurusita',TRUE);
	    $idjurusita=$this->encrypt->decode(base64_decode($data['idjurusita']));		
		if(!is_numeric($idjurusita) OR !intval($idjurusita)>0){
			show_404();
			exit();
		}
		$data['idterdakwa'] = $this->input->post('terdakwa',TRUE);
	    $idterdakwa=$this->encrypt->decode(base64_decode($data['idterdakwa']));		

		$data['idpenuntut'] = $this->input->post('idpenuntut',TRUE);
	    $idpenuntut=$this->encrypt->decode(base64_decode($data['idpenuntut']));		
						
		$data['jenisAkta'] = $this->input->post('jenisAkta',TRUE);
		if(empty($data['jenisAkta']) OR intval($data['jenisAkta'])<1){
			show_404();
			exit();
		}
		
		$data['pembanding'] = $this->input->post('pembanding',TRUE);
        $pembanding=$this->encrypt->decode(base64_decode($data['pembanding']));

		$data['terbanding'] = $this->input->post('terbanding',TRUE);
        $terbanding=$this->encrypt->decode(base64_decode($data['terbanding']));

       	$data['tglpenyerahan'] = $this->input->post('tglpemberitahuan',TRUE);
       	$data['tglpenerimaan'] = $this->input->post('inputpenerimaankontra1',TRUE);       
        
		$data['tglpemberitahuan'] = $this->input->post('tglpemberitahuan',TRUE);

		$this->load->model('generate_template/m_template_pidana_akta_banding','template');		
		$data['dataPerkara'] = $this->template->getDataPerkara($idperkara);
        $data['dataPN'] = $this->template->getDataPN($idperkara);
        $data['tanggalPutus'] = $this->template->getTanggalPutusan($idperkara);
		$data['tanggalPemberitahuan'] = $this->template->getTanggalPemberitahuanBanding($idperkara,$idterdakwa);
		$data['cetakJurusita'] = $this->template->cetakJurusita($idjurusita);
		$data['cetakDataJPU'] = $this->template->cetakPemberitahuanPU($idperkara);
        $data['cetakpartiesbanding'] = $this->template->getDataBandingParties2($idperkara);
        $data['cetakDataTerdakwa'] = $this->template->getDataTerdakwaBanding($idperkara,$idterdakwa);
		$data['cetakPartiesJaksa'] = $this->template->cetakJaksaParties($idperkara);		
		$data['cetaktanggalPemberitahuan'] = $this->template->cetakPemberitahuanBandingPU($idperkara);
		$data['cetakTanggalMemori'] = $this->template->getTanggalPemberitahuanBanding($idperkara, $idterdakwa);
		$data['cetakTglTerdakwaPembanding'] = $this->template->getTanggalPemberitahuanBanding($idperkara, $idterdakwa);
		$data['cetakTglRelaasPU'] = $this->template->getTanggalPemberitahuanBanding($idperkara, $idpenuntut);
		$data['cetakPUBanding'] = $this->template->getJaksaBanding($idperkara,$idpenuntut);
		$data['cetakBandingPT'] = $this->template->getDataBandingPT($idperkara); 
		$data['cetakAllTerdakwa'] = $this->template->getAllTerdakwa($idperkara);       	
		$data['cetakAllPembanding'] = $this->template->getAllPihakBanding($idperkara,$pembanding);
		$data['cetakAllTerbanding'] = $this->template->getAllPihakBanding($idperkara,$terbanding);
		$data['infotglbandingterdakwa'] = $this->template->infoTglBanding($idperkara);		

		if($data['jenisAkta']==1){
	        $data['template']=$this->template->getDataDocumentTemplate('111','20','300','251','');
		}elseif($data['jenisAkta']==2){
	        $data['template']=$this->template->getDataDocumentTemplate('111','20','300','252','');
		}elseif($data['jenisAkta']==3){
	        $data['template']=$this->template->getDataDocumentTemplate('111','20','320','253','');
		}elseif($data['jenisAkta']==4){
	        $data['template']=$this->template->getDataDocumentTemplate('111','20','320','254','');
		}elseif($data['jenisAkta']==5){
	        $data['template']=$this->template->getDataDocumentTemplate('111','20','340','255','');
		}elseif($data['jenisAkta']==6){
	        $data['template']=$this->template->getDataDocumentTemplate('111','20','340','256','');
		}elseif($data['jenisAkta']==7){
	        $data['template']=$this->template->getDataDocumentTemplate('111','20','340','257','');
		}elseif($data['jenisAkta']==8){
	        $data['template']=$this->template->getDataDocumentTemplate('111','20','360','259','');
		}elseif($data['jenisAkta']==9){
	        $data['template']=$this->template->getDataDocumentTemplate('111','20','360','260','');
		}elseif($data['jenisAkta']==10){
	        $data['template']=$this->template->getDataDocumentTemplate('111','20','400','261','');
		}elseif($data['jenisAkta']==11){
	        $data['template']=$this->template->getDataDocumentTemplate('111','20','400','262','');
		}else{
			show_404();
		}

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

}