Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
yeah we did the sales whoo
  • Loading branch information
John Costa III authored and John Costa III committed Dec 8, 2016
1 parent 6157e67 commit ae335ae
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
72 changes: 71 additions & 1 deletion adminPages/Report_Inventory.php
Expand Up @@ -13,10 +13,80 @@ require("../commonFunctions.php");
<?php writeMenuAdm("Reports.php"); ?>
</div>
<div id='contentwrapper'>
//To do
<?php
if (isset($_GET['Category'])){ //Check if category has already been set
$query = "SELECT p.ProductName, cat.CategoryName, p.UnitsInStock, cp.CompanyName as `Supplier's Name`
FROM (((products p LEFT JOIN suppliers s ON p.SupplierID = s.SupplierID)
LEFT JOIN company cp ON s.CompanyID = cp.CompanyID)
LEFT JOIN categories cat ON p.CategoryID = cat.CategoryID)
WHERE cat.CategoryID = ?
AND cp.CompanyName LIKE ?
AND p.ProductName LIKE ?
AND ? <= p.UnitsInStock AND p.UnitsInStock <= ?
" ; //'?' in place of variable
$ProductName = "%" . $_GET['ProductName'] . "%";
$SupplierName = "%" . $_GET['SupplierName'] . "%";
//stock ranges
if (empty($_GET["InStockStart"])){
$InStockStart = 0;
}else{
$InStockStart = $_GET['InStockStart'];
}
if (empty($_GET["InStockEnd"])){
$InStockEnd = 102984573293485490;
}else{
$InStockEnd = $_GET['InStockEnd'];
}

$stmt = $con->prepare($query);
$stmt ->bind_param("dssdd", $_GET['Category'], $SupplierName, $ProductName, $InStockStart,
$InStockEnd); //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_Inventory.php" method = "get">
<h1>Inventory Report</h1>
<div class="form-group">
<!--category stuff-->
<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>
<label>Product Name</label>
<input type="text" name="ProductName" id="ProductName">
<label>Supplier's Name</label>
<input type="text" name="SupplierName" id="SupplierName">
<label>In Stock: Start</label>
<input type="text" name="InStockStart" id="InStockStart">
<label>In Stock: End</label>
<input type="text" name="InStockEnd" id="InStockEnd">

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

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



</html>

2 changes: 1 addition & 1 deletion adminPages/Report_Sales.php
Expand Up @@ -15,7 +15,7 @@ require("../commonFunctions.php");
<div id='contentwrapper'>
<?php
if (isset($_GET['Category'])){ //Check if category has already been set
$query = "SELECT cp.CompanyName as `Supplier's Name`, c.CompanyName as `Customer's Name`,
$query = "SELECT p.ProductName, cat.CategoryName, cp.CompanyName as `Supplier's Name`, c.CompanyName as `Customer's Name`,
od.UnitPrice * od.Quantity as `Dollar Value`, od.UnitPrice, od.Quantity, o.OrderDate, p.UnitsInStock,
c.Address as `Customer's City`, c.Region as `Customer's Region`, c.Country as `Customer's Country`,
cp.Address as `Supplier's City`, cp.Region as `Supplier's Region`, cp.Country as `Supplier's Country`
Expand Down

0 comments on commit ae335ae

Please sign in to comment.