<?php
if($this->session->userdata('is_logged_in')===FALSE){
            redirect('login');
}

$url = base_url("resources/template/akta/perdata_tun/".$filename.".rtf");
$Template = file_get_contents($url);

//-------Data PN----------------------------------//
$dataperkara = $dataumum;
    foreach ($dataperkara->result() as $row) {
            $nomorperkara = $row->nomor_perkara_pn;    
            $tanggalPermohonanKasasi = $this->templatehelper->convertKeTglIndo($row->permohonan_kasasi);
            $hariPermohonanPK = $this->templatehelper->getHari($row->permohonan_kasasi);
            $amar_pk = $this->templatehelper->cleanHtmlTag($row->amar_putusan);
            $jabatan_hakim = $row->jabatan_hakim_nama;
            $nama_hakim = $this->templatehelper->standradnaming($row->hakim_nama);
            $nama_panitera = $this->templatehelper->standradnaming($row->panitera_nama);                       
}

$datapengadilan = $datapn;
if(!empty($datapengadilan)){
    if($datapengadilan->num_rows>0){
        foreach ($datapengadilan->result() as $row) {
            $namapn = $this->templatehelper->standradnaming($row->NamaPN);   
            $alamatpn = $row->AlamatPN;
        }
    }
    
}
//----------------------------------------------//


$pihak1 = '';
$counter1=0;
if (!empty($dataPemohonKasasi->num_rows)){ 
	foreach($dataPemohonKasasi->result() as $row){$counter1++;
		if ($dataPemohonKasasi->num_rows>1) {
            $jumlahPihak1 = '\b Pembanding '.$counter1.'\b0\\par ';
        }else{
            $jumlahPihak1 = '\b Pembanding \b0\\par ';
        }

        $pihak1 .= $jumlahPihak1;
        $pihak1 .= 'a. Nama \tab : '.$this->templatehelper->standradnaming($row->namaPihak).'\\par ';
        $pihak1 .= 'b. Kewarganegaraan \tab : Indonesia\\par ';
        $pihak1 .= 'c. Pekerjaan \tab : '.$this->templatehelper->standradnaming($row->pekerjaanPihak).'\\par ';
        $pihak1 .= 'd. Tempat Tinggal \tab : '.$row->alamatPihak.'\\par ';
    }
}

$pihak2 = '';
$counter2=0;
if (!empty($dataTermohonKasasi->num_rows)){ 
	foreach($dataTermohonKasasi->result() as $row){$counter2++;
		if ($dataTermohonKasasi->num_rows>1) {
            $jumlahPihak2 = '\b Terbanding '.$counter2.'\b0\\par ';
        }else{
            $jumlahPihak2 = '\b Terbanding \b0\\par ';
        }

        $pihak2 .= $jumlahPihak2;
        $pihak2 .= 'a. Nama \tab : '.$this->templatehelper->standradnaming($row->namaPihak).'\\par ';
        $pihak2 .= 'b. Kewarganegaraan \tab : Indonesia\\par ';
        $pihak2 .= 'c. Pekerjaan \tab : '.$this->templatehelper->standradnaming($row->pekerjaanPihak).'\\par ';
        $pihak2 .= 'd. Tempat Tinggal \tab : '.$row->alamatPihak.'\\par ';
    }
}



$Template = str_replace("#nomorPerkara#",''.$nomorPerkaraPN.'',$Template);
$Template = str_replace("#tanggalPermohonan#",''.$tanggalPermohonanBanding.'',$Template);
$Template = str_replace("#hariPermohonan#",''.$tanggalPermohonanBanding.'',$Template);
$Template = str_replace("#namaPTUN#",''.$namaPengadilan.'',$Template);
$Template = str_replace("#namaPembanding#",''.$namaPembanding.'',$Template);
$Template = str_replace("#negaraPembanding#",''.$negaraPembanding.'',$Template);
$Template = str_replace("#alamatPembading#",''.$alamatPembading.'',$Template);
$Template = str_replace("#pekerjaanPembanding#",''.$pekerjaanPembanding.'',$Template);
$Template = str_replace("#tanggalPutusanPN#",''.$tanggalPutusanPN.'',$Template);
$Template = str_replace("#amarPutusanPN#",''.$amarPutusanPN.'',$Template);
$Template = str_replace("#Pihak1#",''.$pihak1.'',$Template);
$Template = str_replace("#Pihak2#",''.$pihak2.'',$Template);
$Template = str_replace("#namaPanses#",''.$namaPanses.'',$Template);
$Template = str_replace("#namaKota#",''.$namaKota.'',$Template);





header("Content-type: application/rtf");
header("Content-disposition: inline; filename=".$namafile."-".$nomorperkara.".rtf");
header("Content-length: ".strlen($Template));
echo $Template;
?>