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

class Report_mediasi_detail_perkara 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 get_data($tabel,$perkara_id){
		try {
			$sql="SELECT * FROM ".$tabel." WHERE perkara_id =".$perkara_id;
			return $this->db->query($sql);
		} catch (Exception $e) {
			
		}
	}

	function get_data_pihak($perkara_id){
		try {
			$sql="SELECT a.alamat_pihak,a.pihak_ke, urutan, FLOOR(DATEDIFF(b.tanggal_pendaftaran,c.`tanggal_lahir`)/365) AS umur, c.*, d.nama AS pendidikan, e.nama AS agama
					FROM 
					(SELECT tanggal_pendaftaran FROM perkara WHERE perkara_id = $perkara_id) AS b,
					(SELECT pihak_id , '1' AS pihak_ke, urutan, alamat AS alamat_pihak
					FROM perkara_pihak1 WHERE perkara_id = $perkara_id UNION 
					SELECT pihak_id , '2' AS pihak_ke, urutan, alamat AS alamat_pihak
					FROM perkara_pihak2 WHERE perkara_id = $perkara_id) AS a
					LEFT JOIN pihak AS c ON a.`pihak_id` = c.`id`
					LEFT JOIN tingkat_pendidikan AS d ON c.`pendidikan_id` = d.id
					LEFT JOIN agama AS e ON c.`agama_id` = e.id
					ORDER BY a.pihak_ke, a.urutan";
			return $this->db->query($sql);
		} catch (Exception $e) {
			
		}
	}

	function get_jadwal_mediasi($mediasi_id){
		try {
			$sql="SELECT * FROM perkara_jadwal_mediasi WHERE mediasi_id =".$mediasi_id;
			return $this->db->query($sql);
		} catch (Exception $e) {
			
		}
	}
}