<?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;
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;
			$namaPihak = $this->templatehelper->standradnaming($perkara->namaPihak);
			$alamatPihak = $this->templatehelper->standradnaming($perkara->alamatPihak);
			$agamaPihak = $perkara->agamaPihak;
			$pekerjaanPihak = $this->templatehelper->standradnaming($perkara->pekerjaanPihak);
			$pendidikanPihak = $perkara->pendidikanPihak;
			$negaraPihak = $perkara->negaraPihak;
			$kelaminPihak = $perkara->kelaminPihak;
			//$umurPihak = $perkara->umurPihak;
			$umurPihak = $this->tanggalhelper->getSelisihTahun($perkara->tanggalLahirPihak,date('Y-m-d'));
			$tempatLahirPihak = $perkara->tempatLahirPihak;
			$tanggalLahirPihak = $this->templatehelper->convertKeTglIndo($perkara->tanggalLahirPihak);
			$namaPN = $this->templatehelper->standradnaming($perkara->namaPengadilan);
			$namaPanitera = $this->templatehelper->standradnaming($perkara->pw);
			$tahapan = $this->templatehelper->standradnaming($perkara->Tahapan);
			$noPerkaraTahapan = $this->templatehelper->standradnaming($perkara->nomorPerkaraTahapan);
			$tglPutusTahapan = $this->templatehelper->convertKeTglIndo($perkara->putusan);
			$statusPanitera = $this->templatehelper->standradnaming($perkara->pejabat);
			$tglpermohonan_kasasi = $this->templatehelper->convertKeTglIndo($perkara->permohonan_kasasi);
			$hariPermohonanKasasi = $this->templatehelper->getHari($perkara->permohonan_kasasi);
 }

//==============================================================================//
#Insert Into Dokumen#
$Template = str_replace('#nomorpermohonan#',''.$nomorPermohonan.'',$Template);
$Template = str_replace('#namapanitera#',''.$namaPanitera.'',$Template);
$Template = str_replace('#namapn#',''.$namaPN.'',$Template);
$Template = str_replace('#namapihak#',''.$namaPihak.'',$Template);
$Template = str_replace('#tempatlahirpihak#',''.$tempatLahirPihak.'',$Template);
$Template = str_replace('#umurpihak#',''.$umurPihak.'',$Template);
$Template = str_replace('#tanggallahirpihak#',''.$tanggalLahirPihak.'',$Template);
$Template = str_replace('#kelaminpihak#',''.$kelaminPihak.'',$Template);
$Template = str_replace('#negarapihak#',''.$negaraPihak.'',$Template);
$Template = str_replace('#alamatpihak#',''.$alamatPihak.'',$Template);
$Template = str_replace('#agamapihak#',''.$agamaPihak.'',$Template);
$Template = str_replace('#pekerjaanpihak#',''.$pekerjaanPihak.'',$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('#tanggalkasasi#',''.$tglpermohonan_kasasi.'',$Template);
$Template = str_replace('#harikasasi#',''.$hariPermohonanKasasi.'',$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\"");
echo $Template;
?>