<?php 
if($this->session->userdata('is_logged_in')===FALSE){
            redirect('login');
}
?>
<div class="templatepopcentering" >
    <div style="border: 1px solid #ffffff;">
        <div id='pop' style="padding:5px;">
			<form id="form_relaas" name="" class="templatepopform" target="_self" method="POST" action="<?php echo base_url().'c_template_relaas_agama/cetak_relaas';?>">
			<table style="padding:5px;">
            <tr><td colspan="2" class="templatepoptitle">
            <?php 
                echo strtoupper("Surat Panggilan (RELAAS)");
            ?>
            </td></tr>
				<input type='hidden' name='sidang_ke' value='<?php echo $urutansidang; ?>'>
  				<input type='hidden' name='encsidang' value='<?php echo $encsidang; ?>'>
  				<input type="hidden" name="enc" id="enc" value="<?php echo $enc; ?>">
  				<input type="hidden" name="pihak_ke" id="pihak_ke" value="<?php echo $pihak_ke; ?>">
				<tr>
					<td class="templatepopleftcol">Jurusita<font color=red>*</font></td>
					<td>
						<span >
						<select style='width:250px;'  name="nama_jurusita" id="nama_jurusita" class="custom-dropdown__select custom-dropdown__select--white">
                               
                                <?php
									foreach($datajurusita->result() as $data)
										{
											?><option value='<?php echo $data->jurusita_id; ?>'><?php echo $data->nama_gelar; ?></option><?php
										}
								?>
						</select> 
						</span>
					</td>
				</tr>
				<tr>
                    <td class="templatepopleftcol">Pilih Surat<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="blangko_relaas" id="blangko_relaas" class="custom-dropdown__select custom-dropdown__select--white">
                                <option value='-1'>--Pilih Surat--</option>
                               <?php
								if(($urutansidang=='1')){
									foreach($blangko_relaas->result() as $data)
										{
											if($pihak_ke=='1'){
												if($data->nomor >= 201 AND $data->nomor <= 220){
													?><option value='<?php echo $data->kode; ?>'><?php echo $this->templatehelper->ucname($data->nama); ?></option><?php
												}
											}else{
												if($data->nomor >= 221 AND $data->nomor <= 240){
													?><option value='<?php echo $data->kode; ?>'><?php echo $this->templatehelper->ucname($data->nama); ?></option><?php
												}
												
											}
											
										}
										
								}else{
									foreach($blangko_relaas->result() as $data)
										{
											if($pihak_ke=='1'){
												if($data->nomor >= 241 AND $data->nomor <= 260){
													?><option value='<?php echo $data->kode; ?>'><?php echo $this->templatehelper->ucname($data->nama); ?></option><?php
												}
											}else{
												if($data->nomor >= 261 AND $data->nomor <= 280){
													?><option value='<?php echo $data->kode; ?>'><?php echo $this->templatehelper->ucname($data->nama); ?></option><?php
												}
											}
										}
								}
							
								foreach($blangko_global->result() as $data)
									{
									?><option value='<?php echo $data->kode; ?>'><?php echo $this->templatehelper->ucname($data->nama); ?></option><?php
									}	
								?>
							</select> 
                        </span>
                    </td> 
                </tr>
           	<?php if($pihak->num_rows()> 1) { ?>
           			<tr>
                    <td class="templatepopleftcol">Pilih Pihak<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="id_pihak" id="id_pihak" class="custom-dropdown__select custom-dropdown__select--white">
                                <option value='-1'>--Pilih Pihak--</option>
                                <?php
									foreach($pihak->result() as $data)
										{
											if($data->id_kuasa!=''){
												$tmp=$data->nama_kuasa.'(Kuasa dari '.$data->nama.')';
											}else{
												$tmp=$data->nama;
											}
											?><option value='<?php echo $data->id_pihak; ?>'><?php echo $tmp; ?></option><?php
										}
								?>
							</select> 
                        </span>
                    </td> 
                </tr>
                        
            <?php }else{ ?>
            	<input type="hidden" name="id_pihak" id="id_pihak" value="<?php echo $pihak->row(0)->id_pihak; ?>">
  			<?php } ?>
                <tr>
					<td colspan="2" style="background:white;padding:10px" align="center">
						<input type="button" id="kembali" value="Kembali" class="btn btn-info">
                        <input type="submit" id="simpan_btn" value="Cetak" class="btn btn-danger">
					</td>
				</tr>
            </table>
			</form>
		</div>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$('#kembali').closingFormWin();
	
	$('#form_relaas').submit(function(e) {
		
			if($("#nama_jurusita").val() == '-1'){message_error_show('Silahkan Pilih Nama Jurusita');e.preventDefault();}
			if($("#blangko_relaas").val() == '-1'){message_error_show('Silahkan Pilih Blangko Relaas');e.preventDefault();}
		
	});
});

</script>