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

class Report_hhk 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_tahun($idalurperkara){
		try {
			return $this->db->query('SELECT YEAR(min(tanggal_pendaftaran)) AS years FROM perkara WHERE alur_perkara_id IN ('.$idalurperkara.');');
		} catch (Exception $e) {
			
		}
	}

	function get_stat_perkara($period,$idalurperkara){
		try {
			return '';
		} catch (Exception $e) {
			
		}
	}

	function get_lap_perkara($period,$idalurperkara){
		try {
			return $this->db->query("
				SELECT jenis.kode, nama, IF(nominal IS NULL ,0,nominal) AS nominal FROM 
					(SELECT jenis_biaya_kode,jenis_biaya_nama,sum(jumlah) AS nominal
						FROM v_perkara_biaya_detil
							WHERE LEFT(tanggal_transaksi,7)='".$period."'
							AND alur_perkara_id IN (".$idalurperkara.") 
							AND kategori_id IS NOT NULL AND kategori_id = 13 
							GROUP BY jenis_biaya_kode) AS biaya
					RIGHT JOIN
					(SELECT kode, nama 
						FROM jenis_biaya 
						WHERE kategori_id = 13 
						GROUP BY kode) AS jenis
					ON jenis.kode = biaya.jenis_biaya_kode;");
		} catch (Exception $e) {
			
		}
	}
}