<table class="table" id="myTab">
	<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>
			<th scope="col" style="text-align: right;">X</th>
		</tr>
	</thead>
	<tbody style="padding: 0px;">
		<?php
		session_start();
		require_once 'db_connection.php'; 
		$agency = $_POST['agency'];
		$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.transfer_by='$user_id' AND mobileagency_stock.stock_transfer_order=0   ORDER BY mobileagency_stock.transfer_id AND  mobileagency_stock.product_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"];
				$agency_id = $row["agency_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>
					<td style="text-align: right;">
						<a class="confirm-text" href="javascript:void(0);"><img src="assets/img/icons/delete-2.svg" alt="img" onclick="deleteCartItem(<?php echo $transfer_id;  ?>,<?php echo $product_id; ?>,<?php echo $quantity; ?>,<?php echo $agency_id; ?>,<?php echo $rowCount; ?>);"></a>
					</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>

<div class="row">
	<div class="col-12 mt-2">
		<button class="btn btn-warning btn-block" onclick="completeTransferNote(<?php echo $total_amount;  ?>);">Complete Agency Transfer Order</button>
	</div>
</div>



