Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Finished AddEmployee page, added simple reporting example to Report_S…
…ales
  • Loading branch information
Josh authored and Josh committed Dec 5, 2016
1 parent 6cb5995 commit bf363fc
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 8 deletions.
91 changes: 86 additions & 5 deletions adminPages/AddEmployee.php
Expand Up @@ -2,6 +2,24 @@
require("../dbCon.php");
require("../commonFunctions.php");

if (isset($_GET['LastName'])){
$query = "INSERT INTO employees (password, LastName, FirstName, Title, TitleOfCourtesy,
BirthDate, HireDate, Address, City, Region,
PostalCode, Country, HomePhone, Extension, Notes,
ReportsTo, Salary)
VALUES(?,?,?,?,?,
?,?,?,?,?,
?,?,?,?,?,
?,?)";
$stmt = $con->prepare($query);
$stmt ->bind_param("sssssssssssssssdd", $_GET['Password'], $_GET['LastName'], $_GET['FirstName'], $_GET['Title'], $_GET['TitleOfCourtesy'],
$_GET['BirthDate'], $_GET['HireDate'], $_GET['Address'], $_GET['City'], $_GET['Region'],
$_GET['PostalCode'], $_GET['Country'], $_GET['HomePhone'], $_GET['Extension'], $_GET['Notes'],
$_GET['ReportsTo'], $_GET['Salary']);

$stmt ->execute();

}
?>

<html>
Expand All @@ -14,11 +32,74 @@ require("../commonFunctions.php");

</div>
<div id='contentwrapper'>
<h1>
<?php
echo "Welcome " . $_SESSION['AdminID'] . "!";
?>
</h1>
<form action = "AddEmployee.php" method = "get">
<h1>Add Employee</h1>
<div class="form-group">
<label>Password</label>
<input type="text" name="Password" id="Password" required>

<label>Last Name</label>
<input type="text" name="LastName" id="LastName" required>

<label>First Name</label>
<input type="text" name="FirstName" id="FirstName" required>

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

<label>Title Of Courtesy</label>
<input type="text" name="TitleOfCourtesy" id="TitleOfCourtesy" required>

<label>Birth Date (yyyy-mm-dd)</label>
<input type="text" name="BirthDate" id="BirthDate" required>

<label>Hire Date (yyyy-mm-dd)</label>
<input type="text" name="HireDate" id="HireDate" required>

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

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

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

<label>Postal Code</label>
<input type="text" name="PostalCode" id="PostalCode" required>

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

<label>Home Phone Number</label>
<input type="text" name="HomePhone" id="HomePhone" required>

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

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

<label>Reports To</label>
<select name="ReportsTo" id="ReportsTo">
<?php
echo "<option value='null'></option>";
$query ="SELECT * FROM employees";
$stmt = $con->prepare($query);
$stmt ->execute();
$result = $stmt->get_result();
while($row = mysqli_fetch_array($result)){
echo "<option value='" . $row['EmployeeID'] . "'>" . $row['FirstName'] . " " . $row['LastName'] . "</option>";
}
?>
</select>

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

<input type="submit" value="Add Employee">
</div>
</form>
</div>
</body>

Expand Down
2 changes: 1 addition & 1 deletion adminPages/Report_Customers.php
Expand Up @@ -13,7 +13,7 @@ require("../commonFunctions.php");
<?php writeMenuAdm("Reports.php"); ?>
</div>
<div id='contentwrapper'>

//To do
</div>
</body>

Expand Down
2 changes: 1 addition & 1 deletion adminPages/Report_Employees.php
Expand Up @@ -13,7 +13,7 @@ require("../commonFunctions.php");
<?php writeMenuAdm("Reports.php"); ?>
</div>
<div id='contentwrapper'>

//To do
</div>
</body>

Expand Down
2 changes: 1 addition & 1 deletion adminPages/Report_Inventory.php
Expand Up @@ -13,7 +13,7 @@ require("../commonFunctions.php");
<?php writeMenuAdm("Reports.php"); ?>
</div>
<div id='contentwrapper'>

//To do
</div>
</body>

Expand Down
37 changes: 37 additions & 0 deletions adminPages/Report_Sales.php
Expand Up @@ -13,7 +13,44 @@ require("../commonFunctions.php");
<?php writeMenuAdm("Reports.php"); ?>
</div>
<div id='contentwrapper'>
<?php
if (isset($_GET['Category'])){ //Check if category has already been set
$query = "SELECT * FROM `sales by category` WHERE CategoryID = ?"; //'?' in place of variable
$stmt = $con->prepare($query);
$stmt ->bind_param("d", $_GET['Category']); //Bind category to query, category is taken in as CategoryID, so it's a digit
$stmt ->execute();

$searchResult = $stmt->get_result(); //Get results

makeTable($searchResult); //Make table from results, makeTable code is in commonFunctions.php

}else{ //If category has not been set, show HTML form to pick category
?>

<form action = "Report_Sales.php" method = "get">
<h1>Sales Report</h1>
<div class="form-group">
<label>Select Product Category</label>
<select name="Category" id="Category">
<?php //Populate category drop down by getting categories from DB
$query ="SELECT * FROM categories"; //Query
$stmt = $con->prepare($query); //'con' is name of DB connection, defined in dbCon.php (which is loaded at the top of this file)

$stmt ->execute(); //Run query
$result = $stmt->get_result(); //Put query results into $results array
while($row = mysqli_fetch_array($result)) { //Iterate through each row of results
echo "<option value='" . $row['CategoryID'] . "'>" . $row['CategoryName'] . "</option>"; //'echo' outputs the given line to the HTML, so this creates a new row in the drop-down for each category
}
?>
</select>

<input type="submit" value="View Report">
</div>
</form>

<?php
} //Close bracket from 'else' above
?>
</div>
</body>

Expand Down

0 comments on commit bf363fc

Please sign in to comment.