<?php
$kode = new Kode;
?>
<script type="text/javascript">
$(document).ready(function(){

	cekLastDet = function(){
		_lastBaris = parseInt($('#_lastBarisDet').val());	
		for(_iC = _lastBaris; _iC > 1; _iC--){
			_cek = $('#barisDet_'+_iC).attr('id');
			if(_cek != undefined){
				return _iC + 1;
			}
		}
		return 1;
	}
	_lastBaris = cekLastDet();
	_lastBarisSblm = _lastBaris - 1;
	_tabDet = '';
	<?php
		foreach($this->data->data as $r){
	?>
			_tabDet+= '<tr id="barisDet_'+_lastBaris+'">';
			<?php 
			$rows = 1;
			foreach($this->data->detail->attr as $keyD => $row){ 
				$idDet = $row['attr'];
				$type = "text";
				if(!empty($row['type'])){
					$type = $row['type'];
				}
				$dis = '';
				if(strtoupper($type) == strtoupper('hidden')){
					$dis = '; display: none';
				}else{
					$tambah = $kode->setAttrDetail($row, '');
				}
			?>
				_tabDet+= '<td style="width: <?php echo $row['width'] ?>px; <?php echo $dis ?>" class="_detTdItem"><input type="<?php echo $type ?>" row="<?php echo $rows ?>" col="'+_lastBaris+'" class="text _detTd _detTd_'+_lastBaris+'_<?php echo $rows ?> <?php echo $row['class'] ?>" style="width:<?php echo ($row['width']) ?>px" name="<?php echo $idDet ?>['+_lastBaris+']" id="<?php echo $idDet.'_' ?>'+_lastBaris+'" autocomplete="off" value="<?php echo $r->$idDet ?>" title="<?php echo $r->$idDet ?>" dec="<?php echo (int)$row['dec'] ?>" _mode="cursor" <?php echo $tambah ?>></td>';
			<?php 
				$rows++;
			} 
			?>
			_tabDet+= '<tr>';
			_lastBaris = _lastBaris + 1;
	<?php 
		}
	?>

	if(_lastBarisSblm <= 0){
		$('#_detBody').html(_tabDet);
	}else{
		$('#barisDet_'+_lastBarisSblm).after(_tabDet);
	}

	_lastBarisNew = _lastBaris;
	$('#_lastBarisDet').val(_lastBarisNew);	
	$('#apankForm').empty();
	setDec();
	<?php if(!empty($this->data->funct)){ ?>
		display('<?php echo $this->data->funct ?>', 1);
	<?php } ?>
})
</script>