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

class c_template_penetapan_agama extends CI_Controller {

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

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

        $segment = $this->uri->segment_array();
        $data['enc']=$this->uri->segment('3'); 
        //$data['ikrar']=$this->uri->segment('4'); 

        $this->load->model('generate_template/m_template_penetapan_agama','template');
        $data['penandatangan']=$this->template->getDataPA();
		foreach ($data['penandatangan']->result() as $config){
			  $data['plhKetua'] =$config->PlhKetua;
			  $data['pltKetua'] =$config->PltKetua;
			  $data['PansekPNNama'] =$config->PansekPNNama;
			  $data['WaPanNama'] =$config->WaPanNama;
			  $data['plhPanitera'] =$config->PlhPanitera;
			  $data['pltPanitera'] =$config->PltPanitera;
		}

        $data['blangko_pppp']=$this->template->blangko_pppp(); //untuk blangko surat

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('15','12','30','1','');
        $i=0;
        $jumdata=count($template->result());
        foreach ($template->result() as $template){
            if ($jumdata=='1'){
                $judul['0']=$template->namatemplate;
                $jnsperkara=$template->jnsperkara;
            }else{
                if ($i=='0'){
                    $judul=$template->namatemplate;
                    $judul=explode("",$judul);
                    $jnsperkara=$template->jnsperkara;
                }
            }
        }
        $data['judul']=$judul['0'];
        $data['jnsperkara']=$jnsperkara;
        
        $this->load->view('generate_template/peradilan_agama/popup_pppp', $data, FALSE);
    }
    function cetak_pppp(){  
        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['ditetapkanoleh'] = $this->input->post('ditetapkanoleh',TRUE);
        if(!is_numeric($data['ditetapkanoleh']) OR !intval($data['ditetapkanoleh'])>0){
            show_404();
            exit();
        }           
		
        $this->load->model('generate_template/m_template_penetapan_agama','template');
		
        $template=$this->template->get_cek_perubahan_pp($idperkara);
		//$i=0;
        $jumdata=count($template->result());
		 if ($jumdata==0){
                 $filenya="peradilan_agama/penetapan/panitera_pengganti/penetapan pp.rtf";
            }else{
             
                 $filenya="peradilan_agama/penetapan/panitera_pengganti/penetapan pp perubahan.rtf";
            }
	
		$data_id=array(
                    'source_file'=>$filenya,
                    'perkara_id'=>$idperkara,
                    'ditetapkan_oleh'=>$this->input->post('ditetapkanoleh',TRUE));  

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

        $segment = $this->uri->segment_array();

        $data['enc']=$this->uri->segment('3'); 
        $data['ikrar']=$this->uri->segment('4');
        $data['pmh']=$this->uri->segment('5'); 
    
        $this->load->model('generate_template/m_template_penetapan_agama','template');
        $data['penandatangan']=$this->template->getDataPA();
		foreach ($data['penandatangan']->result() as $config){
			  $data['plhKetua'] =$config->PlhKetua;
			  $data['pltKetua'] =$config->PltKetua;
			  $data['PansekPNNama'] =$config->PansekPNNama;
			  $data['WaPanNama'] =$config->WaPanNama;
			  $data['plhPanitera'] =$config->PlhPanitera;
			  $data['pltPanitera'] =$config->PltPanitera;
		}

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

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

        $data['ikrar']=$this->input->post('ikrar',TRUE);
        $data['pmh']=$this->input->post('pmh',TRUE);
        $data['ditetapkanoleh'] = $this->input->post('ditetapkanoleh',TRUE);
        $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();
        }           
        if(!is_numeric($data['ditetapkanoleh']) OR !intval($data['ditetapkanoleh'])>0){
            show_404();
            exit();
        }           

        $this->load->model('generate_template/m_template_penetapan_agama','template');
        $data['dataperkara'] = $this->template->getDataPerkara($idperkara);
        $data['datapengadilan'] = $this->template->getDataPA();
        $data['datapenetapanhakim']=$this->template->getDataPenetapanHakim($idperkara);
        $data['datapenetapanhakimsebelumnya']=$this->template->getDataPenetapanHakimSebelumnya($idperkara);
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['penetapanPMHIkrar']=$this->template->getDataPMHIkrar($idperkara);
        
      
        
              
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');
        if ($data['ikrar']==1) {
           
            $filenya="peradilan_agama/penetapan/pmh/pmh ikrar.rtf";
		
        }else {
            if ($data['pmh']==0) {
             
                $filenya="peradilan_agama/penetapan/pmh/pmh pertama.rtf";
			
            }else{
                $data['template']=$this->template2->getDataDocumentTemplate('15','12','20','2','');
                 $filenya="peradilan_agama/penetapan/pmh/pmh perubahan.rtf";
			
            }
        }

         $data_id=array(
                    'source_file'=>$filenya,
                    'perkara_id'=>$idperkara,
                    'ditetapkan_oleh'=>$this->input->post('ditetapkanoleh',TRUE));  
 
        $this->load->model('generate_template/var_template_agama','var_template');
        $this->var_template->kirim_variabel($data_id);
       
    }
	function popup_pjs(){
        if($this->session->userdata('is_logged_in')==FALSE){
        redirect('login'); }

        $segment = $this->uri->segment_array();
        $data['enc']=$this->uri->segment('3'); 

        $this->load->model('generate_template/m_template_penetapan_agama','template');
        $data['penandatangan']=$this->template->getDataPA();
		foreach ($data['penandatangan']->result() as $config){
			  $data['plhKetua'] =$config->PlhKetua;
			  $data['pltKetua'] =$config->PltKetua;
			  $data['PansekPNNama'] =$config->PansekPNNama;
			  $data['WaPanNama'] =$config->WaPanNama;
			  $data['plhPanitera'] =$config->PlhPanitera;
			  $data['pltPanitera'] =$config->PltPanitera;
		}
		$data['blangko_pjs']=$this->template->blangko_pjs(); //untuk blangko surat

        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $template=$this->template2->getDataDocumentTemplate('15','12','40','1','');
        $i=0;
        $jumdata=count($template->result());
        foreach ($template->result() as $template){
            if ($jumdata=='1'){
                $judul['0']=$template->namatemplate;
                $jnsperkara=$template->jnsperkara;
            }else{
                if ($i=='0'){
                    $judul=$template->namatemplate;
                    $judul=explode("",$judul);
                    $jnsperkara=$template->jnsperkara;
                }
            }
        }
        $data['judul']=$judul['0'];
        $data['jnsperkara']=$jnsperkara;
        $this->load->view('generate_template/peradilan_agama/popup_pjs', $data, FALSE);
    }
	
	function cetak_pjs(){  
        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['ditetapkanoleh'] = $this->input->post('ditetapkanoleh',TRUE);
        if(!is_numeric($data['ditetapkanoleh']) OR !intval($data['ditetapkanoleh'])>0){
            show_404();
            exit();
        }           
		$this->load->model('generate_template/m_template_penetapan_agama','template');
		
        $template=$this->template->get_cek_perubahan_pjs($idperkara);
		$i=0;
        $jumdata=count($template->result());
       
            if ($jumdata==0){
                 //  $data['template']=$this->template2->getDataDocumentTemplate('15','12','20','1','');
                $filenya="peradilan_agama/penetapan/jurusita/penetapan jurusita.rtf";
            }else{
               // $data['template']=$this->template2->getDataDocumentTemplate('15','12','20','2','');
                 $filenya="peradilan_agama/penetapan/jurusita/penetapan jurusita perubahan.rtf";
            }
		
		$data_id=array(
                    'source_file'=>$filenya,
                    'perkara_id'=>$idperkara,
                    'ditetapkan_oleh'=>$this->input->post('ditetapkanoleh',TRUE));  

        $this->load->model('generate_template/var_template_agama','var_template');
        $this->var_template->kirim_variabel($data_id);
    }
  
  function popup_phs(){
        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']));
		if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }
        
		$segment = $this->uri->segment_array();
        $data['tgl_sidang']=$this->uri->segment('4'); 
        $data['id_phs']=$this->uri->segment('5');
		
        $this->load->model('generate_template/m_template_penetapan_agama','template');
        
        $idalurperkara = $this->tanggalhelper->getIDAlurPerkara($idperkara);
        $data['blangko_phs']=$this->template->blangko_phs($idalurperkara); //untuk blangko surat

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

    function cetak_phs(){  

        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['blangko_phs'] = $this->input->post('blangko_phs',TRUE);
        $data['tgl_sidang'] = $this->input->post('tgl_sidang',TRUE);
        $data['id_phs'] = $this->input->post('id_phs',TRUE);
		$filenya="peradilan_agama/penetapan/phs/".$data['blangko_phs'].".rtf";
		$data_id=array(
                    'source_file'=>$filenya,
                    'perkara_id'=>$idperkara,
                    'tgl_sidang'=>$data['tgl_sidang'],
                    'id_phs'=>$data['id_phs']
                    );  

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

    }

    function cetak_phs_ikrar(){
        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']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }

        $data['blangko_phs'] = 'PDT_15_18_293_1';
        

        $this->load->model('generate_template/m_template_penetapan_agama','template');
        $data['dataPihak1']=$this->template->get_data_pihak_loop($idperkara,1);
        $data['dataPihak2']=$this->template->get_data_pihak_loop($idperkara,2);
        $data['dataperkara'] = $this->template->getDataPerkara($idperkara);
        $data['datapengadilan'] = $this->template->getDataPA();
        $data['datapenetapanhakim']=$this->template->getDataPenetapanHakimIkrar($idperkara);
        $data['datapenetapansidang']=$this->template->getDataPenetapanSidangIkrar($idperkara);
        $data['datapenetapansidang']=$this->template->getDataPenetapanSidangIkrar($idperkara);
        $data['dataamar']=$this->template->getDataAmar($idperkara);

        
        $this->load->view('generate_template/peradilan_agama/cetak_phs',$data,FALSE);
    }
    function cetak_penetapan_putusan(){
        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']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }

        $this->load->model('generate_template/m_template_penetapan_agama','template');
        $data['dataperkara'] = $this->template->getDataPerkara($idperkara);
        $data['dataPihak1']=$this->template->get_data_pihak_loop($idperkara,1);
        $data['dataPihak2']=$this->template->get_data_pihak_loop($idperkara,2);
        
        $data['datastatuspenetapan'] = $this->template->getDatastatus_penetapan_ikrar_talak_id($idperkara);
        $data['datapengadilan'] = $this->template->getDataPA();
        $data['datapenetapansidang']=$this->template->getDataPenetapanSidangIkrar($idperkara);
        $data['dataamar']=$this->template->getDataAmar($idperkara);
        $data['penetapanPMHIkrar']=$this->template->getDataPMHIkrar($idperkara);
        $data['dataikrartalak'] = $this->template->getDataIkrarTalak($idperkara);
        $data['datapenetapanhakim']=$this->template->getDataPenetapanHakim($idperkara);
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['dataPernikahan']=$this->template->getDataPernikahan($idperkara);
        $data['dataAktaCerai']=$this->template->getDataAktaCerai($idperkara);
        $data['ikrar']='1';
          
        $data['datapenetapanhakimsebelumnya']=$this->template->getDataPenetapanHakimSebelumnya($idperkara);
        $this->load->view('generate_template/peradilan_agama/cetak_penetapan_putusan',$data,FALSE);
    }
    
    function cetak_relaas_ikrar_talak_termohon(){
        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']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }

        $data['blangko_relaas_termohon'] = 'PDT_15_18_294_204';
        $this->load->model('generate_template/m_template_penetapan_agama','template');
        $data['dataPihak1']=$this->template->get_data_pihak_loop($idperkara,1);
        $data['dataPihak2']=$this->template->get_data_pihak_loop($idperkara,2);
        $data['dataperkara'] = $this->template->getDataPerkara($idperkara);

        $data['datapengadilan'] = $this->template->getDataPA();
        $data['datajurusita']=$this->template->getDataJurusitaIkrar($idperkara);
        $data['datapenetapansidang']=$this->template->getDataPenetapanSidangIkrar($idperkara);
        $data['dataputusan']=$this->template->getDataPutusan($idperkara);
        $this->load->view('generate_template/peradilan_agama/cetak_relaas_ikrar_talak_termohon',$data,FALSE);
    }

    function cetak_relaas_ikrar_talak_pemohon(){
        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']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }

        $data['blangko_phs'] = 'PDT_15_18_294_205';
        $this->load->model('generate_template/m_template_penetapan_agama','template');
        $data['dataPihak1']=$this->template->get_data_pihak_loop($idperkara,1);
        $data['dataPihak2']=$this->template->get_data_pihak_loop($idperkara,2);
        $data['dataperkara'] = $this->template->getDataPerkara($idperkara);
        $data['datapengadilan'] = $this->template->getDataPA();
        $data['datajurusita']=$this->template->getDataJurusitaIkrar($idperkara);
        $data['datapenetapansidang']=$this->template->getDataPenetapanSidangIkrar($idperkara);
        $data['dataputusan']=$this->template->getDataPutusan($idperkara);
        $this->load->view('generate_template/peradilan_agama/cetak_relaas_ikrar_talak',$data,FALSE);
    }

    function cetak_relaas_ikrar_talak_termohon_goib(){
        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']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }

        $data['blangko_phs'] = 'PDT_15_18_294_203';
        $this->load->model('generate_template/m_template_penetapan_agama','template');
        $data['dataPihak1']=$this->template->get_data_pihak_loop($idperkara,1);
        $data['dataPihak2']=$this->template->get_data_pihak_loop($idperkara,2);
        $data['dataperkara'] = $this->template->getDataPerkara($idperkara);
        $data['datapengadilan'] = $this->template->getDataPA();
        $data['datajurusita']=$this->template->getDataJurusitaIkrar($idperkara);
        $data['datapenetapansidang']=$this->template->getDataPenetapanSidangIkrar($idperkara);
        $data['dataputusan']=$this->template->getDataPutusan($idperkara);
        $this->load->view('generate_template/peradilan_agama/cetak_relaas_ikrar_talak',$data,FALSE);
    }
    function cetak_relaas_ikrar_talak_termohon_delegasi(){
        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']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
            show_404();
            exit();
        }

        $data['blangko_delegasi_ikrar'] = 'PDT_15_18_294_206';
      //  echo  $data['blangko_delegasi_ikrar'];
        $this->load->model('generate_template/m_template_penetapan_agama','template');
        $data['dataPihak1']=$this->template->get_data_pihak_loop($idperkara,1);
        $data['dataPihak2']=$this->template->get_data_pihak_loop($idperkara,2);
        $data['dataperkara'] = $this->template->getDataPerkara($idperkara);
        $data['datapengadilan'] = $this->template->getDataPA();
        $data['datajurusita']=$this->template->getDataJurusitaIkrar($idperkara);
        $data['datapenetapansidang']=$this->template->getDataPenetapanSidangIkrar($idperkara);
        $data['dataputusan']=$this->template->getDataPutusan($idperkara);
        $this->load->view('generate_template/peradilan_agama/cetak_relaas_ikrar_talak',$data,FALSE);
    }
    

    // MAAF BELUM SELESAI, ANAK SAKIT
    function cetak_penetapan_ikrar_talak(){  
        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();
        }           
        
        $this->load->model('generate_template/m_template_penetapan_agama','template');
        $data['dataperkara'] = $this->template->getDataPerkara($idperkara);
        $data['datapengadilan'] = $this->template->getDataPA();
        $data['jenisperkara'] = $this->template->getJenisPerkara($idperkara);

        $data['dataikrartalak'] = $this->template->getDataIkrarTalak($idperkara);
        $this->load->model('generate_template/m_template_ambil_identitas_template','template2');        
        $data['template']=$this->template2->getDataDocumentTemplate('15','12','40','1',''); 
        $this->load->view('generate_template/peradilan_agama/cetak_pjs',$data,FALSE);
    }

}
?>