<?php

include 'load.php';

?>

<!DOCTYPE html>
<html lang="en">
<head>

	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
	<meta name="description" content="POS - Eat More Resturant   | Pos & Invetory System | Dashboard

">
	<meta name="keywords" content="Eat More Resturant   | Pos & Invetory System | Dashboard

">
	<meta name="author" content="Eat More Resturant   | Pos & Invetory System | Dashboard

">
	<meta name="robots" content="noindex, nofollow">

	<title>View Sales Items List | Eat More Resturant   | Pos & Invetory System | Dashboard

</title>

<?php
require_once 'headercss.php';
?>
</head>
<body>

<div class="main-wrapper">
<?php
require_once 'header.php';
?>

<?php
require_once 'navbar.php';
?>

<div class="page-wrapper">
<div class="content">
<div class="page-header">
<div class="page-title">
<h4>View Sales Items List</h4>
<h6>Manage your sales</h6>
</div>
<div class="page-btn">
<a href="pos.php" class="btn btn-added"><img src="assets/img/icons/plus.svg" alt="img" class="me-1">Add Sales</a>
</div>
</div>

<div class="card">
<div class="card-body">
<div class="table-top">
<div class="search-set">
<div class="search-path">
<a class="btn btn-filter" id="filter_search">
<img src="assets/img/icons/filter.svg" alt="img">
<span><img src="assets/img/icons/closes.svg" alt="img"></span>
</a>
</div>
<div class="search-input">
<a class="btn btn-searchset"><img src="assets/img/icons/search-white.svg" alt="img"></a>
</div>
</div>
<div class="wordset">
<ul>
<li>
<a data-bs-toggle="tooltip" data-bs-placement="top" title="pdf"><img src="assets/img/icons/pdf.svg" alt="img"></a>
</li>
<li>
<a data-bs-toggle="tooltip" data-bs-placement="top" title="excel"><img src="assets/img/icons/excel.svg" alt="img"></a>
</li>
<li>
<a data-bs-toggle="tooltip" data-bs-placement="top" title="print"><img src="assets/img/icons/printer.svg" alt="img"></a>
</li>
</ul>
</div>
</div>

<div class="table-responsive">
<table class="table  datanew">
<thead>
<tr>
<th>Action</th>
<th>#ID</th>
<th>Supplier/Vender</th>
<th>Items</th>
<th>Amount</th>
<th>Qty</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php
if(isset($_GET['order_id'])){
	
$order_id=$_GET['order_id'];

$sql = "SELECT *  FROM mobiletemporarycart LEFT JOIN mobileproducts ON mobileproducts.prid=mobiletemporarycart.proid LEFT JOIN mobilesuppliers ON mobileproducts.supplier=mobilesuppliers.spid
		WHERE mobiletemporarycart.orderid='$order_id'  GROUP BY  mobiletemporarycart.proid,mobiletemporarycart.pro_dis   ORDER BY mobiletemporarycart.tempid  DESC";

		$result = $conn->query($sql);
		$rowCount = 0;
		$pamount = 0;
		$total_discount = 0;
		$total_amount = 0;
		if ($result->num_rows > 0) {
			while($row = $result->fetch_assoc()) {
				$rowCount = $rowCount+1;
				$tempid = $row["tempid"];
				$proid = $row["proid"];
				$proname = $row["proname"];
				$supplierid = $row["spid"];
				$supplier = $row["spname"];
				$cover = $row["cover"];
				$pro_price = $row["pro_price"];
				$pro_dis = $row["pro_dis"];
				$pro_qty = $row["pro_qty"];
				$pamount = ($pro_price * $pro_qty) - $pro_dis;
				$total_discount = $total_discount + $pro_dis;
				$total_amount = $total_amount + $pro_price;
				
			?>
<tr>
<td><a href="changesupplier.php?supplier=<?php echo $supplierid; ?>&product=<?php echo $proid; ?>" class="btn btn-block btn-outline-info active btn-sm text-white" title="Change Supplier" onClick="JavaScript:return confirm('Are your sure change this Supplier ?');"><i class="fas fa-shipping-fast" data-bs-toggle="tooltip" title="" data-bs-original-title="fas fa-shipping-fast" aria-label="fas fa-shipping-fast"></i> Change Supplier</a>
</td>
<td>#<?php echo $tempid; ?></td>
<td><?php echo $supplier; ?></td>
<td class="productimgname">

<a class="product-img">
<?php if($cover==""){$pro_img="assets/img/empty.png";}else{$pro_img="images/products/cover/".$cover;} ?><img src="<?php echo $pro_img; ?>" alt="img" class="me-2" style="width:40px;height:40px;">
<?php echo $proname; ?> | <?php echo number_format((float)$pro_price,2); ?> X <?php echo $pro_qty; ?>
</a>

</td>
<td>

<?php echo number_format((float)$pro_price,2); ?>

</td>
<td>

<?php echo $pro_qty; ?>

</td>
<td>

<?php echo number_format((float)$total_amount,2); ?>


<?php 
} 
}
} 
?>
</tbody>
</table>
</div>
</div>
</div>

</div>
</div>
</div>

<script src="assets/js/jquery-3.6.0.min.js"></script>

<script src="assets/js/feather.min.js"></script>

<script src="assets/js/jquery.slimscroll.min.js"></script>

<script src="assets/js/jquery.dataTables.min.js"></script>
<script src="assets/js/dataTables.bootstrap4.min.js"></script>

<script src="assets/js/bootstrap.bundle.min.js"></script>

<script src="assets/plugins/select2/js/select2.min.js"></script>

<script src="assets/js/moment.min.js"></script>
<script src="assets/js/bootstrap-datetimepicker.min.js"></script>

<script src="assets/plugins/sweetalert/sweetalert2.all.min.js"></script>
<script src="assets/plugins/sweetalert/sweetalerts.min.js"></script>

<script src="assets/js/script.js"></script>
</body>
</html>