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

class m_template_perdata_pemberitahuan_putusan_tergugat extends CI_Model {

	function getListTergugat($idperkara){
		try {
			if(!is_numeric($idperkara)){
				return '';
			}
			return $this->db->query("SELECT urutan, pihak_id, nama FROM perkara_pihak2 WHERE perkara_id=$idperkara ORDER BY urutan ASC");
		} catch (Exception $e) {
		}
	}

	function getListJurusita($idperkara){
		try {
			if(!is_numeric($idperkara)){
				return '';
			}
			return $this->db->query("SELECT perkara_id,jurusita_id,jurusita_nama FROM perkara_jurusita WHERE perkara_id=$idperkara");
		} catch (Exception $e) {
		}
	}
	
	function getBiayaPerkara($idperkara){
		try {
			if(!is_numeric($idperkara)){
				return '';
			}
			$sql="SELECT a.perkara_id, a.kategori_id, a.tahapan_id, a.jumlah
                FROM 
                perkara_biaya AS a 
                WHERE a.perkara_id=$idperkara AND a.kategori_id IN ('4','6')
                GROUP BY a.jumlah";
            $query=$this->db->query($sql);
            return $query;
		} catch (Exception $e) {
		}
	}

	function cetak_pemberitahuan_putusan_pdt($idperkara,$idpihak,$jursit_id){
		try {
			if(!is_numeric($idperkara) OR !is_numeric($idpihak) OR !is_numeric($jursit_id)){
				return '';
			}
			$qry="SELECT 	a.`perkara_id` , 
						a.`nomor_perkara` AS noPerkara ,  
						b.jurusita_id,
						b.jurusita_nama AS jurusita, 
						IF(jumlahP.jmlP >= 2,CONCAT(c.`nama`,' .dkk'),c.`nama`) AS namaPihakP,
						IF(jumlahT.jmlT >= 2,CONCAT(e.`nama`,' .dkk'),e.`nama`) AS namaPihakT,
						d.`tanggal_putusan` AS tglPutusan, 
						d.`amar_putusan` AS amarPutusan,	
						f.nama AS namaPihak,
						f.pekerjaan AS pekerjaanPihak,
						f.alamat AS alamatPihak,
						h.value AS namaPengadilan,
						jumlahP.jmlP, jumlahT.jmlT
				FROM perkara AS a
				LEFT JOIN perkara_jurusita AS b  ON a.perkara_id=b.perkara_id and b.jurusita_id=$jursit_id
				LEFT JOIN perkara_pihak1 AS c ON c.`perkara_id`=a.`perkara_id`
				LEFT JOIN perkara_putusan AS d ON a.`perkara_id`=d.`perkara_id`
				LEFT JOIN perkara_pihak2 AS e ON a.`perkara_id`=e.`perkara_id`
				LEFT JOIN (SELECT pihak_id, y.nama, y.pekerjaan, y.alamat FROM perkara_pihak2 x, pihak y WHERE x.pihak_id=y.id ) AS f ON f.pihak_id = $idpihak
				LEFT JOIN (SELECT id, VALUE FROM sys_config) AS h ON h.id=62
				LEFT JOIN (SELECT COUNT(pihak_id) AS jmlP, perkara_id FROM perkara_pihak1 WHERE perkara_id=$idperkara ) AS jumlahP ON  jumlahP.perkara_id=a.perkara_id
				LEFT JOIN (SELECT COUNT(pihak_id) AS jmlT, perkara_id FROM perkara_pihak2 WHERE perkara_id=$idperkara ) AS jumlahT ON  jumlahT.perkara_id=a.perkara_id
				WHERE  a.perkara_id=$idperkara and c.urutan=1 AND e.urutan=1 ";
		$query=$this->db->query($qry);
		return $query;
		} catch (Exception $e) {
		}
	}
}

/* End of file pemberitahuan_putusan_pdt_m.php */
/* Location: ./application/models/generate_template/pemberitahuan_putusan_pdt_m.php */