<hr class="thick-line" style="clear:both;">
<form id="frm_filter" method="post" action="<?php echo base_url().'reminder/filter';?>">
	<table>
		<col  width="30%" />
		<col  width="5%" />
		<col  width="30%" />
		<col  width="5%" />
		<col  width="30%" />
		<tbody>
			<tr>
				<td>
					<span class="custom-dropdown custom-dropdown--emerald" style="width:200">
						<select style="width:200" name="jenis_perkara" id="jenis_perkara" onchange="" class="custom-dropdown__select custom-dropdown__select--white">
							<option value="-1">-- Semua Alur Perkara --</option>
							<?php
								if($jenis_perkara!=''){
									if($jenis_perkara->num_rows>0){
									    foreach ($jenis_perkara->result() as $row) {
									    	echo '<option value="'.$row->id.'"';echo ($row->id == $jenis_perkara_opt) ? 'selected' : ''; echo ' >'.$row->nama.'</option>';
									    }
									}
								}
							?>
						</select>
					</span>
				</td>
				<td style="width:200"></td>
				<td>
					<span class="custom-dropdown custom-dropdown--emerald" style="width:200">
						<select style="width:200" name="tahapan" id="tahapan" onchange="" class="custom-dropdown__select custom-dropdown__select--white">
							<option value="-1">-- Semua Tahapan --</option>
							<?php
								if($tahapan!=''){
									if($tahapan->num_rows>0){
									    foreach ($tahapan->result() as $row) {
									    	echo '<option value="'.$row->id.'"';echo ($row->id == $tahapan_opt) ? 'selected' : ''; echo ' >'.$row->nama.'</option>';
									    }
									}
								}
							?>
						</select>
					</span>
				</td>
				<td style="width:200">
				</td>
				<td>
					<span class="custom-dropdown custom-dropdown--emerald" style="width:200">
						<select style="width:200" name="proses" id="proses" onchange="" class="custom-dropdown__select custom-dropdown__select--white">
							<option value="-1">-- Semua Proses --</option>
							<?php
								if($proses!=''){
									if($proses->num_rows>0){
									    foreach ($proses->result() as $row) {
									    	echo '<option value="'.$row->id.'"';echo ($row->id == $proses_opt) ? 'selected' : ''; echo ' >'.$row->nama.'</option>';
									    }
									}
								}
							?>
						</select>
					</span>
				</td>
				<input type="submit" id="filter" hidden>
			</tr>
		</tbody>
	</table>
</form>
<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', 'onClick' => 'load()');
	echo form_submit($attributes);
	echo form_close('');
	?>
</div>
<div id="left" style="margin-left:50px;">
	<input type="submit" value="Excel" class="btn"></input>
</div>
<?php
$action = base64_encode($this->encrypt->encode("add"));
if($this->session->userdata('is_logged_in')){
	$AuthorizationForm = $this->nativesession->get('AuthorizationForm');
	if(empty($AuthorizationForm)){
		redirect('logout');
	}
	if( ($this->authorization->isAuthorized('proses_alur_perkara_list',$AuthorizationForm)==FALSE)
		OR ($this->authorization->isAuthorized('proses_alur_perkara_edit_list',$AuthorizationForm)==FALSE)
		OR ($this->authorization->isAuthorized('proses_alur_perkara_edit',$AuthorizationForm)==FALSE)){
		redirect('login');
	}
}else{
	redirect('login');
}
?>
<div id="pages">
    <div id="selector"></div>
</div>
<div class="cssTable">
	<table id="tablePerkaraAll">
		<col  width="3%" />
        <col  width="13%" />
        <col  width="12%" />
        <col  width="23%" />
        <col  width="7%" />
        <col  width="7%" />
        <col  width="16%" />
        <col  width="5%" />
        <col  width="7%" />
        <col  width="5%" />
		<tbody>
			<tr>
				<td>No</td>
				<td onclick="sorting(1)">Jenis Perkara</td>
				<td onclick="sorting(2)">Tahapan</td>
				<td onclick="sorting(3)">Proses</td>
				<td onclick="sorting(4)">Batas Waktu</td>
				<td onclick="sorting(5)">Satuan</td>
				<td onclick="sorting(6)">Dari Proses</td>
				<td onclick="sorting(7)">Aktif</td>
				<td onclick="sorting(8)">Reminder</td>
				<td>Link</td>
			</tr>
			<?php
				if($reminder_list!=''){
					if($reminder_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 ($reminder_list->result() as $row) {
		    				$reminder = ($row->reminder==1)? 'Ya':'Tidak';
		    				echo "<tr>";
			    				echo '<td>'.$con.'</td>';
			    				echo '<td>'.$row->jenis_perkara.'</td>';
			    				echo '<td>'.$row->tahapan_nama.'</td>';
			    				echo '<td>'.$row->proses_nama.'</td>';
			    				echo '<td>'.$row->batas_waktu.'</td>';
			    				echo '<td>'.$row->satuan.'</td>';
			    				echo '<td>'.$row->proses.'</td>';
			    				echo '<td>'.$row->aktif_text.'</td>';
			    				echo '<td>'.$reminder.'</td>';
			    				echo '<td style="cursor:pointer;" align="center" onclick="show_edit(\''.base64_encode($modelClass->encrypt->encode($row->id)).'\')">[<a href="#">edit</a>]</td>';
		    				echo "</tr>";
		    				$con++;
		    			}
			    	}else{
		    			echo "<tr><td colspan='10' align='center'>Data Tidak diTemukan</td></tr>";
		    		}
				}else{
		    		echo "<tr><td colspan='10' 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_reminder" class="popup">
	<div style="margin: 0 auto;top: 50%;margin-top: 10%;margin-bottom: 25px;">
		<div class="detil" style="background-color:white;border-color: white;font-size:14px;margin-top:25px;width: 50%;margin: 0 auto;">
			<div id="sub_title" style="padding:10px;color:#5FB85C;text-align:center;">INFO DATA HAKIM</div>
			<form id="frm_reminder" style="background:white;margin:0;" method="post" action="<?php echo base_url().'reminder/validate_input';?>">
				<table id="tableDetilPerkara">
					<col width="40%">
					<col width="60%">
					<tbody>
						<tr>
							<td>Jenis Perkara</td>
							<td style="padding:0px;padding-left:5px;">
								<input id='jenis_perkara_pop' name='jenis_perkara_pop' value='' class="standard-input" readonly>
							</td>
						</tr>
						<tr>
							<td>Tahapan</td>
							<td style="padding:0px;padding-left:5px;">
								<input id='tahapan_pop' name='tahapan_pop' class="standard-input" readonly>
							</td>
						</tr>
						<tr>
							<td>Proses</td>
							<td style="padding:0px;padding-left:5px;">
								<input id='proses_pop' name='proses_pop' class="standard-input" readonly>
							</td>
						</tr>
						<tr>
							<td>Terhitung Dari</td>
							<td style="padding:0px;padding-left:5px;">
								<span class="custom-dropdown custom-dropdown--emerald" style="width:300">
									<select style="width:300" name="dari_proses" id="dari_proses" class="custom-dropdown__select custom-dropdown__select--white">
										<option value="-1">-- Semua Proses --</option>
										<?php
											if($proses!=''){
												if($proses->num_rows>0){
												    foreach ($proses->result() as $row) {
												    	echo '<option value="'.$row->id.'">'.$row->nama.'</option>';
												    }
												}
											}
										?>
									</select>
								</span>
							</td>
						</tr>
						<tr>
							<td>Batas Waktu Maksimal</td>
							<td style="padding:0px;padding-left:5px;">
								<input id='batas' name='batas' class="standard-input" style="width:60px" readonly>
							</td>
						</tr>
						<tr>
							<td>Satuan</td>
							<td style="padding:0px;padding-left:5px;">
								<span class="custom-dropdown custom-dropdown--emerald" style="width:130px">
									<select style="width:130px" name="satuan" id="satuan" class="custom-dropdown__select custom-dropdown__select--white" disabled>
										<option value="1"> Hari Kerja</option>
										<option value="2"> Hari Kalender</option>
										<option value="3"> Bulan</option>
									</select>
								</span>
							</td>
						</tr>
						<tr>
							<td>Aktif</td>
							<td style="padding:0px;padding-left:5px;">
								<span class="custom-dropdown custom-dropdown--emerald" style="width:130px">
									<select style="width:130px" name="aktif" id="aktif" class="custom-dropdown__select custom-dropdown__select--white" disabled>
										<option value="1"> Ya</option>
										<option value="0"> Tidak</option>
									</select>
								</span>
							</td>
						</tr>
						<tr>
							<td>Pesan Pengingat</td>
							<td style="padding:0px;padding-left:5px;">
								<span class="custom-dropdown custom-dropdown--emerald" style="width:130px">
									<select style="width:130px" name="reminder" id="reminder" class="custom-dropdown__select custom-dropdown__select--white" disabled>
										<option value="1"> Ya</option>
										<option value="0"> Tidak</option>
									</select>
								</span>
							</td>
						</tr>
						<input type="hidden" id='idH' name="idH">
						<tr>
							<td colspan="2" style="background:white;" align="center">
							<input type="button" onClick='kembali_proses_alur();' id="refresh" value="Kembali" class="btn">
							<?php
							if($this->authorization->isAuthorized('proses_alur_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>
					</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 val_to_ma(){
	alert('blm diimplementasi, tarik data dari MA-SIKEP')
}
function edit(){
	$('.custom-dropdown__select').prop('disabled',false);
	$('.custom-dropdown__select').attr('disabled',false);
	$('#simpan_btn').prop('disabled',false);
	$('#edit_btn').prop('disabled',true);
	$('#batas').prop('readonly',false);
	$('#batas').attr('readonly',false);
}
function show_edit(enc){
	if(enc!=''){
		$.post( "<?php echo base_url()?>reminder/info",{
	        enc:enc
	    }).done(function( response ){
	    	var json = jQuery.parseJSON(response);
	        if(json.st==1){
	        	$('#jenis_perkara_pop').val(json.jenis);
	        	$('#idH').val(json.idH);
	        	$('#proses_pop').val(json.proses);
	        	$('#dari_proses').val(json.dari_proses);
	        	$('#tahapan_pop').val(json.tahapan);
	        	$('#aktif').val(json.aktif);
	        	$('#batas').val(json.batas);
	        	$('#satuan').val(json.satuan);

	        	$('#reminder').val(json.reminder);
	        	$('#sub_title').html('INFO DATA');
	        	$('#edit_btn').prop('disabled',false);
	        	$('#edit_btn').attr('disabled',false);
	        	$('.custom-dropdown__select').attr('disabled',true);
	        	$(':input').not('.btn').not('.btn_small').attr('readonly', true);
	        	$('#popup_reminder').fadeIn();
	        	$("body").css({overflow: 'hidden'});
	        }else{
	        	closeLoading();
	        	message_show(json.msg);
	        }
	    },'json');
	}else{
		alert('Error, Please refresh your browser and clear the cache')
	}
   
}

function kembali_proses_alur(){
	$('#popup_reminder').fadeOut();
	if($('#refresh').val()==1){
		//window.open('<?php echo $this->nativesession->get_flash_session("url_requested");?>','_self');
		window.open('<?php echo base_url().'proses_alur_perkara_list';?>','_self');
	}
	$(':input').not('.btn').val('');
	$('.hidden').hide();
	$('#edit_btn').show();
	$('#simpan_btn').prop('disabled',true);
	$("body").css({ overflow: 'inherit' });
	closeLoading();
}

$('#frm_reminder').SubmitHandling({
   	refresh:'1',
    setRefresh:1,
    divRef:'#frm_reminder',
    clicked:1,
    btnClicked:'#refresh',
    whenStatus:1,
});

$(document).ready(function(){
	$('#tahapan').change(function(){
   		openLoadingDialog();
   		$('#filter').click();
   	});
   	$('#jenis_perkara').change(function(){
   		openLoadingDialog()
       	$('#filter').click();
    });
   	$('#proses').change(function(){
   		openLoadingDialog()
       	$('#filter').click();
    });
    $('#batas').ForceNumericOnly();
});
</script>
