Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Copied employee pages into admins, added pages for adding employee an…
…d reporting features
  • Loading branch information
Josh authored and Josh committed Dec 4, 2016
1 parent 662d9f2 commit 6cb5995
Show file tree
Hide file tree
Showing 28 changed files with 1,203 additions and 89 deletions.
27 changes: 27 additions & 0 deletions adminPages/AddEmployee.php
@@ -0,0 +1,27 @@
<?php
require("../dbCon.php");
require("../commonFunctions.php");

?>

<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<?php writeMenuAdm(basename($_SERVER['PHP_SELF'])); ?>

</div>
<div id='contentwrapper'>
<h1>
<?php
echo "Welcome " . $_SESSION['AdminID'] . "!";
?>
</h1>
</div>
</body>



</html>
27 changes: 27 additions & 0 deletions adminPages/Dashboard.php
@@ -0,0 +1,27 @@
<?php
require("../dbCon.php");
require("../commonFunctions.php");

?>

<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<?php writeMenuAdm(basename($_SERVER['PHP_SELF'])); ?>

</div>
<div id='contentwrapper'>
<h1>
<?php
echo "Welcome " . $_SESSION['AdminID'] . "!";
?>
</h1>
</div>
</body>



</html>
78 changes: 78 additions & 0 deletions adminPages/EditCategories.php
@@ -0,0 +1,78 @@
<?php
require("../dbCon.php");
require("../commonFunctions.php");

if (isset($_GET['NewCatName'])){ //Add new category
$query = "INSERT INTO categories (CategoryName, Description) VALUES (?, ?)";
$stmt = $con->prepare($query);
$stmt ->bind_param("ss", $_GET['NewCatName'], $_GET['NewCatDesc']);
$stmt ->execute();
}elseif (isset($_GET['NewName'])){ //Update old category
$query = "UPDATE categories SET CategoryName = ?, Description = ? WHERE CategoryID = ?";
$stmt = $con->prepare($query);
$stmt ->bind_param("ssd", $_GET['NewName'], $_GET['NewDesc'], $_GET['Category']);
$stmt ->execute();
}

?>

<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<?php writeMenuAdm(basename($_SERVER['PHP_SELF'])); ?>
</div>

<div id="contentwrapper">
<div id="contentwrapperLeft">

<form action = "EditCategories.php" method = "get">
<h1>Add Category</h1>
<div class="form-group">
<label>Name</label>
<input type="text" name="NewCatName" id="NewCatName" required>

<label>Description</label>
<input type="text" name="NewCatDesc" id="NewCatDesc" required>

<input type="submit" value="Create Category">
</div>
</form>
</div>

<div id="contentwrapperRight">
<form action = "EditCategories.php" method = "get">
<h1>Edit Category</h1>
<div class="form-group">
<label>Category to Edit</label>
<select name="Category" id="Category" onchange="updateCatNameDesc()">
<?php
$query ="SELECT * FROM categories";
$stmt = $con->prepare($query);

$stmt ->execute();
$result = $stmt->get_result();
while($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row['CategoryID'] . "'>" . $row['CategoryName'] . "</option>";
}
?>
</select>

<label>New Name</label>
<input type="text" name="NewName" id="NewName" required>

<label>New Description</label>
<input type="text" name="NewDesc" id="NewDesc" required>

<input type="submit" value="Update Category">
</div>
</form>
</div>
</div>
</body>



</html>
156 changes: 156 additions & 0 deletions adminPages/EditProducts.php
@@ -0,0 +1,156 @@
<?php
require("../dbCon.php");
require("../commonFunctions.php");

?>

<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<?php writeMenuAdm(basename($_SERVER['PHP_SELF'])); ?>
</div>
<form action = "NewProduct.php" class="form-group" style='display: block; margin: auto; width: 960px;'>
<input type="submit" value="New Product">
</form>

<hr>
<div id="contentwrapper">
<div id='contentwrapperLeft'>

<form action = "EditProducts.php" method = "get">
<h1>Simple Search</h1>
<div class="form-group">
<input type="text" name="SimpleSearch" id="SimpleSearch" required value="<?php
if(isset($_GET['SimpleSearch'])){echo $_GET['SimpleSearch'];}?>">
<input type="submit" value="Search">

</div>
</form>
</div>
<div id="contentwrapperRight">

<form action = "EditProducts.php" method = "get">
<h1>Advanced Search</h1>
<div class="form-group">
<label>Product Name</label>
<input type="text" name="ProductName" id="ProductName" value="<?php
if(isset($_GET['ProductName'])){echo $_GET['ProductName'];}?>">
<label>Category</label>
<select name="Category" id="Category">
<option value=""></option>
<?php
$category = "";
if(isset($_GET['Category'])){
$category = $_GET['Category'];
}

$query ="SELECT * FROM categories";
$stmt = $con->prepare($query);

$stmt ->execute();
$result = $stmt->get_result();
while($row = mysqli_fetch_array($result))
{
echo "<option ";
if($row['CategoryName'] === $category){
echo "selected='selected'";
}
echo "value='" . $row['CategoryName'] . "'>" . $row['CategoryName'] . "</option>";
}
?>
</select>
<label>Company Name</label>
<input type="text" name="CompanyName" id="CompanyName" value="<?php
if(isset($_GET['CompanyName'])){echo $_GET['CompanyName'];}?>">
<label>Unit Price Greater Than</label>
<input type="text" name="UnitPriceLow" id="UnitPriceLow" value="<?php
if(isset($_GET['UnitPriceLow'])){echo $_GET['UnitPriceLow'];}?>">
<label>Unit Price Less Than</label>
<input type="text" name="UnitPriceHigh" id="UnitPriceHigh" value="<?php
if(isset($_GET['UnitPriceHigh'])){echo $_GET['UnitPriceHigh'];}?>">

<input type="submit" value="Search">
</div>
</form>
</div>
</div>
<div id='contentwrapper'>
<?php
if (empty($_GET)) { //Show all products by default
$query ="SELECT 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
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";

$stmt = $con->prepare($query);

}elseif (isset($_GET["SimpleSearch"]) && !empty($_GET["SimpleSearch"])) { //Simple search
$query ="SELECT 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
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
CategoryName LIKE ? OR
ProductName LIKE ? OR
CompanyName LIKE ?";

$SimpleSearch = "%" . $_GET['SimpleSearch'] . "%";
$stmt = $con->prepare($query);
$stmt ->bind_param("sss", $SimpleSearch, $SimpleSearch, $SimpleSearch);

}else{ //Advanced search

$query ="SELECT 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
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
ProductName LIKE ? AND
CompanyName LIKE ? AND
CategoryName LIKE ? AND
UnitPrice > ? AND
UnitPrice < ?";

$ProductName = "%" . $_GET['ProductName'] . "%";
$CompanyName = "%" . $_GET['CompanyName'] . "%";
$Category = "%" . $_GET['Category'] . "%";
if (empty($_GET["UnitPriceLow"])){
$UnitPriceLow = 0.00;
}else{
$UnitPriceLow = number_format($_GET['UnitPriceLow'], 2);
}
if (empty($_GET["UnitPriceHigh"])){
$UnitPriceHigh = 10000000.00;
}else{
$UnitPriceHigh = number_format($_GET['UnitPriceHigh'], 2);
}
$stmt = $con->prepare($query);
$stmt ->bind_param("sssdd", $ProductName, $CompanyName, $Category, $UnitPriceLow, $UnitPriceHigh);

}

$stmt ->execute();
$result = $stmt->get_result();

$trArgs = array("onclick=\"window.document.location='ViewProduct.php?productID=%ProductID%'\"",
array('%ProductID%' => '_ProductID')
);
makeTable($result, $trArgs);


?>
</div>
</body>



</html>
6 changes: 3 additions & 3 deletions employeePages/eNewProduct.php → adminPages/NewProduct.php
Expand Up @@ -11,7 +11,7 @@ if (isset($_GET['ProductName'])){

$stmt ->execute();

header("Location:cEditProducts.php");
header("Location:EditProducts.php");
// $con->query($query);
}
?>
Expand All @@ -22,10 +22,10 @@ if (isset($_GET['ProductName'])){
</head>
<body>
<div id="header">
<?php writeMenuEmp("eEditProducts.php"); ?>
<?php writeMenuAdm("EditProducts.php"); ?>
</div>
<div id="contentwrapper">
<form action = "eNewProduct.php" method = "get">
<form action = "NewProduct.php" method = "get">
<h1>New Product</h1>
<div class="form-group">
<label>Product Name</label>
Expand Down
30 changes: 30 additions & 0 deletions adminPages/OrdersToFill.php
@@ -0,0 +1,30 @@
<?php
require("../dbCon.php");
require("../commonFunctions.php");

?>

<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<?php writeMenuAdm(basename($_SERVER['PHP_SELF'])); ?>
</div>
<div id='contentwrapper'>
<h1>Active orders</h1>
<hr>
<?php
$sql = "SELECT * FROM northwind.`orders qry` WHERE EmployeeID is null ORDER BY RequiredDate 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>
22 changes: 22 additions & 0 deletions adminPages/Report_Customers.php
@@ -0,0 +1,22 @@
<?php
require("../dbCon.php");
require("../commonFunctions.php");

?>

<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<?php writeMenuAdm("Reports.php"); ?>
</div>
<div id='contentwrapper'>

</div>
</body>



</html>
22 changes: 22 additions & 0 deletions adminPages/Report_Employees.php
@@ -0,0 +1,22 @@
<?php
require("../dbCon.php");
require("../commonFunctions.php");

?>

<html>
<head>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div id="header">
<?php writeMenuAdm("Reports.php"); ?>
</div>
<div id='contentwrapper'>

</div>
</body>



</html>

0 comments on commit 6cb5995

Please sign in to comment.