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

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

$url = base_url("resources/template/akta/pidana_umum/".$filename.".rtf");

$Template = file_get_contents($url);
//=============================================roby======================================================
$perkara = $dataTemplate;
$itunganPerkara = count($perkara);

$terpidana = array();
foreach ($perkara->result() as $perkara) {
			$nomorPerkara = $perkara->nomor_perkara;
			$no = explode("/",$perkara->nomor_perkara);
			$nomor = $no[0];
			$kodePerkara = $no[1];
			$tahunPerkara = $no[2];
			$kodePN = $no[3];
			$nomorPermohonan = $nomor."/Akta ".$kodePerkara."/".$tahunPerkara."/".$kodePN;
			$namaPN = $this->templatehelper->standradnaming($perkara->namaPengadilan);
			$namaPanitera = $this->templatehelper->standradnaming($perkara->pw);
			$tahapan = $perkara->Tahapan;
			$noPerkaraTahapan = $this->templatehelper->standradnaming($perkara->nomorPerkaraTahapan);
			$tglPutusTahapan = $this->templatehelper->convertKeTglIndo($perkara->putusan);
			$statusPanitera = $this->templatehelper->standradnaming($perkara->pejabat);
			$tglpermohonan_pk = $this->templatehelper->convertKeTglIndo($perkara->permohonan_pk);
			$pengacara = $this->templatehelper->convertKeTglIndo($perkara->pihak_nama);
			//pihak_nama
 }

//==============================================================================//
#Insert Into Dokumen#
$jaksa = $infoDataJaksaPK;
foreach ($jaksa->result() as $rows) {
	$namaJaksa = $this->templatehelper->standradnaming($rows->nama);
	$nipJaksa = $rows->NIP;
	$pekerjaan = $this->templatehelper->standradnaming($rows->pekerjaan);
	$kejaksaan = $this->templatehelper->standradnaming($rows->kejaksaan);
}

	$Template = str_replace('#nomorpermohonan#',''.$nomorPermohonan.'',$Template);
	$Template = str_replace('#namapanitera#',''.$namaPanitera.'',$Template);
	$Template = str_replace('#namapn#',''.$namaPN.'',$Template);
	$Template = str_replace('#jenisputusan#',''.$tahapan.'',$Template);
	$Template = str_replace('#nomorputusan#',''.$noPerkaraTahapan.'',$Template);
	$Template = str_replace('#tanggalputusan#',''.$tglPutusTahapan.'',$Template);
	$Template = str_replace('#statuspanitera#',''.$statusPanitera.'',$Template);
	$Template = str_replace('#tanggalpk#',''.$tglpermohonan_pk.'',$Template);
	$Template = str_replace('#haripk#',''.$this->templatehelper->getHari($perkara->permohonan_pk).'',$Template);
	$Template = str_replace('#pengacara#',''.$pengacara.'',$Template);
	$Template = str_replace('#namajaksa#',''.$namaJaksa.'',$Template);
	$Template = str_replace('#nipjaksa#',''.$nipJaksa.'',$Template);
	$Template = str_replace('#pekerjaan#',''.$pekerjaan.'',$Template);
	$Template = str_replace('#kejaksaan#',''.$kejaksaan.'',$Template);


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