<?php
if($this->session->userdata('is_logged_in')===FALSE){
            redirect('login');
}
?>
<div class="templatepopcentering" >
    <div id='pop' style="padding:5px;">
            <form id="frm_pen_penahanan_hkm_pn" class="templatepopform" method="" action="">
              <table style="padding:5px;">
                <tr><td colspan="2" class="templatepoptitle">
                <?php 
                    foreach ($template->result() as $template)
                    {
                        echo strtoupper($template->namatemplate."<br/>Perkara ".$template->jnsperkara);
                    }
                ?>
                </td></tr>
                <tr>
                    <td class="templatepopleftcol">Nama Terdakwa <font color=red>*</font></td>
                    <td style="">
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="terdakwa" id="terdakwa" class="custom-dropdown__select custom-dropdown__select--white">
                                <option value='-1'>--Pilih Nama Terdakwa--</option>
                                <?php
                                foreach ($dataterdakwa->result() as $row) {
                                    $pihak_id = base64_encode($this->encrypt->encode($row->pihak_id));
                                    echo "<option value='".$pihak_id."'>".$row->nama."</option>";
                                }
                                ?>
                            </select>
                         </span>
                        </td> 
                            <td> 
                                <?php echo $pihak_id;?>
                            </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="background:white;" align="center">
                            <input type="button" id="kembali" value="Kembali" class="btn">
                            <input type="button" id="cetak" onClick='print_template();' value="Cetak" class="btn">
                        </td>
                    </tr>
                </table>
            </form>
    </div>
</div>
<script type="text/javascript">
$('#kembali').closingFormWin();

function print_template(){
    var idperkara = '<?php echo $enc; ?>';
    var idterdakwa = $('#terdakwa option:selected').attr('value');
    if(idterdakwa==-1){
        alert('Pilih nama terdakwa');
        return;
    }
    window.open('<?php echo base_url("c_template_penetapan/cetak_penetapan_penahanan_hakim_pn")?>/'+idperkara+'/'+idterdakwa,'_self');
}
</script>