<?php
if($this->session->userdata('is_logged_in')===FALSE){
            redirect('login');
}
$jenisAkta=intval($jenisAkta);
if(!is_numeric($jenisAkta)){
    show_404();
    exit();
}

$kasasiTerhadap=intval($kasasiTerhadap);
if(!is_numeric($kasasiTerhadap)){
    show_404();
    exit();
}
$tglPenyerahanKontra=$tglPenyerahanKontra;
$tglPenerimaanKontra=$tglPenerimaanKontra;

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

$url = base_url("resources/template/relaas/pidana_umum/".$filename.".rtf");
$Template = file_get_contents($url);
//------------------------------------------------------------------------//
function cetakPihak(&$strbuf, $tmp_label, $arrDef, $hasilFetch, $cetakLabel = true){
    $tblcnt = 1;
    $jmlphk = count($hasilFetch);
    foreach($hasilFetch as $baris){
        $idxKolom = 1;
        foreach($arrDef as $kolomTabel => $label){
            $counter = (($jmlphk > 1)?($tblcnt.'.'):(''));
            $strbuf = str_replace($tmp_label,
                    (($idxKolom == 1)?($counter):('')).
                        ' \tab '.(($cetakLabel)?$label:('')).(($cetakLabel)?(' \tab : \tab '):('')).$baris[$kolomTabel].'; \\par'.
                        PHP_EOL.
                        //$tmp_label,
                        (($idxKolom < count($arrDef)) ? 
                            ($tmp_label) 
                            :  
                            (($tblcnt<$jmlphk)?($tmp_label):('')) 
                        ),
                    $strbuf);
            $idxKolom++;
        }
        $tblcnt++;
    }
}
//-------------Nomor Perkara & Tanggal Pemerbitahuan----------------------//
$data_perkara = $dataPerkara;
$nomorperkara = '';
foreach ($data_perkara->result() as $row) {
        $nomorperkara = $row->nomor_perkara;
    }
$Template = str_replace("#nomorperkara#",''.$nomorperkara.'',$Template);
//---------------Data Pengadilan--------------------//
$datapengadilan = $dataPN;
$namapn = '';
foreach ($datapengadilan->result() as $row) {
    $namapn = $this->templatehelper->standradnaming($row->NamaPN);
    $namakota =str_replace("Pengadilan Negeri ",'',$namapn);
    $nama_pt = $this->templatehelper->standradnaming($row->NamaPT);     
}

$Template = str_replace('#nama_pn#',''.$namapn.'',$Template);
$Template = str_replace('#namakota#',''.$namakota.'',$Template);
$Template = str_replace('#namapt#',''.$nama_pt.'',$Template);
//----------------Data Jurusita--------------------//
$namajurusita=$cetakJurusita;
foreach ($namajurusita->result() as $row) {
	$namajurusita = $this->templatehelper->standradnaming($row->nama_gelar);
}
$Template = str_replace('#namajurusita#',''.$namajurusita.'',$Template);
//-------------Print Data Jaksa----------------//
if(($jenisAkta==1)||($jenisAkta==4)||($jenisAkta==5)||($jenisAkta==8)){	
	$infoJaksa=$cetakJaksa;
	foreach ($infoJaksa->result() as $row) {
		$namaJaksa=$this->templatehelper->standradnaming($row->nama);
		$nip=($row->NIP);
		$jabatanJaksa=($row->jabatan);
	}	
	if(empty($namaJaksa)){$namaJaksa='...................';}
	if(empty($nip)){$nip='...................';}
	if(empty($jabatanJaksa)){$jabatanJaksa='...................';}
	$Template = str_replace('#jaksa#',''.$namaJaksa.'',$Template);
	$Template = str_replace('#NIP#',''.$nip.'',$Template);
	$Template = str_replace('#jabatan#',''.$jabatanJaksa.'',$Template);
	//--------------Data Terdakwa Parties----------------//
	$dataAllTerdakwa = $cetakAllTerdakwaKasasi;
    $tblcnt = 1;
    $dataAllTerdakwa->num_rows>0;
    $p = array();
    $gkolom = array(
        'nama' => 'Nama Lengkap',
        'tempat_lahir' => 'Tempat Lahir',
        'umur' => 'Umur / Tgl. Lahir',
        'jenis_kelamin' => 'Jenis Kelamin',
        'warga_negara' => 'Kebangsaan',
        'alamat' => 'Tempat Tinggal',
        'agama' => 'Agama',
        'pekerjaan' => 'Pekerjaan'
        );
    foreach ($dataAllTerdakwa->result() as $row){      	
        $inpass = array();
        if(empty($row->nama)){
            $row->nama = '......'; 
        }
        $namaterdakwa = $this->templatehelper->standradnaming($row->nama);
        $inpass['nama'] = $namaterdakwa;

        if(empty($row->tempat_lahir)){
            $row->tempat_lahir = '......'; 
        }
        $tempatlahir = $row->tempat_lahir;
        $inpass['tempat_lahir'] = $tempatlahir;

        if(empty($row->tanggal_lahir)){
            $tgllahir = '......'; 
        }else{
            $tgllahir = $this->templatehelper->convertKeTglIndo($row->tanggal_lahir);
            $umure = $this->tanggalhelper->getSelisihTahun($row->tanggal_lahir,date('Y-m-d'));
        }        
        $inpass['umur'] = $umure.' / '.$tgllahir;

        if(empty($row->warga_negara)){
            $row->warga_negara = '......'; 
        }
        $kebangsaan = $this->templatehelper->standradnaming($row->warga_negara);
        $inpass['warga_negara'] = $kebangsaan;

        if(empty($row->alamat)){
            $row['alamat'] = '......'; 
        }
        $alamat = $row->alamat;
        $inpass['alamat'] = $alamat;

        if(empty($row->agama_nama)){
            $row->agama_nama = '......'; 
        }
        $agama = $this->templatehelper->standradnaming($row->agama_nama);
        $inpass['agama'] = $agama;
        
        if(empty($row->pekerjaan)){
            $row->pekerjaan = '......'; 
        }
        $pekerjaan = $this->templatehelper->standradnaming($row->pekerjaan);     
        $inpass['pekerjaan'] = $pekerjaan;

        if($row->jenis_kelamin=='L'){
            $row->jenis_kelamin = 'Laki - Laki';
        }elseif($row->jenis_kelamin=='P'){
            $row->jenis_kelamin = 'Perempuan';
        }
        $sex = $row->jenis_kelamin;
        $inpass['jenis_kelamin'] = $sex;
        
        $tblcnt++;
        $p[] = $inpass;
    }
    cetakPihak($Template, '#terdakwaparties#', $gkolom, $p);
    if ($dataAllTerdakwa->num_rows>1) {
        $Template = str_replace('#jmlTerdakwa#','Para Terdakwa',$Template);
    } else {
        $Template = str_replace('#jmlTerdakwa#','Terdakwa',$Template);
    }
    //---------------Tgl Permohonan Kasasi----------------------//
    $cetakTanggalKasasi=$cetakTglPermohonanKasasi;
    foreach ($cetakTanggalKasasi->result() as $row) {
    	$tglkasasi=$this->templatehelper->convertKeTglIndo($row->tglKasasi);
    	$tglmemorikasasi=$this->templatehelper->convertKeTglIndo($row->penerimaan_memori_kasasi);
    }
    if(empty($tglkasasi)){
    	$tglkasasi='...................';
    	$harikasasi='...................';
    }
    if(empty($tglmemorikasasi)){$tglmemorikasasi='..................';}
    $harikasasi=$this->templatehelper->getHari($tglkasasi);
    $Template = str_replace('#tglkasasi#',''.$tglkasasi.'',$Template);
    $Template = str_replace('#harikasasi#',''.$harikasasi.'',$Template);
    $Template = str_replace('#tglmemorikasasi#',''.$tglmemorikasasi.'',$Template);
    //----------------Tgl Pemberitahuan Kasasi-------------------//    
    if(empty($tglpenyerahan)){
    	$pemberitahuanKasasiPenuntut='.................';
    	$haripemberitahuanKasasiPenuntut='..................';
    }else{
        $pemberitahuanKasasiPenuntut=$this->templatehelper->convertKeTglIndo($tglpenyerahan);
        $haripemberitahuanKasasiPenuntut=$this->templatehelper->getHari($tglpenyerahan);
    }
    
    $Template = str_replace('#tglpemberitahuan#',''.$pemberitahuanKasasiPenuntut.'',$Template);
    $Template = str_replace('#haripemberitahuan#',''.$haripemberitahuanKasasiPenuntut.'',$Template);
    if($kasasiTerhadap==1){
		$Template = str_replace('#nomorperkarapn/pt#',$nomorperkara,$Template);
		$Template = str_replace('#namapt/namapn#',''.$this->templatehelper->standradnaming($namapn).'',$Template);
	}elseif($kasasiTerhadap==2){
		$nomorBanding = $nobanding;
		foreach ($nomorBanding->result() as $row) {
			$nomorBanding=($row->nomor_perkara_banding);
		}
		if(empty($nomorBanding)){$nomorBanding='...................';}
		$Template = str_replace('#nomorperkarapn/pt#',$nomorBanding,$Template);
		$Template = str_replace('#namapt/namapn#',''.$this->templatehelper->standradnaming($nama_pt).'',$Template);
	}
	$tanggalPutusan=$tanggalPutus;	
	foreach ($tanggalPutusan->result() as $row) {
	    	if($kasasiTerhadap==1){
				$tglputusan=$this->templatehelper->convertKeTglIndo($row->putusan_pn);
			}elseif($kasasiTerhadap==2){
				$tglputusan=$this->templatehelper->convertKeTglIndo($row->putusan_banding);
			}
	}
	if(empty($tglputusan)){$tglputusan='...................';}    
    $Template = str_replace('#tglputus#',$tglputusan,$Template);
    if(empty($tglpenyerahan)){
        $inputtglmemori = '.................';
        $hariinputmemori = '.................';
    }else{
        $inputtglmemori = $this->templatehelper->convertKeTglIndo($tglpenyerahan);
        $hariinputmemori = $this->templatehelper->getHari($tglpenyerahan);
    }
    $Template = str_replace('#tglpenyerahan#',''.$inputtglmemori.'',$Template);
    $Template = str_replace('#haripenyerahan#',''.$hariinputmemori.'',$Template);
    #Data Terdakwa
	$tampilAllTerdakwa=$allTerdakwa;
	$cnt = $tampilAllTerdakwa->num_rows;
	$pihak_nama ='';	
	foreach ($tampilAllTerdakwa->result() as $row){		
		$pihak_nama =$this->templatehelper->standradnaming($row->nama);		
	}
	if($cnt>1){
		$Template = str_replace('#namaterdakwadkk#',''.$pihak_nama.' dkk',$Template);
		$Template = str_replace('#jmterdakwa#','Para Terdakwa',$Template);
	}else{
		$Template = str_replace('#namaterdakwadkk#',''.$pihak_nama.'',$Template);
		$Template = str_replace('#jmterdakwa#','Terdakwa',$Template);
	}
	//---------------Data Pemberitahuan Putusan Kasasi-------------------//	
	if(empty($tglpenyerahan)){
		$tglPemberitahuanKasasiPU='...................';
		$hariPemberitahuanKasasiPU='...................';
	}else{
        $tglPemberitahuanKasasiPU=$this->templatehelper->convertKeTglIndo($tglpenyerahan);
        $hariPemberitahuanKasasiPU=$this->templatehelper->getHari($tglpenyerahan);
    }
	
	$Template = str_replace("#tglPemberitahuanKasasiPU#",''.$tglPemberitahuanKasasiPU.'',$Template);
	$Template = str_replace("#hariPemberitahuanKasasiPU#",''.$hariPemberitahuanKasasiPU.'',$Template);

}
//-----------------Data Terdakwa---------------------------//
if(($jenisAkta==2)||($jenisAkta==3)||($jenisAkta==6)||($jenisAkta==9)){
	$dataterdakwa = $cetakAllTerdakwa;
    foreach ($dataterdakwa->result() as $row){
        if(empty($row->nama)){
            $row->nama = '......'; 
        }
        $namaterdakwa = '\listid1 '.$this->templatehelper->standradnaming($row->nama);

        if(empty($row->tempat_lahir)){
            $row->tempat_lahir = '......'; 
        }
        $tempatlahir = '\listid1 '.$row->tempat_lahir;

        if(empty($row->tanggal_lahir)){
            $tgllahir = '......'; 
            $umur = '......';
        }else{
            $tgllahir = '\listid1 '.$this->templatehelper->convertKeTglIndo($row->tanggal_lahir);
            $umur = '\listid1 '.$this->tanggalhelper->getSelisihTahun($row->tanggal_lahir,date('Y-m-d'));
        } 

        if(empty($row->warga_negara)){
            $row->warga_negara = '......'; 
        }
        $kebangsaan = '\listid1 '.$this->templatehelper->standradnaming($row->warga_negara);

        if(empty($row->alamat)){
            $row->alamat = '......'; 
        }
        $alamat = '\listid1 '.$this->templatehelper->standradnaming($row->alamat);

        if(empty($row->agama_nama)){
            $row->agama_nama = '......'; 
        }
        $agama = '\listid1 '.$this->templatehelper->standradnaming($row->agama_nama);
        
        if(empty($row->pekerjaan)){
            $row->pekerjaan = '......'; 
        }
        $pekerjaan = '\listid1 '.$this->templatehelper->standradnaming($row->pekerjaan);
        
        if($row->jenis_kelamin=='L'){
            $row->jenis_kelamin = 'Laki - Laki';
        }elseif($row->jenis_kelamin=='P'){
            $row->jenis_kelamin = 'Perempuan';
        }
        $sex = '\listid1 '.$row->jenis_kelamin;
    }
    $Template = str_replace('#namaterdakwa#',''.$namaterdakwa.'',$Template);
    $Template = str_replace('#tempatlahir#',''.$tempatlahir.'',$Template);
    $Template = str_replace('#umur#',''.$umur.'',$Template);
    $Template = str_replace('#tgllahir#',''.$tgllahir.'',$Template);
    $Template = str_replace('#kebangsaan#',''.$kebangsaan.'',$Template);
    $Template = str_replace('#alamat#',''.$alamat.'',$Template);
    $Template = str_replace('#agama#',''.$agama.'',$Template);
    $Template = str_replace('#pekerjaan#',''.$pekerjaan.'',$Template);
    $Template = str_replace('#jeniskelamin#',''.$sex.'',$Template);
    //--------------Data Jaksa Parties-----------------------------//
    $dataJaksa = $cetakPartiesJaksa;
    $tblcnt2 = 1;
    $dataJaksa->num_rows>0;    
    $p2 = array();
    $gkolom2 = array(
        'nama' => 'Nama lengkap',
		'nip' => 'NIP',
		'jabatan' => 'Jabatan'
        );
    foreach ($dataJaksa->result() as $row){    	
        $inpass = array();
        if(empty($row->nama)){
            $row->nama = '......'; 
        }
        $namajaksa = $this->templatehelper->standradnaming($row->nama);
        $inpass['nama'] = $namajaksa;        

        if(empty($row->NIP)){
            $row->NIP = '......'; 
        }
        $nip = $row->NIP;
        $inpass['nip'] = $nip;        
        
        if(empty($row->pekerjaan)){
            $row->pekerjaan = '......'; 
        }
        $pekerjaan = $this->templatehelper->standradnaming($row->pekerjaan);     
        $inpass['jabatan'] = $pekerjaan;        
        
        $tblcnt2++;

        $p2[] = $inpass;
    }
    cetakPihak($Template, '#jaksaparties#', $gkolom2, $p2);
    //---------------Tgl Permohonan Kasasi----------------------//
    $cetakTanggalKasasi=$cetakTglPermohonanKasasi;
    foreach ($cetakTanggalKasasi->result() as $row) {
    	$tglkasasi=$this->templatehelper->convertKeTglIndo($row->tglKasasi);
    	$tglmemorikasasi=$this->templatehelper->convertKeTglIndo($row->penerimaan_memori_kasasi);
    }
    if(empty($tglkasasi)){
    	$tglkasasi='...................';
    	$harikasasi='...................';
    }
    if(empty($tglmemorikasasi)){$tglmemorikasasi='..................';}
    $harikasasi=$this->templatehelper->getHari($tglkasasi);
    $Template = str_replace('#tglkasasi#',''.$tglkasasi.'',$Template);
    $Template = str_replace('#harikasasi#',''.$harikasasi.'',$Template);
    $Template = str_replace('#tglmemorikasasi#',''.$tglmemorikasasi.'',$Template);
    //----------------Tgl Pemberitahuan Kasasi-------------------//    
    if(empty($tglpenyerahan)){
    	$pemberitahuanKasasiT='.................';
    	$haripemberitahuanKasasiT='..................';
    }else{
        $pemberitahuanKasasiT=$this->templatehelper->convertKeTglIndo($tglpenyerahan);
        $haripemberitahuanKasasiT=$this->templatehelper->getHari($tglpenyerahan);
    }
    
    $Template = str_replace('#tglpemberitahuan#',''.$pemberitahuanKasasiT.'',$Template);
    $Template = str_replace('#haripemberitahuan#',''.$haripemberitahuanKasasiT.'',$Template);
    if($kasasiTerhadap==1){
		$Template = str_replace('#nomorperkarapn/pt#',$nomorperkara,$Template);
		$Template = str_replace('#namapt/namapn#',''.$this->templatehelper->standradnaming($namapn).'',$Template);
	}elseif($kasasiTerhadap==2){
		$nomorBanding = $nobanding;
		foreach ($nomorBanding->result() as $row) {
			$nomorBanding=($row->nomor_perkara_banding);
	}
	if(empty($nomorBanding)){$nomorBanding='...................';}
	$Template = str_replace('#nomorperkarapn/pt#',$nomorBanding,$Template);
	$Template = str_replace('#namapt/namapn#',''.$this->templatehelper->standradnaming($nama_pt).'',$Template);
	}
	$tanggalPutusan=$tanggalPutus;	
	foreach ($tanggalPutusan->result() as $row) {
	    	if($kasasiTerhadap==1){
				$tglputusan=$this->templatehelper->convertKeTglIndo($row->putusan_pn);
			}elseif($kasasiTerhadap==2){
				$tglputusan=$this->templatehelper->convertKeTglIndo($row->putusan_banding);
			}
	}
	if(empty($tglputusan)){$tglputusan='...................';}    
    $Template = str_replace('#tglputus#',$tglputusan,$Template);
    if(empty($tglpenyerahan)){
        $tanggalserah = '...................';
        $hariserah = '...................';
    }else{
        $tanggalserah = $this->templatehelper->convertKeTglIndo($tglpenyerahan);
        $hariserah = $this->templatehelper->getHari($tglpenyerahan);
    }
    $Template = str_replace('#tglpenyerahan#',''.$tanggalserah.'',$Template);
    $Template = str_replace('#haripenyerahan#',''.$hariserah.'',$Template);
    //---------------Data Pemberitahuan Putusan Kasasi-------------------//	
	if(empty($tglpenyerahan)){
		$tglPemberitahuanKasasiT='...................';
		$hariPemberitahuanKasasiT='...................';
	}else{
        $tglPemberitahuanKasasiT=$this->templatehelper->convertKeTglIndo($tglpenyerahan);
        $hariPemberitahuanKasasiT=$this->templatehelper->getHari($tglpenyerahan);
    }
	$Template = str_replace("#tglPemberitahuanKasasiT#",''.$tglPemberitahuanKasasiT.'',$Template);
	$Template = str_replace("#hariPemberitahuanKasasiT#",''.$hariPemberitahuanKasasiT.'',$Template);
	//---------------Data All Terdakwa--------------//
	$tampilAllTerdakwa=$allTerdakwa;
	$cnt = $tampilAllTerdakwa->num_rows;
	$pihak_nama ='';	
	foreach ($tampilAllTerdakwa->result() as $row){		
		$pihak_nama =$this->templatehelper->standradnaming($row->nama);		
	}
	if($cnt>1){
		$Template = str_replace('#namaterdakwadkk#',''.$pihak_nama.' dkk',$Template);
		$Template = str_replace('#jmterdakwa#','Para Terdakwa',$Template);
	}else{
		$Template = str_replace('#namaterdakwadkk#',''.$pihak_nama.'',$Template);
		$Template = str_replace('#jmterdakwa#','Terdakwa',$Template);
	}
}
//-----------Data Pemohon------------------//
if($jenisAkta==7){	
	$dataPemohon = $cetakAllPemohon;
    foreach ($dataPemohon->result() as $row){
    	$namapemohon = $this->templatehelper->standradnaming($row->nama);
		$alamatpemohon = $this->templatehelper->standradnaming($row->alamat);
		$pekerjaanpemohon = $row->pekerjaan;
	}
	$Template = str_replace('#namapemohon#',''.$namapemohon.'',$Template);
	$Template = str_replace('#alamatpemohon#',''.$alamatpemohon.'',$Template);
	$Template = str_replace('#pekerjaanpemohon#',''.$pekerjaanpemohon.'',$Template); 

	//-----------Data Termohon-----------------//
	$dataTermohon = $cetakAllTermohon;	
	foreach($dataTermohon->result() as $row){
		$namatermohon = $this->templatehelper->standradnaming($row->nama);
		$alamattermohon = ($row->alamat);
		$pekerjaantermohon = ($row->pekerjaan);
	}
	$Template = str_replace('#namatermohon#',''.$namatermohon.'',$Template);
	$Template = str_replace('#alamattermohon#',''.$alamattermohon.'',$Template);
	$Template = str_replace('#pekerjaantermohon#',''.$pekerjaantermohon.'',$Template);          
    
    #Data Terdakwa
	$tampilAllTerdakwa=$allTerdakwa;
	$cnt = $tampilAllTerdakwa->num_rows;
	$pihak_nama ='';	
	foreach ($tampilAllTerdakwa->result() as $row){		
		$pihak_nama =$this->templatehelper->standradnaming($row->nama);		
	}
	if($cnt>1){
		$Template = str_replace('#namaterdakwadkk#',''.$pihak_nama.' dkk',$Template);
	}else{
		$Template = str_replace('#namaterdakwadkk#',''.$pihak_nama.'',$Template);
	}		
	$Template = str_replace("#tglpenyerahankontramemori#",''.$this->templatehelper->convertKeTglIndo($tglPenyerahanKontra).'',$Template);
	$Template = str_replace("#haripenyerahankontramemori#",''.$this->templatehelper->getHari($tglPenyerahanKontra).'',$Template);
	$Template = str_replace("#tglpenerimaankontramemori#",''.$this->templatehelper->convertKeTglIndo($tglPenerimaanKontra).'',$Template);

	if($kasasiTerhadap==1){
		$Template = str_replace('#nomorperkarapn/pt#',$nomorperkara,$Template);
		$Template = str_replace('#namapt/namapn#',''.$this->templatehelper->standradnaming($namapn).'',$Template);
	}elseif($kasasiTerhadap==2){
		$nomorBanding = $nobanding;
		foreach ($nomorBanding->result() as $row) {
			$nomorBanding=($row->nomor_perkara_banding);
	}
	if(empty($nomorBanding)){$nomorBanding='...................';}
	$Template = str_replace('#nomorperkarapn/pt#',$nomorBanding,$Template);
	$Template = str_replace('#namapt/namapn#',''.$this->templatehelper->standradnaming($nama_pt).'',$Template);
	}
	$tanggalPutusan=$tanggalPutus;	
	foreach ($tanggalPutusan->result() as $row) {
	    	if($kasasiTerhadap==1){
				$tglputusan=$this->templatehelper->convertKeTglIndo($row->putusan_pn);
			}elseif($kasasiTerhadap==2){
				$tglputusan=$this->templatehelper->convertKeTglIndo($row->putusan_banding);
			}
	}
	if(empty($tglputusan)){$tglputusan='...................';}    
    $Template = str_replace('#tglputus#',$tglputusan,$Template);
}
//----------------Data Kasasi di MA------------------//
if(($jenisAkta==8)||($jenisAkta==9)){	
	$dataMA=$cetakKasasiMA;
    foreach ($dataMA->result() as $row) {
			$nomorPerkaraMA=($row->nomor_perkara_kasasi);
			$tglPutusMA=$this->templatehelper->convertKeTglIndo($row->tglPutusanKasasi);
			$amarPutusanMA=$this->templatehelper->cleanHtmlTag($row->amar_putusan_kasasi);	
	}
	if(empty($nomorPerkaraMA)){$nomorPerkaraMA = '..................';}
	if(empty($tglPutusMA)){$tglPutusMA = '..................';}
	if(empty($amarPutusanMA)){$amarPutusanMA = '-Isi Amar Putusan Banding PT-';}
	$Template = str_replace("#nomorkasasi#",''.$nomorPerkaraMA.'',$Template);
	$Template = str_replace("#tglputuskasasi#",''.$tglPutusMA.'',$Template);
	$Template = str_replace("#amarkasasi#",''.$amarPutusanMA.'',$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;
?>