<?php 
include 'load.php';
$qid = $_GET['gid'];
$total = 0;
$quotationinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM grn WHERE grn_no='$qid'"));

$grn_nomber = $quotationinfo['grn_nomber'];
$date = $quotationinfo['date'];
$alldiscount = $quotationinfo['alldiscount'];
$discountedtotal = $quotationinfo['discountedtotal'];
$rdallownce = $quotationinfo['rdallownce'];
$formattedDate = date("M d, Y", strtotime($date));
$supplier = $quotationinfo['supplier'];

$supplerinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobilesuppliers WHERE spid='$supplier'"));
$supname =  $supplerinfo['spname'];
$spemail =  $supplerinfo['spemail'];
$spphone =  $supplerinfo['spphone'];
$spaddress =  $supplerinfo['spaddress'];

$quotationiteminfo = mysqli_query($conn, "SELECT * FROM grn_item WHERE grn_no='$qid'");
$c= 1;
$tbody="";
while($row = mysqli_fetch_assoc($quotationiteminfo)) {
	$prid = $row['product_id'];
	$productinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobileproducts WHERE prid='$prid'"));
    $tbody.='<tr class="tb">
                <td>'.$c.'</td>
                <td class="pname" style="font-family:iskoola_pota;">'.$productinfo['proname'].'</td>		
                <td>'.$row['qty'].'</td>
				<td>'.$row['discount'].'</td>
                <td>LKR '.number_format($row['price'], 2).'</td>
                <td style="text-align:right;">LKR '.number_format($row['discount_price']*$row['qty'], 2).'</td>';
                $total = $total + ($row['discount_price']*$row['qty']);
               
$c++;
}

$header = '<div class="header">
	<div class="headerleft">
	<img src="images/settings/999882.png" width="170" height="auto">
		
	</div>
	<div class="headerright">
		<div class="wrap">
			<div class="qtitle">Good Received  Note</div>
			<div class="qtydate">GRN No  #  <span><strong>'.' '.$grn_nomber.'</strong></span></div>
			<div class="qtydate"> Date  <span><strong>'.' '.$formattedDate.'</span></strong></div>
			
			
		</div>
	</div>
</div>';
?>