0% found this document useful (0 votes)
2 views

Project Doc

The document presents a project on Restaurant Management completed by Aryan Kumar, a student of class 12-A at Kendriya Vidyalaya N.A.D. Karanja, under the guidance of Mrs. Kiran Sonone. It outlines the project's objectives, system requirements, and implementation using Python and MySQL, detailing various modules for different restaurant roles. The project aims to automate operations, enhance efficiency, and ensure data security within the restaurant management system.

Uploaded by

Aryan Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Project Doc

The document presents a project on Restaurant Management completed by Aryan Kumar, a student of class 12-A at Kendriya Vidyalaya N.A.D. Karanja, under the guidance of Mrs. Kiran Sonone. It outlines the project's objectives, system requirements, and implementation using Python and MySQL, detailing various modules for different restaurant roles. The project aims to automate operations, enhance efficiency, and ensure data security within the restaurant management system.

Uploaded by

Aryan Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

BIODATA

NAME: - ARYAN KUMAR

CLASS: - 12-A (SCIENCE)

TOPIC: - Restaurant Management

SUBJECT TEACHER: - Mrs. Kiran Sonone

1|Page
CERTIFICATE

This is to certify that Mr. ARYAN KUMAR of class XII – Science,


Kendriya Vidayalaya N.A.D. Karanja has completed the project on
Restaurant Management of Mrs. Kiran Sonone, PGT – Computer
Science. This project is a requirement of All India Senior Secondary
Certificate Examination (AISSCE) as prescribed by CBSE for the year
2024-25.
CBSE Roll No. _________________

Internal Examiner External Examiner


(Mrs. Kiran Sonone)

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.

I am also thankful to my respected teachers, who provided valuable insights,


and to the library and office staff for their support and cooperation. Each of
them contributed significantly to making this project a learning experience.

A special thanks to my friends, classmates, and, most importantly, my parents,


whose unwavering encouragement and belief in my abilities kept my
confidence high and motivated me to persevere through every challenge.
Without their collective support, completing this project would not have been
possible.

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

The programming language used in the project is Python,


while MySQL serves as the database system.

Python's role includes handling modules for different


restaurant roles (e.g., admin, waiter, cook, and
storekeeper) and managing the program's main workflow.
Key libraries include mysql.connector for MySQL
interactions and prettytable for displaying data in tables.

The MySQL database contains structured tables for


various data aspects, including announcements,
complaints, menu, orders, requests, staff, and store
items, to support comprehensive management of the
restaurant's operations.

5|Page
REQUIREMENTS

For this Python-based Restaurant Management program using MySQL, here are the
minimum and recommended system requirements:

Minimum System Requirements

• Operating System: Windows 7 / macOS 10.10 (Yosemite) / Ubuntu 16.04 or


equivalent Linux
• Processor: Dual-core CPU (2.0 GHz)
• RAM: 4 GB
• Storage: 500 MB free space
• Python Version: Python 3.6
• MySQL Version: MySQL 5.7
• Dependencies:
o MySQL Connector (pip install mysql.connector)
o PrettyTable (pip install prettytable)

Recommended System Requirements

• Operating System: Windows 10 or later / macOS 10.15 (Catalina) or later / Ubuntu


18.04 or later
• Processor: Quad-core CPU (2.5 GHz or faster)
• RAM: 8 GB or more
• Storage: 1 GB free space
• Python Version: Python 3.8 or higher
• MySQL Version: MySQL 8.0 or higher
• Additional Requirements: Stable internet connection for downloading dependencies,
administrative rights for installations

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.

• Streamline Inventory Management: Allow the storekeeper to track, update, and


manage inventory to maintain optimal stock levels and reduce waste.

• 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")

# Create 'announcements' table


cursor.execute("""
CREATE TABLE IF NOT EXISTS announcements (
id INT NOT NULL,
message TEXT NOT NULL,
priority ENUM('Low', 'Medium', 'High') DEFAULT 'Low',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
)
""")

# Create 'complaints' table


cursor.execute("""
CREATE TABLE IF NOT EXISTS complaints (
complaint_id INT NOT NULL,
waiter_name VARCHAR(50),
complaint TEXT NOT NULL,
date_submitted DATE,
status VARCHAR(20) DEFAULT 'Pending',
PRIMARY KEY (complaint_id)
)
""")

9|Page
# Create 'menu' table
cursor.execute("""
CREATE TABLE IF NOT EXISTS menu (
food_item VARCHAR(50),
price DECIMAL(5,2)
)
""")

# Create 'orders' table


cursor.execute("""
CREATE TABLE IF NOT EXISTS orders (
id INT NOT NULL,
items TEXT NOT NULL,
status ENUM('Pending', 'Accepted', 'Rejected',
'Completed') DEFAULT 'Pending',
reason VARCHAR(255),
time_required INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
)
""")

# Create 'requests' table


cursor.execute("""
CREATE TABLE IF NOT EXISTS requests (
request_id INT NOT NULL,
staff_name VARCHAR(50),
request TEXT NOT NULL,
date_submitted DATE,
PRIMARY KEY (request_id)
)
""")

# Create 'staff' table


cursor.execute(""" CREATE TABLE IF NOT EXISTS staff ( name
VARCHAR(50), employee_id INT NOT NULL, position VARCHAR(20), salary
DECIMAL(7,2), performance VARCHAR(20), password VARCHAR(255), PRIMARY
KEY (employee_id)) """)

# Create 'store' table


10 | P a g e
cursor.execute("""
CREATE TABLE IF NOT EXISTS store (
item VARCHAR(50),
quantity INT,
MFG_Date_of_purchase DATE
)
""")

# Insert admin user into 'staff' table


cursor.execute("""
INSERT INTO staff (name, employee_id, position, salary,
performance, password)
VALUES ('admin', 1, 'Admin', NULL, 'Good', '123')
""")

db.commit() # Commit changes


print("Database, tables, and admin user created successfully!")

# Close the connection


cursor.close()
db.close()

create_database_and_tables()

2nd File : Main.py


import mysql.connector
from admin import admin_module
from waiter import waiter_module
from cook import cook_module
from storekeeper import storekeeper_module

#connect to the database


def connect_to_db():
return mysql.connector.connect( host="localhost", user="root",
password="octane", database="archyansrestaurant",
auth_plugin='mysql_native_password')

11 | P a g e
def login_module(cursor):
try:
position = input("Enter your position (Waiter, Cook, Admin,
Storekeeper): ")
password = input("Enter your password: ")

#check if the position and password match


cursor.execute("SELECT name FROM Staff WHERE position='" +
position + "' AND password='" + password + "'")
result = cursor.fetchone()

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():

while True: # Loop for multiple logins


connection = connect_to_db()
12 | P a g e
cursor = connection.cursor()

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.")

logout_choice = get_yes_no_input("Do you want to log out?


(Yes/No): ")

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

# Cleanup before exiting


cursor.close()
connection.close()

main()

3rd file: Admin.py

13 | P a g e
import mysql.connector
from prettytable import PrettyTable #for tables

def admin_module(cursor, connection):


while True:
print("\n--- Admin Module ---")
print("1. Add Food Items to Menu")
print("2. Update Staff Details")
print("3. Delete food items from menu")
print("4. Make Announcements")
print("5. View Staff List")
print("6. Update existing Staff Details")
print("7. Update Staff password")
print("8. View and fix complaints")
print("9. View Requests from employees")
print("10. Delete Employees")
print("11. Exit")

while True: # This type of try_except will be found almost in


every input commnad as to avoid any mixup in inputs
try:

choice = int(input("Enter choice: "))

if choice not in [i for i in range(1,12)]:


raise ValueError

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.")

cursor.close() # Close the cursor


connection.close() # Close the connection

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"]

# Add all staff records to the table


for row in staff_records:
table.add_row(row)

# Print the table


15 | P a g e
print(table)
else:
print("No staff records found.")

except mysql.connector.Error as err:


print(f"Error: {err}")

def add_food_items(cursor, connection):


print("Enter food items in the format: item_name1:price1,
item_name2:price2, ...")
food_items_input = input("Enter multiple food items and prices: ")

food_items = food_items_input.split(',')

for food_item in food_items:


try:
name, price = food_item.split(':')
name = name.strip()
price = float(price.strip())

cursor.execute("INSERT INTO Menu (food_item, price) VALUES


('" + name + "', " + str(price) + ")")
print("Added " + name + " to the menu with price @" +
str(price))
except ValueError:
print("Invalid format for " + food_item + ". Use
'item_name:price' format.")
except mysql.connector.Error as err:
print("Error: " + str(err))

# Commit changes to the database using the connection


connection.commit()
print("Menu updated successfully.\n")

def delete_food_item(cursor, connection):


print("\n--- Delete Food Item from Menu ---")
food_item = input("Enter the name of the food item to delete:
").strip()

16 | P a g e
cursor.execute("SELECT * FROM Menu WHERE food_item = '" +
food_item + "'")
result = cursor.fetchone()

if result:

cursor.execute("DELETE FROM Menu WHERE food_item = '" +


food_item + "'")
print("Deleted " + food_item + " from the menu.")
else:
print("Food item '" + food_item + "' not found in the menu.")

connection.commit()
print("Menu updated successfully.\n")

def add_staff(cursor, connection):


print("\n--- Add Staff ---")

name = input("Enter staff name: ").title()


employee_id = input("Enter employee ID (unique): ")
position = input("Enter position: ").title()

while True:

try:

salary = float(input("Enter salary: "))


break
except ValueError:
print("Invalid input for salary. Please enter in decimal
format.")

performance = input("Enter performance: ")

# 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))

# Commit changes to the database


connection.commit()

def make_announcement(cursor, connection):


print("\n--- Make an Announcement ---")
announcement = input("Enter the announcement message: ").strip()

# Let admin choose priority level


print("Select priority: 1. Low 2. Medium 3. High")
priority_choice = int(input("Enter priority (1-3): "))

priority_map = {1: 'Low', 2: 'Medium', 3: 'High'}


priority = priority_map.get(priority_choice)

cursor.execute("INSERT INTO Announcements (message, priority)


VALUES ('" + announcement + "', '" + priority + "')")

connection.commit()
print("Announcement made successfully.\n")

# Function to update staff details except password


def update_staff_details(cursor, connection):
try:
employee_id = input("Enter the Employee ID of the staff to
update details: ")

# Fetch the current details of the staff


cursor.execute("SELECT name, position, salary, performance
FROM Staff WHERE employee_id = '" + employee_id + "'")
result = cursor.fetchone()

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]

# Update details in database


cursor.execute("UPDATE Staff SET name='" + new_name + "',
position='" + new_position + "', salary=" + new_salary + ",
performance='" + new_performance + "' WHERE employee_id='" +
employee_id + "'")
connection.commit()
print("Staff details updated successfully!")
else:
print("Staff with this Employee ID does not exist.")

except Exception as e:
print("An error occurred: " + str(e))

# Function to update password only


def update_staff_password(cursor, connection):
try:
employee_id = input("Enter the Employee ID of the staff to
update password: ")

# Fetch the staff's current password


cursor.execute("SELECT name, password FROM Staff WHERE
employee_id = '" + employee_id + "'")
result = cursor.fetchone()

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: ")

# Update the password in database


cursor.execute("UPDATE Staff SET password='" +
new_password + "' WHERE employee_id='" + employee_id + "'")
connection.commit()
print("Password updated successfully!")
else:
print("Staff with this Employee ID does not exist.")

except Exception as e:
print("An error occurred: " + str(e))

def view_and_fix_complaints(cursor, connection):


print("\n--- Complaints ---")
cursor.execute("SELECT complaint_id, waiter_name, complaint,
date_submitted, status FROM Complaints WHERE status='Pending'")
complaints = cursor.fetchall()

if not complaints:
print("No pending complaints.")
return

for complaint in complaints:


print("Complaint ID: " + str(complaint[0]) + ", Waiter: " +
complaint[1] + ", Complaint: " + complaint[2] + ", Date Submitted: " +
str(complaint[3]) + ", Status: " + complaint[4])

complaint_id = input("Enter the complaint ID to mark as fixed: ")


update_query = "UPDATE Complaints SET status='Fixed' WHERE
complaint_id=" + complaint_id
cursor.execute(update_query)
connection.commit()
print("Complaint " + complaint_id + " has been marked as
fixed.\n")

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()

# Define table columns


table.field_names = ["Staff Name", "Request", "Date
Submitted"]

# Add rows to the table


for rq in requests:
table.add_row(rq)

# Print the table


print(table)

def delete_employee(cursor, connection):


print("\n--- Delete Employee ---")
employee_id = input("Enter the Employee ID of the staff member to
delete: ").strip()

# Check if the employee exists in the staff table


cursor.execute("SELECT * FROM Staff WHERE employee_id = " +
employee_id)
result = cursor.fetchone()

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}.")

print("Staff table updated successfully.\n")

4th file: Waiter.py

def waiter_module(cursor, connection):


def display_announcement(cursor):
cursor.execute("SELECT message, priority, created_at FROM
Announcements ORDER BY created_at DESC LIMIT 1")
result = cursor.fetchone()

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

# Insert the order into the Orders table with 'Pending'


status
cursor.execute("INSERT INTO Orders (items, status) VALUES
('" + order + "', 'Pending')")
connection.commit()
print("Order has been placed and is pending for cook's
approval.")

# Call generate_bill to print the bill


def generate_bill(order, cursor, issued_by, connection):
restaurant_name = "ARCHYAN'S RESTAURANT"

# Calculate the total bill and store item details


23 | P a g e
total = 0
ordered_items = []

# Split the order items entered by the waiter


items_ordered = order.split(',')

for item in items_ordered:


item = item.strip()
cursor.execute("SELECT price FROM Menu WHERE
food_item='" + item + "'")
result = cursor.fetchone()

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:")

for item, price in ordered_items:


print(item + ": @" + str(price))

print("-" * 30)
print("Total: @" + str(total))
print("Issued by: " + issued_by)
print("="*30 + "\n")

connection.commit()

# Return the total


return total

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 ---")

# Fetch all orders from the Orders table


cursor.execute("SELECT id, items, status,
time_required, reason FROM Orders")
orders = cursor.fetchall()

# Check if there are any orders


if orders:
for order in orders:
order_id = order[0]
items = order[1]
status = order[2]
time_required = order[3]
reason = order[4]

print("\nOrder ID: " + str(order_id))


print("Items: " + items)
print("Status: " + 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

def add_complaint(cursor, connection):


25 | P a g e
waiter_name = input("Enter your name: ")
complaint = input("Enter the customer's complaint: ")
current_date = datetime.date.today()

try:

query = f"INSERT INTO Complaints (waiter_name,


complaint, date_submitted) VALUES ('{waiter_name}', '{complaint}',
'{current_date}')"

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 ---")

# Take staff name as input from the user


staff_name = input("Enter your name: ")

request = input("Enter your request: ")


date_submitted = "CURRENT_DATE"

query = "INSERT INTO Requests (staff_name, request,


date_submitted) VALUES ('" + staff_name + "', '" + request + "', " +
date_submitted + ")"

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.")

5th file: Cook.py

def cook_module(cursor, connection):


def display_announcement(cursor):
cursor.execute("SELECT message, priority, created_at FROM
Announcements ORDER BY created_at DESC LIMIT 1")
result = cursor.fetchone()

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--- Cook Module ---")


print("1. View Pending Orders")
print("2. Accept/Reject Order")
print("3. Mark Order as Completed")
print("4. Add Request")
print("5. Exit") # Adding option to exit

try:

27 | P a g e
choice = int(input("Enter your choice (1, 2, 3, 4 or 5):
"))

if choice not in [i for i in range(1,6)]:


raise ValueError

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])

order_id = int(input("Enter the Order ID to process:


"))

cursor.execute("SELECT items FROM Orders WHERE id=" +


str(order_id) + " AND status='Pending'")
order = cursor.fetchone()

if not order:
print("Invalid Order ID or order is not pending.")
continue

decision = input("Do you want to accept or reject the


order? (accept/reject): ").strip().lower()

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])

order_id = int(input("Enter the Order ID to mark


as completed: "))

cursor.execute("UPDATE Orders SET


status='Completed' WHERE id=" + str(order_id) + " AND
status='Accepted'")
connection.commit()
print("Order " + str(order_id) + " has been marked
as completed.")
except Exception as e:
print("Error marking order as completed: " + str(e))

elif choice == 4:
def add_request(cursor, connection):
print("\n--- Add Request ---")

# Take staff name as input from the user


staff_name = input("Enter your name: ")

request = input("Enter your request: ")


date_submitted = "CURRENT_DATE"
30 | P a g e
query = "INSERT INTO Requests (staff_name, request,
date_submitted) VALUES ('" + staff_name + "', '" + request + "', " +
date_submitted + ")"

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.")

6th file: storekeeper.py


import mysql
from prettytable import PrettyTable
from datetime import datetime

def storekeeper_module(cursor, connection):


def display_announcement(cursor):
cursor.execute("SELECT message, priority, created_at FROM
Announcements ORDER BY created_at DESC LIMIT 1")
result = cursor.fetchone()

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:

print("\n--- Storekeeper Module ---")

# Prompt user to choose action: Update quantity or add a new


item
print("1. Update existing item quantity")
print("2. Add a new item")
print("3. Add Request")
print("4. Delete item from store") # Corrected option number
for exit
print("5. View Items") # Corrected option number for exit
print("6. Exit") # Corrected option number for exit
choice = input("Enter your choice: ")

if choice == '1':
# Update the quantity of an existing item
item = input("Enter item name to update: ")

cursor.execute("SELECT * FROM Store WHERE item='" + item +


"'")
result = cursor.fetchone()

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.")

elif choice == '2':


# Add a new item to the store
item = input("Enter new item name: ")

while True:
try:
quantity = int(input("Enter quantity: "))
break
except ValueError:
print("Invalid input for quantity. Please enter an
integer.")

# Validate date format for MFG/Date of purchase


while True:
date_input = input("Enter MFG/Date of Purchase (YYYY-
MM-DD): ")
try:
date_of_purchase = datetime.strptime(date_input,
'%Y-%m-%d').date()
break
except ValueError:
print("Invalid date format. Please enter date in
YYYY-MM-DD format.")

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))

elif choice == '3':


def add_request(cursor, connection):
print("\n--- Add Request ---")

# Take staff name as input from the user


staff_name = input("Enter your name: ")

request = input("Enter your request: ")


date_submitted = "CURRENT_DATE"

query = "INSERT INTO Requests (staff_name, request,


date_submitted) VALUES ('" + staff_name + "', '" + request + "', " +
date_submitted + ")"

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 == '4':

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))

elif choice == '5':


try:
query = "SELECT * FROM store"
cursor.execute(query)

items = cursor.fetchall()

# Create Table
table = PrettyTable()
table.field_names = ["Item", "Quantity",
"MFG/Date_of_purchase"]

# Add rows to the table


if items:
for row in items:
table.add_row([row[0], row[1], row[2]])
print(table)
else:
print("No items found in the store.")

except mysql.connector.Error as error:


print("Failed to retrieve store items:
{}".format(error))

elif choice == '6':


print("Exiting.......")
break
else:
print("Invalid choice. Please select either 1 or 2.")

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:

1. Python must be installed

2. MySQL must be installed

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')

2. Make sure all files are in same folder.

3. Make sure to change database name and


password as per your MySQL Database.

39 | P a g e
OUTPUT
---Login Interface---

--- Admin Module ---

40 | P a g e
---Waiter---

---Cook---

---Storekeeper---

Prettytable library to present output in tabular format

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.

MySQL's role in the project ensures efficient data handling,


storage, and retrieval, creating a centralized database that keeps
data well-organized and secure. User-defined SQL commands
and functions facilitate the creation of structured tables—such
as staff, orders, menu, and inventory—that integrate seamlessly
with the Python modules. The use of MySQL connectors in
Python ensures smooth database communication, which,
combined with Python's error-handling capabilities, results in a
system that is both reliable and responsive. Together, Python and
MySQL offer a scalable and efficient backend for managing
restaurant operations, showcasing a robust design that could be
effectively implemented in real-world settings.

42 | P a g e
BIBLIOGRAPHy

• WEBSITE REFRENCES:

• Book References:

43 | P a g e
44 | P a g e

You might also like