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

class Report_gugatan_sederhana_penyelesaian_keberatan extends CI_Model{
	
	function get_info_pn(){
		try {
			$this->db->select('*');
			$this->db->where('id >=', 61); 
			return $this->db->get('sys_config');
		} catch (Exception $e) {
			log_message('error', $e);
		}
	}
	function getJenisPerkara($idalurperkara){
		if(empty($idalurperkara)) return '';
		try {
			$this->db->where('id',$idalurperkara);
			return $this->db->get('alur_perkara')->row()->nama;
		} catch (Exception $e) {
			log_message('error', $e);
		}
	}

	function get_rekap($idalurperkara,$year){
		try {
			return $this->db->query("SELECT 
				jenisPerkara.nama AS jenis_perkara_nama,
				(SELECT COUNT(*) FROM perkara_keberatan 
					WHERE YEAR(tanggal_pendaftaran_keberatan)='".$year."' 
					AND perkara_id IN(GROUP_CONCAT(jenisPerkara.id))) AS jumlahPerkara,
				(SELECT COUNT(*) FROM perkara_keberatan 
					WHERE YEAR(tanggal_sidang_pertama_keberatan)='".$year."' 
					AND DATEDIFF(putusan_keberatan,penetapan_majelis_hakim)>='1' 
					AND DATEDIFF(putusan_keberatan,penetapan_majelis_hakim)<='7' 
					AND perkara_id IN(GROUP_CONCAT(jenisPerkara.id))) AS value1,
				(SELECT COUNT(*) FROM perkara_keberatan 
					WHERE YEAR(tanggal_sidang_pertama_keberatan)='".$year."' 
					AND DATEDIFF(putusan_keberatan,penetapan_majelis_hakim)>='8' 
					AND DATEDIFF(putusan_keberatan,penetapan_majelis_hakim)<='14' 
					AND perkara_id IN(GROUP_CONCAT(jenisPerkara.id))) AS value2
				FROM v_jenis_perkara AS jenisPerkara
				WHERE jenisPerkara.alur_perkara_id='".$idalurperkara."'
				GROUP BY jenisPerkara.nama
				ORDER BY jenisPerkara.nama ASC");
		} catch (Exception $e) {
			log_message('error', $e);
		}
	}
}