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

class c_template_akta_permohonan_kasasi_pid extends CI_Controller {
	public function index(){
        if($this->session->userdata('is_logged_in')==FALSE){
        redirect('login');
        }       
		$this->load->view('dashboard', FALSE);
	}

	function popup_akta_permohonan_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){
            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_permohonan_akta_kasasi_pid','template');
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['info_penadatangan']=$this->template->getDataPejabat();
        $data['info_DataTerdakwa']=$this->template->infoDataTerdakwa($idperkara);
        $data['info_dataJaksaKasasi']=$this->template->getDataJaksaKasasi($idperkara);
        $data['info_DataPHKasasi']=$this->template->infoDataPHKasasi($idperkara);
        $data['info']=$this->template->getInfo($idperkara);
        $data['template']=$this->template->getDataDocumentTemplate('111','30','410','','akta permohonan');
        $this->load->view('generate_template/popup_akta_pidana_permohonan_kasasi', $data, FALSE);
    }

    function cetak_akta_permohonan_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['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('jenisTemplate',TRUE);
        $data['terdakwa_id'] = $this->input->post('terdakwa',TRUE);
        $terdakwa_id=$this->encrypt->decode(base64_decode($data['terdakwa_id']));
        $data['diwakilkan'] = $this->input->post('diwakilkan',TRUE);
        $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_permohonan_akta_kasasi_pid','template');
    	if($data['jenisTemplate']==1){
    		$data['dataTemplate'] = $this->template->cetak_permohonan_kasasi($idperkara,$idpembuatakta,$idput);
            $data['template']=$this->template->getDataDocumentTemplate('111','30','410','992','');
    		$this->load->view('generate_template/cetak_akta_pidana_permohonan_kasasi_terdakwa',$data,FALSE);
    	}elseif ($data['jenisTemplate']==2) {
    		$data['dataTemplate'] = $this->template->cetak_permohonan_kasasi($idperkara,$idpembuatakta,$idput);
            $data['template']=$this->template->getDataDocumentTemplate('111','30','410','993','');
    		$this->load->view('generate_template/cetak_akta_pidana_permohonan_kasasi_terdakwa_tidak_menghadap',$data,FALSE);
    	}elseif ($data['jenisTemplate']==3) {
    		$data['dataTemplate'] = $this->template->cetak_permohonan_kasasi_ph($idperkara,$idpembuatakta,$idput);
            $data['template']=$this->template->getDataDocumentTemplate('111','30','410','994','');
    		$this->load->view('generate_template/cetak_akta_pidana_permohonan_kasasi_penasihat_hukum',$data,FALSE);
    	}elseif ($data['jenisTemplate']==4) {
    		$data['dataTemplate'] = $this->template->cetak_AktaPermohonanKasasiPenuntutUmum($idperkara,$idpembuatakta,$idput);
    		$data['DataJaksaKasasi'] = $this->template->getDataJaksaKasasi($idperkara);
            $data['template']=$this->template->getDataDocumentTemplate('111','30','410','995','');
    		$this->load->view('generate_template/cetak_akta_pidana_permohonan_kasasi_penuntut_umum',$data,FALSE);

    	}
    }

    function popup_cabut_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){
            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_akta_kasasi_pid','template');      
        $data['listPihakKasasi'] = $this->template->getDataPihakKasasi($idperkara,$idpemohon); 
        $data['info_DataTerdakwa']=$this->template->getTerdakwaKasasi($idperkara);       
        $data['listKuasa'] = $this->template->getDataKuasaHukum($idperkara);
        $data['listPenuntut'] = $this->template->getDataJaksa($idperkara,$idpemohon);
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['listPembuatAkta'] = $this->template->pembuatAkta($idperkara);
        foreach ($data['listPihakKasasi']->result() as $row) {
            $data['tglcabut'] = $row->tanggal_cabut;
            $data['tglkasasi'] = $row->tglPemberitahuan;
        }       
        $data['template']=$this->template->getDataDocumentTemplate('111','20','290','','pencabutan banding');
        $this->load->view('generate_template/popup_akta_cabut_kasasi',$data,FALSE);
    }   
    function cetak_cabut_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['idpembuatakta'] = $this->input->post('idpembuatakta',TRUE);
        $idpembuatakta=$this->encrypt->decode(base64_decode($data['idpembuatakta']));                                       
        $data['jenisTemplate'] = $this->input->post('jenisAkta',TRUE);
        if(empty($data['jenisTemplate']) OR intval($data['jenisTemplate'])<1){
            show_404();
        } 
        $data['tglcabut'] = $this->input->post('tglcabut',TRUE);
        $data['diwakilkan'] = $this->input->post('kasasiMelalui',TRUE);
        $data['idput'] = $this->input->post('putusan',TRUE);
        $idput=$this->encrypt->decode(base64_decode($data['idput']));
        $this->load->model('generate_template/m_template_cabut_akta_kasasi_pid','template');
        if($data['jenisTemplate']==1){
            $data['dataTemplate'] = $this->template->cetak_cabut_kasasi_terdakwa($idperkara,$idpembuatakta,$idput);
            $data['template']=$this->template->getDataDocumentTemplate('111','30','410','996','');
            $this->load->view('generate_template/cetak_cabut_kasasi_pidana_terdakwa',$data,FALSE);
        }elseif ($data['jenisTemplate']==2) {
            $data['dataTemplate'] = $this->template->cetak_cabut_kasasi_terdakwa($idperkara,$idpembuatakta,$idput);
            $data['template']=$this->template->getDataDocumentTemplate('111','30','410','997','');
            $this->load->view('generate_template/cetak_cabut_kasasi_pidana_terdakwa_diwakilkan',$data,FALSE);
        }elseif ($data['jenisTemplate']==3) {
            $data['dataTemplate'] = $this->template->cetak_cabut_kasasi_ph($idperkara,$idpembuatakta,$idput);
            $data['template']=$this->template->getDataDocumentTemplate('111','30','410','998','');
            $this->load->view('generate_template/cetak_cabut_kasasi_pidana_penasihat_hukum',$data,FALSE);
        }elseif ($data['jenisTemplate']==4) {
            $data['dataTemplate'] = $this->template->cetak_cabut_kasasi_terdakwa($idperkara,$idpembuatakta,$idput);
            $data['DataJaksaKasasi'] = $this->template->getDataJaksaKasasi($idperkara);
            $data['template']=$this->template->getDataDocumentTemplate('111','30','410','999','');
            $this->load->view('generate_template/cetak_cabut_kasasi_pidana_penuntut_umum',$data,FALSE);
        }
    } 

}
