Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added more functionality to view employees page, added pages for each…
… employee
  • Loading branch information
Josh authored and Josh committed Dec 7, 2016
1 parent ba82e25 commit 55efdda
Show file tree
Hide file tree
Showing 13 changed files with 188 additions and 61 deletions.
2 changes: 1 addition & 1 deletion adminPages/AddEmployee.php
Expand Up @@ -28,7 +28,7 @@ if (isset($_GET['LastName'])){
</head>
<body>
<div id="header">
<?php writeMenuAdm(basename($_SERVER['PHP_SELF'])); ?>
<?php writeMenuAdm('Employees.php'); ?>

</div>
<div id='contentwrapper'>
Expand Down
4 changes: 2 additions & 2 deletions adminPages/OrdersToFill.php → adminPages/AllOrders.php
Expand Up @@ -13,10 +13,10 @@ require("../commonFunctions.php");
<?php writeMenuAdm(basename($_SERVER['PHP_SELF'])); ?>
</div>
<div id='contentwrapper'>
<h1>Active orders</h1>
<h1>All orders</h1>
<hr>
<?php
$sql = "SELECT * FROM northwind.`orders qry` WHERE EmployeeID is null ORDER BY RequiredDate ASC;";
$sql = "SELECT * FROM northwind.`orders qry` ORDER BY ShippedDate ASC;";
if (!$result = $con->query($sql)){}


Expand Down
35 changes: 35 additions & 0 deletions adminPages/Employees.php
@@ -0,0 +1,35 @@
<?php
require("../dbCon.php");
require("../commonFunctions.php");

?>

<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<?php writeMenuAdm('AllOrders.php'); ?>
</div>
<form action = "AddEmployee.php" class="form-group" style='display: block; margin: auto; width: 960px;'>
<input type="submit" value="New Employee">
</form>
<div id='contentwrapper'>
<?php
$sql = "SELECT
EmployeeID, LastName, FirstName, Title, TitleOfCourtesy, BirthDate, HireDate, Address, City, Region, PostalCode, Country, HomePhone, Extension, ReportsTo, Salary
FROM employees";

$result = $con->query($sql);
$trArgs = array("onclick=\"window.document.location='ViewEmployee.php?EmployeeID=%EmployeeID%'\"",
array('%EmployeeID%' => 'EmployeeID')
);
makeTable($result, $trArgs);
?>
</div>
</body>



</html>
22 changes: 0 additions & 22 deletions adminPages/Report_Customers.php

This file was deleted.

22 changes: 0 additions & 22 deletions adminPages/Report_Employees.php

This file was deleted.

7 changes: 1 addition & 6 deletions adminPages/Reports.php
Expand Up @@ -16,15 +16,10 @@ require("../commonFunctions.php");
<form action = "Report_Sales.php" class="form-group" style='display: block; margin: auto; width: 960px;'>
<input type="submit" value="Sales Report">
</form>
<form action = "Report_Employees.php" class="form-group" style='display: block; margin: auto; width: 960px;'>
<input type="submit" value="Employee Productivity Report">
</form>
<form action = "Report_Inventory.php" class="form-group" style='display: block; margin: auto; width: 960px;'>
<input type="submit" value="Inventory Report">
</form>
<form action = "Report_Customers.php" class="form-group" style='display: block; margin: auto; width: 960px;'>
<input type="submit" value="Customers Report">
</form>

</div>
</body>

Expand Down
43 changes: 43 additions & 0 deletions adminPages/ViewEmployee.php
@@ -0,0 +1,43 @@
<?php
require("../dbCon.php");
require("../commonFunctions.php");

?>

<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<?php writeMenuAdm('Employees.php'); ?>
</div>
<div id='contentwrapper'>
<?php
$sql = "SELECT
EmployeeID, LastName, FirstName, Title, TitleOfCourtesy, BirthDate, HireDate, Address, City, Region, PostalCode, Country, HomePhone, Extension, ReportsTo, Salary
FROM employees WHERE EmployeeID = " . $_GET['EmployeeID'];
$result = $con->query($sql);
makeTable($result);
?>

<hr>

<?php
$sql = "SELECT Photo, Notes
FROM employees WHERE EmployeeID = " . $_GET['EmployeeID'];
$result = $con->query($sql);
$row = $result->fetch_assoc();
if ($row['Photo'] !== null){
loadPicture($row['Photo'], 40);
}
?>
<hr>
<h3>Notes:</h3>
<p><?php echo $row['Notes']; ?> </p>
</div>
</body>



</html>
2 changes: 1 addition & 1 deletion adminPages/ViewOrder.php
Expand Up @@ -11,7 +11,7 @@ $orderID = $_GET['orderID'];
</head>
<body>
<div id="header">
<?php writeMenuAdm('OrdersToFill.php'); ?>
<?php writeMenuAdm('AllOrders.php'); ?>
</div>
<div id='contentwrapper'>
<?php
Expand Down
5 changes: 3 additions & 2 deletions commonFunctions.php
Expand Up @@ -24,6 +24,7 @@ function writeMenuEmp($activePage){
$menuItems = array(
"Dashboard.php" => array("Home", ""),
"OrdersToFill.php" => array("Active Orders", ""),
"AllOrders.php" => array("All Orders", ""),
"EditProducts.php" => array("Search/Edit Products", ""),
"EditCategories.php" => array("Edit Categories", ""),
"ReviewCustomerDemographics.php" => array("View Customers", ""),
Expand All @@ -41,11 +42,11 @@ function writeMenuAdm($activePage){
//Menu items given in form (Page, (display name, class args))
$menuItems = array(
"Dashboard.php" => array("Home", ""),
"OrdersToFill.php" => array("Active Orders", ""),
"AllOrders.php" => array("All Orders", ""),
"EditProducts.php" => array("Search/Edit Products", ""),
"EditCategories.php" => array("Edit Categories", ""),
"ReviewCustomerDemographics.php" => array("View Customers", ""),
"AddEmployee.php" => array("Add Employee", ""),
"Employees.php" => array("View Employees", ""),
"Reports.php" => array("Reports", ""),
"logout.php" => array("Log Out", "class='fRight'")
);
Expand Down
7 changes: 4 additions & 3 deletions customerPages/cCreateOrder.php
Expand Up @@ -41,15 +41,16 @@ if ($row) {
</ul>
</div>
<?php
//if(!isset($_SESSION['RequiredBy']) || !isset($_SESSION['shoppingCart']) || $_SESSION['shoppingCart'] === ""){
if(!isset($_SESSION['shoppingCart']) || $_SESSION['shoppingCart'] === ""){
?>

<div class='form-group'>
<h3>Please add at least one item first!</h3>

</div>

<?php
//}else{
}else{
?>
<div id='contentwrapper' class="form-group">

Expand Down Expand Up @@ -251,4 +252,4 @@ if ($row) {


</html>
<?php //}
<?php }
41 changes: 41 additions & 0 deletions employeePages/AllOrders.php
@@ -0,0 +1,41 @@
<?php
require("../dbCon.php");
require("../commonFunctions.php");

$sql = "SELECT * FROM employees WHERE EmployeeID = '" . $_SESSION["EmployeeID"] . "'";
//echo $sql;
if (!$result = $con->query($sql)) {}

$row = $result->fetch_assoc();
if ($row) {
$FirstName = $row['FirstName'];

}

//echo "Welcome " . $_SESSION["userName"] . "!";
?>

<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<?php writeMenuEmp(basename($_SERVER['PHP_SELF'])); ?>
</div>
<div id='contentwrapper'>
<h1>All orders</h1>
<hr>
<?php
$sql = "SELECT * FROM northwind.`orders qry` ORDER BY ShippedDate ASC;";
if (!$result = $con->query($sql)){}


$trArgs = array("onclick=\"window.document.location='ViewOrder.php?orderID=%OrderID%'\"",
array('%OrderID%' => 'OrderID')
);
makeTable($result, $trArgs);
?>
</div>
</body>
</html>
3 changes: 2 additions & 1 deletion employeePages/OrdersToFill.php
Expand Up @@ -27,7 +27,8 @@ if ($row) {
<h1>Active orders</h1>
<hr>
<?php
$sql = "SELECT * FROM northwind.`orders qry` WHERE EmployeeID is null ORDER BY RequiredDate ASC;";
$sql = "SELECT OrderID, CustomerID, OrderDate, RequiredDate, ShipVia, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry, CompanyName, Address, City, Region, PostalCode, Country
FROM northwind.`orders qry` WHERE EmployeeID is null OR ShippedDate is null ORDER BY RequiredDate ASC;";
if (!$result = $con->query($sql)){}


Expand Down
56 changes: 55 additions & 1 deletion employeePages/ViewOrder.php
Expand Up @@ -3,7 +3,44 @@ require("../dbCon.php");
require("../commonFunctions.php");

$orderID = $_GET['orderID'];
//echo "Welcome " . $_SESSION["userName"] . "!";

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>
Expand All @@ -13,7 +50,24 @@ $orderID = $_GET['orderID'];
<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 . " ";
Expand Down

0 comments on commit 55efdda

Please sign in to comment.