<div id="_hedBill">
	<?php 
		if(empty($this->data->kasir->no_order)){
			echo $this->data->meja->nm_merek; 
		}
		else{
			echo date("dmy", strtotime($this->data->kasir->tgl)).str_pad($this->data->kasir->no_order, 3, "0", STR_PAD_LEFT).' ('.date("H.i", strtotime($this->data->kasir->tgl)).')<br>'.$this->data->meja->nm_merek; 	
		}
		
	?>
</div>
<div id="_detBill">
		
</div>
<form id="postItem">
	<input type="hidden" id="kodemeja">
</form>
<input type="hidden" id="baseUrl" value="<?php echo $this->baseUrl ?>">
<script>
$(document).ready(function(){	
	$('#kodemeja').val('<?php echo $this->data->meja->kd_merek ?>');
	
	_loadOrder = false;
	loadOrder = function(){
		_meja = $('#kodemeja').val();
		if(_loadOrder != false){
			_loadOrder.abort();
		}
		$('#_detBill').html('Loading...');
		
		_loadOrder = $.ajax({
			url: $('#baseUrl').val()+'posrmobile/loadOrder/&kode='+_meja,
			type : 'POST',
			data : $('#postItem').serialize(),
			success: function(data){
				$('#_detBill').html(data);
			}
		});
	}
	loadOrder();
	
	_makeCheckItem = false;
	makeCheckItem = function(_kode, _status = "T"){
		_meja = $('#kodemeja').val();
		if(_makeCheckItem != false){
			_makeCheckItem.abort();
		}
		$('#_detBill').html('Loading...');
		
		_makeCheckItem = $.ajax({
			url: $('#baseUrl').val()+'posrmobile/checkItem/&kode='+_meja+'&no_item='+_kode+'&status='+_status,
			type : 'POST',
			data : $('#postItem').serialize(),
			success: function(data){
				$('#_detBill').html(data);
			}
		});
	}
    
    $('._iconMeja').removeClass('_mejaAktif');
	<?php foreach($this->data->aktif as $meja){ ?>
		$('#_iconMeja_<?php echo $meja ?>').addClass("_mejaAktif");
	<?php } ?>
})
</script>