Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
191 lines (160 sloc) 8.74 KB
<?php
require("../dbCon.php");
$sql = "SELECT * FROM customers WHERE CustomerID = '" . $_SESSION["CustomerID"] . "'";
//echo $sql;
if (!$result = $con->query($sql)) {}
$row = $result->fetch_assoc();
if ($row) {
$CompanyName = $row['CompanyName'];
}
//echo "Welcome " . $_SESSION["userName"] . "!";
?>
<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<ul id="menu" class="blue">
<li><a href="cDashboard.php">Home</a></li>
<li><a href="cEditProfile.php">Edit Profile</a></li>
<li><a href="cSearchProduct.php">Search Product</a></li>
<li><a href="cCreateOrder.php">Create Order</a></li>
<li><a href="cPayment.php">Payment</a></li>
<li class="active"><a href="cCart.php">Cart</a></li>
<li><a href="cPastOrders.php">Past Orders</a></li>
<li class='fRight'><a href="logout.php">Log Out</a></li>
</ul>
</div>
<?php
if(!isset($_SESSION['RequiredBy']) || !isset($_SESSION['PaymentType'])){
?>
<div class='form-group'>
<h3>Please complete payment options first!</h3>
</div>
<?php
}else{
?>
<div id='contentwrapperShort' class='form-group'>
<h1>Shipping Summary</h1>
<div id='contentwrapperRight'>
<table id='niceTable'>
<tr><td>Required By</td><td><?php echo $_SESSION['RequiredBy'];?></td></tr>
<tr><td>Delivery Type</td><td><?php
$query ="SELECT * FROM DeliveryType WHERE DeliveryTypeID = " . $_SESSION['DeliveryMethod'];
$stmt = $con->prepare($query);
$stmt ->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
echo $row['DeliveryTypeName'] . " - " . $row['Description'];
?></td></tr>
<tr><td>Shipment Type</td><td><?php
$query ="SELECT * FROM ShipmentType WHERE ShipmentTypeID = " . $_SESSION['ShipmentMethod'];
$stmt = $con->prepare($query);
$stmt ->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
echo $row['ShipmentTypeName'] . " - " . $row['Description'];
?></td></tr>
<tr><td>Shipped By</td><td><?php
$query ="SELECT * FROM shippers s LEFT JOIN company c ON s.CompanyId = c.CompanyID WHERE c.CompanyId = " . $_SESSION['ShipmentCompany'];
$stmt = $con->prepare($query);
$stmt ->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
echo $row['CompanyName'];
?></td></tr>
</table>
</div>
<div id='contentwrapperLeft'>
<table id='niceTable'>
<tr><td>Ship to</td><td><?php echo $_SESSION['Name'];?></td></tr>
<tr><td>Address</td><td><?php echo $_SESSION['Address'];?></td></tr>
<tr><td>City</td><td><?php echo $_SESSION['City'];?></td></tr>
<tr><td>Region</td><td><?php echo $_SESSION['Region'];?></td></tr>
<tr><td>Postal Code</td><td><?php echo $_SESSION['PostalCode'];?></td></tr>
<tr><td>Country</td><td><?php echo $_SESSION['Country'];?></td></tr>
</table>
</div>
</div>
<hr>
<div id='contentwrapper' class='form-group'>
<h1>Order Summary</h1>
<form action = "cCart_save.php" method = "POST">
<?php
// echo "Welcome " . EXPLODE(" ",$ContactName)[0] . "!";
// $_SESSION['confirmationCode'] = $random_hash = substr(md5(uniqid(rand(), true)), 8, 24);
$_SESSION['confirmationCode'] = uniqid();
$_SESSION['fqPayment'] = " INSERT INTO payment (OrderID, Total, PaymentTypeID, ConfNum) VALUES (" .
"(SELECT MAX(OrderID) FROM orders), " .
$_SESSION['TotalDue'] . ", " .
$_SESSION['PaymentType'] . ", " .
"'" . $_SESSION['confirmationCode'] . "');";
$_SESSION['finInsert'] = $_SESSION['fqOrder'] . $_SESSION['fqOrderDetailsInsert'] . $_SESSION['fqShipments'] . $_SESSION['fqShipAddresses'] . $_SESSION['fqPayment'];
// echo $_SESSION['fqOrder'] . $_SESSION['fqOrderDetailsInsert'] . $_SESSION['fqShipments'] . $_SESSION['fqShipAddresses'] . $fqPayment;
// echo $_SESSION['finInsert'];
// echo $_SESSION['fqOrderDetailsInsert'];
// if (!empty($_SESSION)) {
$shoppingCart = $_SESSION['shoppingCart'];
$shoppingCart = explode(" ", $shoppingCart);
echo "<table id='niceTable'>
<tr>
<th>Product</th>
<th>Category</th>
<th>Company</th>
<th>Quantity</th>
<th>Price</th>
<th>Stock</th>
<th>Amount</th>
<th>Sub-total</th>
</tr>";
foreach ($shoppingCart as $productID_Quantity){
$productID = explode("_", $productID_Quantity)[0];
$productQuantity = explode("_", $productID_Quantity)[1];
$query ="SELECT * FROM
((products as p LEFT JOIN suppliers as s ON p.SupplierID = s.SupplierID)
LEFT JOIN categories c ON p.CategoryID = c.CategoryID)
LEFT JOIN company co ON s.CompanyId = co.CompanyID
WHERE
ProductID = " . $productID;
$stmt = $con->prepare($query);
$stmt ->execute();
$result = $stmt->get_result();
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['ProductName'] . "</td>";
echo "<td>" . $row['CategoryName'] . "</td>";
echo "<td>" . $row['CompanyName'] . "</td>";
echo "<td>" . $row['QuantityPerUnit'] . "</td>";
echo "<td>" . "$" . number_format($row['UnitPrice'], 2) . "</td>";
echo "<td>" . $row['UnitsInStock'] . "</td>";
echo "<td>" . $productQuantity . "</td>";
echo "<td>" . "$" . number_format($productQuantity * $row['UnitPrice'],2) . "</td>";
}
echo "</tr>";
// echo $productID;
}
echo "</table>";
// }
$query ="SELECT * FROM paymenttype WHERE PaymentTypeID = " . $_SESSION['PaymentType'];
$stmt = $con->prepare($query);
$stmt ->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
echo "<hr><h1>A total of $" . number_format($_SESSION['TotalDue'],2) . " will be deducted from your " . $row['Name'] . "</h1>";
// echo $fqOrder . "<hr>" . $fqOrderDetailsInsert . "<hr>" . $fqShipments . "<hr>" . $fqShipAddresses;
?>
<hr>
<div class="form-group">
<!-- <input type='text' name='finalQuery' id='finalQuery' value='<?php
// echo $fqOrder . $fqOrderDetailsInsert . $fqShipments . $fqShipAddresses; ?>' style='display: none'/> -->
<input type="submit" value="Place Order">
</div>
</form>
</div>
</body>
</html>
<?php
}
?>
You can’t perform that action at this time.