Project Doc
Project Doc
1|Page
CERTIFICATE
Principal
2|Page
ACKNOWLEDGEMENT
I would like to express my heartfelt gratitude to my Computer Science
teacher, Mrs. Kiran Sonone. Her invaluable guidance, expertise, and
encouragement were instrumental throughout the preparation of this
project. Her dedication and support have been a source of immense
inspiration.
3|Page
INDEX
1. Introduction
2. Requirements
3. Objective of project
4. Flow Of Programme
5. CODE
6. MySQL Database and Tables
7. Execution of programme
8. Output
9. Conclusion
10. Bibliography
4|Page
INTRODUNCTION
5|Page
REQUIREMENTS
For this Python-based Restaurant Management program using MySQL, here are the
minimum and recommended system requirements:
These requirements ensure the program runs smoothly, particularly during multi-role
operations and data-intensive tasks.
6|Page
OBJECTIVE OF PROJECT
• Automate Restaurant Operations: Simplify daily tasks such as order management,
inventory tracking, and staff coordination through a terminal-based interface.
• Enhance Role-Based Efficiency: Develop dedicated modules for Admin, Cook, Waiter,
and Storekeeper roles to streamline specific tasks relevant to each position.
• Improve Order Processing: Enable quick order placement, status checking, and order
fulfilment, reducing wait times and enhancing customer service.
• Optimize Staff Management: Provide an Admin module for adding, updating, and
viewing staff details, ensuring efficient personnel management and role-based access
control.
• Facilitate Communication and Complaint Resolution: Include options for staff to submit
complaints or requests and for Admin to view and address these, fostering better
internal communication.
• Ensure Data Security: Implement password encryption to secure access and ensure
sensitive information is protected.
• Centralize Data Storage: Maintain organized tables for menu items, staff details,
announcements, orders, complaints, and requests within a MySQL database for easy
data retrieval and management.
7|Page
FLOW OF PROGRAME
8|Page
CODE
1st File: Create Database and Tables.py
import mysql.connector
def create_database_and_tables():
db = mysql.connector.connect(host="localhost", user="root",
password="octane", auth_plugin='mysql_native_password')
cursor = db.cursor()
# Create database
cursor.execute("CREATE DATABASE IF NOT EXISTS test3")
cursor.execute("USE test3")
9|Page
# Create 'menu' table
cursor.execute("""
CREATE TABLE IF NOT EXISTS menu (
food_item VARCHAR(50),
price DECIMAL(5,2)
)
""")
create_database_and_tables()
11 | P a g e
def login_module(cursor):
try:
position = input("Enter your position (Waiter, Cook, Admin,
Storekeeper): ")
password = input("Enter your password: ")
if result:
print("Welcome, " + result[0] + "!") # result[0] is the
name of the user
return position
else:
print("Invalid credentials!")
return None
except mysql.connector.Error as e:
print("Database error: " + str(e))
return None
except Exception as e:
print("An unexpected error occurred: " + str(e))
return None
def get_yes_no_input(prompt):
"""Utility function to get a valid 'Yes' or 'No' input."""
while True:
try:
choice = input(prompt).strip().title()
if choice not in ['Yes', 'No']:
raise ValueError
return choice
except ValueError:
print("Invalid input. Please enter 'Yes' or 'No'.")
def main():
role = login_module(cursor)
if role == "Waiter":
waiter_module(cursor, connection)
elif role == "Cook":
cook_module(cursor, connection)
elif role == "Admin":
admin_module(cursor, connection)
elif role == "Storekeeper":
storekeeper_module(cursor, connection)
else:
print("No valid role found.")
if logout_choice == 'Yes':
exit_choice = get_yes_no_input("Do you want to exit the
program? (Yes/No): ")
if exit_choice == 'Yes':
print("Exiting the Program!")
break # Exit the while loop and close the program
else:
print("Logging out...\n")
# Reset the connection and cursor for the next login
continue
main()
13 | P a g e
import mysql.connector
from prettytable import PrettyTable #for tables
else:
break
except ValueError:
print("Invalid Input. Try again!")
if choice == 1:
add_food_items(cursor, connection)
elif choice == 2:
add_staff(cursor, connection)
elif choice == 3:
delete_food_item(cursor, connection)
elif choice == 4:
14 | P a g e
make_announcement(cursor, connection)
elif choice == 5:
view_staff_list(cursor)
elif choice == 6:
update_staff_details(cursor, connection)
elif choice == 7:
update_staff_password(cursor, connection)
elif choice == 8:
view_and_fix_complaints(cursor, connection)
elif choice == 9:
view_requests(cursor)
elif choice == 10:
delete_employee(cursor, connection)
elif choice == 11:
break
else:
print("Invalid choice. Please try again.")
def view_staff_list(cursor):
print("\n--- Staff List ---")
try:
# get all staff details
cursor.execute("SELECT name, employee_id, position, salary,
performance, password FROM Staff")
staff_records = cursor.fetchall() # Fetch all records
if staff_records:
# Create Table
table = PrettyTable()
table.field_names = ["Name", "Employee ID", "Position",
"Salary", "Performance", "Password"]
food_items = food_items_input.split(',')
16 | P a g e
cursor.execute("SELECT * FROM Menu WHERE food_item = '" +
food_item + "'")
result = cursor.fetchone()
if result:
connection.commit()
print("Menu updated successfully.\n")
while True:
try:
# Password input
while True:
password = input("Enter password: ")
break
try:
17 | P a g e
cursor.execute("INSERT INTO Staff (name, employee_id,
position, salary, performance, password) VALUES ('" + name + "', '" +
employee_id + "', '" + position + "', " + str(salary) + ", '" +
performance + "', '" + password + "')")
print("Staff details added successfully.\n")
except mysql.connector.Error as err:
print("Error: " + str(err))
connection.commit()
print("Announcement made successfully.\n")
if result:
18 | P a g e
print("Current Details: Name: " + result[0] + ", Position:
" + result[1] + ", Salary: " + str(result[2]) + ", Performance: " +
result[3])
#updated details
new_name = input("Enter new name (Leave blank to keep as "
+ result[0] + "): ") or result[0]
new_position = input("Enter new position (Leave blank to
keep as " + result[1] + "): ") or result[1]
new_salary = input("Enter new salary (Leave blank to keep
as " + str(result[2]) + "): ") or str(result[2])
new_performance = input("Enter new performance (Leave
blank to keep as " + result[3] + "): ") or result[3]
except Exception as e:
print("An error occurred: " + str(e))
if result:
print("Current password for " + result[0] + " is hidden
for security purposes.")
19 | P a g e
#new password
new_password = input("Enter new password: ")
except Exception as e:
print("An error occurred: " + str(e))
if not complaints:
print("No pending complaints.")
return
def view_requests(cursor):
print("\n--- View Requests ---")
20 | P a g e
# Query to retrieve all requests
cursor.execute("SELECT staff_name, request, date_submitted FROM
Requests")
requests = cursor.fetchall() # Fetch all requests instead of
fetchmany
if not requests:
print("No requests found.")
else:
# Create Table
table = PrettyTable()
if result:
# Confirm before deletion
confirmation = input(f"Are you sure you want to delete
{result[0]} (Employee ID: {employee_id})? (yes/no): ").lower()
if confirmation == 'yes':
cursor.execute("DELETE FROM Staff WHERE employee_id = " +
employee_id)
21 | P a g e
print(f"Employee {result[0]} with Employee ID
{employee_id} has been deleted.")
connection.commit()
else:
print("Deletion cancelled.")
else:
print(f"No employee found with Employee ID: {employee_id}.")
if result:
message = result[0]
priority = result[1]
created_at = result[2]
print("\n--- Announcement ---")
print("Priority: " + str(priority))
print("Date: " + created_at.strftime('%Y-%m-%d %H:%M:%S'))
print("Message: " + message + "\n")
else:
print("\nNo announcements at this time.\n")
display_announcement(cursor)
while True:
print("\n--- Waiter Module ---")
print("1. Place a new order")
print("2. Check order status")
print("3. Register a complaint")
print("4. Add Request")
print("5. Exit")
22 | P a g e
try:
choice = int(input("Enter your choice: "))
except ValueError:
print("Invalid input. Please enter a number.")
continue
if choice == 1:
# Place a new order
cursor.execute("SELECT * FROM Menu")
menu = cursor.fetchall()
if not menu:
print("No items in the menu.")
return
print("Menu:")
for item in menu:
print(str(item[0]) + ": @" + str(item[1]))
# Take order
order = input("Enter food items ordered (comma separated):
").strip()
if not order:
print("No order was placed.")
return
if result:
price = result[0]
ordered_items.append((item, price)) #
Store item and its price as a tuple
total += price
else:
print(item + " is not available on the
menu.")
# Print bill
print("\n" + "="*30)
print(restaurant_name)
print("-" * 30)
print("Items Ordered:")
print("-" * 30)
print("Total: @" + str(total))
print("Issued by: " + issued_by)
print("="*30 + "\n")
connection.commit()
24 | P a g e
generate_bill(order, cursor, issued_by="Waiter",
connection=connection)
elif choice == 2:
def check_order_status(cursor):
print("\n--- Check Order Status ---")
if status == 'Accepted':
print("Time required: " +
str(time_required) + " minutes")
elif status == 'Rejected':
print("Reason for rejection: " + reason)
else:
# No orders found
print("No orders found.")
check_order_status(cursor)
elif choice == 3:
import datetime
try:
cursor.execute(query)
connection.commit()
print("Complaint submitted successfully.")
except Exception as e:
print(f"Error submitting complaint: {e}")
add_complaint(cursor, connection)
elif choice == 4:
def add_request(cursor, connection):
print("\n--- Add Request ---")
try:
cursor.execute(query)
connection.commit()
print("Request added successfully.\n")
except Exception as e:
print(f"An error occurred: {e}")
26 | P a g e
add_request(cursor, connection)
elif choice == 5:
print("Exiting")
break
else:
print("Invalid choice. Please try again.")
if result:
message = result[0]
priority = result[1]
created_at = result[2]
print("\n--- Announcement ---")
print("Priority: " + str(priority))
print("Date: " + created_at.strftime('%Y-%m-%d %H:%M:%S'))
print("Message: " + message + "\n")
else:
print("\nNo announcements at this time.\n")
display_announcement(cursor)
while True:
try:
27 | P a g e
choice = int(input("Enter your choice (1, 2, 3, 4 or 5):
"))
except ValueError:
print("Invalid input. Please enter a number (1, 2, 3, 4 or
5).")
continue
if choice == 1:
# View all pending orders
try:
cursor.execute("SELECT id, items, status FROM Orders
WHERE status='Pending'")
pending_orders = cursor.fetchall()
if not pending_orders:
print("******************************* No
pending orders. *******************************")
else:
print("Pending Orders:")
for order in pending_orders:
print("Order ID: " + str(order[0]) + ", Items:
" + order[1] + ", Status: " + order[2])
except Exception as e:
print("Error fetching pending orders: " + str(e))
elif choice == 2:
# Accept or reject an order
try:
cursor.execute("SELECT id, items FROM Orders WHERE
status='Pending'")
orders = cursor.fetchall()
if not orders:
print("No pending orders.")
continue
print("Pending Orders:")
28 | P a g e
for order in orders:
print("Order ID: " + str(order[0]) + ", Items: " +
order[1])
if not order:
print("Invalid Order ID or order is not pending.")
continue
if decision == 'accept':
try:
time_required = int(input("Enter time required
(in minutes) to prepare the order: "))
cursor.execute("UPDATE Orders SET
status='Accepted', time_required=" + str(time_required) + " WHERE id="
+ str(order_id))
connection.commit()
print("Order " + str(order_id) + " accepted.
Time required: " + str(time_required) + " minutes.")
except ValueError:
print("Invalid input for time required. Please
enter a number.")
elif decision == 'reject':
reason = input("Enter the reason for rejecting the
order: ")
cursor.execute("UPDATE Orders SET
status='Rejected', reason='" + reason + "' WHERE id=" + str(order_id))
connection.commit()
print("Order " + str(order_id) + " rejected.
Reason: " + reason)
else:
29 | P a g e
print("Invalid choice. Please enter 'accept' or
'reject'.")
except Exception as e:
print("Error processing order: " + str(e))
elif choice == 3:
# Mark an order as completed
try:
cursor.execute("SELECT id, items, status FROM Orders
WHERE status='Accepted'")
accepted_orders = cursor.fetchall()
if not accepted_orders:
print("No accepted orders to mark as completed.")
else:
print("Accepted Orders:")
for order in accepted_orders:
print("Order ID: " + str(order[0]) + ", Items:
" + order[1] + ", Status: " + order[2])
elif choice == 4:
def add_request(cursor, connection):
print("\n--- Add Request ---")
try:
cursor.execute(query)
connection.commit()
print("Request added successfully.\n")
except Exception as e:
print(f"An error occurred: {e}")
add_request(cursor, connection)
elif choice == 5:
print("Exiting Cook Module.")
break
else:
print("Invalid choice. Please try again.")
if result:
message = result[0]
priority = result[1]
created_at = result[2]
print("\n--- Announcement ---")
print("Priority: " + str(priority))
31 | P a g e
print("Date: " + created_at.strftime('%Y-%m-%d %H:%M:%S'))
print("Message: " + message + "\n")
else:
print("\nNo announcements at this time.\n")
display_announcement(cursor)
while True:
if choice == '1':
# Update the quantity of an existing item
item = input("Enter item name to update: ")
if result:
while True:
try:
quantity = int(input("Enter new quantity: "))
break
except ValueError:
print("Invalid input for quantity. Please
enter an integer.")
try:
cursor.execute("UPDATE Store SET quantity=" +
str(quantity) + " WHERE item='" + item + "'")
32 | P a g e
connection.commit()
print("Quantity of " + item + " updated to " +
str(quantity) + ".")
except Exception as e:
print("Error updating item: " + str(e))
else:
print("Item '" + item + "' does not exist in the
store.")
while True:
try:
quantity = int(input("Enter quantity: "))
break
except ValueError:
print("Invalid input for quantity. Please enter an
integer.")
try:
cursor.execute("INSERT INTO Store (item, quantity,
`MFG/Date_of_purchase`) VALUES ('" + item + "', " + str(quantity) + ",
'" + str(date_of_purchase) + "')")
connection.commit()
print("New item '" + item + "' added to the store with
quantity " + str(quantity) + " and date " + str(date_of_purchase) +
".")
33 | P a g e
except Exception as e:
print("Error adding new item: " + str(e))
try:
cursor.execute(query)
connection.commit()
print("Request added successfully.\n")
except Exception as e:
print(f"An error occurred: {e}")
add_request(cursor, connection)
try:
item_name = input("Enter Name of Item to Delete: ")
query = "DELETE FROM store WHERE item = '" + item_name
+ "'"
cursor.execute(query)
connection.commit()
if cursor.rowcount > 0:
print("Item '" + item_name + "' deleted
successfully!")
else:
print("Item '" + item_name + "' not found!")
34 | P a g e
except mysql.connector.Error as error:
print("Failed to delete item from store:
{}".format(error))
items = cursor.fetchall()
# Create Table
table = PrettyTable()
table.field_names = ["Item", "Quantity",
"MFG/Date_of_purchase"]
35 | P a g e
MySQL DATABASE AND TABLES
36 | P a g e
37 | P a g e
Execution of Program
STEP 1:
This program is divided into several files. All the files will be executed through the file " ". Before that, the file
"create Database and tables.py" must be executed in order to create the database in MySQL. If the database is
already created, no need to run this file again.
STEP 2:
Requirements to run this program:
3. Few other Python libraries need to be installed, run all the commands in the command prompt as an
administrator:
(i) MySQL connector:
Run this command:
pip install mysql.connector
(ii) prettytable:
pip install prettytable
STEP 3:
First run the "create Database and tables.py" file to create a database in MySQL and create all the required tables. If
the database is already created, no need to run this file again. This file includes a user-defined function
"create_database_and_tables ()" which first creates the database, then uses it to create multiple tables as per the
requirements.
Tables included:
announcements
complaints
menu
orders
requests
staff
store
38 | P a g e
STEP 4:
To run the main program, the user needs to run the main file (" ").
STEP 5:
After running program, it takes you to login page where you have to login as "Admin" and default password will be
"123". After login you have to setup staff details for Cook, Waiter, Storekeeper. Make sure you enter
position first letter capital and rest as lower case. Only assign one person per position and while login
you should keep upper and lower case same as said earlier.
Precautions:
1.Make sure whenever you run Database file or try to
connect to database, you include this
auth_plugin='mysql_native_password' Otherwise it
will raise an error while executing.
It should look like this:
mysql. connector. Connect (host="localhost",
user="root",password="octane", database="ArchyansRestaurant",
auth_plugin='mysql_native_password')
39 | P a g e
OUTPUT
---Login Interface---
40 | P a g e
---Waiter---
---Cook---
---Storekeeper---
41 | P a g e
CONCLUSION
The project efficiently leverages Python and MySQL, creating a
powerful, user-friendly restaurant management system that
simplifies day-to-day operations. By employing Python's
versatility, the project uses multiple user-defined functions,
which modularize tasks such as adding, updating, and viewing
menu items, orders, staff details, and inventory, making the code
organized and easily maintainable. This structure not only
enhances readability but also promotes code reusability,
allowing each function to perform specific tasks without
redundancy.
42 | P a g e
BIBLIOGRAPHy
• WEBSITE REFRENCES:
• Book References:
43 | P a g e
44 | P a g e