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

class penetapan_m extends CI_Model{
	
	function get_proses_terakhir($id_perkara){
		try {
			$query = $this->db->query("SELECT proses_terakhir_id
				FROM perkara 
				WHERE perkara_id='".$id_perkara."';");
			return $query->row(0);
		} catch (Exception $e) {
			return '';
		}
	}

	function getInfoPerlawanan($idperkara){
		try {
			$this->db->where('perkara_id',$idperkara);
			$this->db->select('perkara_id');
			$this->db->from('perkara_verzet');
			$query = $this->db->get();
			if($query->num_rows()>0){
				return 1;
			}else{
				return 0;
			}
			
		} catch (Exception $e) {
			log_message('error', $e);
		}
	}

	#12-10-2015
	function getDataPemeriksaanPersiapan($idperkara){
		try{
			$this->db->where('perkara_id',$idperkara);
			return $this->db->get('perkara_persiapan');
		} catch (Exception $e) {
			log_message('error', $e);
		}
	}

	function getInfoDiversi($idperkara){
		try {
			$this->db->where('perkara_id',$idperkara);
			$this->db->where('hasil_diversi',0);
			$this->db->select('perkara_id');
			$this->db->from('perkara_diversi');
			return $this->db->get()->num_rows();
		} catch (Exception $e) {
			return '';
		}
	}
	
	function get_penetapan($id_perkara){
		try {
			$query = $this->db->query("SELECT *
				FROM perkara_penetapan 
				WHERE perkara_id='".$id_perkara."';");
			return $query->result_array();
		} catch (Exception $e) {
			return '';
		}
	}
	
	function get_penetapan_detail($id_perkara){
		try {
			$query = $this->db->query("SELECT *
				FROM perkara_hakim_pn 
				WHERE tahapan_id=10 AND perkara_id='".$id_perkara."' ORDER BY tanggal_penetapan ASC, diinput_tanggal ASC, urutan ASC;");
			return $query->result_array();
		} catch (Exception $e) {
			return '';
		}
	}

	function get_penunjukan_pp_detail($id_perkara){
		try {
			$query = $this->db->query("SELECT *
				FROM perkara_panitera_pn 
				WHERE tahapan_id=10 AND perkara_id='".$id_perkara."' ORDER BY tanggal_penetapan ASC, diinput_tanggal ASC, urutan ASC;");
			return $query->result_array();
		} catch (Exception $e) {
			return '';
		}
	}

	function get_penunjukan_jurusita_detail($id_perkara){
		try {
			$query = $this->db->query("SELECT *
				FROM perkara_jurusita 
				WHERE tahapan_id=10 AND perkara_id='".$id_perkara."' ORDER BY tanggal_penetapan ASC, diinput_tanggal ASC, urutan ASC;");
			return $query->result_array();
		} catch (Exception $e) {
			return '';
		}
	}

	function get_penetapan_sidang_pertama_detail($id_perkara){
		try {
			$query = $this->db->query("SELECT *, (SELECT COUNT(*) FROM perkara_penetapan_hari_sidang WHERE perkara_id='".$id_perkara."') AS jumdata FROM perkara_penetapan_hari_sidang 
										WHERE perkara_id='".$id_perkara."' ORDER BY id ASC;");
			return $query->result_array();
		} catch (Exception $e) {
			return '';
		}
	}
}
?>