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

class c_template_putusan_agama extends CI_Controller {

	function index() {
        show_404();
    }

    function popup_putusan(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }
        $data['enc']=$this->uri->segment('3');
        $data['idalur']=$this->uri->segment('4');
        $data['status']=$this->uri->segment('5');

        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        
        $this->load->model('generate_template/m_template_putusan_agama','template');
        $dataAlur = $this->template->getAlurPerkara($idperkara);
        foreach ($dataAlur->result() as $dataAlur) {
            $alurPerkara = $dataAlur->alur_perkara_id;
        }
        
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('15','15','210','1','');
        $i=0;
        $jumdata=count($template->result());
        foreach ($template->result() as $template){
            if ($jumdata=='1'){
                $judul['0']=$template->namatemplate;
            }else{
                if ($i=='0'){
                    $judul=$template->namatemplate;
                    $judul=explode("Voluntair",$judul);
                }
            }
        }

        $data['judul']="PUTUSAN AKHIR";
        if ($data['idalur']==15) {
            $data['jnsperkara']="GUGATAN";
        }else if ($data['idalur']==16) {
            $data['jnsperkara']="PERMOHONAN";
        }
        
        $data['idperkara']=$idperkara;
        $data['alurPerkara']=$alurPerkara;
        $this->load->view('generate_template/popup_putusan_agama', $data, FALSE);
    }


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

        $segment = $this->uri->segment_array();
        $data['enc']=$this->uri->segment('3');
        $jenisTemplate=$this->uri->segment('4');
        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
             show_404();
             exit();
        }
        $jenisTemplate =$segment[4];
        if(!is_numeric($jenisTemplate) OR !intval($jenisTemplate)>0){
             show_404();
             exit();
        }
		if($jenisTemplate==1){
            $data['blangko_putusan'] = '02 a Putusan Cerai Talak Verstek OK';
        } else if ($jenisTemplate==2){
           $data['blangko_putusan'] = '01 Putusan Cerai Talak eksepsi kewenangan Rekonvensi Harta Bersama OK';
        }else if ($jenisTemplate==20){
           $data['blangko_putusan'] = '02 b Putusan Cerai Gugat Verstek OK';
        } else if ($jenisTemplate==3){
            $data['blangko_putusan'] = '04 Putusan Gugur OK';
        } else if ($jenisTemplate==4){
            $data['blangko_putusan'] = '05 Putusan Cabut OK';
        } else if ($jenisTemplate==5){
            $data['blangko_putusan'] = '06 Putusan NO';
        } else if ($jenisTemplate==6){
            $data['blangko_putusan'] = '07 Putusan Verstek NO';
        } else if ($jenisTemplate==7){
           $data['blangko_putusan'] = '08 Putusan Batal Daftar OK';
        } else if ($jenisTemplate==8){
           $data['blangko_putusan'] = '09 Penetapan Permohonan Kabul OK';
        } else if ($jenisTemplate==9){
            $data['blangko_putusan'] = '10 Penetapan Permohonan Tolak';
        } else if ($jenisTemplate==10){
           $data['blangko_putusan'] = '11 Penetapan Gugur OK';
        } else if ($jenisTemplate==11){
            $data['blangko_putusan'] = '12 Penetapanan Cabut OK';
        } else if ($jenisTemplate==12){
            $data['blangko_putusan'] = '13 Penetapan Batal Daftar OK';
        } else if ($jenisTemplate==13){
           $data['blangko_putusan'] = '14 Penetapan Tentang Tidak Berkekuatan Hukumnya Putusan Cerai Talak OK';
        } else if ($jenisTemplate==14){
            $data['blangko_putusan'] = '15 Penetapan Tentang Terjadinya Talak OK';
        } else if ($jenisTemplate==15){
           $data['blangko_putusan'] = '16 Penetapan saat ikrar, para pihak rukun OK';
        } else if ($jenisTemplate==16){
            $data['blangko_putusan'] = '02 a Putusan Cerai Talak Verstek OK';
        } else if ($jenisTemplate==99){
            $data['blangko_putusan'] = '01 Putusan Cerai Talak eksepsi kewenangan Rekonvensi Harta Bersama OK';
        }else {
            show_404();
            exit();
        }
		
		$filenya="peradilan_agama/putusan/".$data['blangko_putusan'].".rtf";
		$data_id=array(
                    'source_file'=>$filenya,
                    'perkara_id'=>$idperkara,
					'jadwal_sidang_id'=> $data['idjadwal']);  

        $this->load->model('generate_template/var_template_agama','var_template');
        $this->var_template->kirim_variabel($data_id);  
		}
	function cetak_instrumen_amar_putusan_agama(){
			if($this->session->userdata('is_logged_in')==FALSE){
				redirect('login');
			}       

			$segment = $this->uri->segment_array();
			$data['enc']=$this->uri->segment('3');
			   
			$idperkara=$this->encrypt->decode(base64_decode($data['enc']));
			// echo "ID : ".$idperkara; exit;
			if(!is_numeric($idperkara) OR !intval($idperkara)>0){
				 show_404();
				 exit();
			}
			$this->load->model('generate_template/peradilan_agama/m_skum','skum');
			 $data['getsatker'] = $this->skum->getsatker($idperkara,'1');
			$this->load->model('generate_template/peradilan_agama/m_template_relaas_agama','template');    
			$data['dataPutusan']=$this->template->getDataPutusan($idperkara);   
			$data['datajurusita']=$this->template->getDataJurusita($idperkara);	
			$data['dataPerkara']=$this->template->getDataPerkara($idperkara);	
			$data['dataHakim']=$this->template->getDataHakim_ketua($idperkara);	
			$this->load->view('generate_template/peradilan_agama/cetak_instrumen_amar',$data,FALSE);
		}
   function cetak_putusan_agama_backup(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }       

        $segment = $this->uri->segment_array();
        $data['enc']=$this->uri->segment('3');
        $jenisTemplate=$this->uri->segment('4');
        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
             show_404();
             exit();
        }
        $jenisTemplate =$segment[4];
        if(!is_numeric($jenisTemplate) OR !intval($jenisTemplate)>0){
             show_404();
             exit();
        }

        $this->load->model('generate_template/m_template_putusan_agama','template');
        $data['dataPN'] = $this->template->get_data_pn($idperkara);
        $data['dataPihak1']=$this->template->get_data_pihak($idperkara,1);
        $data['dataPengacaraPihak1']=$this->template->get_data_pengacara($idperkara,1);
        $data['dataPihak2']=$this->template->get_data_pihak($idperkara,2);
        $data['dataPengacaraPihak2']=$this->template->get_data_pengacara($idperkara,2);
        $data['dataPihak3']=$this->template->get_data_pihak($idperkara,3);
        $data['dataPengacaraPihak3']=$this->template->get_data_pengacara($idperkara,3);
        $data['dataPihak4']=$this->template->get_data_pihak($idperkara,4);
        $data['dataSaksi']=$this->template->get_data_pihak($idperkara,5);
        $data['dataPerkara']=$this->template->get_data_perkara($idperkara);
        $data['dataPutusan']=$this->template->get_data_putusan($idperkara);
        $data['dataBiayaPerkara']=$this->template->get_biaya_perkara($idperkara);
        $data['dataBiayaIkrar']=$this->template->get_biaya_ikrar($idperkara);
        $data['dataPenetapanHakim']=$this->template->get_data_penetapan_hakim($idperkara);
        $data['dataPenetapanPP_Sidang']=$this->template->get_data_penetapan_pp_sidang($idperkara);
        $data['dataPenetapanPersiapan']=$this->template->getPenetapanPersiapan($idperkara);
        $data['dataDismissal']=$this->template->get_data_dismissal($idperkara);
        $data['dataMediasi']=$this->template->get_data_mediasi($idperkara);
        $data['dataCabut']=$this->template->get_data_cabut($idperkara);
        $data['dataPernikahan']=$this->template->get_data_pernikahan($idperkara);
        $data['dataIkrarTalak']=$this->template->get_data_ikrar_talak($idperkara);
        $data['dataPersiapan']=$this->template->get_data_persiapan($idperkara);        
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        

        if($jenisTemplate==1){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','1','');
        } else if ($jenisTemplate==2){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','2','');
        } else if ($jenisTemplate==3){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','3','');
        } else if ($jenisTemplate==4){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','4','');
        } else if ($jenisTemplate==5){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','5','');
        } else if ($jenisTemplate==6){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','6','');
        } else if ($jenisTemplate==7){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','7','');
        } else if ($jenisTemplate==8){
            $data['template']=$this->template2->getDataDocumentTemplate('16','15','210','1','');
        } else if ($jenisTemplate==9){
            $data['template']=$this->template2->getDataDocumentTemplate('16','15','210','2','');
        } else if ($jenisTemplate==10){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','10','');
        } else if ($jenisTemplate==11){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','11','');
        } else if ($jenisTemplate==12){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','12','');
        } else if ($jenisTemplate==13){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','13','');
        } else if ($jenisTemplate==14){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','14','');
        } else if ($jenisTemplate==15){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','15','');
        } else if ($jenisTemplate==16){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','8','');
        } else if ($jenisTemplate==99){
            $data['template']=$this->template2->getDataDocumentTemplate('15','15','210','16','');
        }else {
            show_404();
            exit();
        }
        $this->load->view('generate_template/cetak_putusan_agama',$data,FALSE);
    }

    function cetak_putusan_sela(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }
        $segment = $this->uri->segment_array();
        $data['enc']=$this->uri->segment(3);
        $data['jenisTemplate']=$this->uri->segment(4);
        $data['encPutusanSela']=$this->uri->segment(5);
        $jenisTemplate=$data['jenisTemplate'];

        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        $idPutusanSela=$this->encrypt->decode(base64_decode($data['encPutusanSela']));
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2'); 

        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
             show_404();
             exit();
        }
        $this->load->model('generate_template/m_template_putusan_agama','template');
        $data['dataPN'] = $this->template->get_data_pn($idperkara);
        $data['dataPihak1']=$this->template->get_data_pihak($idperkara,1);
        $data['dataPengacaraPihak1']=$this->template->get_data_pengacara($idperkara,1);
        $data['dataPihak2']=$this->template->get_data_pihak($idperkara,2);
        $data['dataPengacaraPihak2']=$this->template->get_data_pengacara($idperkara,2);
        $data['dataPihak3']=$this->template->get_data_pihak($idperkara,3);
        $data['dataPengacaraPihak3']=$this->template->get_data_pengacara($idperkara,3);
        $data['dataPihak4']=$this->template->get_data_pihak($idperkara,4);
        $data['dataSaksi']=$this->template->get_data_pihak($idperkara,5);
        $data['dataPerkara']=$this->template->get_data_perkara($idperkara);
        $data['dataPutusan']=$this->template->get_data_putusan($idperkara);
        $data['dataBiayaPerkara']=$this->template->get_biaya_perkara($idperkara);
        $data['dataPenetapanHakim']=$this->template->get_data_penetapan_hakim($idperkara);
        $data['dataPenetapanPP_Sidang']=$this->template->get_data_penetapan_pp_sidang($idperkara);
        $data['dataPenetapanPersiapan']=$this->template->getPenetapanPersiapan($idperkara);
        $data['dataDismissal']=$this->template->get_data_dismissal($idperkara);
        $data['dataCabut']=$this->template->get_data_cabut($idperkara);
        $data['dataPersiapan']=$this->template->get_data_persiapan($idperkara);

        if ($jenisTemplate=='pencabutan_gugatan_dikabulkan'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','1','');
        } else if ($jenisTemplate=='pencabutan_gugatan_ditolak'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','2','');
        } else if($jenisTemplate=='ktun_dikabulkan'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','3','');
        } else if ($jenisTemplate=='ktun_ditolak'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','4','');
        } else if ($jenisTemplate=='penetapan_intervensi_dikabulkan'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','5','');
        } else if ($jenisTemplate=='penetapan_intervensi_ditolak'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','6','');
        } else if ($jenisTemplate=='gugatan_tidak_dapat_diterima'){
            $data['template']=$this->template2->getDataDocumentTemplate('9','12','211','7','');
        } else{
            show_404();
            exit();
        }

        $this->load->view('generate_template/cetak_putusan_sela_agama',$data,FALSE);
    }
}