<hr class="thick-line" style="clear:both;">
<div id="left">
	<?php
	echo form_open(base_url().$page_url.'/search');
	$attributes = array('name' => 'search', 'id' => 'search-box', 'type' => 'text','size' => '50','placeholder'=>"  Ketik kata kunci  ");
	echo form_input($attributes);
	echo "<span>  </span>";
	$attributes = array('value' => 'Search', 'id' => 'search-btn1','class' => 'btn', 'type' => 'submit');
	echo form_submit($attributes);
	echo form_close('');
	?>
</div>
<?php
$page_name = "biaya_perkara_list";
$action = base64_encode($this->encrypt->encode("add"));
if($this->session->userdata('is_logged_in')){
	$AuthorizationForm = $this->nativesession->get('AuthorizationForm');
	if($this->authorization->isAuthorized($page_name,$AuthorizationForm)==FALSE){
		redirect('login');
	}
	$AuthorizationAction = $this->nativesession->get('getAuthorizationAction');
	if($this->authorization->isAuthorized('BiayaPerkaraManage',$AuthorizationAction)){
?>
<?php
	}else{
		redirect('login');
	}
}else{
	redirect('login');
}
?>
<div id="pages">
    <div id="selector"></div>
</div>
<div class="cssTable">
	<table id="tablePerkaraAll">
		<col  width="3%" />
        <col  width="8%" />
        <col  width="8%" />
        <col  width="8%" />
        <col  width="10%" />
        <col  width="15%" />
        <col  width="10%" />
        <col  width="20%" />
        <col  width="5%" />
        <col  width="5%" />
		<tbody>
			<tr>
				<td>No</td>
				<td onclick="sorting(2)">Klasifikasi Perkara</td>
				<td onclick="sorting(3)">Tahapan Proses</td>
				<td onclick="sorting(4)">Jenis Transaksi</td>
				<td onclick="sorting(5)">Kategori Biaya</td>
				<td onclick="sorting(6)">Jenis Biaya</td>
				<td onclick="sorting(7)">Jumlah</td>
				<td onclick="sorting(8)">Keterangan</td>
				<td onclick="sorting(9)">Aktif</td>
				<td>Link</td>
			</tr>
			<?php
				if($biaya_list!=''){
					if($biaya_list->num_rows>0){
						if($page_active<1){
							$con = 1;
						}else{
							$con = $page_active+1;
						}
						$modelClass =& get_instance();
						
						# set history URL REQUESTED, this will be used to back on previous page.
						# 

			
						$this->nativesession->set_flash_session('history', current_url());
		    			foreach ($biaya_list->result() as $row) {
		    				echo "<tr>";
			    				echo '<td>'.$con.'</td>';
			    				echo '<td>'.$row->alur_perkara_nama.'</td>';
			    				echo '<td>'.$row->nama_tahapan.'</td>';
			    				echo '<td>'.$row->jenis_transaksi_text.'</td>';
			    				echo '<td>'.$row->kategori_nama.'</td>';
			    				echo '<td>'.$row->jenis_biaya_nama.'</td>';
			    				echo '<td> Rp.  '.number_format($row->jumlah).'</td>';
			    				echo '<td>'.$row->keterangan.'</td>';
			    				echo '<td>'.$row->aktif.'</td>';
			    				echo '<td style="cursor:pointer;" align="center" onclick="show_edit(\''.base64_encode($this->encrypt->encode($row->alur_perkara_id))."','".base64_encode($this->encrypt->encode($row->jenis_biaya_id)).'\')">[<a href="#">edit</a>]</td>';
		    				echo "</tr>";
		    				$con++;
		    			}
			    	}else{
		    			echo "<tr><td colspan='6' align='center'>Data Tidak diTemukan</td></tr>";
		    		}
				}else{
		    		echo "<tr><td colspan='6' align='center'>Data Tidak diTemukan</td></tr>";
		    	}
			?>
		</tbody>
	</table>
</div>
<div id="pages_bottom" style="width:100%;padding-left:5px;padding-top:5px;">
    <div id="selector_bottom"></div>
</div>
<div id="popup_biaya_perkara" class="popup">
	<div class="centering" style="width:500px;margin-top: 5%;z-index:-100">
		<div id='edit_biaya_perkara' style="border: 1px solid #ffffff;">
			<div class="detil" style="padding: 2px;background-color: white;">
			<form id="frm_biaya_perkara" style="background:white;margin:0;" method="post" action="<?php echo base_url().'manage_ref_biaya_perkara/validate_input';?>">
				<table id="tableDetilPerkara">
					<col width="40%">
					<col width="60%">
					<tbody hidden>
						<tr>
						<td>Klasifikasi Perkara</td>
							<td style="padding:0px;padding-left:5px;">
								<span class="custom-dropdown custom-dropdown--emerald" style="width:300px;border:1px solid #ddd">
									<select style="width:300px" name="klasifikasi" id="klasifikasi" class="custom-dropdown__select custom-dropdown__select--white">
										<option value="-1"> Pilih klasifikasi perkara</option>
										<?php 
										foreach ($klasifikasiX->result() as $isi) {
											echo '<option value="'.$isi->id.'">'.$isi->nama.'</option>';	
										}
										?>
									</select>
								</span>
							</td>
						</tr>
						<td>Tahapan</td>
							<td style="padding:0px;padding-left:5px;">
								<span class="custom-dropdown custom-dropdown--emerald" style="width:300px;border:1px solid #ddd">
									<select style="width:300px" name="tahapan_proses" id="tahapan_proses" class="custom-dropdown__select custom-dropdown__select--white">
										<option value="-1"> Pilih tahapan</option>
										<?php 
										foreach ($tahapan->result() as $isi) {
											echo '<option value="'.$isi->id.'">'.$isi->nama.'</option>';	
										}
										?>
									</select>
								</span>
							</td>
						</tr>
						<tr>
							<td>Jenis Transaksi<font color="red">*</font></td>
							<td style="padding:0px;padding-left:5px;">
								<span class="custom-dropdown custom-dropdown--emerald" style="width:300px;border:1px solid #ddd">
									<select style="width:300px" name="jenis_transaksi" id="jenis_transaksi" class="custom-dropdown__select custom-dropdown__select--white" disabled>
										<option value="none">Pilih jenis transaksi</option>
										<option value="1">Pemasukan</option>
										<option value="-1">Pengeluaran</option>
									</select>
								</span>
							</td>
						</tr>
						<td>Kategori Biaya</td>
							<td style="padding:0px;padding-left:5px;">
								<span class="custom-dropdown custom-dropdown--emerald" style="width:300px;border:1px solid #ddd">
									<select style="width:300px" name="kategori_biaya" id="kategori_biaya" class="custom-dropdown__select custom-dropdown__select--white">
										<option value="-1"> Pilih kategori biaya</option>
										<?php 
										foreach ($kategoriBiaya->result() as $isi) {
											echo '<option value="'.$isi->id.'">'.$isi->nama.'</option>';	
										}
										?>
									</select>
								</span>
							</td>
						</tr>

						<td>Jenis Biaya</td>
							<td style="padding:0px;padding-left:5px;">
								<span class="custom-dropdown custom-dropdown--emerald" style="width:300px;border:1px solid #ddd">
									<select style="width:300px" name="jenis_biaya" id="jenis_biaya" class="custom-dropdown__select custom-dropdown__select--white">
										<option value="-1"> Pilih jenis biaya</option>
										<?php 
										foreach ($jenisBiaya->result() as $isi) {
											echo '<option value="'.$isi->id.'">'.$isi->nama.'</option>';	
										}
										?>
									</select>
								</span>
							</td>
						</tr>
					</tbody>
					<tbody>
						<tr>
							<td colspan="2" style='text-align:center;background:#fff;color:#5fb85c;border:2px solid #fff;margin-bottom:10px;font-size: 20px;'>INFO BIAYA PERKARA</td>
						</tr>
						<tr>
							<td>Jumlah<font color="red">*</font></td>
							<td style="padding:0px;padding-left:5px;">
								<input style="width:300px;" type="text" id='jumlah' name='jumlah' class="standard-input" maxlength="50" readonly="readonly">
							</td>
						</tr>
						<tr>
							<td>Aktif</td>
							<td style="padding:0px;padding-left:5px;">
								<span class="custom-dropdown custom-dropdown--emerald" style="width:300px;border:1px solid #ddd">
									<select style="width:300px" name="aktif" id="aktif" class="custom-dropdown__select custom-dropdown__select--white" disabled>
										<option value="Y"> Ya</option>
										<option value="T"> Tidak</option>
									</select>
								</span>
							</td>
						</tr>
						<tr>
							<td>Keterangan</td>
							<td style="padding:0px;padding-left:5px;">
								<textarea id="keterangan" name="keterangan" class="standard-input" style="resize: none;margin: 0px; width: 300px; height: 100px;" readonly="readonly"></textarea>								
							</td>
						</tr>
						<tr>
							<td colspan="2" style="background:white;" align="center">
							<input type="button" onClick='kembali_biaya_perkara();' id="refresh" value="Kembali" class="btn">
							<?php
							if($this->authorization->isAuthorized('biaya_perkara_edit',$AuthorizationForm)){
							?>
								<input type="button" id="edit_btn" onClick='edit();' value="Edit" class="btn">
								<input type="submit" id="simpan_btn" value="Simpan" class="btn" disabled>
							<?php
							}?>
						</td>
						</tr>
						<tr>
						<td hidden>
							<input id='enc_al' name='enc_al' class="standard-input">
							<input id='enc_by' name='enc_by' class="standard-input">
						</td>
						</tr>

					</tbody>
				</table>
			</form>
		</div>
	</div>
</div>
<?php
$url = base_url().$page_url.'/sort/';
$keyword = (!empty($keyword))?'/'.$keyword : '';
?>
<script type="text/javascript">
	function sorting(col){
		window.open('<?php echo $url;?>'+col+'/<?php echo $enc; ?><?php echo $keyword; ?>','_self')
	}
	<?php $enc = (!empty($enc)) ? "/".$enc : $enc;?>
	function searchDetilShow(){
		window.open('<?php echo base_url();?>search','_self')
	}

function edit(){
	$(':input').prop('readonly', false);
	$(':input').attr('readonly', false);
	$('.custom-dropdown__select').prop('disabled',false);
	$('.custom-dropdown__select').attr('disabled',false);
	$('#jenis_transaksi').prop('disabled',false);
	$('#aktif').prop('disabled',false);
	$('#simpan_btn').prop('disabled',false);
	$('#edit_btn').prop('disabled',true);
}
function show_edit(enc_alur,enc){
	
	if(enc!=''){	
		$.post( "<?php echo base_url()?>manage_ref_biaya_perkara/info",{
	        enc_alur:enc_alur,enc:enc
	    }).done(function( response ){
	    	var json = jQuery.parseJSON(response);
	        if(json.st==1){
	        	$('#enc_by').val(json.enc_by);
	        	$('#enc_al').val(json.enc_al);
	    		$('#klasifikasi').val(json.klasifikasi);
	        	$('#tahapan_proses').val(json.tahapan_proses);
	        	$('#jenis_transaksi').val(json.jenis_transaksi);
	        	$('#kategori_biaya').val(json.kategori_biaya);
	        	$('#jenis_biaya').val(json.jenis_biaya);
	        	$('#jumlah').val(json.jumlah);
	        	$('#keterangan').val(json.keterangan);
	        	$('#aktif').val(json.aktif);
	        	$('#sub_title').html('INFO BIAYA PERKARA');
	        	$('#edit_btn').prop('disabled',false);
	        	$('#edit_btn').attr('disabled',false);
	        	$('.custom-dropdown__select').attr('disabled',true);
	        	$('#klasifikasi_dropdown').attr('disabled',false);
	        	$(':input').not('.btn').not('.btn_small').attr('readonly', true);
	        }else{
	        	return;
	        }
	    },'json');
	}else{
		edit();
	}
    $('#popup_biaya_perkara').fadeIn();
    $("body").css({overflow: 'hidden'});
}

function kembali_biaya_perkara(){
	$('#popup_biaya_perkara').fadeOut();
	if($('#refresh').val()==1){
		window.open('<?php echo base_url().'ref_biaya_perkara_list';?>','_self');
	}
	$(':input').not('.btn').not('.btn_small').val('');
	$('.hidden').hide();
	$('#edit_btn').show();
	$('#simpan_btn').prop('disabled',true);
	$("body").css({ overflow: 'inherit' })
}

$('#frm_biaya_perkara').SubmitHandling({
   	refresh:'1',
    setRefresh:1,
    divRef:'#frm_biaya_perkara',
    clicked:1,
    btnClicked:'#refresh',
    whenStatus:1,
});
</script>
