<table class="table">
	<thead>
		<tr>
			<th scope="col">#</th>
			<th scope="col">Code</th>
			<th scope="col">Name</th>
			<th scope="col" style="text-align: right;">Price</th><th scope="col" style="text-align: right;">Quantity</th><th scope="col" style="text-align: right;">Amount</th>
		</tr>
	</thead>
	<tbody style="padding: 0px;">
		<?php
		session_start();
		require_once 'db_connection.php'; 
		$tr_note_id = $_POST['tr_note_id'];
		$user_id = $_SESSION['emid'];
		$total_amount = 0; 

		$sql = "SELECT *  FROM mobileagency_stock LEFT JOIN mobileproducts ON mobileproducts.prid=mobileagency_stock.product_id
		WHERE mobileagency_stock.stock_transfer_order='$tr_note_id'   ORDER BY mobileagency_stock.transfer_id  DESC";

		$result = $conn->query($sql);
		$rowCount = 0;
		if ($result->num_rows > 0) {
			while($row = $result->fetch_assoc()) {
				$rowCount = $rowCount+1;
				$transfer_id = $row["transfer_id"];
				$product_id = $row["product_id"];
				$proname = $row["proname"];
				$prcode = $row["prcode"];
				$quantity = $row["agency_quantity"];
				$price =$row["agency_price"];
				$amount = $price*$quantity;
				$total_amount = $total_amount+$amount;
				?>

				<tr>
					<th scope="row"><?php echo $rowCount; ?></th>
					<td><?php echo $prcode; ?></td>
					<td style="text-align: left;"><?php echo $proname; ?></td>
					<td style="text-align: right;"><?php echo number_format((float)$price,2); ?></td>
					<td style="text-align: right;"><?php echo $quantity; ?></td>
					<td style="text-align: right;"><?php echo number_format((float)$amount,2); ?></td>
				</tr>
				<?php
			}
		}else{
			echo "Not found items..";
		}
		?>
	</tbody>
	<tfoot style="background: #ebebeb;">
		<tr>
			<td colspan="5">Total </td>
			<td style="text-align: right;"><?php echo number_format((float)$total_amount,2); ?></td>
			<td colspan=""> </td>
		</tr>
	</tfoot>
</table>
