Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DatabasesPhase2_GroupE/employeePages/ViewOrder.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
127 lines (107 sloc)
5.94 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |