<?php
$jursitLbl = intval($jursitLbl);
$jurusita=intval($jurusita);

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

$url = base_url("resources/template/relaas/pidana_pra/".$filename.".rtf");
$Template = file_get_contents($url);
//=============================================roby======================================================
$perkara = $data_template;
$itunganPerkara = count($perkara);
foreach ($perkara->result() as $perkara) {                
			$nomorPerkara = $perkara->nomor_perkara;
			$namaPN =  $this->templatehelper->standradnaming($perkara->nmPengadilan);
			$alamatPengadilan =  $this->templatehelper->standradnaming($perkara->alamatPengadilan);
			$sidang_pertama = $this->templatehelper->convertKeTglIndo($perkara->sidang_pertama);
			$hariSidang = $this->templatehelper->getHari($perkara->sidang_pertama);
			$jamSidangx = $perkara->jamSidang;
			$jurusita_id = $perkara->jurusita_id;
			$jurusita_nama =  $this->templatehelper->standradnaming($perkara->jurusita_nama);
			$pihak_id = $perkara->pihak_id;
			$namaP =  $this->templatehelper->standradnaming($perkara->nama);
			$hours = explode(":",$jamSidangx);
			$hh = $hours['0'];
			$mm = $hours['1'];
			$jamSidang = $hh.":".$mm;
 }

//==============================================================================//
if($itunganPerkara==1){
    $jenPemohon = "Pemohon";
} else {
    $jenPemohon = "Para Pemohon";
}

if($jursitLbl==1){
    $jursitLbl = "Jurusita";
} else {
    $jursitLbl = "Jurusita Pengganti";
}

		$Template = str_replace("#nomorperkara#",''.$nomorPerkara.'',$Template);
		$Template = str_replace("#namaPN#",''.$namaPN.'',$Template);
		$Template = str_replace("#alamatPengadilan#",''.$alamatPengadilan.'',$Template);
		$Template = str_replace("#alamatPengadilan#",''.$alamatPengadilan.'',$Template);
		$Template = str_replace("#sidang_pertama#",''.$sidang_pertama.'',$Template);
		$Template = str_replace("#hariSidang#",''.$hariSidang.'',$Template);
		$Template = str_replace("#jamSidang#",''.$jamSidang.'',$Template);
		$Template = str_replace("#jurusita_nama#",''.$jurusita_nama.'',$Template);
		$Template = str_replace("#namaP#",''.$namaP.'',$Template);
		$Template = str_replace("#jenPemohon#",''.$jenPemohon.'',$Template);
		$Template = str_replace("#jursitLbl#",''.$jursitLbl.'',$Template);

header("Content-Type: application/vnd.ms-word");
header("Expires: 0");
header("Cache-Control:  must-revalidate, post-check=0, pre-check=0");
header("Content-disposition: attachment; filename=\"".$namafile."-".$nomorPerkara.".rtf\"");
header("Content-length: ".strlen($Template));
echo $Template;
?>