<table align="center" style="border-spacing: 0in 0in; overflow: hidden !important;" id="<?=count($_POST['product_id'])?>">

<?php

$per_row_count = 3;
$min_width_mm = 35;
$min_height_mm = 22;
$max_height_mm = 22;

if(isset($_POST['product_id'])){
    error_log("Product Id Varudhu");
    $i=1; 
    for($p=0;$p<count($_POST['product_id']);$p++){
               
        error_log("For Loop Count Kulla Varudhu");       
        for($c=0;$c<$_POST['lable_quantity'][$p];$c++){
            
            error_log("For Loop Count Kulla Varudhu");   
            
            if($i % $per_row_count == 1 || $i==1){ 
                echo '<tr>';
            }
?>


			<td align="center" valign="center">
                <div style="overflow: hidden !important; display: flex; flex-wrap: wrap; align-content: center; 
                min-width: <?=$min_width_mm?>mm; min-height: <?=$min_height_mm?>mm; max-height: <?=$max_height_mm?>mm; 
                justify-content: center;">
                    <div><br>
						<span style="display: block !important; font-size:11px">
						    <b>HSN: </b>
    						<?php if(strlen($_POST['hsn_code'][$p]) > 17){
                                echo  substr($_POST['hsn_code'][$p], 0, 15) . '...';
    						}else{
    						    echo $_POST['hsn_code'][$p];
    						} ?>
						</span>
						<span style="display: block !important; font-size: 14px !important;"><b>Stone Cost: </b><?=number_format($_POST['stone_cost'][$p],2)?></span>
				        <?php  echo "<img alt='Barcode' style='margin-bottom:5px !important;max-width:125% !important;height:25px;width:125px;' src='official-barcode.php?codetype=Code128&size=25&text=".$_POST['pro_unit'][$p].''.str_pad($i, 3, '0', STR_PAD_LEFT)."'/>"; ?>
	                    <br><span style="font-size:11x !important;"><b>C-S-N: <?=$_POST['weight_details'][$p]?></b></span> <br>&nbsp;
				    </div>
                </div>
		    </td>
<?php 
    if($i % $per_row_count == 0){ 
        echo '</tr>';
    }
$i++;
} } } 
?>
</table>




<style type="text/css">

@media  print{
	    
	    
	    
	table{
		page-break-after: always;
	}
		
		
		
    body{
        margin: 0px !important;
        font-family: sans-serif !important;
    }



	@page  {
		size: 4in 22mm;
		margin-top: 0in !important;
		margin-bottom: 0in !important;
		margin-left: 0in !important;
		margin-right: 0in !important;
	}
	
	
	
}
</style>

<script>window.print()</script>