<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class c_template_akta_cabut_pk extends CI_Controller {
	public function index(){

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

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

	function popup_akta_cabut_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();
        }
        $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_pencabutan_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['info']=$this->template->getInfo($idperkara);
        $data['template']=$this->template->getDataDocumentTemplate('111','40','510','','pencabutan peninjauan');
        $this->load->view('generate_template/popup_akta_pidana_pencabutan_peninjauan_kembali', $data, FALSE);
    }

    function cetak_akta_cabut_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']));
        
    	
        $this->load->model('generate_template/m_template_pidana_akta_pencabutan_peninjauan_kembali','template');
    	if($data['jenisTemplate']==1){
    		$data['dataTemplate'] = $this->template->cetak_cabut_terdakwa_pk($idperkara,$idpembuatakta,$idput,$terdakwa_id);
            $data['template']=$this->template->getDataDocumentTemplate('111','40','510','637','');
    		$this->load->view('generate_template/cetak_akta_pidana_cabut_peninjauan_kembali_terdakwa',$data,FALSE);
    	}elseif ($data['jenisTemplate']==2) {
    		$data['dataTemplate'] = $this->template->cetak_cabut_terdakwa_pk($idperkara,$idpembuatakta,$idput,$terdakwa_id);
            $data['template']=$this->template->getDataDocumentTemplate('111','40','510','638','');
    		$this->load->view('generate_template/cetak_akta_pidana_cabut_peninjauan_kembali_ahli_waris',$data,FALSE);
    	}elseif ($data['jenisTemplate']==3) {
    		$data['dataTemplate'] = $this->template->cetak_cabut_ph_pk($idperkara,$idpembuatakta,$idput,$pengacara_id);
            $data['info_DataPH_PK']=$this->template->infoDataPH_PK($idperkara);
            $data['template']=$this->template->getDataDocumentTemplate('111','40','510','639','');
    		$this->load->view('generate_template/cetak_akta_pidana_cabut_peninjauan_kembali_penasihat_hukum',$data,FALSE);
    	}elseif ($data['jenisTemplate']==4) {
    		$data['dataTemplate'] = $this->template->cetak_cabut_jpu_pk($idperkara,$idpembuatakta,$idput,$jpu_id);
            $data['infoDataJaksaPK'] = $this->template->getDataJaksaPK($idperkara);
            $data['template']=$this->template->getDataDocumentTemplate('111','40','510','640','');
    		$this->load->view('generate_template/cetak_akta_pidana_cabut_peninjauan_kembali_penuntut_umum',$data,FALSE);
    	}else{
            show_404();
            exit();
        }
    }

}