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

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

		$this->load->view('dashboard', FALSE);
	}

    function popup_akta_permohonan_kasasi(){
        $segment=$this->uri->segment_array();
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        }         
        $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['pihakasal']=$this->uri->segment('4');        
        if(!is_numeric($data['pihakasal']) OR !intval($data['pihakasal'])>0){
            show_404();
            exit();
        }
        $data['encpemohon']=$this->uri->segment('5');
        $idpemohon=$this->encrypt->decode(base64_decode($data['encpemohon']));        
        if(!is_numeric($idpemohon) OR !intval($idpemohon)>0){
            show_404();
            exit();
        }
       
        $data['idakta'] = $this->uri->segment('6');
        $this->load->model('generate_template/m_template_mil_permohonan_akta_kasasi_pid','template');
        $data['dataPutusan']=$this->template->getDataPutusan($idperkara);
        $data['info_penadatangan']=$this->template->getDataPejabat();
        $data['info_DataTerdakwa']=$this->template->infoDataTerdakwa($idperkara,$idpemohon);
        $data['info_DataTerdakwa2']=$this->template->infoDataTerdakwa2($idperkara);
        /*print_r($data['info_DataTerdakwa2']->result());
        exit();*/
      /* print_r($data['info_DataTerdakwa']->result()); 
       exit();*/
        $data['info']=$this->template->getInfo($idperkara);
        
		if ($data['idakta']=='1'){
			if ($data['pihakasal']=='2'){
				$data['template']=$this->template->getDataDocumentTemplate('120','30','410','1','');
			}else{
				$data['template']=$this->template->getDataDocumentTemplate('120','30','410','2','');
			}
		}elseif ($data['idakta']=='1c'){
			if ($data['pihakasal']=='2'){
				$data['template']=$this->template->getDataDocumentTemplate('120','30','410','3','');
			}else{
				$data['template']=$this->template->getDataDocumentTemplate('120','30','410','4','');
			}
		}elseif ($data['idakta']=='1pc'){
			if ($data['pihakasal']=='2'){
				$data['template']=$this->template->getDataDocumentTemplate('120','30','420','3','');
			}else{
				$data['template']=$this->template->getDataDocumentTemplate('120','30','420','4','');
			}
		}elseif ($data['idakta']=='2'){
			if ($data['pihakasal']=='2'){
				$data['template']=$this->template->getDataDocumentTemplate('120','30','420','1','');
			}else{
				$data['template']=$this->template->getDataDocumentTemplate('120','30','420','2','');
			}
		}elseif ($data['idakta']=='3'){
			if ($data['pihakasal']=='2'){
				$data['template']=$this->template->getDataDocumentTemplate('120','30','430','1','');
			}else{
				$data['template']=$this->template->getDataDocumentTemplate('120','30','430','2','');
			}
		}elseif ($data['idakta']=='4'){
			if ($data['pihakasal']=='2'){
				$data['template']=$this->template->getDataDocumentTemplate('120','30','450','1','');
			}else{
				$data['template']=$this->template->getDataDocumentTemplate('120','30','450','2','');
			}
		}elseif ($data['idakta']=='5'){
			if ($data['pihakasal']=='2'){
				$data['template']=$this->template->getDataDocumentTemplate('120','30','460','1','');
			}else{
				$data['template']=$this->template->getDataDocumentTemplate('120','30','460','2','');
			}
		}elseif ($data['idakta']=='6'){
			if ($data['pihakasal']=='2'){
				$data['template']=$this->template->getDataDocumentTemplate('120','30','500','1','');
			}else{
				$data['template']=$this->template->getDataDocumentTemplate('120','30','500','2','');
			}
		}elseif ($data['idakta']=='7'){
			$data['template']=$this->template->getDataDocumentTemplate('120','30','500','3','');
		}elseif ($data['idakta']=='8'){
			if ($data['pihakasal']=='2'){
				$data['template']=$this->template->getDataDocumentTemplate('120','30','410','5','');
			}else{
				$data['template']=$this->template->getDataDocumentTemplate('120','30','410','6','');
			}
		}elseif ($data['idakta']=='9'){
			$data['template']=$this->template->getDataDocumentTemplate('120','30','430','5','');
		}elseif ($data['idakta']=='10'){
			if ($data['pihakasal']=='2'){
				$data['template']=$this->template->getDataDocumentTemplate('120','30','430','3','');
			}else{
				$data['template']=$this->template->getDataDocumentTemplate('120','30','430','7','');
			}
		}elseif ($data['idakta']=='11'){
			if ($data['pihakasal']=='2'){
				$data['template']=$this->template->getDataDocumentTemplate('120','30','460','3','');
			}else{
				$data['template']=$this->template->getDataDocumentTemplate('120','30','460','4','');
			}
		}elseif ($data['idakta']=='12'){
			if ($data['pihakasal']=='2'){
				$data['template']=$this->template->getDataDocumentTemplate('120','30','430','4','');
			}else{
				$data['template']=$this->template->getDataDocumentTemplate('120','30','430','6','');
			}
		}elseif ($data['idakta']=='13'){
			$data['template']=$this->template->getDataDocumentTemplate('120','30','410','7','');
		}
        $this->load->view('generate_template/popup_mil_akta_permohonan_kasasi',$data);
    }

    function cetak_akta_permohonan_kasasi(){
        if($this->session->userdata('is_logged_in')==FALSE){
            redirect('login');
        } 
        $data['enc'] = $this->input->post('enc',TRUE);
        $data['encpemohon'] = $this->input->post('encpemohon',TRUE);
        $idpemohon=$this->encrypt->decode(base64_decode($data['encpemohon']));
        if(!is_numeric($idpemohon) OR !intval($idpemohon)>0){
            show_404();
            exit();
        }
        $data['pemohon_id']=$idpemohon; 
        //echo $idpemohon; 
        //xit();
        $data['idterdakwa'] = $this->input->post('terdakwa',TRUE);
        $idterdakwa=$this->encrypt->decode(base64_decode($data['idterdakwa']));

        //echo $idterdakwa; 
        //exit();

        $data['pihakasal'] = $this->input->post('pihakasal',TRUE);
        $idperkara=$this->encrypt->decode(base64_decode($data['enc']));
        if(!is_numeric($idperkara) OR !intval($idperkara)>0){
             show_404();
             exit();
        }
        $data['idpembuatakta'] = $this->input->post('pembuat',TRUE);
        $idpembuatakta=$this->encrypt->decode(base64_decode($data['idpembuatakta']));
        if(!is_numeric($idpembuatakta) OR !intval($idpembuatakta)>0){
             show_404();
             exit();
        }

        $data['idput'] = $this->input->post('putusan',TRUE);
        $idput=$this->encrypt->decode(base64_decode($data['idput']));
        if(!is_numeric($idput) OR !intval($idput)>0){
            show_404();
            exit();
        }

        
        $this->load->model('generate_template/m_template_mil_permohonan_akta_kasasi_pid','template');
        $data['info_DataTerdakwa']=$this->template->infoDataTerdakwa($idperkara,$idpemohon);
        $data['info_DataTerdakwa2']=$this->template->infoDataTerdakwa2($idperkara);
        $data['data_oditur']=$this->template->getDataOditur($idperkara);
        $data['idakta'] = $this->input->post('idakta',TRUE);

        //echo 'idpemohon='.$idpemohon.';idterdakwa='.$idterdakwa.';idperkara='.$idperkara.';idpihakasal='.$data['pihakasal'];
        //exit();

        $data['tgl_pemberitahuan_cabut'] = $this->input->post('tgl_pemberitahuan_cabut',TRUE);
        if ($data['pihakasal']=='2'){
            $data['dataTemplate'] = $this->template->cetak_permohonan_kasasi($idperkara,$idpembuatakta,$idput,$idterdakwa);
            $data['info_DataOditur']=$this->template->getDataOditur($idperkara);        
        }elseif ($data['pihakasal']=='1'){
            $data['dataTemplate'] = $this->template->cetak_permohonan_kasasi_oditur($idperkara,$idpembuatakta,$idput,$idpemohon);
            $data['info_DataOditur']=$this->template->getDataOditur($idperkara);    
        }		
       
        switch ($data['idakta']) {
            case '1':
                if ($data['pihakasal']=='1'){
                    $doc='2';
                }elseif ($data['pihakasal']=='2'){
                    $doc='1';
                }
                $data['template']=$this->template->getDataDocumentTemplate('120','30','410',$doc,'');
            break;
            case '1c':
                if ($data['pihakasal']=='1'){
                    $doc='4';
                }elseif ($data['pihakasal']=='2'){
                    $doc='3';
                }
                $data['template']=$this->template->getDataDocumentTemplate('120','30','410',$doc,'');
            break;
            case '1pc':
                if ($data['pihakasal']=='1'){
                    $doc='4';
                }elseif ($data['pihakasal']=='2'){
                    $doc='3';
                }
                $data['template']=$this->template->getDataDocumentTemplate('120','30','420',$doc,'');
            break;
            case '2':
                if ($data['pihakasal']=='1'){
                    $doc='2';
                }elseif ($data['pihakasal']=='2'){
                    $doc='1';
                }
                $data['template']=$this->template->getDataDocumentTemplate('120','30','420',$doc,'');
            break;
            case '3':
                if ($data['pihakasal']=='1'){
                    $doc='2';
                }elseif ($data['pihakasal']=='2'){
                    $doc='1';
                }
                $data['template']=$this->template->getDataDocumentTemplate('120','30','430',$doc,'');
            break;
             case '4':
                if ($data['pihakasal']=='1'){
                    $doc='2';
                }elseif ($data['pihakasal']=='2'){
                    $doc='1';
                }
                $data['template']=$this->template->getDataDocumentTemplate('120','30','450',$doc,'');
            break;
            case '5':
                if ($data['pihakasal']=='1'){
                    $doc='2';
                }elseif ($data['pihakasal']=='2'){
                    $doc='1';
                }
                $data['template']=$this->template->getDataDocumentTemplate('120','30','460',$doc,'');   
            break;
            case '6':
                if ($data['pihakasal']=='1'){
                    $doc='2';
                }elseif ($data['pihakasal']=='2'){
                    $doc='1';
                }
                $data['template']=$this->template->getDataDocumentTemplate('120','30','500',$doc,'');
            break;            
            case '7':
                $data['template']=$this->template->getDataDocumentTemplate('120','30','500','3','');
            break;            
            case '8':
                if ($data['pihakasal']=='1'){
                    $doc='6';
                }elseif ($data['pihakasal']=='2'){
                    $doc='5';
                }
                $data['template']=$this->template->getDataDocumentTemplate('120','30','410',$doc,'');
            break;            
            case '9':
                $data['template']=$this->template->getDataDocumentTemplate('120','30','430','5','');
			break;
            case '10':
                if ($data['pihakasal']=='1'){
                    $doc='7';
                }elseif ($data['pihakasal']=='2'){
                    $doc='3';
                }
                $data['template']=$this->template->getDataDocumentTemplate('120','30','430',$doc,'');
            break;            
            case '11':
                if ($data['pihakasal']=='1'){
                    $doc='4';
                }elseif ($data['pihakasal']=='2'){
                    $doc='3';
                }
                $data['template']=$this->template->getDataDocumentTemplate('120','30','460',$doc,'');
            break;            
            case '12':
                if ($data['pihakasal']=='1'){
                    $doc='6';
                }elseif ($data['pihakasal']=='2'){
                    $doc='4';
                }
                $data['template']=$this->template->getDataDocumentTemplate('120','30','430',$doc,'');
            break;            
            case '13':
                $data['template']=$this->template->getDataDocumentTemplate('120','30','410','7','');
			break;
            default:
                $data['template']=array();
            break;
        }
        $this->load->view('generate_template/cetak_mil_akta_pidana_permohonan_kasasi_terdakwa',$data,FALSE);
    }
}
/* End of file c_template_mil_akta_penerimaan_memori_kasasi_terdakwa.php */
/* Location: ./application/controllers/c_template_mil_akta_penerimaan_memori_kasasi_terdakwa.php */