forked from jevuu/e-ceipt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from jevuu/master
Merge My Changes
- Loading branch information
Showing
90 changed files
with
6,023 additions
and
758 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
/build | ||
/captures | ||
.externalNativeBuild | ||
oldPHP | ||
PHP/conn.php | ||
app/google-services.json | ||
.git.zip |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
require "conn.php"; | ||
|
||
$json = file_get_contents('php://input'); | ||
$obj = json_decode($json); | ||
$rID = $obj->{'receiptID'}; | ||
|
||
//Delete receipt | ||
$qString = "DELETE FROM receipts WHERE receiptID = " . $rID; | ||
if(mysqli_query($conn, $qString) === FALSE){ | ||
echo "Failed to delete receipt."; | ||
} | ||
|
||
//Test deletion | ||
/*$qString = "SELECT FROM receipts WHERE receiptID = " . $rID; | ||
$result = mysqli_query($conn, $qString); | ||
if(mysqli_num_rows($result) == 0){ | ||
echo "Receipt was deleted! <br />"; | ||
}else{ | ||
echo "Receipt was not deleted! <br />"; | ||
}*/ | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
require "conn.php"; | ||
|
||
$json = file_get_contents('php://input'); | ||
$obj = json_decode($json); | ||
$userID = $obj->{'userID'}; | ||
|
||
$qString = "DELETE FROM users WHERE userID = '$uID'"; | ||
mysqli_query($conn, $qString); | ||
|
||
//Test deletion | ||
$qString = "SELECT name FROM users WHERE userID = '$uID'"; | ||
$result = mysqli_query($conn, $qString); | ||
if(mysqli_num_rows($result) == 0){ | ||
echo "Donatello was deleted! <br />"; | ||
}else{ | ||
echo "Donatello was not deleted! <br />"; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
require "conn.php"; | ||
|
||
//Get userName from JSON | ||
$json = file_get_contents('php://input'); | ||
$obj = json_decode($json); | ||
$rID = $obj->{'receiptID'}; | ||
|
||
//If userName doesn't exist, use grab from John Doe. ONLY FOR TESTING PURPOSES. REMOVE IN FINAL | ||
if($rID == ""){ | ||
$rID = "1"; | ||
} | ||
|
||
//Get one receipt by receiptID | ||
//$qString = "SELECT u.name, r.receiptID, r.creationDate, r.totalCost, r.tax, r.businessID | ||
$qString = "SELECT u.name, r.receiptID, r.creationDate, r.totalCost, r.tax, r.businessName | ||
FROM users u | ||
INNER JOIN receipts r ON r.userID = u.userID | ||
WHERE r.receiptID= '$rID'" ; | ||
$qReceipt= mysqli_query($conn, $qString); | ||
$receipt= mysqli_fetch_row($qReceipt); | ||
|
||
/*Get business name from Business table | ||
$qString = "SELECT u.name | ||
FROM users u | ||
INNER JOIN businesses b ON b.userID = u.userID | ||
WHERE b.businessID = $receipt[5] limit 1"; | ||
$qBusiness = mysqli_query($conn, $qString); | ||
$businessName = mysqli_fetch_object($qBusiness); | ||
*/ | ||
|
||
//Build an array of items from the receipt | ||
//Then push into the "items" array | ||
$items = array(); | ||
$qString = "SELECT i.name, i.description, i.price | ||
FROM items i | ||
INNER JOIN receiptItems ri ON ri.itemID = i.itemID | ||
INNER JOIN receipts r ON r.receiptID = ri.receiptID | ||
WHERE r.receiptID =" . $receipt[1]; | ||
$qReceiptItems= mysqli_query($conn, $qString); | ||
while($receiptItem= mysqli_fetch_row($qReceiptItems)){ | ||
$tempItem = [ | ||
'itemName' => $receiptItem[0], | ||
'itemDesc' => $receiptItem[1], | ||
'itemPrice' => $receiptItem[2] | ||
]; | ||
array_push($items, $tempItem); | ||
} | ||
|
||
//Build the receipt | ||
$receipt = [ | ||
'name' => $receipt[0], | ||
'receiptID' => $receipt[1], | ||
'date' => $receipt[2], | ||
'totalCost' => $receipt[3], | ||
'tax' => $receipt[4], | ||
'items' => $items, | ||
//'businessName' => $businessName->name //Not used as business is stored in receipt now | ||
'businessName' => $receipt[5] | ||
]; | ||
|
||
//Display the data in json format | ||
echo json_encode($receipt); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.