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

class c_edit_jurnal_prodeo extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        $this->load->model('generate_template/peradilan_agama/m_skum','skum');
    }

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

    function popup_edit_jurnal(){
        if($this->session->userdata('is_logged_in')==FALSE){
        redirect('login');
        }      
		$data['enc'] = $this->uri->segment(3);
		$data['tahapan'] = $this->uri->segment(4);
        $data['judul']='Ubah Jenis Pembiayan Perkara';
        $this->load->view('jurnal_perkara/popup_ubah_prodeo', $data, FALSE);
    }

	 function simpan(){

        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }       
		
        $perkara_id =$this->encrypt->decode(base64_decode($this->input->post('enc',TRUE)));
		//echo "Nomor Perkar ".$this->input->post('tahapan',TRUE);exit;
        $id_pembiayaan =$this->input->post('is_prode',TRUE);
		$this->load->model('biaya_perkara/biaya_perkara_m','biaya');
		$this->biaya->edit_kategori_prodeo($perkara_id,$id_pembiayaan);
		
        redirect('biaya_detil/'.$this->input->post('enc',TRUE).'/'.$this->input->post('tahapan',TRUE));
    }

    function tampil_ubah_gugatan($enc_perkara){   
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }  
        $perkara_id = $this->encrypt->decode(base64_decode($enc_perkara));
        $alurperkaraid = $this->tanggalhelper->getIDAlurPerkara($perkara_id);
        if($alurperkaraid==1){          
            $data['title'] = 'UBAH ALUR PERDATA GUGATAN KE BANTAHAN';
        }elseif($alurperkaraid==7){         
            $data['title'] = 'UBAH ALUR PERDATA BANTAHAN KE GUGATAN';
        }
        $data['enc_perkara'] = $enc_perkara;
        $this->load->vars($data);
        $this->load->view('perkara_tab/edit_alur_perdata');
    }

    function validate_ubah_gugatan(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }
        $perkara_id =$this->encrypt->decode(base64_decode($this->input->post('enc_perkara',TRUE)));
        $alurperkaraid = $this->tanggalhelper->getIDAlurPerkara($perkara_id);
        if($alurperkaraid==1){
            $alur_menjadi = 7;
        }elseif($alurperkaraid==7){
            $alur_menjadi = 1;
        }
        $this->load->model('biaya_perkara/biaya_perkara_m','biaya');
        if($this->biaya->edit_alur_perdata($perkara_id,$alur_menjadi)){
            echo json_encode(array('st'=>1,'msg'=>'Berhasil Disimpan'));
        }else{
            echo json_encode(array('st'=>0,'msg'=>'Data Tidak Berhasil Disimpan'));
        }
    }
}
        