Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
128 lines (107 sloc) 5.94 KB
<?php
require("../dbCon.php");
require("../commonFunctions.php");
$orderID = $_GET['orderID'];
if (isset($_GET['Freight'])){
$sql = "UPDATE ((((orders o LEFT JOIN employees e ON o.EmployeeID = e.EmployeeID)
LEFT JOIN shipments sh ON o.OrderID = sh.OrderID)
LEFT JOIN shipaddresses s ON sh.ShipmentsID = s.ShipAddrID)
LEFT JOIN payment p ON o.orderID = p.orderID)
LEFT JOIN paymenttype pt ON pt.paymenttypeid = p.paymenttypeid
SET
o.EmployeeID = " . $_SESSION['EmployeeID'] . ",
s.Freight = " . $_GET['Freight'] . ",
s.ShippedDate = NOW()
WHERE o.OrderID = " . $orderID;
$con->query($sql);
}
$where = " WHERE o.OrderID=" . $orderID . " ";
$sql = "SELECT
o.OrderID as _OrderID,
CONCAT(e.FirstName, ' ', e.LastName) as Employee,
DATE_FORMAT(OrderDate, '%m-%d-%Y') as `Order Date`, DATE_FORMAT(s.RequiredDate, '%m-%d-%Y') as `Required Date`, DATE_FORMAT(ShippedDate, '%m-%d-%Y') as `Shipped Date`,
Freight, ShipName as `Ship To`,
CONCAT(ShipAddress, ', ', ShipCity, '<br>', ShipRegion, ' ', ShipPostalCode, ', ', ShipCountry) as `Ship Address`,
CONCAT('$', FORMAT(Total,2)) as Total, pt.Name as `Paid Via`
FROM
((((orders o LEFT JOIN employees e ON o.EmployeeID = e.EmployeeID)
LEFT JOIN shipments sh ON o.OrderID = sh.OrderID)
LEFT JOIN shipaddresses s ON sh.ShipmentsID = s.ShipAddrID)
LEFT JOIN payment p ON o.orderID = p.orderID)
LEFT JOIN paymenttype pt ON pt.paymenttypeid = p.paymenttypeid
" . $where . " ORDER BY OrderDate DESC";
$result = $con->query($sql);
$row = mysqli_fetch_array($result);
$employee = $row['Employee'];
$shippedDate = $row['Shipped Date'];
?>
<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<?php writeMenuEmp('OrdersToFill.php'); ?>
</div>
<?php if($employee === null OR $shippedDate === null){ ?>
<div id ='contentwrapperShort'>
<form action = "ViewOrder.php" method = "get">
<h1>Fill Order</h1>
<div class="form-group">
<input type="text" name="orderID" id="orderID" value='<?php echo $orderID; ?>' style='display: none'>
<label>Shipping Weight</label>
<input type="text" name="Freight" id="Freight" required>
<input type="submit" value="Fill Order">
</div>
</form>
</div>
<?php } ?>
<div id='contentwrapper'>
<?php
$where = " WHERE o.OrderID=" . $orderID . " ";
$sql = "SELECT
o.OrderID as _OrderID,
CONCAT(e.FirstName, ' ', e.LastName) as Employee,
DATE_FORMAT(OrderDate, '%m-%d-%Y') as `Order Date`, DATE_FORMAT(s.RequiredDate, '%m-%d-%Y') as `Required Date`, DATE_FORMAT(ShippedDate, '%m-%d-%Y') as `Shipped Date`,
Freight, ShipName as `Ship To`,
CONCAT(ShipAddress, ', ', ShipCity, '<br>', ShipRegion, ' ', ShipPostalCode, ', ', ShipCountry) as `Ship Address`,
CONCAT('$', FORMAT(Total,2)) as Total, pt.Name as `Paid Via`
FROM
((((orders o LEFT JOIN employees e ON o.EmployeeID = e.EmployeeID)
LEFT JOIN shipments sh ON o.OrderID = sh.OrderID)
LEFT JOIN shipaddresses s ON sh.ShipmentsID = s.ShipAddrID)
LEFT JOIN payment p ON o.orderID = p.orderID)
LEFT JOIN paymenttype pt ON pt.paymenttypeid = p.paymenttypeid
" . $where . " ORDER BY OrderDate DESC";
$result = $con->query($sql);
$trArgs = array("onclick=\"window.document.location='ViewOrder.php?orderID=%OrderID%'\"",
array('%OrderID%' => '_OrderID')
);
makeTable($result, $trArgs);
echo "<hr>";
$sql = "SELECT
p.ProductID as _ProductID,
ProductName as Product,
CategoryName as Category,
CompanyName as Company,
QuantityPerUnit as Quantity,
CONCAT('$', FORMAT(p.UnitPrice,2)) as Price,
UnitsInStock as Stock,
Quantity as `Amount Ordered`,
CONCAT('$', FORMAT(Quantity*p.UnitPrice,2)) as `Sub-total`
FROM
(((`order details` od LEFT JOIN products p ON od.ProductID = p.ProductID)
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 orderid = " . $orderID . "
order by od.ProductID ASC";
$result = $con->query($sql);
$trArgs = array("onclick=\"window.document.location='ViewProduct.php?productID=%ProductID%'\"",
array('%ProductID%' => '_ProductID')
);
makeTable($result, $trArgs);
?>
</div>
</body>
</html>
You can’t perform that action at this time.