<style>
#_labelGridManual{
	text-align: left;
	font-size: 13px;
	font-weight: bold;
	margin-top: -20px;
	margin-bottom: 5px;
}
#_labelGridKet{
	text-align: left;
	font-size: 12px;
	margin-top: -10px;
	margin-bottom: 10px;
}
._gridPopUpManual{
	border: 1px solid #cfcfcf;
	width: 100%;
}
._gridPopUpManual thead{
	background: url("<?php echo $this->baseUrl.'assets/css/flexigrid/images/' ?>thead_bg.png") repeat-x scroll
}
._gridPopUpManual th{
	font-weight: bold;
	padding: 3px;
	font-size: 13px;
	border-right: 1px solid #cfcfcf;
	text-align: center;
	center bottom #fafafa;
}
._gridPopUpManual tr td ._manualGridTd{
	padding: 3px;
	padding-top: 5px;
	padding-botom: 5px;
	font-size: 12px;
	border-right: 1px solid #cfcfcf;
    overflow: hidden;
}
._recManualGrid{
	font-size: 12px;
	border: none;
}
._gridPopUpManual tbody {
    height: 300px;
    overflow: auto;
}
#_gridPopUpManual thead > tr{
    display:block;
}
#_gridPopUpManual tbody{
    display:block;
}
._filterManualGrid{
	font-size: 11px;
}
._recManualGrid{
	background: none;
}
input[type="text"][readonly]{
	background: none;
}
._recManualGrid:focus{
	background-color: yellow;
}
</style>
<?php
$data = $this->data->data;
$no = $data->get['nomor'];
?>
<input type="hidden" id="_typeBrowse" value="<?php echo $this->data->mode ?>">
<input type="hidden" id="_maxNo" value="<?php echo $data->total ?>">
<input type="hidden" id="_noFirst">
<input type="hidden" id="_noLast">
<p id="_labelGridManual"><?php echo $this->data->set->modul ?></p>
<p id="_labelGridKet">
	<?php echo ' Jumlah Data '.number_format($data->total).' Record' ?>
</p>
<div id="_loadManualGridTop" style="font-size: 12px;"></div>
<table id="_gridPopUpFlexy" class="_gridPopUpFlexy" cellspacing="0" cellpadding="0">
	<thead>
		<tr>
			<th style="width: 30px">&nbsp;</th>
			<th style="width: 30px">No</th>
			<?php foreach($this->data->set->grid->attr as $row){  ?>
				<th style="width: <?php echo $row['width'] ?>px">
					<div class="_manualGridTd" style="width: <?php echo $row['width'] ?>px" align="<?php echo $row['align']?>">
						<?php echo $row['label'] ?>
					</div>
				</th>
			<?php } ?>
		</tr>
		<tr>
			<th>
				<div class="_manualGridTd" style="width: 30px" align="<?php echo $row['align']?>">
					<input type="hidden" style="width: 15px">
				</div>
			</th>
			<th>
				<div class="_manualGridTd" style="width: 30px" align="<?php echo $row['align']?>">
					<input type="hidden" style="width: 15px">
				</div>
			</th>
			<?php 
			foreach($this->data->set->grid->attr as $key => $row){  
				$id = 'filter'.str_ireplace(".", "", $row['attr']);
				$disBld = "";
				if(strtoupper($row['filter']) == strtoupper('disabled')){
					$disBld = 'readonly';
				}
				
				$valDef = '';
				if($this->data->mode != 'popUp'){
					if(!empty($row['default'])){
						$valDef = $row['default'];
					}
				}
				
			?>
				<th style="width: <?php echo $row['width'] ?>px">
					<div class="_manualGridTd" style="width: <?php echo $row['width'] ?>px" align="<?php echo $row['align']?>">
						<input type="text" <?php echo $disBld ?> class="text <?php echo $cls ?> _filterManualGrid <?php echo $id ?>" baris="0" _no=<?php echo $key ?> id="_filterManualGrid_<?php echo $key ?>" style="width: <?php echo ($row['width'] - 5) ?>px" value="<?php echo $valDef ?>">
					</div>
				</th>
			<?php } ?>
		</tr>
	</thead>
	<tbody id="_displayManualGridData"><?php include "dataManualGridFlexy.phtml" ?></tbody>
</table>
<div id="_divNavManualGrid" style="margin-top: 5px;">
	<a id="_manualGridFirst" href="#"><img title="First" src="<?php echo $this->baseUrl.'assets/css/flexigrid/images/first.gif' ?>"></a>
	&nbsp;&nbsp;
	<a id="_manualGridPrev" href="#"><img title="Prev" src="<?php echo $this->baseUrl.'assets/css/flexigrid/images/prev.gif' ?>"></a>
	&nbsp;&nbsp;
	<a id="_manualGridNext" href="#"><img title="Next" src="<?php echo $this->baseUrl.'assets/css/flexigrid/images/next.gif' ?>"></a>
	&nbsp;&nbsp;
	<a id="_manualGridLast" href="#"><img title="Last" src="<?php echo $this->baseUrl.'assets/css/flexigrid/images/last.gif' ?>"></a>
</div>
<div id="_loadManualGridBottom" style="font-size: 12px;"></div>
<div id="_loadManualGrid"></div>
<?php
if(empty($_GET['ctrl'])){
	$cls = $this->getParameter['controller'];
	$_SESSION['dataSetting'][$cls] = $this->data->set->set;
	$_SESSION['dataSetting'][$cls]->database = $this->config['dbConnection.dbServer'];
}
?>
<script type='text/javascript'>
$(document).ready(function(){
	$('#_cls').val("<?php echo $cls ?>");
	makeFilterManualGrid = function(){
		_fil = '';
		<?php 
		foreach($this->data->set->grid->attr as $key => $row){  
			$id = 'filter'.str_ireplace(".", "", $row['attr']);
		?>
			_fil+= '&<?php echo $id ?>='+$('.<?php echo $id ?>').val();
		<?php } ?>
		_fil = str_ireplace("undefined", "", _fil);
		_fil = str_ireplace("/", "___", _fil);
		_fil = str_ireplace("+", "***", _fil);
		_fil = str_ireplace("%", "---", _fil);
		return _fil;
	}
	
	_cariManualGrid = false;
	$('._filterManualGrid').keyup(function(e){
		_kode = parseInt(e.which);
		if(_kode === 37 || _kode === 39){
			_no = parseInt($(this).attr("_no"));
			if(_kode === 37){
				_no = _no - 1; 
			}
			if(_kode === 39){
				_no = _no + 1; 
			}
			if(_no < 0){
				_no = 0;
			}
			$('#_filterManualGrid_'+_no).focus().select();
		}
		if(_kode === 13){
			_fil = makeFilterManualGrid();
			
			if(_cariManualGrid != false){
				_cariManualGrid.abort();
			}
			
			$("#_displayManualGridData").html('Loading......');
			_cariManualGrid = $.ajax({
			type: "GET",
				url: "<?php echo $this->baseUrl ?>Basic/cariData/&_ctrl=<?php echo $cls ?>"+_fil,
				data: $(this).serialize(),
				success: function(data) {
					$("#_displayManualGridData").html(data);
				}
			})
			
		}
		if(_kode === 27){
			$('#apankForm').empty();
		}
	})

	_navManualGrid = false;
	$('#_manualGridFirst').click(function(){
		if(_navManualGrid != false){
			_navManualGrid.abort();
		}
		$("#_displayManualGridData").html('Loading......');
		_fil = makeFilterManualGrid();
		_navManualGrid = $.ajax({
		type: "GET",
			url: "<?php echo $this->baseUrl ?>Basic/manGridFirst/&_ctrl=<?php echo $cls ?>"+_fil,
			data: $(this).serialize(),
			success: function(data) {
				$("#_displayManualGridData").html(data);
			}
		})
	})
	$('#_manualGridLast').click(function(){
		if(_navManualGrid != false){
			_navManualGrid.abort();
		}
		$("#_displayManualGridData").html('Loading......');
		_fil = makeFilterManualGrid();
		_navManualGrid = $.ajax({
		type: "GET",
			url: "<?php echo $this->baseUrl ?>Basic/manGridlast/&_ctrl=<?php echo $cls ?>"+_fil,
			data: $(this).serialize(),
			success: function(data) {
				$("#_displayManualGridData").html(data);
			}
		})
	})
	$('#_manualGridNext').click(function(){
		$('#_loadManualGridBottom').html("Loading.....");
		loadManualGrid($('#_noLast').val(), 'next');
	})
	$('#_manualGridPrev').click(function(){
		$('#_loadManualGridTop').html("Loading.....");
		loadManualGrid($('#_noFirst').val(), 'back');
	})
	makeBesarFont = function(){
		$('._recManualGrid, ._filterManualGrid').css("font-weight", "bold").css("font-size", "15px");
	}
	_cls = $('#_cls').val();
	if(_cls === 'Pcc1'){
		makeBesarFont();
	}
	<?php if(!empty($_GET['get_def'])){ ?>
		$('.<?php echo $this->data->def_filter ?>').val('<?php echo $_GET['get_def'] ?>');
	<?php } ?>
	
	$('#_gridPopUpFlexy').flexigrid({
		height: 400,
	});
})
</script>
