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

class c_template_relaas_pemberitahuan_permintaan_pk extends CI_Controller {

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

		$this->load->view('dashboard', FALSE);
	}

	function popup_relass_pemberitahuan_pk(){
        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();
        }
        $this->load->model('generate_template/m_template_relaas_pidana_peninjauan_kembali','template');
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['info_penadatangan']=$this->template->getDataPejabat();
        $data['info_DataTerdakwa']=$this->template->infoDataTerdakwa($idperkara);
        $data['info_dataDataJaksaPK']=$this->template->getDataJaksaPK($idperkara);
        $data['info_DataPH_PK']=$this->template->infoDataPH_PK($idperkara);
        $data['listJurusita'] = $this->template->getAllJurusita($idperkara);
        $data['info']=$this->template->getInfo($idperkara);
        $data['template']=$this->template->getDataDocumentTemplate('111','40','571','','putusan peninjauan');
        $this->load->view('generate_template/popup_relaas_pidana_peninjauan_kembali', $data, FALSE);
    }

    function cetak_relaas_pemberitahuan_permintaan_pk(){
        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['idpembuatakta'] = $this->input->post('pembuat',TRUE);   
        $idpembuatakta=$this->encrypt->decode(base64_decode($data['idpembuatakta']));
        if(!is_numeric($idpembuatakta) OR !intval($idpembuatakta)>0){
            show_404();
            exit();
        }
        $data['idput'] = $this->input->post('putusan',TRUE);   
        $idput=$this->encrypt->decode(base64_decode($data['idput']));
        if(!is_numeric($idput) OR !intval($idput)>0){
            show_404();
            exit();
        }   
        $data['jenisTemplate'] = $this->input->post('jenisAkta',TRUE); 
        $data['terdakwa_id'] = $this->input->post('terdakwa',TRUE);
        $terdakwa_id=$this->encrypt->decode(base64_decode($data['terdakwa_id']));
        
        $data['pengacara_id'] = $this->input->post('ph',TRUE);  
        $pengacara_id=$this->encrypt->decode(base64_decode($data['pengacara_id']));
        
        $data['jpu_id'] = $this->input->post('jpu',TRUE);  
        $jpu_id=$this->encrypt->decode(base64_decode($data['jpu_id']));

        $data['idjurusita'] = $this->input->post('jurusita',TRUE);  
        $idjurusita=$this->encrypt->decode(base64_decode($data['idjurusita']));
           
    	$this->load->model('generate_template/m_template_relaas_pidana_peninjauan_kembali','template');
    	if($data['jenisTemplate']==1){
            $data['DataJaksaKasasi'] = $this->template->getDataJaksa($idperkara);
            $data['cetakJurusita'] = $this->template->cetakJurusita($idjurusita);
    		$data['dataTemplate'] = $this->template->cetak_pemberitahuan_pk($idperkara,$idpembuatakta,$idput);
            $data['template']=$this->template->getDataDocumentTemplate('111','40','571','278','');
    	}elseif ($data['jenisTemplate']==4) {    		
            $data['DataJaksaKasasi'] = $this->template->getDataJaksa($idperkara);
            $data['cetakJurusita'] = $this->template->cetakJurusita($idjurusita);
    		$data['dataTemplate'] = $this->template->cetak_pemberitahuan_pk($idperkara,$idpembuatakta,$idput);
            $data['template']=$this->template->getDataDocumentTemplate('111','40','571','277','');
    	}else{
            show_404();
            exit();
        }
        $this->load->view('generate_template/cetak_relaas_pidana_putusan_peninjauan_kembali',$data,FALSE);
    }
}
