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

class c_template_relaas_pidana_kasasi extends CI_Controller {
	function index() {
         if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }  
    }
	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 OR !is_numeric($idperkara)){
		    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_relaas_pidana_kasasi','template');
		$data['listPemohonKasasiTerdakwa'] = $this->template->getDataPermohonanKasasiTerdakwa($idperkara);
		$data['listPemohonKasasiPenuntut'] = $this->template->getDataPermohonanKasasiPU($idperkara);
		$data['listTglPenyerahanMemori'] = $this->template->tglPenyerahanMemori($idperkara);
		$data['listTerdakwa'] = $this->template->getDataTerdakwa($idperkara);
		$data['listJaksa'] = $this->template->getDataJaksa($idperkara);
		$data['listJurusita'] = $this->template->getAllJurusita($idperkara);
		$data['listPemohon'] = $this->template->getAllPemohonKasasi($idperkara);
		$data['listTermohon'] = $this->template->getAllTermohonKasasi($idperkara);
		$data['infotglpemberitahuan'] = $this->template->getTanggalPemberitahuanKasasi($idperkara,$idpihak);
		foreach ($data['infotglpemberitahuan']->result() as $row) {
			if($data['jenisrelas']==1){
				$data['tglpemberitahuan'] = $row->pemberitahuan_kasasi;
				$data['tglpemberitahuanindo'] = $this->templatehelper->convertKeTglIndo($row->pemberitahuan_kasasi);       	
			}
			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']==4){
				$data['tglpemberitahuan'] = $row->pemberitahuan_putusan_kasasi;
				$data['tglpemberitahuanindo'] = $this->templatehelper->convertKeTglIndo($row->pemberitahuan_putusan_kasasi);       	
			}			
		}
		
		$data['judul'] = '';
		if($data['jenisrelas']==1){
        	$data['judul'] = "RELAAS PEMBERITAHUAN PERMOHONAN KASASI";
        }elseif($data['jenisrelas']==2){
        	$data['judul'] = "RELAAS PENYERAHAN MEMORI KASASI";
        }elseif($data['jenisrelas']==3){
        	$data['judul'] = "RELAAS PENYERAHAN KONTRA MEMORI KASASI";
        }elseif($data['jenisrelas']==4){
        	$data['judul'] = "RELAAS PEMBERITAHUAN PUTUSAN KASASI";
        }else{
        	$data['judul'] = "RELAAS PEMBERITAHUAN";
        }		
		$this->load->view('generate_template/popup_relaas_pidana_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['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('penuntut',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['pemohonKasasi'] = $this->input->post('pemohon',TRUE);
        $pemohonKasasi=$this->encrypt->decode(base64_decode($data['pemohonKasasi']));
		$data['termohonKasasi'] = $this->input->post('termohon',TRUE);
        $termohonKasasi=$this->encrypt->decode(base64_decode($data['termohonKasasi']));	
		$data['tglpenyerahan'] = $this->input->post('tglpemberitahuan',TRUE);       	
       	$data['tglPenerimaanKontra'] = $this->input->post('inputtgltermohon1',TRUE);
		$data['tglPenyerahanKontra'] = $this->input->post('tglpemberitahuan',TRUE);
		$data['kasasiTerhadap'] = $this->input->post('kasasiTerhadap',TRUE);
		
		$this->load->model('generate_template/m_template_relaas_pidana_kasasi','template');		
		$data['dataPerkara'] = $this->template->getDataPerkara($idperkara);
        $data['dataPN'] = $this->template->getDataPN($idperkara);
        $data['tanggalPutus'] = $this->template->getTanggalPutusan($idperkara);
        $data['cetakJurusita'] = $this->template->cetakJurusita($idjurusita); 
        $data['cetakJaksa'] = $this->template->cetakDataJaksa($idperkara);
        $data['cetakAllTerdakwaKasasi'] = $this->template->cetakAllTerdakwaAjukanKasasi($idperkara);
        $data['cetakTglPermohonanKasasi'] = $this->template->cetakTglKasasi($idperkara);        
        $data['nobanding'] = $this->template->cetakNobanding($idperkara);
        $data['cetakAllTerdakwa'] = $this->template->cetakAllTerdakwa($idperkara,$idterdakwa);
        $data['cetakPartiesJaksa'] = $this->template->cetakJaksaParties($idperkara);
        $data['cetakAllPemohon'] = $this->template->getAllPihakKasasi($idperkara,$pemohonKasasi);
		$data['cetakAllTermohon'] = $this->template->getAllPihakKasasi($idperkara,$termohonKasasi);
		$data['allTerdakwa'] = $this->template->getAllTerdakwa($idperkara);
		$data['cetakKasasiMA'] = $this->template->getKasasiMA($idperkara);
		
		
		if($data['jenisAkta']==1){
        	$data['template']=$this->template->getDataDocumentTemplate('111','30','420','263','');
		}elseif($data['jenisAkta']==2){
        	$data['template']=$this->template->getDataDocumentTemplate('111','30','420','264','');
		}elseif($data['jenisAkta']==3){
        	$data['template']=$this->template->getDataDocumentTemplate('111','30','440','265','');
		}elseif($data['jenisAkta']==4){
        	$data['template']=$this->template->getDataDocumentTemplate('111','30','440','266','');
		}elseif($data['jenisAkta']==5){
        	$data['template']=$this->template->getDataDocumentTemplate('111','30','460','267','');
		}elseif($data['jenisAkta']==6){
        	$data['template']=$this->template->getDataDocumentTemplate('111','30','460','268','');
		}elseif($data['jenisAkta']==7){
        	$data['template']=$this->template->getDataDocumentTemplate('111','30','460','269','');
		}elseif($data['jenisAkta']==8){
        	$data['template']=$this->template->getDataDocumentTemplate('111','30','500','271','');
		}elseif($data['jenisAkta']==9){
        	$data['template']=$this->template->getDataDocumentTemplate('111','30','500','272','');
		}else {
			show_404();
			exit();
		}
        $this->load->view('generate_template/cetak_relaas_pidana_kasasi',$data,FALSE);
	}
}