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

class Report_rekap_upaya_hukum_eksekusi 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 
			1 as nomor
			,'Masuk' as nama
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and left(permohonan_eksekusi,7) = CONCAT('".$year."','-01') and CONCAT('".$year."','-01') <= left(CURRENT_DATE(),7) ) as bl01
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and left(permohonan_eksekusi,7) = CONCAT('".$year."','-02') and CONCAT('".$year."','-02') <= left(CURRENT_DATE(),7) ) as bl02
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and left(permohonan_eksekusi,7) = CONCAT('".$year."','-03') and CONCAT('".$year."','-03') <= left(CURRENT_DATE(),7) ) as bl03
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and left(permohonan_eksekusi,7) = CONCAT('".$year."','-04') and CONCAT('".$year."','-04') <= left(CURRENT_DATE(),7) ) as bl04
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and left(permohonan_eksekusi,7) = CONCAT('".$year."','-05') and CONCAT('".$year."','-05') <= left(CURRENT_DATE(),7) ) as bl05
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and left(permohonan_eksekusi,7) = CONCAT('".$year."','-06') and CONCAT('".$year."','-06') <= left(CURRENT_DATE(),7) ) as bl06
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and left(permohonan_eksekusi,7) = CONCAT('".$year."','-07') and CONCAT('".$year."','-07') <= left(CURRENT_DATE(),7) ) as bl07
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and left(permohonan_eksekusi,7) = CONCAT('".$year."','-08') and CONCAT('".$year."','-08') <= left(CURRENT_DATE(),7) ) as bl08
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and left(permohonan_eksekusi,7) = CONCAT('".$year."','-09') and CONCAT('".$year."','-09') <= left(CURRENT_DATE(),7) ) as bl09
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and left(permohonan_eksekusi,7) = CONCAT('".$year."','-10') and CONCAT('".$year."','-10') <= left(CURRENT_DATE(),7) ) as bl10
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and left(permohonan_eksekusi,7) = CONCAT('".$year."','-11') and CONCAT('".$year."','-11') <= left(CURRENT_DATE(),7) ) as bl11
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and left(permohonan_eksekusi,7) = CONCAT('".$year."','-12') and CONCAT('".$year."','-12') <= left(CURRENT_DATE(),7) ) as bl12
			,(select count(*) from perkara_eksekusi where alur_perkara_id in(".$idalurperkara.") and year(permohonan_eksekusi) = ".$year.") as total
			");
		} catch (Exception $e) {
			
		}
	}
}