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

$jenisAkta=intval($jenisAkta);
if(!is_numeric($jenisAkta)){
    show_404();
    exit();
}
$penandatangan=$this->encrypt->decode(base64_decode($penandatangan));
$penandatangan=intval($penandatangan);
if(!is_numeric($penandatangan)){
    show_404();
    exit();
}
//$tglBanding=$tglBanding;
$bandingMelalui=intval($bandingMelalui);
if(!is_numeric($bandingMelalui)){
    show_404();
    exit();
}
foreach ($template->result() as $template)
{
    $filename=$template->kdtemplate;
    $namafile=str_replace(" ","",$template->namatemplate);
}
$url = base_url("resources/template/akta/pidana_militer/".$filename.".rtf");
$Template = file_get_contents($url);
//--------------MULAI--------------------------------------------//
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----------------------//
$data_perkara = $dataPerkara;
$nomorperkara = '';
foreach ($data_perkara->result() as $row) {
        $nomorperkara = $row->nomor_perkara;
    }
if(empty($nomorperkara)){ $nomorperkara = '........'; }
$akta="Akta ";
$nomorperkarabaru=substr_replace($nomorperkara, $akta, 
    strpos($nomorperkara,'/')+1, 
    0);
$Template = str_replace("#nomorperkarabaru#",''.$nomorperkarabaru.'',$Template);
$Template = str_replace("#nomorperkara#",''.$nomorperkara.'',$Template);
//---------------Tanggal/Hari Banding-------------//
$tglpermohonan = $tglBanding;

if(empty($tglpermohonan)){
    $tglpermohonan = '..................';
    $haripermohonan = '.................';
}else{
    $haripermohonan = $this->templatehelper->getHari($tglpermohonan);
}
$Template = str_replace("#tglpermohonan#",''.$this->templatehelper->convertKeTglIndo($tglpermohonan).'',$Template);
$Template = str_replace("#haripermohonan#",''.$haripermohonan.'',$Template);

$Template = str_replace('#terdakwajudul#','TERDAKWA',$Template);
$Template = str_replace('#jmlterdakwa#','Terdakwa',$Template);

if(($bandingMelalui==1)||($bandingMelalui==10)) {    
    $Template = str_replace('#judul#','KALAPAS',$Template);
    $Template = str_replace('#tahanan#','Kepala Lembaga Pemasyarakatan',$Template);
}else if ($bandingMelalui==2) {
    $Template = str_replace('#judul#','KARUTAN',$Template);
    $Template = str_replace('#tahanan#','Rumah Tahanan Negara',$Template);
}
//---------------Data Pengadilan--------------------//
$datapengadilan = $dataPN;
$namapn = '';
$pansek = '';
foreach ($datapengadilan->result() as $row) {
    $namapn = $this->templatehelper->standradnaming($row->NamaPN);
    $namakota =str_replace("Pengadilan Negeri ",'',$namapn);
    $pansek = $this->templatehelper->standradnaming($row->Panses);   
    $wapan = $this->templatehelper->standradnaming($row->Wapan); 
}
if(empty($namapn)){ $namapn = '........'; }
if($penandatangan==68){    
    $Template = str_replace('#pansek#',''.$pansek.'',$Template);
    $Template = str_replace('#jabatan#','Panitera',$Template);
} else if($penandatangan==70){
    $Template = str_replace('#pansek#',''.$wapan.'',$Template);
    $Template = str_replace('#jabatan#','a.n. Panitera',$Template);
}
$Template = str_replace('#namapn#',''.$namapn.'',$Template);
$Template = str_replace('#namakota#',''.$namakota.'',$Template);
//-------------Data Tanggal Putusan-------------------//
$tanggalPutusan=$tanggalPutus;
foreach ($tanggalPutusan->result() as $row) {
    $tglputus=$this->templatehelper->convertKeTglIndo($row->tanggal_putusan);
}
$Template = str_replace('#tglputus#',''.$tglputus.'',$Template);
//-------------Data Terdakwa-------------------------//
//print_r($dataTemplate2->result());
//gagal
$datazTemplate = $dataTemplate2;
foreach ($datazTemplate->result() as $rowz) {
 $noregband = $rowz->nomor_perkara; 
}

if(($jenisAkta==1) || ($jenisAkta==2) || ($jenisAkta==5) || ($jenisAkta==6) || ($jenisAkta==9) || ($jenisAkta==10)){
    $loopingTerdakwa = $cetakDataTerdakwa;
    foreach ($loopingTerdakwa->result() as $row){
        if(empty($row->nama)){
            $row->nama = '......'; 
        }

        $namaterdakwa = '\listid1 '.$this->templatehelper->standradnaming($row->nama);    
        $pangkatband = $row->pangkat; 
        $nrpband = $row->nrp; 
        $kesatuanband = $row->kesatuan; 
        $jabatanband = $row->jabatan; 
        $namaband = $row->nama; 

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

        $tempatlahir = '\listid1 '.$row->tempat_lahir;

        if(empty($row->umur)){
            $tgllahir = '......'; 
        }else{
            $tgllahir = '\listid1 '.$this->templatehelper->convertKeTglIndo($row->tanggal_lahir);
        }

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

        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); 
    $Template = str_replace('#pangkat_korp_terdakwa#',''.$pangkatband.'',$Template);
    $Template = str_replace('#nrp_terdakwa#',''.$nrpband.'',$Template); 
    $Template = str_replace('#kesatuan_terdakwa#',''.$kesatuanband.'',$Template); 
    $Template = str_replace('#jabatan_terdakwa#',''.$jabatanband.'',$Template);
    //$Template = str_replace('#no_register#',''.$noregband.'',$Template); 
}
if(($jenisAkta==3)||($jenisAkta==7)||($jenisAkta==11)){
    $dataterdakwa = $cetakpartiesbanding;
    $tblcnt = 1;
    $dataterdakwa->num_rows>0;
    //$jmltdkw = count($dataterdakwa);
    $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 ($dataterdakwa->result() as $row){
        $namaKuasa=$this->templatehelper->standradnaming($row->pemohonbanding);
        $tglkuasa=$this->templatehelper->convertKeTglIndo($row->tglKuasa);
        $nomorkuasa=$row->nomorKuasa;
        $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->umur)){
            $tgllahir = '......'; 
        }else{
            $tgllahir = $this->templatehelper->convertKeTglIndo($row->tanggal_lahir);
        }

        if(empty($row->umur)){
            $row->umur = '......'; 
        }
        $umur = $row->umur;
        $inpass['umur'] = $umur.' / '.$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=='L'){
            $row->jenis_kelamin = 'Perempuan';
        }
        $sex = $row->jenis_kelamin;
        $inpass['jenis_kelamin'] = $sex;
        
        $tblcnt++;

        $p[] = $inpass;
    }
    cetakPihak($Template, '#terdakwaparties#', $gkolom, $p);
    if ($dataterdakwa->num_rows>1) {
        $Template = str_replace('#jmlterdakwa3#','Para Terdakwa',$Template);
    } else {
        $Template = str_replace('#jmlterdakwa3#','Terdakwa',$Template);
    }
    $Template = str_replace("#penasehat#",''.$namaKuasa.'',$Template);

    $tglMemoriBanding=$cetakDataBanding;
    foreach ($tglMemoriBanding->result() as $row) {
        $tglMemoriPenuntut=$this->templatehelper->convertKeTglIndo($row->tglMemori);
    }
    if(empty($tglMemoriPenuntut)){
        $tglMemoriPenuntut='.................';
    }
    $Template = str_replace("#tanggalmemori#",''.$tglMemoriPenuntut.'',$Template);
    if(empty($tglkuasa)){$tglkuasa='..........';}
    if(empty($nomorkuasa)){$nomorkuasa='..........';}
    $Template = str_replace('#tglkuasa#',''.$tglkuasa.'',$Template);
    $Template = str_replace('#nomorkuasa#',''.$nomorkuasa.'',$Template);
}
//--------------------Data JPU---------------//
if(($jenisAkta==4)||($jenisAkta==8)){
    $databanding = $cetakDataJPU;
    $jpu = '';
    $nip = '';
    $tglpermohonan ='';
    foreach ($databanding->result() as $row) {        
        $jpu = $this->templatehelper->standradnaming($row->pemohon_nama);        
        $nip = $row->NIP;
        $tglpermohonan = $this->templatehelper->convertKeTglIndo($row->permohonan_banding);
    }
    if(empty($tglpermohonan)){
        $tglpermohonan = '..................';
        $haripermohonan = '.................';
    }else{
        $haripermohonan = $this->templatehelper->getHari($tglpermohonan);
    }
    if(empty($jpu)){
        $jpu = '..................';
    }
    if(empty($nip)){
        $nip = '..........................';
    }
    $Template = str_replace("#tglpermohonan#",''.$tglpermohonan.'',$Template);
    $Template = str_replace("#haripermohonan#",''.$haripermohonan.'',$Template);
    $Template = str_replace("#nip#",''.$nip.'',$Template);
    $Template = str_replace("#jaksa#",''.$jpu.'',$Template);
}
if($jenisAkta==12){
    $databanding = $cetakDataPUKontra;
    $jpu = '';
    $nip = '';
    foreach ($databanding->result() as $row) {        
        $jpu = $this->templatehelper->standradnaming($row->pihak_nama);        
        $nip = $row->NIP;        
    }    
    if(empty($jpu)){
        $jpu = '..................';
    }
    if(empty($nip)){
        $nip = '..........................';
    }    
    $Template = str_replace("#nip#",''.$nip.'',$Template);
    $Template = str_replace("#jaksa#",''.$jpu.'',$Template);
    $tglMemoriBanding=$cetakDataBanding;
    foreach ($tglMemoriBanding->result() as $row) {
        $tglmemori=$this->templatehelper->convertKeTglIndo($row->tglMemori);
    }
    if(empty($tglmemori)){
        $tglmemori='.................';
    }
    $Template = str_replace("#tanggalmemori#",''.$tglmemori.'',$Template);
}

   $namaoditur = $this->templatehelper->standradnaming($oditur->row()->nama);
   $pangkatoditur = $oditur->row()->pangkat; 
   $nrpoditur = $oditur->row()->NIP; 
   $nrpterdakwa = $oditur->row()->nrp; 
   $namapangkatkorp = $this->templatehelper->standradnaming($oditur->row()->namapangkatkorp);
   $pangkatkorp = $oditur->row()->pangkatkorp; 
   $namapanitera =  $this->templatehelper->standradnaming($oditur->row()->panitera_nama);
   $pangkatkorppanitera = $oditur->row()->pangkatpan; 
   $nippanitera = $oditur->row()->nippan; 
   $namapangkatkorppanitera = $this->templatehelper->standradnaming($oditur->row()->namapangkatkorppan);
   $tglptsbanding =  $this->templatehelper->convertKeTglIndo($oditur->row()->putusan_banding);
   $noptsbanding = $oditur->row()->nomor_putusan_banding; 
   $pemberitahuanptsban = $this->templatehelper->convertKeTglIndo($oditur->row()->pemberitahuan_putusan_banding);
   $hari_pemberitahuan_ptsban = $this->templatehelper->getHari($oditur->row()->pemberitahuan_putusan_banding);
   $namaterdakwa = $this->templatehelper->standradnaming($oditur->row()->namaterdak);
   $pangkatkorpterdakwa = $oditur->row()->pangkatkorpter;  
   $jabatanterdakwa = $oditur->row()->jabatanter; 
   $kesatuanterdakwa = $oditur->row()->kesatuanter; 
   $penerimaan_memori_banding = $this->templatehelper->convertKeTglIndo($oditur->row()->penerimaan_memori_banding);
   $hari_penerimaan_memori_band = $this->templatehelper->getHari($oditur->row()->penerimaan_memori_banding);
   $pemberitahuan_permohonan_band = $this->templatehelper->convertKeTglIndo($oditur->row()->pemberitahuan_permohonan_banding);
   $hari_pemberitahuan_permohonan_band = $this->templatehelper->getHari($oditur->row()->pemberitahuan_permohonan_banding);
   $pangkatterdakwa = $oditur->row()->pangkatter;
   $tanggal_putusan_pertama = $this->templatehelper->convertKeTglIndo($oditur->row()->tanggal_putusan_pertama);
   $nomor_putusan_pertama = $oditur->row()->nomor_putusan_pertama;
   $oditur_tgl_pemberitahuan_permohonanban = $this->templatehelper->convertKeTglIndo($oditur2->row()->pemberitahuan_permohonan_banding);
   $oditur_hari_pemberitahuan_permohonanban = $this->templatehelper->getHari($oditur2->row()->pemberitahuan_permohonan_banding);
   $oditur_penerimaan_memori_banding = $this->templatehelper->convertKeTglIndo($oditur2->row()->penerimaan_memori_banding);
   $oditur_hari_penerimaan_memori_band = $this->templatehelper->getHari($oditur2->row()->penerimaan_memori_banding);
   $pangkat_korp_odt = $oditur2->row()->pangkatkorpodt; 
   $penyerahan_memori_band_terdakwa = $this->templatehelper->convertKeTglIndo($oditur->row()->penyerahan_memori_banding);
   $hari_penyerahan_memori_band_terdakwa = $this->templatehelper->getHari($oditur->row()->penyerahan_memori_banding);
   
   $penyerahan_memori_band_odt = $this->templatehelper->convertKeTglIndo($oditur2->row()->penyerahan_memori_banding_odt);
   $hari_penyerahan_memori_band_odt = $this->templatehelper->getHari($oditur2->row()->penyerahan_memori_banding_odt);
   
   $alamat_pengadilan = $dataPN->row()->AlamatPN;
   $tgl_pemberitahuan_putusan_banding_ter = $this->templatehelper->convertKeTglIndo($oditur->row()->pemberitahuan_putusan_banding_ter);
   $hari_pemberitahuan_putusan_banding_ter = $this->templatehelper->getHari($oditur->row()->pemberitahuan_putusan_banding_ter);
   $tgl_pemberitahuan_putusan_banding_odt = $this->templatehelper->convertKeTglIndo($oditur2->row()->pemberitahuan_putusan_banding_odt);
   $hari_pemberitahuan_putusan_banding_odt = $this->templatehelper->getHari($oditur2->row()->pemberitahuan_putusan_banding_odt);
   $jabatan_oditur = $oditur->row()->jabatan;
   $kesatuan_oditur = $oditur->row()->kesatuan; 
   $penerimaan_kontra_banding_ter = $this->templatehelper->convertKeTglIndo($oditur->row()->penerimaan_kontra_banding_ter);
   $penerimaan_kontra_banding_odt = $this->templatehelper->convertKeTglIndo($oditur2->row()->penerimaan_kontra_banding_odt);
   $hari_penerimaan_kontra_banding_ter = $this->templatehelper->getHari($oditur->row()->penerimaan_kontra_banding_ter); 
   $hari_penerimaan_kontra_banding_odt = $this->templatehelper->getHari($oditur2->row()->penerimaan_kontra_banding_odt);
   $tgl_permohonan_banding_odt = $this->templatehelper->convertKeTglIndo($oditur2->row()->permohonan_banding_odt);
   $tgl_permohonan_banding_ter = $this->templatehelper->convertKeTglIndo($oditur->row()->permohonan_banding_ter);
    //$Spengadilan = explode(" ",$rowz->pengadilan);
    //$nmPengadilan = $Spengadilan['0'].' '.$Spengadilan['1'];
    //$kotaPengadilan = $Spengadilan['3'];
   $kotaPengadilan = $this->templatehelper->standradnaming($oditur->row()->kota_pn);
   $tgl_penerimaan_kontra_banding_ter = $this->templatehelper->convertKeTglIndo($oditur->row()->penerimaan_kontra_banding_ter);
   $tgl_penerimaan_kontra_banding_odt = $this->templatehelper->convertKeTglIndo($oditur2->row()->penerimaan_kontra_banding_odt);
   $hari_penerimaan_kontra_banding_ter = $this->templatehelper->getHari($oditur->row()->penerimaan_kontra_banding_ter);
   $hari_penerimaan_kontra_banding_odt = $this->templatehelper->getHari($oditur2->row()->penerimaan_kontra_banding_odt);
   $tgl_penyerahan_kontra_banding_ter = $this->templatehelper->convertKeTglIndo($oditur->row()->penyerahan_kontra_banding_ter);
   $tgl_penyerahan_kontra_banding_odt = $this->templatehelper->convertKeTglIndo($oditur2->row()->penyerahan_kontra_banding_odt);
   $hari_penyerahan_kontra_banding_ter = $this->templatehelper->getHari($oditur->row()->penyerahan_kontra_banding_ter);
   $hari_penyerahan_kontra_banding_odt = $this->templatehelper->getHari($oditur2->row()->penyerahan_kontra_banding_odt);
   $nama_kuasa_hukum = $this->templatehelper->standradnaming($oditur->row()->nama_kuasa_hukum_ter);
   $pangkatkorp_kuasa_hukum = $oditur->row()->pangkatkorp_kuasa_hukum; 
   $nrp_kuasa_hukum = $oditur->row()->nrp_kuasa_hukum; 
   $jabatan_kuasa_hukum = $oditur->row()->jabatan_kuasa_hukum;
   $kesatuan_kuasa_hukum = $oditur->row()->kesatuan_kuasa_hukum; 
   $tgl_pemberitahuan_inzage_ter = $this->templatehelper->convertKeTglIndo($oditur->row()->pemberitahuan_inzage_ter);
   $tgl_pemberitahuan_inzage_odt = $this->templatehelper->convertKeTglIndo($oditur2->row()->pemberitahuan_inzage_odt);
   $hari_pemberitahuan_inzage_ter = $this->templatehelper->getHari($oditur->row()->pemberitahuan_inzage_ter);
   $hari_pemberitahuan_inzage_odt = $this->templatehelper->getHari($oditur2->row()->pemberitahuan_inzage_odt); 
   $kode_otmil = $oditur2->row()->kode_otmil; 
   $no_register = $oditur->row()->nomor_register; 
   $matra = $oditur->row()->matra;
   $bulan = $oditur->row()->bulan;
   $tahun = $oditur->row()->tahun; 
   $kode_pt = $oditur->row()->kode_pt;
   $kota_pt = $this->templatehelper->standradnaming($oditur->row()->kota_pt);
   $tanggal_cabut_ter = $this->templatehelper->convertKeTglIndo($oditur->row()->tanggal_cabut_ter);
   $tanggal_cabut_odt =  $this->templatehelper->convertKeTglIndo($oditur2->row()->tanggal_cabut_odt);
   $hari_cabut_ter = $this->templatehelper->getHari($oditur->row()->tanggal_cabut_ter);
   $hari_cabut_odt =  $this->templatehelper->getHari($oditur2->row()->tanggal_cabut_odt);
   $kodee_pn = $oditur->row()->kodee_pn;
   $kode_pn = "PM." . $kodee_pn;

   $no_akta_permohonan_banding = "APB/" . $no_register ."/". $kode_pn . "/" . $matra . "/" . $bulan . "/" . $tahun;
   
   if (count($biaya_banding->result())> 0)
   {
        $biayabanding = $biaya_banding->row()->durasi_nominal;
   }

//   $terdakwaparties = $cetakpartiesbanding->row()->nama; 
//   $i = 1;
//foreach ($cetakpartiesbanding->result() as $row)
//{
//$namaterdakwaparties = $row->nama; 
//$i++;
//}

   if(empty($namaoditur)){ $namaoditur = '....................'; }
   if(empty($pangkatoditur)){ $pangkatoditur = '....................'; } 
   if(empty($nrpoditur)){ $nrpoditur = '....................'; } 
   if(empty($nrpterdak)){ $nrpterdakwa = '....................'; } 
   if(empty($namapangkatkorp)){ $namapangkatkorp = '....................'; } 
   if(empty($pangkatkorp)){ $pangkatkorp = '....................'; } 
   if(empty($namapanitera)){ $namapanitera = '....................'; } 
   if(empty($pangkatkorppanitera)){ $pangkatkorppanitera = '....................'; } 
   if(empty($nippanitera)){ $nippanitera = '....................'; } 
   if(empty($namapangkatkorppanitera)){ $namapangkatkorppanitera = '....................'; } 
   if(empty($tglptsbanding)){ $tglptsbanding = '....................'; } 
   if(empty($noptsbanding)){ $noptsbanding = '....................'; } 
   if(empty($pemberitahuanptsban)){ $pemberitahuanptsban = '....................'; } 
   if(empty($hari_pemberitahuan_ptsban)){ $hari_pemberitahuan_ptsban = '....................'; } 
   if(empty($namaterdakwa)){ $namaterdakwa = '....................'; } 
   if(empty($pangkatkorpterdakwa)){ $pangkatkorpterdakwa = '....................'; } 
   if(empty($jabatanterdakwa)){ $jabatanterdakwa = '....................'; } 
   if(empty($kesatuanterdakwa)){ $kesatuanterdakwa = '....................'; } 
   if(empty($penerimaan_memori_banding)){ $penerimaan_memori_banding = '....................'; } 
   if(empty($hari_penerimaan_memori_band)){ $hari_penerimaan_memori_band = '....................'; } 
   if(empty($pemberitahuan_permohonan_band)){ $pemberitahuan_permohonan_band = '....................'; } 
   if(empty($hari_pemberitahuan_permohonan_band)){ $hari_pemberitahuan_permohonan_band = '....................'; } 
   if(empty($pangkatterdakwa)){ $pangkatterdakwa = '....................'; } 
   if(empty($tanggal_putusan_pertama)){ $tanggal_putusan_pertama = '....................'; } 
   if(empty($nomor_putusan_pertama)){ $nomor_putusan_pertama = '....................'; } 
   if(empty($oditur_tgl_pemberitahuan_permohonanban)){ $oditur_tgl_pemberitahuan_permohonanban = '....................'; }
   if(empty($oditur_hari_pemberitahuan_permohonanban)){ $oditur_hari_pemberitahuan_permohonanban = '....................'; }
   if(empty($oditur_penerimaan_memori_banding)){ $oditur_penerimaan_memori_banding = '....................'; } 
   if(empty($oditur_hari_penerimaan_memori_band)){ $oditur_hari_penerimaan_memori_band = '....................'; } 
   if(empty($pangkat_korp_odt)){ $pangkat_korp_odt = '....................'; } 
   if(empty($penyerahan_memori_band_terdakwa)){ $penyerahan_memori_band_terdakwa = '....................'; } 
   if(empty($hari_penyerahan_memori_band_terdakwa)){ $hari_penyerahan_memori_band_terdakwa = '....................'; } 
   if(empty($alamat_pengadilan)){ $alamat_pengadilan = '....................'; } 
   if(empty($tgl_pemberitahuan_putusan_banding_ter)){ $tgl_pemberitahuan_putusan_banding_ter = '....................'; } 
   if(empty($hari_pemberitahuan_putusan_banding_ter)){ $hari_pemberitahuan_putusan_banding_ter = '....................'; }
   if(empty($tgl_pemberitahuan_putusan_banding_odt)){ $tgl_pemberitahuan_putusan_banding_odt = '....................'; }
   if(empty($hari_pemberitahuan_putusan_banding_odt)){ $hari_pemberitahuan_putusan_banding_odt = '....................'; }   
   if(empty($jabatan_oditur)){ $jabatan_oditur = '....................'; }   
   if(empty($kesatuanodt)){ $kesatuanodt = '....................'; }   
   if(empty($tgl_permohonan_banding_odt)){ $tgl_permohonan_banding_odt = '....................'; }   
   if(empty($tgl_permohonan_banding_ter)){ $tgl_permohonan_banding_ter = '....................'; }   
   if(empty($terdakwaparties)){ $terdakwaparties = '....................'; } 
   if(empty($kotaPengadilan)){ $kotaPengadilan = '....................'; } 
   if(empty($tgl_penerimaan_kontra_banding_odt)){ $tgl_penerimaan_kontra_banding_odt = '....................'; } 
   if(empty($tgl_penerimaan_kontra_banding_ter)){ $tgl_penerimaan_kontra_banding_ter = '....................'; } 
   if(empty($hari_penerimaan_kontra_banding_ter)){ $hari_penerimaan_kontra_banding_ter = '....................'; } 
   if(empty($tgl_penyerahan_kontra_banding_ter)){ $tgl_penyerahan_kontra_banding_ter = '....................'; } 
   if(empty($tgl_penyerahan_kontra_banding_odt)){ $tgl_penyerahan_kontra_banding_odt = '....................'; } 
   if(empty($hari_penyerahan_kontra_banding_ter)){ $hari_penyerahan_kontra_banding_ter = '....................'; } 
   if(empty($hari_penyerahan_kontra_banding_odt)){ $hari_penyerahan_kontra_banding_odt = '....................'; } 
   if(empty($nama_kuasa_hukum)){ $nama_kuasa_hukum = '....................'; } 
   if(empty($pangkatkorp_kuasa_hukum)){ $pangkatkorp_kuasa_hukum = '....................'; } 
   if(empty($nrp_kuasa_hukum)){ $nrp_kuasa_hukum = '....................'; } 
   if(empty($jabatan_kuasa_hukum)){ $jabatan_kuasa_hukum = '....................'; } 
   if(empty($kesatuan_kuasa_hukum)){ $kesatuan_kuasa_hukum = '....................'; } 
   if(empty($tgl_pemberitahuan_inzage_ter)){ $tgl_pemberitahuan_inzage_ter = '....................'; } 
   if(empty($tgl_pemberitahuan_inzage_odt)){ $tgl_pemberitahuan_inzage_odt = '....................'; } 
   if(empty($hari_pemberitahuan_inzage_ter)){ $hari_pemberitahuan_inzage_ter = '....................'; } 
   if(empty($hari_pemberitahuan_inzage_odt)){ $hari_pemberitahuan_inzage_odt = '....................'; } 
   if(empty($kode_otmil)){ $kode_otmil = '....................'; } 
   if(empty($penyerahan_memori_band_odt)){ $penyerahan_memori_band_odt = '....................'; } 
   if(empty($hari_penyerahan_memori_band_odt)){ $hari_penyerahan_memori_band_odt = '....................'; } 
   if(empty($tanggal_cabut_ter)){ $tanggal_cabut_ter = '....................'; } 
   if(empty($tanggal_cabut_odt)){ $tanggal_cabut_odt = '....................'; } 
   if(empty($hari_cabut_ter)){ $hari_cabut_ter = '....................'; } 
   if(empty($hari_cabut_odt)){ $hari_cabut_odt = '....................'; } 

   if(empty($no_register)){ $no_register = '....................'; } 
   if(empty($matra)){ $matra = '....................'; } 
   if(empty($bulan)){ $bulan = '....................'; } 
   if(empty($tahun)){ $tahun = '....................'; } 
   if(empty($kode_pt)){ $kode_pt = '....................'; }
   if(empty($kota_pt)){ $kota_pt = '....................'; }
   if(empty($kode_pn)){ $kode_pn = '....................'; }
   if(empty($no_akta_permohonan_banding)){ $no_akta_permohonan_banding = '....................'; } 
   if(empty($biayabanding)){ $biayabanding = '....................'; } 
 
$Template = str_replace('#nama_oditur#',''.$namaoditur.'',$Template); 
$Template = str_replace('#pangkat_oditur#',''.$pangkatoditur.'',$Template); 
$Template = str_replace('#nrp_oditur#',''.$nrpoditur.'',$Template); 
$Template = str_replace('#nrp_terdakwa#',''.$nrpterdakwa.'',$Template); 
$Template = str_replace('#nama_pangkat_korp_terdakwa#',''.$namapangkatkorp.'',$Template); 
$Template = str_replace('#pangkat_korp#',''.$pangkatkorp.'',$Template); 
$Template = str_replace('#nama_panitera#',''.$namapanitera.'',$Template); 
$Template = str_replace('#pangkat_korp_panitera#',''.$pangkatkorppanitera.'',$Template); 
$Template = str_replace('#nrp_panitera#',''.$nippanitera.'',$Template); 
$Template = str_replace('#nama_pangkat_korp_panitera#',''.$namapangkatkorppanitera.'',$Template); 
$Template = str_replace('#tanggal_putusan_banding#',''.$tglptsbanding.'',$Template); 
$Template = str_replace('#nomor_putusan_banding#',''.$noptsbanding.'',$Template); 
$Template = str_replace('#tanggal_pemberitahuan#',''.$pemberitahuanptsban.'',$Template); 
$Template = str_replace('#nama_terdakwa#',''.$namaterdakwa.'',$Template); 
$Template = str_replace('#tanggal_putusan_tk_banding#',''.$tglptsbanding.'',$Template);
$Template = str_replace('#nomor_putusan_tk_banding#',''.$noptsbanding.'',$Template); 
$Template = str_replace('#pangkat_korp_terdakwa#',''.$pangkatkorpterdakwa.'',$Template); 
$Template = str_replace('#jabatan_terdakwa#',''.$jabatanterdakwa.'',$Template); 
$Template = str_replace('#kesatuan_terdakwa#',''.$kesatuanterdakwa.'',$Template); 
$Template = str_replace('#nomor_putusan#',''.$noptsbanding.'',$Template); 
$Template = str_replace('#tanggal_putus#',''.$tglptsbanding.'',$Template);
$Template = str_replace('#hari_pemberitahuan_putusan_banding#',''.$hari_pemberitahuan_ptsban.'',$Template);
//$Template = str_replace('#kode_pn#',''.$kode_pn.'',$Template); 
//$Template = str_replace('#kode_pn1#',''.$kode_pn.'',$Template);
$Template = str_replace('#tanggal_penerimaan#',''.$penerimaan_memori_banding.'',$Template);
$Template = str_replace('#hari_penerimaan#',''.$hari_penerimaan_memori_band.'',$Template);
$Template = str_replace('#tanggal_pemberitahuan_permban#',''.$pemberitahuan_permohonan_band.'',$Template);
$Template = str_replace('#hari_pemberitahuan_permban#',''.$hari_pemberitahuan_permohonan_band.'',$Template);
$Template = str_replace('#pangkat_terdakwa#',''.$pangkatterdakwa.'',$Template);
$Template = str_replace('#tanggal_putusan_pertama#',''.$tanggal_putusan_pertama.'',$Template);
$Template = str_replace('#nomor_putusan_pertama#',''.$nomor_putusan_pertama.'',$Template);
$Template = str_replace('#tanggal_pemberitahuan_permban_oditur#',''.$oditur_tgl_pemberitahuan_permohonanban.'',$Template);
$Template = str_replace('#hari_pemberitahuan_permban_oditur#',''.$oditur_hari_pemberitahuan_permohonanban.'',$Template);
$Template = str_replace('#tanggal_penerimaan_oditur#',''.$oditur_penerimaan_memori_banding.'',$Template);
$Template = str_replace('#hari_penerimaan_oditur#',''.$oditur_hari_penerimaan_memori_band.'',$Template);
$Template = str_replace('#pangkat_korp_oditur#',''.$pangkat_korp_odt.'',$Template);
$Template = str_replace('#tanggal_penyerahan_memori_banding_ter#',''.$penyerahan_memori_band_terdakwa.'',$Template);
$Template = str_replace('#hari_pemberitahuan_memori_banding_ter#',''.$hari_penyerahan_memori_band_terdakwa.'',$Template);
$Template = str_replace('#alamat_pn#',''.$alamat_pengadilan.'',$Template);
$Template = str_replace('#tanggal_pemberitahuan_putusan_banding_ter#',''.$tgl_pemberitahuan_putusan_banding_ter.'',$Template);
$Template = str_replace('#hari_pemberitahuan_putusan_banding_ter#',''.$hari_pemberitahuan_putusan_banding_ter.'',$Template);
$Template = str_replace('#tanggal_pemberitahuan_putusan_banding_odt#',''.$tgl_pemberitahuan_putusan_banding_odt.'',$Template);
$Template = str_replace('#hari_pemberitahuan_putusan_banding_odt#',''.$hari_pemberitahuan_putusan_banding_odt.'',$Template);
$Template = str_replace('#jabatan_oditur#',''.$jabatan_oditur.'',$Template);
$Template = str_replace('#kesatuan_oditur#',''.$kesatuanodt.'',$Template); 
$Template = str_replace('#tanggal_permohonan_banding_terdakwa#',''.$tgl_permohonan_banding_odt.'',$Template);
$Template = str_replace('#tanggal_permohonan_banding_oditur#',''.$tgl_permohonan_banding_ter.'',$Template);
$Template = str_replace('#kota_pn#',''.$kotaPengadilan.'',$Template); 
$Template = str_replace('#kota_pn1#',''.$kotaPengadilan.'',$Template); 
$Template = str_replace('#tanggal_penerimaan_kontra_memori_banding_odt#',''.$tgl_penerimaan_kontra_banding_odt.'',$Template);
$Template = str_replace('#tanggal_penerimaan_kontra_memori_banding_ter#',''.$tgl_penerimaan_kontra_banding_ter.'',$Template);
$Template = str_replace('#hari_penerimaan_kontra_memori_banding_odt#',''.$hari_penerimaan_kontra_banding_odt.'',$Template);
$Template = str_replace('#hari_penerimaan_kontra_memori_banding_ter#',''.$hari_penerimaan_kontra_banding_ter.'',$Template);
$Template = str_replace('#tanggal_pemberitahuan_kontra_memori_banding_ter#',''.$tgl_penyerahan_kontra_banding_ter.'',$Template);
$Template = str_replace('#tanggal_pemberitahuan_kontra_memori_banding_odt#',''.$tgl_penyerahan_kontra_banding_odt.'',$Template);
$Template = str_replace('#hari_pemberitahuan_kontra_memori_banding_ter#',''.$hari_penyerahan_kontra_banding_ter.'',$Template);
$Template = str_replace('#hari_pemberitahuan_kontra_memori_banding_odt#',''.$hari_penyerahan_kontra_banding_odt.'',$Template);
$Template = str_replace('#nama_kuasa_hukum#',''.$nama_kuasa_hukum.'',$Template);
$Template = str_replace('#pangkat_korp_kuasa_hukum#',''.$pangkatkorp_kuasa_hukum.'',$Template); 
$Template = str_replace('#nrp_kuasa_hukum#',''.$nrp_kuasa_hukum.'',$Template); 
$Template = str_replace('#jabatan_kuasa_hukum#',''.$jabatan_kuasa_hukum.'',$Template);
$Template = str_replace('#kesatuan_kuasa_hukum#',''.$kesatuan_kuasa_hukum.'',$Template);
$Template = str_replace('#tanggal_mempelajari_ter#',''.$tgl_pemberitahuan_inzage_ter.'',$Template);
$Template = str_replace('#tanggal_mempelajari_odt#',''.$tgl_pemberitahuan_inzage_odt.'',$Template);
$Template = str_replace('#hari_mempelajari_odt#',''.$hari_pemberitahuan_inzage_odt.'',$Template);
$Template = str_replace('#hari_mempelajari_ter#',''.$hari_pemberitahuan_inzage_ter.'',$Template); 
$Template = str_replace('#kode_otmil#',''.$kode_otmil.'',$Template); 
$Template = str_replace('#tanggal_pemberitahuan_memori_banding_odt#',''.$penyerahan_memori_band_odt.'',$Template); 
$Template = str_replace('#hari_penyerahan_memori_band_odt#',''.$hari_penyerahan_memori_band_odt.'',$Template); 
$Template = str_replace('#no_register#',''.$no_register.'',$Template); 
$Template = str_replace('#matra#',''.$matra.'',$Template); 
$Template = str_replace('#bulan#',''.$bulan.'',$Template); 
$Template = str_replace('#tahun#',''.$tahun.'',$Template); 
$Template = str_replace('#kode_pt#',''.$kode_pt.'',$Template); 
$Template = str_replace('#kota_pt#',''.$kota_pt.'',$Template); 
$Template = str_replace('#kode_pn#',''.$kode_pn.'',$Template); 
$Template = str_replace('#kode_pn1#',''.$kode_pn.'',$Template); 
$Template = str_replace('#tanggal_cabut_ter#',''.$tanggal_cabut_ter.'',$Template); 
$Template = str_replace('#tanggal_cabut_odt#',''.$tanggal_cabut_odt.'',$Template); 
$Template = str_replace('#hari_cabut_ter#',''.$hari_cabut_ter.'',$Template); 
$Template = str_replace('#hari_cabut_odt#',''.$hari_cabut_odt.'',$Template); 
$Template = str_replace('#nomor_akta_permohonan_banding_oditur#',''.$no_akta_permohonan_banding.'',$Template); 
$Template = str_replace('#nomor_akta_permohonan_banding_terdakwa#',''.$no_akta_permohonan_banding.'',$Template); 
$Template = str_replace('#biaya_perkara_tk_banding#',''.$biayabanding.'',$Template); 

//$Template = str_replace('#terdakwaParties#',''.$terdakwaparties.'',$Template);
//$Template = str_replace('#terdakwaParties#',''.$namaterdakwaparties.'',$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;

?>