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

class C_new_template extends CI_Controller {    
    
    function __construct() {
        parent::__construct();
        $this->load->library('Var_template');
        $this->load->model('generate_template/m_new_template');
    }

    function popup($file_name){
        $data['file_name']=$file_name;
        $this->load->vars($data);
        $this->load->view('generate_template/all_template_popup'); 
    }

    function kirim_variabel(){
        $data_id=$this->session->userdata('data_id');
         
        $file=$data_id['source_file'];
        if ($file[0]=='/'){
            $file=substr($data_id['source_file'],1);
        }
        $source_file = $this->var_template->filename_fixed(base_url("resources/template/new_template/".$file));      
        $data['target_file']    = 'template_hasil.rtf';
        $data['Template'] = file_get_contents($source_file);
        $variabel   = array('var_general',
                            'var_penetapan',
                            'var_diversi',
                            'var_dismissal',
                            'var_mediasi',
                            'var_bas',
                            'var_penetapan_hari_sidang',
                            'var_persidangan',
                            'var_putusan_sela',
                            'var_putusan_akhir',
                            'var_pihak',
                            'var_keuangan',
                            'var_putusan_sela',
                            'var_penetapan_persiapan'
                            );

        // $data_id = array ('perkara_id'=>$perkara_id,
        //                   'pihak_id'=>$pihak_id,
        //                   'tahapan_id'=>$tahapan_id,
        //                   'proses_id'=>$proses_id,
        //                   'pihak_ke'=>$pihak_ke,
        //                   'jadwal_sidang_id'=>$jadwalsidang_id,
        //                   'keterangan_ph'=>$keterangan_ph,
        //                   'mengerti_dakwaan'=>$mengerti_dakwaan,
        //                   'ditetapkan_oleh'=>$data_id['ditetapkan_oleh'],
        //                   'jurusita_id'=>$jurusita_id);

        $data['variabel'] = $this->var_template->get_variabel_and_value($variabel,$data_id); 
        $this->load->view('generate_template/cetak_new_template.php',$data);
    }



    function tes_all_variabel($file,$perkara_id=111,$tahapan_id,$proses_id,$pihak_id,$jadwalsidang_id=3004,$jurusita_id=NULL){
        
        $source_file = $this->var_template->filename_fixed(base_url("resources/template/new_template/".base64_decode($file)));      
        $data['target_file']    = 'template_hasil.rtf';
        $data['Template'] = file_get_contents($source_file);
        $variabel   = array('var_general',
                            'var_penetapan',
                            'var_diversi',
                            'var_dismissal',
                            'var_mediasi',
                            'var_bas',
                            'var_penetapan_hari_sidang',
                            'var_persidangan',
                            'var_putusan_sela',
                            'var_putusan_akhir',
                            'var_pihak',
                            'var_keuangan',
                            'var_putusan_sela',
                            'var_penetapan_persiapan',
                            'var_bukti'
                            );

        $data_id = array ('perkara_id'=>$perkara_id,
                          'pihak_id'=>$pihak_id,
                          'tahapan_id'=>$tahapan_id,
                          'proses_id'=>$proses_id,
                          'pihak_ke'=>$pihak_ke,
                          'keterangan_ph'=>$keterangan_ph,
                          'mengerti_dakwaan'=>$mengerti_dakwaan,
                          'jurusita_id'=>$jurusita_id);

        $data['variabel'] = $this->var_template->get_variabel_and_value($variabel,$data_id); 
        $this->load->view('generate_template/cetak_new_template.php',$data);
    }


}
