<table align="center" style="border-spacing: 0in 0in; overflow: hidden !important;" id="">

<?php
include "config/config.php";
if(isset($_GET['product_variant_id']) && $_GET['product_variant_id']){
    $product_variant_id = $_GET['product_variant_id'];
}else{
    $product_variant_id = 0;
}

$statements = $pdo->prepare("SELECT p.*,tbl_ids_purity.short_name,
tbl_products_name.product_hsn_code
FROM `tbl_product_variants` p 
LEFT JOIN tbl_ids_purity ON tbl_ids_purity.id=p.purity
LEFT JOIN tbl_products_name ON tbl_products_name.id=p.product_name
WHERE p.id=?");
$statements->execute(array($product_variant_id));
$resultss = $statements->fetchAll(PDO::FETCH_ASSOC);
$totalDatas = $statements->rowCount();
        
        
if(isset($_GET['quantity']) && $_GET['quantity']){
    $product_quantity = $_GET['quantity'];
}else{
    $product_quantity = 0;
}
$per_row_count = 3;
$min_width_mm = 35;
$min_height_mm = 22;
$max_height_mm = 22;


$product_id = $product_variant_id; 

if(isset($product_id)){
    $i=1; 
    for($p=0;$p<count($product_id);$p++){
        
        
        $hsn_code = $resultss[0]['hsn_code'];
        $stone_cost = $resultss[0]['stone_cost'];
        $short_name = "(".$resultss[0]['short_name'].")";
        $product_org_hsn_code = $resultss[0]['product_hsn_code'];
                     
        for($c=0;$c<$product_quantity[$p];$c++){
              
            
            if($i % $per_row_count == 1 || $i==1){ 
                echo '<tr>';
            }
?>


			<td align="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>
						<span style="display: block !important; font-size:11px">
						    <b>
    						<?php if(strlen($product_org_hsn_code) > 17){
                                echo substr($product_org_hsn_code, 0, 15) . '...';
    						}else{
    						    echo $product_org_hsn_code;
    						} ?>
    						
    						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    						<?=number_format($stone_cost,2)?>
    						</b>
						</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=".$product_id.''.str_pad($i, 3, '0', STR_PAD_LEFT)."'/>"; ?>
	                    <br>
	                    <span style="font-size:11x !important;">
	                        <b><?=$hsn_code?>
	                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	                        <?=$short_name?>
	                        </b>
	                    </span>
				    </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>