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

class m_template_akta_kasasi_agama extends CI_Model {
	function infoTglKasasiAll($idperkara){
		try {
			return $this->db->query ("SELECT id,permohonan_kasasi, pemohon_nama
							FROM perkara_kasasi_detil 
							WHERE perkara_id=$idperkara AND permohonan_kasasi IS NOT NULL;");
			} catch(PDOException $e) {
			}
	}
	function cetaktglbanding($id){
		try {
			return $this->db->query ("SELECT * FROM perkara_kasasi_detil WHERE id =".$id);
			} catch(PDOException $e) {
			}
	}
	function infoPN(){
		try {
			return $this->db->query ("SELECT id,pt_id,nama FROM pengadilan_negeri WHERE jenis_pengadilan=4 GROUP BY nama;");
			} catch(PDOException $e) {
			}
	}

	function getDataPN(){
		try {
			return $this->db->query ("SELECT * FROM 
					(SELECT value AS NamaPN FROM sys_config WHERE id = 62) AS T1,
					(SELECT value AS Panses FROM sys_config WHERE id = 68) AS T2,
					(SELECT value AS AlamatPN FROM sys_config WHERE id = 63) AS T3,
					(SELECT value AS Wapan FROM sys_config WHERE id = 70) AS T4,
					(SELECT value AS ZonaWaktu FROM sys_config WHERE id = 75) AS T5,
					(SELECT value AS NamaPT FROM sys_config WHERE id = 76) AS T6,
					(SELECT value AS Ketua FROM sys_config WHERE id = 64) AS T7,
					(SELECT value AS Wakilketua FROM sys_config WHERE id = 66) AS T8;");
			} catch(PDOException $e) {
			}
	}
	function getKuasaPemohon($idperkara,$idpihak){
		try {
			if(!is_numeric($idperkara) AND !is_numeric($idpihak)){
					return '';
				}
			return $this->db->query("SELECT k.pemohon_nama,k.pihak_nama AS pihakdiwakili,k.pemohon_tanggal_surat, p.tanggal_lahir,p.alamat,p.pekerjaan,a.nama AS agama,tp.nama AS pendidikan
								FROM perkara_kasasi_detil AS k
								LEFT JOIN pihak AS p ON p.id=k.pemohon_id
								LEFT JOIN agama AS a ON a.id=p.agama_id
								LEFT JOIN tingkat_pendidikan AS tp ON tp.id=p.pendidikan_id
								WHERE k.perkara_id=$idperkara AND pemohon_id=$idpihak AND k.pihak_diwakili='Y' ");
		} catch(PDOException $e) {		
		}
	}
	function getKuasaPenggugat($idperkara,$idpihak){
		try {
			if(!is_numeric($idperkara) AND !is_numeric($idpihak)){
					return '';
				}
			return $this->db->query("SELECT  pemohon_nama AS nama, pemohon_id AS IDPihak, pihak_asal AS pihakke, permohonan_kasasi AS tglPemberitahuan, pemohon_tanggal_surat AS tglKuasa, pemohon_nomor_surat AS nomorKuasa, penerimaan_memori_kasasi AS tglMemori 
						FROM perkara_kasasi_detil 
						WHERE pemohon_id NOT IN (SELECT pihak_id FROM perkara_pihak2 WHERE perkara_id =$idperkara)
						AND perkara_id =$idperkara AND pihak_asal = 1 AND pihak_id=$idpihak AND pihak_diwakili='Y' ");
		} catch(PDOException $e) {		
		}
	}

	function getKuasaTergugat($idperkara,$idpihak){
		try {
			if(!is_numeric($idperkara) AND !is_numeric($idpihak)){
					return '';
				}
			return $this->db->query("SELECT  pemohon_nama AS nama, pemohon_id AS IDPihak, pihak_asal AS pihakke, permohonan_kasasi AS tglPemberitahuan, pemohon_tanggal_surat AS tglKuasa, pemohon_nomor_surat AS nomorKuasa, penerimaan_memori_kasasi AS tglMemori 
						FROM perkara_kasasi_detil 
						WHERE pemohon_id NOT IN (SELECT pihak_id FROM perkara_pihak1 WHERE perkara_id =$idperkara)
						AND perkara_id =$idperkara AND pihak_asal = 2 AND pihak_id=$idpihak AND pihak_diwakili='Y' ");
		} catch(PDOException $e) {		
		}
	}
	function getKuasaIntervensi($idperkara,$idpihak){
		try {
			if(!is_numeric($idperkara) AND !is_numeric($idpihak)){
					return '';
				}
			return $this->db->query("SELECT  pemohon_nama AS nama, pemohon_id AS IDPihak, pihak_asal AS pihakke, permohonan_kasasi AS tglPemberitahuan, pemohon_tanggal_surat AS tglKuasa, pemohon_nomor_surat AS nomorKuasa, penerimaan_memori_kasasi AS tglMemori 
						FROM perkara_kasasi_detil 
						WHERE pemohon_id NOT IN (SELECT pihak_id FROM perkara_pihak1 WHERE perkara_id =$idperkara)
						AND pemohon_id NOT IN ((SELECT pihak_id FROM perkara_pihak2 WHERE perkara_id =$idperkara))
						AND perkara_id =$idperkara AND pihak_asal = 3 AND pihak_id=$idpihak AND pihak_diwakili='Y' ");
		} catch(PDOException $e) {		
		}
	}
	function infoKuasaPenggugat($idperkara,$idpihak){
		try {
			if(!is_numeric($idperkara) AND !is_numeric($idpihak)){
					return '';
				}
			return $this->db->query("SELECT  pemohon_nama AS nama, pemohon_id AS IDPihak, pihak_asal AS pihakke, permohonan_kasasi AS tglPemberitahuan, pemohon_tanggal_surat AS tglKuasa, pemohon_nomor_surat AS nomorKuasa, penerimaan_memori_kasasi AS tglMemori 
						FROM perkara_kasasi_detil 
						WHERE perkara_id =$idperkara AND pihak_asal = 1 AND pemohon_id=$idpihak AND pihak_diwakili='Y' ");
		} catch(PDOException $e) {		
		}
	}
	function infoKuasaTergugat($idperkara,$idpihak){
		try {
			if(!is_numeric($idperkara) AND !is_numeric($idpihak)){
					return '';
				}
			return $this->db->query("SELECT  pemohon_nama AS nama, pemohon_id AS IDPihak, pihak_asal AS pihakke, permohonan_kasasi AS tglPemberitahuan, pemohon_tanggal_surat AS tglKuasa, pemohon_nomor_surat AS nomorKuasa, penerimaan_memori_kasasi AS tglMemori 
						FROM perkara_kasasi_detil 
						WHERE perkara_id =$idperkara AND pihak_asal = 2 AND pemohon_id=$idpihak AND pihak_diwakili='Y' ");
		} catch(PDOException $e) {		
		}
	}
	function infoKuasaIntervensi($idperkara,$idpihak){
		try {
			if(!is_numeric($idperkara) AND !is_numeric($idpihak)){
					return '';
				}
			return $this->db->query("SELECT  pemohon_nama AS nama, pemohon_id AS IDPihak, pihak_asal AS pihakke, permohonan_kasasi AS tglPemberitahuan, pemohon_tanggal_surat AS tglKuasa, pemohon_nomor_surat AS nomorKuasa, penerimaan_memori_kasasi AS tglMemori 
						FROM perkara_kasasi_detil 
						WHERE perkara_id =$idperkara AND pihak_asal = 3 AND pemohon_id=$idpihak AND pihak_diwakili='Y' ");
		} catch(PDOException $e) {		
		}
	}

	function getInfo($idperkara){
		try {
				$qry="SELECT 
				CONCAT(pihak_nama,' / ',status_pihak_text) AS pihak_nama,
				status_pihak_text,
				IF(pihak_diwakili='Y', CONCAT(pemohon_nama), 'Tidak Diwakili') AS diwakili, pihak_id,pihak_diwakili,pemohon_nama
				FROM perkara_kasasi_detil WHERE perkara_id=$idperkara AND permohonan_kasasi IS NOT NULL AND status_pihak_id=1 ";
		return $this->db->query($qry);
		} catch (Exception $e) {
		}
	}
	function getInfo2($idperkara,$idpihak){
		try {
				$qry="SELECT 
				CONCAT(pihak_nama,' / ',status_pihak_text) AS pihak_nama,
				status_pihak_text,
				IF(pihak_diwakili='Y', CONCAT(pemohon_nama), 'Tidak Diwakili') AS diwakili, pihak_id,pihak_diwakili,pemohon_nama
				FROM perkara_kasasi_detil WHERE perkara_id=$idperkara AND pihak_id=$idpihak ";
		return $this->db->query($qry);
		} catch (Exception $e) {
		}
	}
	function listAllPemohonKasasi($idperkara){
		try {
			return $this->db->query ("SELECT pkd.pihak_nama,pkd.pihak_asal_text,pkd.status_pihak_text,pkd.urutan_kasasi,pihak.tanggal_lahir,agama.nama AS agama,pihak.pekerjaan,tp.nama AS pendidikan,pihak.alamat
							FROM perkara_kasasi_detil AS pkd
							LEFT JOIN pihak ON pihak.id=pkd.pemohon_id
							LEFT JOIN agama ON agama.id=pihak.agama_id
							LEFT JOIN tingkat_pendidikan AS tp ON tp.id=pihak.pendidikan_id 
							WHERE pkd.perkara_id=$idperkara AND pkd.status_pihak_id IN(1,2) AND pkd.pemohon_id IS NOT NULL;");
			} catch(PDOException $e) {
			}
	}
	function listAllTermohonKasasi($idperkara){
		try {
			return $this->db->query ("SELECT pkd.pihak_nama,pkd.pihak_asal_text,pkd.status_pihak_text,pkd.urutan_kasasi,pihak.tanggal_lahir,agama.nama AS agama,pihak.pekerjaan,tp.nama AS pendidikan,pihak.alamat
							FROM perkara_kasasi_detil AS pkd
							LEFT JOIN pihak ON pihak.id=pkd.pihak_id
							LEFT JOIN agama ON agama.id=pihak.agama_id
							LEFT JOIN tingkat_pendidikan AS tp ON tp.id=pihak.pendidikan_id 
							WHERE pkd.perkara_id=$idperkara  AND status_pihak_id IN(3,4,5);");
			} catch(PDOException $e) {
			}
	}
	function listBiayaPemberitahuan($idperkara){
		try {
			return $this->db->query ("SELECT jenis_biaya_id,uraian,jumlah FROM perkara_biaya
							WHERE perkara_id=$idperkara AND kategori_id=6 AND tahapan_id=20;");
			} catch(PDOException $e) {
			}
	}

	function getAllJurusita(){
		try{			
		return $this->db->query("SELECT id, nama_gelar FROM jurusita WHERE aktif!='T' GROUP BY nama_gelar ASC");
		} catch(PDOException $e) {		
		}
	}
	function cetakJurusita($idjurusita){
		try{
			if(!is_numeric($idjurusita)){
					return '';
		}			
		return $this->db->query("SELECT id, nama_gelar, jabatan FROM jurusita WHERE id=".$idjurusita);
		} catch(PDOException $e) {		
		}
	}	
	function getTanggalPemberitahuanKasasi($idperkara,$idpihak){
		try{
			if(!is_numeric($idperkara) OR !is_numeric($idpihak)){
					return '';
		}
		return $this->db->query('SELECT pihak_id, permohonan_kasasi, status_pihak_text, pemberitahuan_kasasi AS pemberitahuan, penerimaan_memori_kasasi, penyerahan_memori_kasasi, 
			penerimaan_kontra_kasasi, penyerahan_kontra_kasasi, pemberitahuan_putusan_kasasi 
			FROM perkara_kasasi_detil WHERE   perkara_id='.$idperkara.' AND pihak_id='.$idpihak);
		} catch(PDOException $e) {		
		}
	}
	function cetakPemberitahuanBandingPU($idperkara){
		try{
			if(!is_numeric($idperkara)){
					return '';
		}
		return $this->db->query('SELECT pemberitahuan_kasasi AS pemberitahuan FROM perkara_kasasi_detil WHERE  pihak_asal=1 AND status_pihak_id!=1 AND perkara_id='.$idperkara);
		} catch(PDOException $e) {		
		}
	}	
	function cetakPemberitahuanPU($idperkara){
		try{
			if(!is_numeric($idperkara)){
					return '';
		}
		return $this->db->query('SELECT a.nama, b.NIP FROM perkara_pihak1 a, pihak_jaksa b WHERE a.pihak_id = b.pihak_id AND perkara_id='.$idperkara);
		} catch(PDOException $e) {		
		}
	}
	function getPihakPemohon($idperkara){
		try{
			if(!is_numeric($idperkara)){
					return '';
		}
		return $this->db->query('SELECT pihak_id AS IDPihak, pihak_nama AS nama, penyerahan_kontra_kasasi FROM perkara_kasasi_detil WHERE perkara_id='.$idperkara.' AND status_pihak_id IN (1,2)');
		} catch(PDOException $e) {		
		}
	}

	function getDataPihak($idperkara,$idpemohon){
		try {
			if(!is_numeric($idperkara) AND !is_numeric($idpemohon)){
					return '';
				}
			return $this->db->query('SELECT perkara_id as IDPerkara,pihak_nama AS nama,permohonan_kasasi AS tglPemberitahuan, penerimaan_memori_kasasi AS tglmemori, penerimaan_kontra_kasasi AS tglkontramemori, pihak_id AS IDPihak, pihak_asal AS pihakke,status_pihak_text FROM perkara_kasasi_detil WHERE perkara_id ='.$idperkara.' AND pihak_id ='.$idpemohon);
		} catch(PDOException $e) {		
		}
	}
	function getDataTerdakwa($idperkara,$idpemohon){
		try {
			if(!is_numeric($idperkara) AND !is_numeric($idpemohon)){
					return '';
				}
			return $this->db->query('SELECT pihak_nama AS nama,pihak_id AS IDPihak, pihak_asal AS pihakke, permohonan_kasasi AS tglPemberitahuan, penerimaan_memori_kasasi AS tglMemori 
				FROM perkara_kasasi_detil WHERE perkara_id ='.$idperkara.' AND pihak_id ='.$idpemohon);
		} catch(PDOException $e) {		
		}
	}

	function getDataJaksa($idperkara,$idpemohon){
		try {
			if(!is_numeric($idperkara) AND !is_numeric($idpemohon)){
					return '';
				}
			return $this->db->query('SELECT pihak_nama AS nama,pihak_id AS IDPihak, pihak_asal AS pihakke, permohonan_kasasi AS tglPemberitahuan, penerimaan_memori_kasasi AS tglMemori FROM perkara_kasasi_detil WHERE perkara_id='.$idperkara.' AND pemohon_id='.$idpemohon);
		} catch(PDOException $e) {		
		}
	}
	function getInfoPihak($idperkara,$idpihak){
		try {
			if(!is_numeric($idperkara) AND !is_numeric($idpihak)){
					return '';
				}
			return $this->db->query('SELECT pihak_nama AS nama, pihak_id AS IDPihak FROM perkara_kasasi_detil WHERE perkara_id='.$idperkara.' AND pihak_id='.$idpihak);
		} catch(PDOException $e) {		
		}
	}

	
	function infoTglTerimaMemori($idperkara){
		try {
			return $this->db->query ("SELECT id,penerimaan_memori_kasasi, pihak_nama
							FROM perkara_kasasi_detil 
							WHERE perkara_id=$idperkara AND penerimaan_memori_kasasi IS NOT NULL;");
			} catch(PDOException $e) {
				echo "string";
			}
	}
	function infoTglTerimaKontraMemori($idperkara){
		try {
			return $this->db->query ("SELECT id,penerimaan_kontra_kasasi, pihak_nama
							FROM perkara_kasasi_detil 
							WHERE perkara_id=$idperkara AND penerimaan_kontra_kasasi IS NOT NULL;");
			} catch(PDOException $e) {
			}
	}
	function ttdKetua(){
		try {			
			return $this->db->query("SELECT id,CONCAT('Ketua-> [ ',value,' ]') AS namaKetua FROM sys_config WHERE id = '64' UNION
				SELECT id,CONCAT('Wakil Ketua-> [ ',value,' ]') AS namaKetua FROM sys_config WHERE id = '66' ");
		} catch(PDOException $e) {				
		}
	}

	function getDataPutusan($idperkara){
		try {
			return $this->db->query("SELECT tahapan.* FROM 
                    (SELECT '1' AS idPut,
                    (SELECT value FROM sys_config WHERE id = 62) AS tahapan,
                    (SELECT nomor_perkara FROM perkara WHERE perkara_id=$idperkara) AS nomorPerkara,
                    tanggal_putusan AS tglPutus, perkara_id 
                    FROM perkara_putusan AS a 
                    UNION ALL
                    SELECT '2' AS idPut,( SELECT value  FROM sys_config WHERE id=76 ),
                    nomor_perkara_banding,putusan_banding,perkara_id 
                    FROM perkara_banding AS a) AS tahapan 
                WHERE tahapan.perkara_id=$idperkara limit 2");
		} catch (Exception $e) {
		}
	}
	function pembuatAkta(){
		try {			
			return $this->db->query("SELECT id,CONCAT('PanSek-> [ ',value,' ]') AS namaPanitera FROM sys_config WHERE id = '68' UNION
				SELECT id,CONCAT('WaPan-> [ ',value,' ]') AS namaPanitera FROM sys_config WHERE id = '70' ");
		} catch(PDOException $e) {				
		}
	}

	function getKasasiTerhadap($idputusan,$idperkara){
		try {
			if($idputusan==1)
				return $this->db->query("SELECT tanggal_putusan AS tglputusan, nomor_perkara AS nomor_perkara, (SELECT VALUE FROM sys_config WHERE id = 62) AS namasatker FROM v_perkara WHERE perkara_id = ".$idperkara.";");
			else
				return $this->db->query("SELECT putusan_banding AS tglputusan, nomor_putusan_banding AS nomor_perkara, (SELECT VALUE FROM sys_config WHERE id = 76) AS namasatker FROM perkara_banding WHERE perkara_id = ".$idperkara.";");
		} catch (Exception $e) {
			
		}
	}
	
	function cetak_AktaPermohonanKasasi($idperkara,$idpembuatakta,$pihakid,$idput){
		try {
			$qry="SELECT a.pihak_id,
				z.nomor_perkara,
				a.permohonan_kasasi,
				c.nama AS namaPihak,
				c.alamat AS alamatPihak,
				c.tanggal_lahir  AS tanggalLahirPihak,
				agama.nama  AS agamaPihak,
				c.pekerjaan  AS pekerjaanPihak,
				tp.nama  AS pendidikanPihak,
				c.warga_negara  AS negaraPihak,
				a.pihak_asal_text,a.status_pihak_text,
				a.catatan_putusan_kasasi,kasasi.tidak_memenuhi_syarat,
				put.*, info.*
		FROM perkara_kasasi_detil AS a
		LEFT JOIN perkara_kasasi AS kasasi ON kasasi.perkara_id=a.perkara_id
		LEFT JOIN perkara AS z ON a.perkara_id=z.perkara_id		
		LEFT JOIN pihak AS c ON a.pemohon_id=c.id
		LEFT JOIN agama ON agama.id=c.agama_id
		LEFT JOIN tingkat_pendidikan AS tp ON tp.id=c.pendidikan_id
		LEFT JOIN (SELECT '1' AS idPut,(SELECT value FROM sys_config WHERE id = 62) AS Tahapan,
				(SELECT nomor_perkara FROM perkara WHERE perkara_id=$idperkara ) AS nomorPerkaraTahapan,
				tanggal_putusan AS putusan, perkara_id 
				FROM perkara_putusan AS a 
				WHERE a.perkara_id=$idperkara
			UNION ALL
				SELECT '2' AS idPut,(SELECT value FROM sys_config WHERE id = 76) AS tahapan,
				nomor_perkara_banding AS nomorPerkaraTahapan,
				putusan_banding AS putusan,perkara_id 
				FROM perkara_banding AS a 
				WHERE a.perkara_id=$idperkara) AS put ON put.idPut IN ('1','2')
		LEFT JOIN (SELECT 	b.id,a.namaPengadilan,
			IF (b.nama = 'PanSekNama','Panitera Sekretaris','Wakil Panitera' ) AS pejabat,b.pw
			FROM    (SELECT id,value AS namaPengadilan FROM sys_config WHERE id=62) AS a,
		        (SELECT id,VALUE AS pw, NAME AS nama FROM sys_config WHERE id IN (64,66,68,70)) AS b) AS info ON info.id IN (64,66,68,70)
		WHERE a.perkara_id=$idperkara AND info.id=$idpembuatakta AND put.idput=$idput AND a.pemohon_id=$pihakid ";
		// echo $qry;
		return $this->db->query($qry);
		} catch (Exception $e) {
		}
	}
	function cetak_AktaKontraKasasi($idperkara,$idpembuatakta,$pihakid,$idput){
		try {
			$qry="SELECT a.pihak_id,
				z.nomor_perkara,
				a.penerimaan_kontra_kasasi AS permohonan_kasasi,
				c.nama AS namaPihak,
				c.alamat AS alamatPihak,
				c.tanggal_lahir  AS tanggalLahirPihak,
				agama.nama  AS agamaPihak,
				c.pekerjaan  AS pekerjaanPihak,
				tp.nama  AS pendidikanPihak,
				c.warga_negara  AS negaraPihak,
				a.pihak_asal_text,a.status_pihak_text,
				a.catatan_putusan_kasasi,kasasi.tidak_memenuhi_syarat,
				put.*, info.*
		FROM perkara_kasasi_detil AS a
		LEFT JOIN perkara_kasasi AS kasasi ON kasasi.perkara_id=a.perkara_id
		LEFT JOIN perkara AS z ON a.perkara_id=z.perkara_id		
		LEFT JOIN pihak AS c ON a.pihak_id=c.id
		LEFT JOIN agama ON agama.id=c.agama_id
		LEFT JOIN tingkat_pendidikan AS tp ON tp.id=c.pendidikan_id
		LEFT JOIN (SELECT '1' AS idPut,(SELECT value FROM sys_config WHERE id = 62) AS Tahapan,
				(SELECT nomor_perkara FROM perkara WHERE perkara_id=$idperkara ) AS nomorPerkaraTahapan,
				tanggal_putusan AS putusan, perkara_id 
				FROM perkara_putusan AS a 
				WHERE a.perkara_id=$idperkara
			UNION ALL
				SELECT '2' AS idPut,(SELECT value FROM sys_config WHERE id = 76) AS tahapan,
				nomor_perkara_banding AS nomorPerkaraTahapan,
				putusan_banding AS putusan,perkara_id 
				FROM perkara_banding AS a 
				WHERE a.perkara_id=$idperkara) AS put ON put.idPut IN ('1','2')
		LEFT JOIN (SELECT 	b.id,a.namaPengadilan,
			IF (b.nama = 'PanSekNama','Panitera Sekretaris','Wakil Panitera' ) AS pejabat,b.pw
			FROM    (SELECT id,value AS namaPengadilan FROM sys_config WHERE id=62) AS a,
		        (SELECT id,VALUE AS pw, NAME AS nama FROM sys_config WHERE id IN (64,66,68,70)) AS b) AS info ON info.id IN (64,66,68,70)
		WHERE a.perkara_id=$idperkara AND info.id=$idpembuatakta AND put.idput=$idput AND a.pihak_id=$pihakid ";
		// echo $qry;
		return $this->db->query($qry);
		} catch (Exception $e) {
		}
	}

	function getDataDocumentTemplate($idalurperkara,$idatahapan,$idproses,$notemplate,$keyword){
		if (empty($keyword) or $keyword==''){
		$sql="SELECT a.nama AS jnsperkara,b.nomor AS notenmplate,b.kode AS kdtemplate,b.nama AS namatemplate 
				FROM alur_perkara a,template_dokumen b 
				WHERE a.id=b.alur_perkara_id 	AND a.id=$idalurperkara 
												AND b.tahapan_id =$idatahapan 
												AND b.proses_id=$idproses 
												AND b.nomor=$notemplate";
		}else{
		$sql="SELECT a.nama AS jnsperkara,b.nomor AS notenmplate,b.kode AS kdtemplate,b.nama AS namatemplate 
				FROM alur_perkara a,template_dokumen b 
				WHERE a.id=b.alur_perkara_id 	AND a.id=$idalurperkara 
												AND b.tahapan_id =$idatahapan 
												AND b.proses_id=$idproses 
												AND b.nama LIKE '%$keyword%'";
		}
		$query=$this->db->query($sql);
		return $query;
	}

	function getDataPerkara($idperkara){
		try {
			if(!is_numeric($idperkara)){
					return '';
				}
			return $this->db->query('SELECT nomor_perkara,nomor_surat,tanggal_surat, tanggal_pendaftaran FROM perkara WHERE perkara_id ='.$idperkara);
		} catch(PDOException $e) {		
		}
	}

	function getTanggalPutusan($idperkara){
		try {
			if(!is_numeric($idperkara)){
					return '';
				}
			return $this->db->query('SELECT pp.tanggal_putusan, pp.amar_putusan,pb.nomor_putusan_kasasi,pb.amar_putusan_kasasi,pb.putusan_kasasi
					FROM perkara_putusan AS pp
					LEFT JOIN ((SELECT * FROM perkara_kasasi  WHERE perkara_id='.$idperkara.') AS pb)  ON pb.perkara_id=pp.perkara_id
					WHERE pp.perkara_id ='.$idperkara);
		} catch(PDOException $e) {		
		}
	}

	function infoPihak($idperkara,$idpihak){
		try{
			if(!is_numeric($idperkara) OR !is_numeric($idpihak)){
				return '';
		}
		return $this->db->query("SELECT pbd.pihak_asal_text,pbd.status_pihak_text,pihak.nama,pihak.warga_negara,pihak.alamat,pihak.pekerjaan,pihak.jenis_pihak_id,pbd.pemberitahuan_kasasi,(YEAR(CURRENT_DATE()) - YEAR(pihak.tanggal_lahir)) AS umur,agama.nama AS agama,tp.nama AS pendidikan
							FROM perkara_kasasi_detil AS pbd
							LEFT JOIN pihak AS pihak ON pihak.id=pbd.pihak_id
							LEFT JOIN agama AS agama ON agama.id=pihak.agama_id
							LEFT JOIN tingkat_pendidikan AS tp ON tp.id=pihak.pendidikan_id
							WHERE pbd.perkara_id=".$idperkara." AND pbd.pihak_id=".$idpihak);
		} catch (Exception $e){
			}
	}

	function infoAllPemohon($idperkara){
		try {
			return $this->db->query ("SELECT pbd.permohonan_kasasi,pbd.status_pihak_text,pbd.urutan_kasasi,pbd.pemohon_nama,pbd.pemohon_tanggal_surat,pbd.pemohon_nomor_surat, pihak.nama, pihak.alamat,pihak.pekerjaan,pihak.jenis_pihak_id,pbd.pihak_asal_text,pbd.pihak_asal
							FROM perkara_kasasi_detil AS pbd
							LEFT JOIN (SELECT * FROM pihak WHERE id IN (SELECT pihak_id FROM perkara_kasasi_detil WHERE perkara_id=$idperkara)) AS pihak ON pihak.id=pbd.pihak_id
							WHERE pbd.perkara_id=$idperkara AND pbd.status_pihak_id IN (1,2,4) AND pbd.pemohon_id IS NOT NULL;");
			} catch(PDOException $e) {
			}
	}

	function infoAllTermohon($idperkara){
		try {
			return $this->db->query ("SELECT pbd.pihak_asal,pbd.pihak_asal_text,pbd.urutan_kasasi,pihak.nama, pihak.alamat,pihak.pekerjaan,pihak.jenis_pihak_id,pbd.status_pihak_text
							FROM perkara_kasasi_detil AS pbd
							LEFT JOIN (SELECT * FROM pihak WHERE id IN (SELECT pihak_id FROM perkara_kasasi_detil WHERE perkara_id=$idperkara)) AS pihak ON pihak.id=pbd.pihak_id
							WHERE pbd.perkara_id=$idperkara AND pbd.status_pihak_id IN (3,4,5);");
			} catch(PDOException $e) {
			}
	}

	function infoKuasaPihak($idperkara,$idpihak){
		try{
			if(!is_numeric($idperkara) OR !is_numeric($idpihak)){
				return '';
		}
		return $this->db->query("SELECT  pbd.permohonan_kasasi, pbd.pemohon_tanggal_surat AS tglKuasa, pbd.pemohon_nomor_surat AS nomorKuasa, p.nama,p.alamat,p.pekerjaan,pbd.pihak_nama AS pihakdiwakili,pbd.status_pihak_text, (YEAR(CURRENT_DATE()) - YEAR(p.tanggal_lahir)) AS umur, a.nama AS agama
							FROM perkara_kasasi_detil pbd
							LEFT JOIN pihak AS p ON pbd.pemohon_id=p.id
							LEFT JOIN agama AS a ON a.id=p.agama_id 
							WHERE pemohon_id =$idpihak
							AND perkara_id =$idperkara AND pihak_diwakili='Y';");
	} catch (Exception $e){
		}
	}
}