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

class c_template_pendukung_agama extends CI_Controller {

	function index() {
        show_404();
    }

    function popup_pra_persidangan(){
        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) {
            $data['alurPerkara'] = $dataAlur->alur_perkara_id;
        }
        $data['pilih_template']=$this->template->blangko_pra_persidangan();
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
              
        $jenisperkara=$this->template2->getDataPerkara($idperkara);
			foreach ($jenisperkara->result() as $row){
				$data['jenisperkara']=$row->jenis_perkara_text;
		}
		
		$data['judul']='TEMPLATE PENDUKUNG</br><b> PERKARA '.$data['jenisperkara'].'</b>';
		
        $data['idperkara']=$idperkara;
        
		//print_r($data['alurPerkara']);exit;
        $this->load->view('generate_template/peradilan_agama/popup_template_pendukung_agama', $data, FALSE);
    }
	function popup_proses_persidangan(){
        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) {
            $data['alurPerkara'] = $dataAlur->alur_perkara_id;
        }
        $data['pilih_template']=$this->template->blangko_pra_persidangan();
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
              
        $jenisperkara=$this->template2->getDataPerkara($idperkara);
			foreach ($jenisperkara->result() as $row){
				$data['jenisperkara']=$row->jenis_perkara_text;
		}
		
		$data['judul']='TEMPLATE PENDUKUNG</br>PROSES PERSIDANGAN</br><b> PERKARA '.$data['jenisperkara'].'</b>';
		
        $data['idperkara']=$idperkara;
		$this->load->view('generate_template/peradilan_agama/popup_template_pendukung_agama_proses_sidang', $data, FALSE);
    }
	function popup_pasca_persidangan(){
        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) {
            $data['alurPerkara'] = $dataAlur->alur_perkara_id;
        }
        $data['pilih_template']=$this->template->blangko_pra_persidangan();
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
              
        $jenisperkara=$this->template2->getDataPerkara($idperkara);
			foreach ($jenisperkara->result() as $row){
				$data['jenisperkara']=$row->jenis_perkara_text;
		}
		
		$data['judul']='TEMPLATE PENDUKUNG</br>PASCA PERSIDANGAN</br><b> PERKARA '.$data['jenisperkara'].'</b>';
		$data['idperkara']=$idperkara;
        $this->load->view('generate_template/peradilan_agama/popup_template_pendukung_agama_proses_sidang', $data, FALSE);
    }
	 function popup_instrumen_sidang(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }
        $data['enc']=$this->uri->segment('3');
        $data['idalur']=$this->uri->segment('4');
        $jenispihak=$this->uri->segment('5');

        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        $this->load->model('generate_template/peradilan_agama/m_template_relaas_agama','pilihjurusita');
		$data['pilihjurusita'] = $this->pilihjurusita->getDataJurusita($idperkara);
		$data['pilihAgendaSidang'] = $this->pilihjurusita->getDetailTanggalPersidangan($idperkara);
        if($jenispihak==6){
			$data['pilihPihak'] = $this->pilihjurusita->getPengacaraPihak($idperkara);
		}else{
			$data['pilihPihak'] = $this->pilihjurusita->get_data_pihak_loop($idperkara,$jenispihak);
		}
		
		
        $this->load->model('generate_template/m_template_putusan_agama','template');
        $dataAlur = $this->template->getAlurPerkara($idperkara);
        foreach ($dataAlur->result() as $dataAlur) {
            $data['alurPerkara'] = $dataAlur->alur_perkara_id;
        }
        $data['pilih_template']=$this->template->blangko_pra_persidangan();
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
              
        $jenisperkara=$this->template2->getDataPerkara($idperkara);
			foreach ($jenisperkara->result() as $row){
				$data['jenisperkara']=$row->jenis_perkara_text;
		}
		
		$data['judul']='INSTRUMEN PANGGILAN</br><b> PERKARA '.$data['jenisperkara'].'</b>';
		
        $data['idperkara']=$idperkara;
        $data['jenispihak']=$jenispihak;
		//print_r($data['alurPerkara']);exit;
        $this->load->view('generate_template/peradilan_agama/popup_template_instrumen_panggilan', $data, FALSE);
    }
	function cetak_instrumen_persidangan(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }       

        $segment = $this->uri->segment_array();
        $data['enc']=$this->uri->segment('3');
        $pihakID=$this->uri->segment('4');
		$sidangID=$this->uri->segment('5');
		$jurusitaID=$this->uri->segment('6');
		$rupiah=$this->uri->segment('7');
		$jenispihak=$this->uri->segment('8');
		//print_r($pihakID);exit;
        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
             show_404();
             exit();
        }
		$this->load->model('generate_template/peradilan_agama/m_template_relaas_agama','pilihjurusita');
		$data['pilihjurusita'] = $this->pilihjurusita->getIDJurusita($jurusitaID);
		$data['sidangID'] = $this->pilihjurusita->getTanggalPersidangan($sidangID);
		if($jenispihak=6){
			$data['get_data_pihak'] = $this->pilihjurusita->getIDPengacaraPihak($idperkara,$pihakID);
		}else{
			$data['get_data_pihak'] = $this->pilihjurusita->get_data_pihak($idperkara,$jenispihak,$pihakID);
		}
		foreach($data['get_data_pihak']->result() as $row){
			$nomorPerk = $row->nomor_perkara;
			$nama = $row->nama;
			$id_pihak = $row->id_pihak;
		}
		//echo "Nomor Perkara : ".$nomorPerk."</br> Nama Pihak : ".$nama."</br> Pihak Ke  : ".$id_pihak;exit;
		$filenya="peradilan_agama/template_pendukung/Instrumen Panggilan-Tanda Terima.rtf";
		
		$this->load->view('generate_template/peradilan_agama/cetak_teguran_panjar', $data, FALSE);
		$data_id=array(
                    'source_file'=>$filenya,
                    'perkara_id'=>$idperkara);    

        $this->load->model('generate_template/var_template_agama','var_template');
        $this->var_template->kirim_variabel($data_id);  
		
    }
    function cetak_pra_persidangan(){
        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();
        }
		
		$filenya="peradilan_agama/template_pendukung/".$jenisTemplate.".rtf";
		$data_id=array(
                    'source_file'=>$filenya,
                    'perkara_id'=>$idperkara);    

        $this->load->model('generate_template/var_template_agama','var_template');
        $this->var_template->kirim_variabel($data_id);  
		
    }

   
    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);
    }
}