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

class c_template_putusan_mil_temp_atria extends CI_Controller {

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

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

        $jPut = $this->uri->segment('3');
        $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();
        }  

        $jns_template=$this->input->post('jns_template',TRUE);
        if(!is_numeric($jns_template) OR !intval($jns_template)>0){
            show_404();
            exit();
        }   

    	$this->load->model('generate_template/m_template_mil','template');
        $this->load->model('putusan/data_putusan_akhir','putusan');
        $data['status_putusan'] = $this->putusan->getPutusanTerdakwa($idperkara);

    	$data['dataTemplate'] = $this->template->getDataPutusan($idperkara);
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        if($jPut==1){
            if($jns_template==1){
                $data['template']=$this->template2->getDataDocumentTemplate('120','15','210','6','');        
            }elseif($jns_template==2){
                $data['template']=$this->template2->getDataDocumentTemplate('120','15','210','2','');        
            }elseif($jns_template==3){
                $data['template']=$this->template2->getDataDocumentTemplate('120','15','210','3','');        
            }elseif($jns_template==4){
                $data['template']=$this->template2->getDataDocumentTemplate('120','15','210','4','');        
            }elseif($jns_template==5){
                $data['template']=$this->template2->getDataDocumentTemplate('120','15','210','5','');        
            }
        }elseif($jPut==2) {
            $data['template']=$this->template2->getDataDocumentTemplate('120','12','30','1','');    
        }else{
            $data['template']=$this->template2->getDataDocumentTemplate('120','12','80','1','');    
        }              

        $data['dataterdakwa']=$this->template->getDataTerdakwaMil($idperkara);
        $data['getTglPts']=$this->template->getTglPts($idperkara);
        $data['datapenahanan'] = $this->template->getDataPenahananTerdakwaMil($idperkara);
    	$this->load->view('generate_template/cetak_putusan_mil',$data,FALSE);
    }

    function cetak_akta_menerima_putusan($enc, $pihak_id, $pihak_ke){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }       
        
        $segment = $this->uri->segment_array(); 
        $perkara_id=$this->encrypt->decode(base64_decode($enc));       
        $data['perkara_id'] = $perkara_id;
        if(!is_numeric($perkara_id) OR !intval($perkara_id)>0){            
            show_404();
            exit();
        }   
        
        $pihak_id=$this->encrypt->decode(base64_decode($pihak_id));
        $data['pihak_id'] = $pihak_id;
        if(!is_numeric($pihak_id) OR !intval($pihak_id)>0){            
            show_404();
            exit();
        }   
        $data['pihak_ke'] = $pihak_ke;
        if ($pihak_ke=='1'){
            $var='7';
        }elseif($pihak_ke=='2'){
            $var='6';
        }
        $this->load->model('generate_template/m_template_mil','template');
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        
        $PN=$this->template->getDataPN()->result();
        $id_pn=$PN[0]->IDPN;
        $info_pn=$this->template->get_pn($id_pn)->result();
        $info_pn=$info_pn[0];
        $data['info_pn']=$info_pn;
        $info_putusan=$this->template2->getDataPutusanPerkara($perkara_id)->result();
        $data['tgl_putusan']=$info_putusan[0]->tanggal_putusan;
        $data['info_panitera']=$this->template->get_perkara_panitera($perkara_id)->result();
        $data['ls_pemberitahuan_putusan']= $this->template->getDataPemberitahuanPutusanMil($perkara_id, $pihak_ke, $pihak_id);
        $data['template']=$this->template2->getDataDocumentTemplate('120','16','240',$var,'');    
        $this->load->view('generate_template/cetak_pemberitahuan_putusan_mil',$data,FALSE);
    }

}
?>