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

foreach ($template->result() as $template)
{
    $filename=$template->kdtemplate;
    $namafile=str_replace(" ","",$template->namatemplate);
}

$tglCabut = $tglCabut;
$jenisPihak = intval($pengaju);
if(!is_numeric($jenisPihak)){
    show_404();
    exit();
}

$tglCetak = $this->templatehelper->convertKeTglIndo($tglCabut);
$hariCetak = $this->templatehelper->getHari($tglCabut);


$url = base_url("resources/template/akta/pidana_umum/".$filename.".rtf");
$Template = file_get_contents($url);
//=============================================roby======================================================
$getDataAkta = $dataTemplate;
//print_r($getDataAkta->result());

$namaPengadilan = '......';
$nomorPerkara   = '......';
$pejabat = '......';
$namaPengadilan = '......';
$jabatan = '......';
$tahapan = '......';
$nomorYangdDPKkan = '......';
$tglPutusanYangDiPKkan = '......';

foreach ($getDataAkta->result() as $row) {
            $namaPengadilan     =$this->templatehelper->standradnaming($row->nama_pengadilan);
            $nomorPerkara   =$row->nomor_perkara;
			$pejabat = $row->pw;
			$jabatan =  $row->jabatan;
			$tahapan =  $row->tahapan;
			$nomorYangdDPKkan =  $row->nomorPerkara;
			$tglPutusanYangDiPKkan =  $this->templatehelper->convertKeTglIndo($row->putusan);
 }

$nomorPerkara   = $row->nomor_perkara;
$no = explode("/",$nomorPerkara);
$nomor = $no['0'];
$kodePerkara = $no['1'];
$tahunPerkara = $no['2'];
$kodePN = $no['3'];
$nomorAkta = $nomor."/Akta ".$kodePerkara."/".$tahunPerkara."/".$kodePN;

if($jenisPihak==1){
	$jenisPihak = 'Penuntut Umum';
	} elseif ($jenisPihak==2) {
	$jenisPihak = 'Terdakwa';
	}elseif ($jenisPihak==3) {
	$jenisPihak = 'Para Terdakwa';
	}elseif ($jenisPihak==4) {
	$jenisPihak = 'Penasihat Hukum Terdakwa';
	}elseif ($jenisPihak==5) {
	$jenisPihak = 'Penasihat Hukum Para Terdakwa';
	}

		$Template = str_replace("#nomorperkara#",''.$nomorPerkara.'',$Template);
		$Template = str_replace("#namaPengadilan#",''.$namaPengadilan.'',$Template);
		$Template = str_replace("#nomorAkta#",''.$nomorAkta.'',$Template);
		$Template = str_replace("#pejabat#",''.$pejabat.'',$Template);
		$Template = str_replace("#Jabatan#",''.$jabatan.'',$Template);
		$Template = str_replace("#tahapan#",''.$tahapan.'',$Template);
		$Template = str_replace("#nomorYgdDiPK#",''.$nomorYangdDPKkan.'',$Template);
		$Template = str_replace("#tglPtsDiPKkan#",''.$tglPutusanYangDiPKkan.'',$Template);
		$Template = str_replace("#tglCetak#",''.$tglCetak.'',$Template);
		$Template = str_replace("#hariCetak#",''.$hariCetak.'',$Template);
		$Template = str_replace("#jenisPihak#",''.$jenisPihak.'',$Template);

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