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

class M_template_tun_upaya_hukum extends CI_Model {

	 function getDataPengadilan(){
		try{
			$sql = "SELECT * FROM 
					(SELECT value AS NamaPN FROM sys_config WHERE id = 62) AS T1,
					(SELECT value AS KetuaPNNama FROM sys_config WHERE id = 64) AS T2,
					(SELECT value AS AlamatPN FROM sys_config WHERE id = 63) AS T3,
					(SELECT value AS WakilKetuaPNNama FROM sys_config WHERE id = 66) AS T4,
					(SELECT value AS PansekPNNama FROM sys_config WHERE id = 68) AS T5,
					(SELECT value AS WaPanNama FROM sys_config WHERE id = 70) AS T6, 
					(SELECT value AS ZonaWaktu FROM sys_config WHERE id = 75) AS T7,
					(SELECT value AS NamaPT FROM sys_config WHERE id = 76) AS T8";
					$query=$this->db->query($sql);
			return $query;	
		}catch(Exception $e) { 
			log_message('error', $e); 
		}
	}
//-----------------------------------------------------------------------------------//
	function getDataBanding($IDPerkara){
		try{
			return $this->db->query("SELECT
				banding.*,
				putusan.amar_putusan
				FROM perkara_banding AS banding
				LEFT JOIN perkara_putusan AS putusan ON putusan.perkara_id=banding.perkara_id 
				WHERE banding.perkara_id=".$IDPerkara."");
		}catch(Exception $e) { 
			log_message('error', $e); 
		}
	}

	function getDataKasasi($idperkara){
		try{
			return $this->db->query("SELECT
				kasasi.*,
				putusan.amar_putusan
				FROM perkara_kasasi AS kasasi
				LEFT JOIN perkara_putusan AS putusan ON putusan.perkara_id=kasasi.perkara_id 
				WHERE kasasi.perkara_id=".$idperkara."");
		}catch(Exception $e) { 
			log_message('error', $e); 
		}
	}
	
	function getDataPK($IDPerkara){
		try{
			return $this->db->query("SELECT
				pk.*,
				putusan.amar_putusan
				FROM perkara_pk AS pk
				LEFT JOIN perkara_putusan AS putusan ON putusan.perkara_id=pk.perkara_id 
				WHERE pk.perkara_id=".$IDPerkara."");
		}catch(Exception $e) { 
			log_message('error', $e); 
		}
	}
//--------------------------------------------------------------------------------------------//
	function getDataPihakBanding($IDPerkara,$JenisPihak){
		try{
			return $this->db->query("SELECT
				pihak.nama AS namaPihak,
				pihak.alamat AS alamatPihak,
				pihak.pekerjaan AS pekerjaanPihak,
				bandingDetil.pihak_asal_text AS pihakAsal
				FROM perkara_banding_detil AS bandingDetil
				LEFT JOIN pihak ON pihak.id=bandingDetil.pihak_id
				WHERE bandingDetil.perkara_id=".$IDPerkara."
				AND bandingDetil.status_pihak_id=".$JenisPihak."
				ORDER BY bandingDetil.urutan_banding ASC");
		}catch(Exception $e) { 
			log_message('error', $e); 
		}
	}

function getDataPihakKasasi($idperkara,$jenispihak){
		try{
			return $this->db->query("SELECT
				pihak.nama AS namaPihak,
				pihak.alamat AS alamatPihak,
				pihak.pekerjaan AS pekerjaanPihak,
				kasasiDetil.pihak_asal_text AS pihakAsal
				FROM perkara_kasasi_detil AS kasasiDetil
				LEFT JOIN pihak ON pihak.id=kasasiDetil.pihak_id
				WHERE kasasiDetil.perkara_id=".$idperkara."
				AND kasasiDetil.status_pihak_id=".$jenispihak."
				ORDER BY kasasiDetil.urutan_kasasi ASC");
		}catch(Exception $e) { 
			log_message('error', $e); 
		}
	}


function getDataPihakPK($idperkara,$JenisPihak){
		try{
			return $this->db->query("SELECT pihak.nama AS namaPihak,
			pihak.alamat AS alamatPihak,
			pihak.pekerjaan AS pekerjaanPihak,
			pkDetil.pihak_asal_text AS pihakAsal
			FROM perkara_pk_detil AS pkDetil
			LEFT JOIN pihak ON pihak.id=pkDetil.pihak_id
			WHERE pkDetil.perkara_id=".$idperkara."
			AND pkDetil.status_pihak_id=".$JenisPihak."
			ORDER BY pkDetil.urutan_pk ASC");
		}catch(Exception $e) { 
			log_message('error', $e); 
		}
	}

//--------------------------------------------------------------------------------//
function getDataPihakPemohonBanding($IDPerkara,$IDPemohonBanding){
		try{
			return $this->db->query("SELECT
				pihak.nama AS namaPihak,
				pihak.alamat AS alamatPihak,
				pihak.pekerjaan AS pekerjaanPihak,
				bandingDetil.pihak_asal_text AS pihakAsal
				FROM perkara_banding_detil AS bandingDetil
				LEFT JOIN pihak ON pihak.id=bandingDetil.pihak_id
				WHERE bandingDetil.perkara_id=".$IDPerkara."
				AND bandingDetil.id=".$IDPemohonBanding."
				ORDER BY bandingDetil.urutan_banding ASC");
		}catch(Exception $e) { 
			log_message('error', $e); 
		}
	}

function getDataPihakPemohonKasasi($idperkara,$IDPemohonKasasi){
		try{
			return $this->db->query("SELECT
				pihak.nama AS namaPihak,
				pihak.alamat AS alamatPihak,
				pihak.pekerjaan AS pekerjaanPihak,
				kasasiDetil.pihak_asal_text AS pihakAsal
				FROM perkara_kasasi_detil AS kasasiDetil
				LEFT JOIN pihak ON pihak.id=kasasiDetil.pihak_id
				WHERE kasasiDetil.perkara_id=".$idperkara."
				AND kasasiDetil.id=".$IDPemohonKasasi."
				ORDER BY kasasiDetil.urutan_kasasi ASC");				

		}catch(Exception $e) { 
			log_message('error', $e); 
		}
	}

function getDataPihakPemohonPK($IDPerkara,$IDPemohonPK){
		try{
			return $this->db->query("SELECT
				pihak.nama AS namaPihak,
				pihak.alamat AS alamatPihak,
				pihak.pekerjaan AS pekerjaanPihak,
				pkDetil.pihak_asal_text AS pihakAsal
				FROM perkara_pk_detil AS pkDetil
				LEFT JOIN pihak ON pihak.id=pkDetil.pihak_id
				WHERE pkDetil.perkara_id=".$IDPerkara."
				AND pkDetil.id=".$IDPemohonPK."
				ORDER BY pkDetil.urutan_pk ASC");
		}catch(Exception $e) { 
			log_message('error', $e); 
		}
	}

}
?>