<?php
    $grup = array();
	foreach($this->data->item as $r){
		$grup[$r->no_pos][] = $r;
	}
	
	foreach($grup as $row){
		echo "<div class='_divItem0'>";
		echo "<h3>Meja ".$row[0]->meja.'</h3>';
		foreach($row as $r){
			$cLr = '';
			if(empty($r->status)){
				$cLr = '_notApp';
			}
			else if($r->status == "T"){
				$cLr = '_orderFinish';
			}
	?>
	<div class="_divItem <?php echo $cLr ?>">
		<div class="_divItem1">
			<?php 
			echo $r->no_pos;
        	echo "<br>".$r->tgl.' - '.$r->model;
        	if($cLr == '_orderFinish'){
        	    echo "- Last Print: ".$r->tgl_print;
        	}
			?>
		</div>
		<div class="_divItem3">
			<input type="button" url="<?php echo $r->url ?>" kode="<?php echo $r->no_print ?>" class="_btnCheck" value="Print">
		</div>
	</div>
<?php 
    	}
    	echo "</div>";
    } 
?> 
<script>
$(document).ready(function(){
	$('._btnCheck').click(function(){
		_url = $(this).attr('url');
		_kode = $(this).attr('kode');
		
		window.open(_url, '_blank', 'height=600,width=800');
		makeCheckPrint(_kode);
	});
	
	$('._divItem._notApp ._btnCheck').each(function(index){
		setTimeout(() => {
			$(this).trigger('click');
		}, index * 800);
	});
})
</script>