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 55efdda commit 6157e67
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
/nbproject/private/
92 changes: 84 additions & 8 deletions adminPages/Report_Sales.php
Expand Up @@ -15,14 +15,69 @@ require("../commonFunctions.php");
<div id='contentwrapper'>
<?php
if (isset($_GET['Category'])){ //Check if category has already been set
$query = "SELECT * FROM `sales by category` WHERE CategoryID = ?
AND ProductName LIKE ?
AND SupplierName LIKE ?
AND InStock = ?"; //'?' in place of variable
$query = "SELECT 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`
FROM ((((((((orders o LEFT JOIN `Order Details` od ON o.OrderID = od.OrderID)
LEFT JOIN Customers c ON o.CustomerID = c.CustomerID)
LEFT JOIN shipments sh ON o.OrderID = sh.OrderID)
LEFT JOIN shipaddresses sa ON sh.ShipmentsID = sa.ShipAddrID)
LEFT JOIN Products p ON od.ProductID = p.ProductID)
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 p.ProductName LIKE ?
AND cp.CompanyName LIKE ?
AND ? <= p.UnitsInStock AND p.UnitsInStock <= ?
AND ? <= o.OrderDate <= ?
AND c.CompanyName LIKE ?
AND c.Address LIKE ?
AND c.Region LIKE ?
AND c.Country LIKE ?
AND cp.Address LIKE ?
AND cp.Region LIKE ?
AND cp.Country LIKE ?
" ; //'?' in place of variable
$ProductName = "%" . $_GET['ProductName'] . "%";

$CustomerName = "%" . $_GET['CustomerName'] . "%";
$CustomerAddress = "%" . $_GET['CustomerAddress'] . "%";
$CustomerRegion = "%" . $_GET['CustomerRegion'] . "%";
$CustomerCountry = "%" . $_GET['CustomerCountry'] . "%";

$SupplierName = "%" . $_GET['SupplierName'] . "%";
$SupplierAddress = "%" . $_GET['SupplierAddress'] . "%";
$SupplierRegion = "%" . $_GET['SupplierRegion'] . "%";
$SupplierCountry = "%" . $_GET['SupplierCountry'] . "%";
//stock ranges
if (empty($_GET["InStockStart"])){
$InStockStart = 0;
}else{
$InStockStart = $_GET['InStockStart'];
}
if (empty($_GET["InStockEnd"])){
$InStockEnd = 102984573293485490;
}else{
$InStockEnd = $_GET['InStockEnd'];
}
//to and from duration
if (empty($_GET["DurTo"])){
$DurTo = "9999-12-12";
}else{
$DurTo = $_GET['DurTo'];
}
if (empty($_GET["DurFrom"])){
$DurFrom = "0000-01-01";
}else{
$DurFrom = $_GET['DurFrom'];
}
$stmt = $con->prepare($query);
$stmt ->bind_param("dssd", $_GET['Category'], $ProductName, $SupplierName, $_GET['InStock']); //Bind category to query, category is taken in as CategoryID, so it's a digit
$stmt ->bind_param("dssddsssssssss", $_GET['Category'], $SupplierName, $ProductName, $InStockStart,
$InStockEnd, $DurFrom, $DurTo, $CustomerName, $CustomerAddress, $CustomerRegion,
$CustomerCountry, $SupplierAddress, $SupplierRegion, $SupplierCountry
); //Bind category to query, category is taken in as CategoryID, so it's a digit
$stmt ->execute();

$searchResult = $stmt->get_result(); //Get results
Expand Down Expand Up @@ -50,10 +105,31 @@ require("../commonFunctions.php");
</select>
<label>Product Name</label>
<input type="text" name="ProductName" id="ProductName">
<label>Supplier Name</label>
<label>Supplier's Name</label>
<input type="text" name="SupplierName" id="SupplierName">
<label>In Stock</label>
<input type="text" name="InStock" id="InStock">
<label>In Stock: Start</label>
<input type="text" name="InStockStart" id="InStockStart">
<label>In Stock: End</label>
<input type="text" name="InStockEnd" id="InStockEnd">
<label>Duration Choices: To:</label>
<input type="text" name="DurTo" id="DurTo">
<label>Duration Choices: From:</label>
<input type="text" name="DurFrom" id="DurFrom">
<label>Customer Name:</label>
<input type="text" name="CustomerName" id="CustomerName">
<label>Customer's City:</label>
<input type="text" name="CustomerAddress" id="CustomerAddress">
<label>Customer's State:</label>
<input type="text" name="CustomerRegion" id="CustomerRegion">
<label>Customer's Country:</label>
<input type="text" name="CustomerCountry" id="CustomerCountry">
<label>Supplier's City:</label>
<input type="text" name="SupplierAddress" id="SupplierAddress">
<label>Supplier's State:</label>
<input type="text" name="SupplierRegion" id="SupplierRegion">
<label>Supplier's Country:</label>
<input type="text" name="SupplierCountry" id="SupplierCountry">

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

0 comments on commit 6157e67

Please sign in to comment.