Skip to content

Commit

Permalink
Frontend housekeeping. Preparing to add more functionality to Managers.
Browse files Browse the repository at this point in the history
  • Loading branch information
raynelfss committed May 15, 2022
1 parent 2f8b68c commit 43a2874
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 35 deletions.
7 changes: 5 additions & 2 deletions api/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from database import orders, customers
from helpers import isChef, isDeliveryBoy, isLoggedIn, isManager, isCustomer
from database.shoppingCart import calcPrices, getDishes
from database.customers import getBalance, getMoneySpent, updateBalance, updateMoneySpent
from database.customers import getBalance, getMoneySpent, getNumOfOrders ,updateBalance, updateMoneySpent, updateNumOrders
from datetime import datetime

orderBlueprint = Blueprint('app_order', __name__, url_prefix = '/order')
Expand Down Expand Up @@ -87,10 +87,13 @@ def order(id):
data['datetime'], data['deliveryMethod'], data['employeeID'], data['status'])
balance = getBalance(data['customerID'])['balance']
spent = getMoneySpent(data['customerID'])['balance']
numOrders = getNumOfOrders(data['customerID'])['balance']
balance = balance + price
spent = spent - price
spent = spent - price if spent - price >= 0 else 0
numOrders = numOrders - 1 if numOrders >= 0 else 0
updateBalance(data['customerID'], balance)
updateMoneySpent(data['customerID'], spent)
updateNumOrders(data['customerID'], numOrders);

else:
orders.updateOrder(id, dishes, data['customerID'], data['address'], price,
Expand Down
57 changes: 31 additions & 26 deletions build/menu-staff.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,42 @@


{% block body %}
<h1 class="h1">Menu</h1>
<div class="whitebox">
<div class="header">
<h1>List of items:</h1>
<button id="additem" onclick="openDiag('Create item:','Create')">Add item</button>
</div>
<table class="ptable", id="ptable">
<tr>
<th>Chef ID</th>
<th>Description</th>
<th>Item ID</th>
<th>Name</th>
<th>Image</th>
<th>Price</th>
<th></th>
</tr>
</table>
<div class="cover" id="cover" onclick="closeDiag('creatediv')"></div>
<div class="create-edit", id="creatediv">
<h1 id="subject">Create new item:</h3>
<label for="dishName">Name of item</label>
<input type="text" id="dishName" name="dishName" placeholder="Milk Tea"> <br>
<label for="dishDescription">Description:</label>
<textarea id="dishDescription" name="dishDescription" rows="4" maxlength="250" inputmode="latin" placeholder="Traditional milk tea."></textarea> <br>
<label for="imageURL">Image link:</label>
<input type="url" id="imageURL" name="imageURL" placeholder="https://img.buzzfeed.com/thumbnailer-prod-us-east-1/8f1e6c865e5b4ef0a1f8d15b3f676202/BFV69042_HowToMakeBobaFromScratch_JP_Final_YT.jpg?resize=1200:*&output-format=jpg&output-quality=auto"> <br>
<label for="price">Price:</label>
<input type="text" id="price" name="price" placeholder="9.99"> <br>
<div id="buttons">
<button onclick="addElementtoTable()", id="editorcreate">Add</button>
<button onclick="closeDiag('creatediv')">Cancel</button>
</div>
<div class="tablecont">
<table class="ptable", id="ptable">
<tr>
<th>Chef ID</th>
<th>Description</th>
<th>Item ID</th>
<th>Name</th>
<th>Image</th>
<th>Price</th>
<th></th>
</tr>
</table>
</div>
</div>
<div class="cover" id="cover" onclick="closeDiag('creatediv')"></div>
<div class="create-edit", id="creatediv">
<h1 id="subject">Create new item:</h3>
<label for="dishName">Name of item</label>
<input type="text" id="dishName" name="dishName" placeholder="Milk Tea"> <br>
<label for="dishDescription">Description:</label>
<textarea id="dishDescription" name="dishDescription" rows="4" maxlength="250" inputmode="latin" placeholder="Traditional milk tea."></textarea> <br>
<label for="imageURL">Image link:</label>
<input type="url" id="imageURL" name="imageURL" placeholder="https://img.buzzfeed.com/thumbnailer-prod-us-east-1/8f1e6c865e5b4ef0a1f8d15b3f676202/BFV69042_HowToMakeBobaFromScratch_JP_Final_YT.jpg?resize=1200:*&output-format=jpg&output-quality=auto"> <br>
<label for="price">Price:</label>
<input type="text" id="price" name="price" placeholder="9.99"> <br>
<div id="buttons">
<button onclick="addElementtoTable()", id="editorcreate">Add</button>
<button onclick="closeDiag('creatediv')">Cancel</button>
</div>
</div>
<script src="/scripts/menu-staff.js"></script>

{% endblock %}
2 changes: 1 addition & 1 deletion build/styles/dashboard-layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ button{
padding: 10px;
border: none;
/* background-color: rgb(245, 245, 245); */
transition: 1s;
transition: 0.3s;
}

button:hover{
Expand Down
27 changes: 21 additions & 6 deletions build/styles/menu-staff.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,28 @@ body {
text-align: center;
}

.whitebox{
display: flex;
flex-direction: column;
justify-content: center;
border-radius: 10px;
margin: 10px 80px;
margin-bottom: 40px;
background-color: white;
padding: 10px 50px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
}
.tablecont{
overflow-x: auto;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
margin-bottom: 40px;
}


table {
position: relative;
border: 2px solid rgb(133, 126, 127);
border-radius: 5px;
width: 80%;
left: 50%;
transform: translate(-50%, 0%);
margin-bottom: 40px;
/* overflow: hidden; */
box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
border-collapse: collapse;
overflow: hidden;
Expand All @@ -23,6 +36,8 @@ table {
th {
color: black;
padding: 10px;
border-collapse: collapse;
padding: 10px;
}

tr:first-child {
Expand Down
9 changes: 9 additions & 0 deletions database/customers.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ def updateMoneySpent(customerID, spent):
with DatabaseConnection('./database/database.db') as cursor:
cursor.execute("UPDATE CustomerTable SET MoneySpent=? WHERE CustomerID=?", (spent, customerID,))

def getNumOfOrders(customerID):
with DatabaseConnection('./database/database.db') as cursor:
rows = cursor.execute("SELECT NumberOfOrders FROM CustomerTable WHERE CustomerID = ?", (customerID,))
return [listToDictBal(row) for row in rows][0]

def updateNumOrders(customerID, orders):
with DatabaseConnection('./database/database.db') as cursor:
cursor.execute("UPDATE CustomerTable SET NumberOfOrders=? WHERE CustomerID=?", (orders, customerID,))

def demoteOnePoint(userID):
points = getCustomerDemotionPoint(userID) #if error maybe because this doesnt return int value
points -=1
Expand Down

0 comments on commit 43a2874

Please sign in to comment.