0% found this document useful (0 votes)
48 views97 pages

DBMS Advanced Gym Management System Report

advanced gym management system report

Uploaded by

JACOB IMMANUEL.C
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views97 pages

DBMS Advanced Gym Management System Report

advanced gym management system report

Uploaded by

JACOB IMMANUEL.C
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 97

ADVANCED GYM MANAGEMENT SYSTEM

A PROJECT REPORT

Submitted by
Jacob Immanuel RA2212701010008
Sai Krisha D RA2212701010016
Nukala Dinakar Nisank RA2212701010033

Under the Guidance of


Dr. Beaulah Jeyavathana R
Assistant Professor, Department of Computational Intelligence

in partial fulfillment of the requirements for the degree of

BACHELOR OF TECHNOLOGY
in
ARTIFICIAL INTELLIGENCE

DEPARTMENT OF COMPUTATIONAL INTELLIGENCE

COLLEGE OF ENGINEERING AND TECHNOLOGY SRM


INSTITUTE OF SCIENCE AND TECHNOLOGY
KATTANKULATHUR– 603 203

NOV 2024
DEPARTMENT OF COMPUTATIONAL INTELLIGENCE
SCHOOL OF COMPUTING
COLLEGE OF ENGINEERING AND TECHNOLOGY SRM
INSTITUTE OF SCIENCE AND TECHNOLOGY
KATTANKULATHUR – 603 203

BONAFIDE CERTIFICATE

Certified that this project report "Advanced Gym Management System" is the
bonafide work of Jacob Immanuel [RA2212701010008], Sai Krisha D
[RA2212701010016] and Nukala Dinakar Nisank [RA2212701010033], who
carried out the project work under my supervision in the project course Database
Management Systems [21CSC205P] for the academic year 2024-2025 [III
year / V semester].

Date:

FACULTY IN CHARGE HEAD OF THE DEPARTMENT


Dr. Beaulah Jeyavathana R Dr. Annie Uthra R
Assistant Professor Head Of the Department
Department of Computational Intelligence Department of Computational Intelligence
SRMIST - KTR SRMIST - KTR
ABSTRACT
The Gym Management System (GMS) is a comprehensive database solution designed to
automate and streamline the operations of a gym or fitness center. The system manages
essential functions, including member registration, coach assignment, payment tracking,
membership plans, supplement inventory, staff management, and administrative operations.
By integrating various facets of gym management into a unified platform, GMS facilitates
efficient data storage, retrieval, and processing, ultimately improving operational
transparency and customer service.

By implementing a robust relational database management system, this project aims to reduce
manual paperwork, minimize errors, and enable quick and accurate decision-making. With
features like seamless member enrolment, real-time tracking of payments, supplement
inventory management, and staff salary processing, the system provides a holistic approach to
gym operations.

The use of structured queries ensures data integrity, while foreign key relationships maintain
consistency across the database. This system is scalable and can be expanded to incorporate
additional features such as equipment maintenance tracking, member activity monitoring, and
gym attendance reporting in the future.
E-R DIAGRAM
RELATIONAL TABLES
Member Entity:
Member_id Name Date of Gender Date of joining Plan chosen Phone
birth number

Schema Representation:
Member (Member_id, Name, Date of birth, Gender, Date of joining, Plan chosen, Phone
number)
Primary Key- Member_id

Coach Entity:
Coach_id Name Gender Phone number

Schema Representation:
Coach (Coach_id, Name, Gender, Phone number)
Primary Key- Coach_id

Payments Entity:
Transaction_id Member_id Date Plan Amount

Schema representation:
Payments (Transactionn_id, Name, Date, Plan, Amount)
Primary Key- Transactionn_id

Supplements Entity:
Supplement_id Supplement Name Quantity Cost

Schema Representation:
Supplements (Supplement_id, Supplement Name, Quantity, Cost)
Primary Key- Supplement_id

Membership Entity:
Plan Type Amount

Schema Representation:
Membership (Plan_Type, Amount)
Primary Key-Plan_Type

Support Staff Entity:


Staff_id Name Gender

Schema Representation:
Support Staff (Staff_id, Name, Gender)
Primary Key- Staff_id

Admin Entity:
Staff_id Name

Schema Representation:
Admin (Staff_id, Name)
Primary Key- Staff_id

GMS Portal Entity:


Username Password

Schema Representation:
GMS Portal (Username, Password)
SQL QUERIES – IMPLEMENTATION OF THE BACKEND
1. DATABASE CREATION IN SQL

2. USE THE NEWLY CREATED DATABASE

USE GymManagementSystem;

3. Table 1: Member

CREATE TABLE Member (

member_id INT PRIMARY KEY AUTO_INCREMENT,

name VARCHAR(100) NOT NULL,

dob DATE,

gender VARCHAR(10),

height DECIMAL(5, 2),

date_of_joining DATE NOT NULL,

phone_number VARCHAR(15),

address TEXT);

4. Table 2: Coach

CREATE TABLE Coach (

coach_id INT PRIMARY KEY AUTO_INCREMENT,

name VARCHAR(100) NOT NULL,

gender VARCHAR(10),

phone_number VARCHAR(15),

address TEXT,
salary DECIMAL(10, 2) NOT NULL);

5. Table 3: Payments

CREATE TABLE Payments (

transaction_id INT PRIMARY KEY AUTO_INCREMENT,

member_id INT,

date DATE NOT NULL,

plan_type VARCHAR(50),

amount DECIMAL(10, 2) NOT NULL,

FOREIGN KEY (member_id) REFERENCES Member(member_id) ON DELETE


CASCADE);

6. Table 4: Supplements

CREATE TABLE Supplements (

supplement_id INT PRIMARY KEY AUTO_INCREMENT,

supplement_name VARCHAR(100) NOT NULL,

quantity INT NOT NULL,

cost DECIMAL(10, 2) NOT NULL);

7. Table 5: Membership

CREATE TABLE Membership (

plan_type VARCHAR(50) PRIMARY KEY,

amount DECIMAL(10, 2) NOT NULL);

8. Table 6: Support Staff

CREATE TABLE Support_Staff (

staff_id INT PRIMARY KEY AUTO_INCREMENT,


name VARCHAR(100) NOT NULL,

gender VARCHAR(10),

salary DECIMAL(10, 2),

address TEXT );

9. Table 7: Admin

CREATE TABLE Admin (

staff_id INT PRIMARY KEY AUTO_INCREMENT,

name VARCHAR(100) NOT NULL,

address TEXT,

phone_number VARCHAR(15),

salary DECIMAL(10, 2) );

10. Table 8: GMS Portal

CREATE TABLE GMS_Portal (

username VARCHAR(50) PRIMARY KEY,

password VARCHAR(100) NOT NULL);

11. SHOW TABLES


12. MEMBER Table Creation

13. VIEW MEMBER TABLE


13. COACH Table Creation

14. VIEW COACH Table

15. PAYMENTS Table Creation


16. DELETING THIS VALUES

17. INSERTING NEW VALUES


18. VIEW PAYMENTS TABLE
19. SUPPLEMENTS Table Creation

20. ALTERING COLUMN IN SUPPLEMENTS

21. INSERTING NEW VALUES INTO SUPPLEMENTS

22. VIEW SUPPLEMENTS


23. MEMBERSHIP Table creation

24. VIEW MEMBERSHIP TABLE

25. SUPPORT STAFF Table Creation

26. VIEW SUPPORT STAFF TABLE


27. ADMIN Table Creation

28. VIEW ADMIN TABLE

29. GMS PORTAL Table Creation

30. VIEW GMS PORTAL TABLE

31. ALTERING THE TABLE-ADDING ROLE OF USERS


32. UPDATING AND SETTING ROLE AS ADMIN

33. VIEW MODIFIED GMS PORTAL TABLE

34. SELECTING 41ST MEMBER INFORMATION

35. DELETING 41ST MEMBER


36. SELECTING TRANSACTION OF 41ST MEMBER

37. DELETING THE TRANSACTION RECORD

38. COUNTING TOTAL ROWS IN ‘PAYMENTS’ ENTITY

39. COUNTING TOTAL ROWS IN ‘MEMBER’ ENTITY

40. ALTERING MEMBER TABLE BY ADDING NEW COLUMN PLAN


CHOSEN
41. JOIN MEMBER AND PAYMENT USING PLAN CHOSEN

42. VIEWING THE UPDATED MEMBER TABLE

43. JOINING PAYMENTS AND MEMBER TO GET THEIR TRANSACTION


DETAILS

44. Count Members by Plan Type USING GROUP BY


45. Get Total Revenue from Payments

46. Find Members Who Have Not Made Payments

47. Get Members Joined in a Specific Month/Year

48. Find Total Number of Members by Gender

49. List All Payments Made in a Specific Month


50. CALCULATING Average Height of Members

51. SELECTING Members Who Joined in the Last 30 Days

52. Retrieving Names, Roles, and Salaries OF EMPLOYEES USING UNION


53. FINDING FEMALE MEMBERS

54. SELECTING members with a height greater than 180 CM

55. SELECTING members whose names start with 'A'

56. FINDING the highest-paid coach

57. INSERTING NEW MEMBERS


58. VIEW THE UPDATED TABLE

59. UPDATE THE PLAN CHOSEN TO STUDENT

60. VIEWING STUDENT MEMBERS ALONE

61. SELECT THE MEMBER ID OF STUDENTS

62. UPDATING PAYMENTS TABLE


63. REVIEW THE UPDATE

64. FINDIG TOTAL REVENUE

65. AVERAGE SALARY OF ALL THE COACHES

66. FINDING THE YOUNGEST MEMBER

67. AVERAGE COST OF SUPPLEMENTS


68. CALCULATING SALARY OF EMPLOYEES

69. TOTAL COST FOR SALARIES

70. UPDATING SALARY OF SUPPORT STAFF

71. VIEWING THE UPDATED TABLE


72. VIEWING MEMBERS FROM T. NAGAR

73. SELECTING COSTLIEST SUPPLEMENT

74. ALTERING MEMBER TABLE WITH COACH ID

75. ASSIGNING COACH TO MEMBERS


76. SELECTING MEMBERS WITH COACHES

77. INCOME RECEIVED PLAN WISE

78. SELECTING MEMBERS WIHOUT ANY TRANSACTIONS

79. INSERTING A NEW TRANSACTION


80. UPDATING THE PROCEDURE MEMBER PLAN

81. CREATE A NEW PROCEDURE TO DELETE A MEMBER

82. CREATE A PROCEDURE TO ADD A NEW COACH

83. CREATE A PROCEDURE TO UPDATE COACH SALARY


84. CREATE A PROCEDURE TO ASSIGN COACH TO MEMBER

85. CREATE A PROCEDURE TO ADD A NEW PAYMENT RECORD

86. CREATE A PROCEDURE TO RETRIVE MEMBER INFO


87. CREATE A PROCEDURE TO INSERT NEW MEMBER

88. CALL ALL THE PROCEDURES

87. CALCUTE AGE ON INSERT USING TRIGGER

88. LOG MEMBER DETAILS


89. ASSIGN DEFAULT COACH

90. UPDATE MEMBERSHIP STATUS ON PAYMENT

91. SET MEMBER STATUS INACTIVE

92. ENSURING SINGLE COACH


93. ALTER MEMBER TABLE ADD COLUMN MEMBERSHIP_STATUS

94. UPDATE MEMBER TABLE

95. UPDATE MEMBER TABLE MEMBEERSHIP_STATUS COLUMN TO NEW

96. UPDATE MEMER TABLE MEMBERSHIP_STATUS COLUMS WITH


EXPIRE

97. UPDATE MEMBER TABLE MEMBERSHPI_STATU COLUMN WITH


ACTIVE
98. DISPLAYING MEMBER TABLE WITH MEMBERSHIP_STATUS

99. INSER INTO PAYMENTS TABLE


100. DISPLAY PAYMENTS TABLE
101. JOIN MEMBER AND PAYMENT TABBLE

102. DISPLAY TOTAL PAYMENTS VALUE

103. DISPLAY TOTAL AMOUNT GROUP BY PLAN


104. JOIN MEMBER TABLE AND PAYMENT TABLE

105. TOTAL REVVENUE GROUP BY MONTH


106. DISPLAYING AVG PAYMENTS BY MEMBER AND TOTAL
REVENUE

107. DISPLAYING MEMBER COUNT GROUP BY AGE

108. DISPLAYING COUNT OF NEW MEMBERS THIS YEAR


109. NO OF TRANSACTIONS AND TOTAL AMOUNT GROUP BY PLAN

110. MEMEBR AMOUNT THEY PAID


111. DISPLAYING TRANSACTION ID AMOUNT MEMBER_NAME
APPLYING NORMALISATIONS
1.MEMBER TABLE

Normalization Used – 2-nf & 3-nf

Table after normalizations:

member_i plan_chosen membership_status


d
1 Monthly Active
2 Monthly Active
3 Monthly Active
4 Monthly Active

member_id name coach_id


1 Aarav Singh 1
2 Rohan 2
3 Sneha Patil 1
4 Ishita 3

coach_i coach_name
d
1 Rahul
2 Neha
3 Deepa
member_id joining_date plan_chosen membership_status
1 2023-01-10 Monthly Active
2 2022-05-12 Monthly Active
3 2021-09-18 Monthly Active
4 2020-11-14 Monthly Active
2.ADMIN TABLE

Normalization Used – This Table is already in the Third normal form. So no further
normalization is required. The table can be further decomposed to reduce
redundancies. They are:

staff_id name
1 Rahul Nair
2 Meera Iyer

staff_id name salary


1 Rahul Nair 40000.00
2 Meera Iyer 42000.00

staff_id name phone_number


1 Rahul Nair 9876543200
2 Meera Iyer 9876543201
staff_id name address
1 Rahul Nair T. Nagar, Chennai, Tamil Nadu
2 Meera Iyer Velachery, Chennai, Tamil Nadu

3. GYM MANAGEMENT SYSTEM-LOGIN TABLE

Normalization Used – This Table is already in the Third normal form. So no further
normalization is required.

4.MEMBERSHIP TABLE
Normalization Used – This Table is already in the Second normal form. So no further
normalization is required.

5.COACH TABLE

Normalization Used – This Table is already in the Third normal form. So no further
normalization is required. The table can be further decomposed to reduce
redundancies. They are:

coach_id name salary


1 Rahul Mehta 30000.00
2 Neha Sharma 52000.00
3 Vivek Reddy 35000.00
4 Deepa Nair 28000.00

coach_id phone_number
1 9966554433
2 9966554455
3 9966554466
4 9966554477

coach_id address
1 T. Nagar, Chennai, Tamil Nadu
2 Adyar, Chennai, Tamil Nadu
3 Velachery, Chennai, Tamil Nadu
4 Anna Nagar, Chennai, Tamil Nadu

6.SUPPLEMENTS TABLE
Normalization Used – This Table is already in the Third normal form. So no further
normalization is required. The table can be further decomposed to reduce
redundancies. They are:

supplement_id supplement_name
S1001 Whey Protein
S1002 Creatine Monohydrate
S1003 BCAAs
S1004 Multivitamins
S1005 Fish Oil
S1006 Pre-Workout
S1007 Glutamine

supplement_id quantity cost


S1001 500 3500.00
S1002 300 1500.00
S1003 200 1200.00
S1004 100 800.00
S1005 90 900.00
S1006 250 2000.00
S1007 200 1800.00

7. SUPPORT STAFF TABLE

Normalization Used – 3-nf

Table after normalizations:

staff_id name gender salary


1 Ravi Kumar Male 8876.00
2 Suman Reddy Female 8784.00
3 Ajay Gupta Male 7291.00
4 Priya Sharma Female 8105.00
5 Manoj Menon Male 8652.00

Splitting the address attribute to reduce data redundancy:


address_id staff_id area city state
1 1 T. Nagar Chennai Tamil Nadu
2 2 Velachery Chennai Tamil Nadu
3 3 Adyar Chennai Tamil Nadu
4 4 Mylapore Chennai Tamil Nadu
5 5 Kodambakkam Chennai Tamil Nadu
8. PAYMENTS TABLE

Normalization Used – 3-nf

Table after normalizations:

transaction_id member_id amount


10001 1 2500.00
10002 2 25000.00
10003 3 7000.00
10004 4 2500.00
transaction_id date amount
10001 2023-01-10 2500.00
10002 2023-02-10 25000.00
10003 2023-03-10 7000.00
10004 2023-04-10 2500.00

transaction_id member_id date amount


10001 1 2023-01-10 2500.00
10002 2 2023-02-10 25000.00
10003 3 2023-03-10 7000.00
10004 4 2023-04-10 2500.00

CONCURRENCY CONTROL AND RECOVERY


MECHANISMS
Concurrency control and recovery mechanisms are essential components in database
management systems (DBMS) to ensure data integrity and consistency, especially when
multiple users or processes access and modify data concurrently.

Concurrency Control

Concurrency control in databases manages the simultaneous execution of transactions to


ensure that they do not interfere with each other in ways that would compromise data
integrity.

a. Transactions in Stored Procedures

The example procedure, EnrollMember, uses a transaction to perform multiple database


actions (e.g., enrolling a new member and recording a payment) as a single atomic unit. By
using START TRANSACTION and COMMIT, all operations are committed only if all
succeed. If an error occurs, the ROLLBACK statement undoes all changes, maintaining data
consistency.

b. Row-Level Locking

Row-level locking secures individual rows to prevent concurrent sessions from making
conflicting updates. For example, if a session is updating a specific member_id, using FOR
UPDATE in SELECT locks that row, so no other session can modify it until the first session
completes and commits.

c. Optimistic Locking

Optimistic locking is helpful in high-read environments. By adding a version column to


tables, you ensure that updates occur only if the version matches. This prevents overwrite
conflicts when multiple sessions attempt to update the same data.

Recovery Mechanisms

Recovery mechanisms are designed to restore the database to a consistent state following a
failure, such as a system crash or a hardware failure.

a. Logging with Triggers

The audit_log table tracks modifications, and the before_member_delete trigger logs
deletions, storing details like the user, action, and affected member ID. This helps with both
recovery and accountability by creating an audit trail for critical actions.
b. Cascading Data into Backup Tables

Before updating a member’s information, the before_member_update trigger copies the


original row to member_backup. This approach enables recovery from unintended updates, as
backup data is readily available.

c. Scheduled Backups

Using tools like mysqldump, you can create daily backups of the entire database or specific
tables. Binary logging enables point-in-time recovery, which is critical for recovering to a
precise point following system issues or errors.

d. Enforcing Membership Status Updates with Triggers

The update_membership_status_on_payment trigger updates a member’s status to "Active"


automatically upon successful payment. This ensures consistency in membership records
without requiring manual updates, which could lead to errors.

Error handling in stored procedures

The UpdateMemberPlan procedure shows an example of structured error handling within


stored procedures. The EXIT HANDLER captures any errors during execution. If an error
occurs, the transaction is rolled back to avoid partial updates that could lead to
inconsistencies.
In summary, these mechanisms work together to:

 Control and coordinate access (concurrency) to the database.


 Provide a means to roll back and recover from failures, ensuring data accuracy and
integrity.
 Automate maintenance and backup processes, reducing manual intervention.

Implementing these practices in the gymmanagementsystem database will help maintain


a robust, reliable environment for managing gym members, staff, payments, and other
essential records.
PYTHON CODE
from flask import Flask
from flask import Blueprint , render_template, redirect, url_for, flash, request, session
from flask_sqlalchemy import SQLAlchemy # Add this import
from flask_mysql_connector import MySQL
import mysql.connector
from mysql.connector import Error # Import the Error class for handling exceptions
from datetime import datetime
import qrcode
from io import BytesIO
from flask import send_file
import base64
import os

app = Flask(name)
app.config['SECRET_KEY'] = '@Bunny455'

# Add logs to the rest of the routes in the same way


# Configure MySQL
def get_db_connection():
try:
connection = mysql.connector.connect(
host='127.0.0.1',
user='root',
port=3306,
password='@Bunny455',
database='gymmanagementsystem'
)
if connection.is_connected():
print("Connection to MySQL DB successful")
return connection
except Error as e:
print(f"Error: {e}")
return None

conn = get_db_connection()

if conn is None:
print("Not Connected to MySQL DB")

def get_member_id_from_username(username):
connection = get_db_connection() # Make sure to get a DB connection
cursor = connection.cursor(dictionary=True)
cursor.execute("SELECT Member_id FROM member WHERE username = %s",
(username,))
member = cursor.fetchone() # Fetch the member details
cursor.close()
connection.close()
if member:
return member['Member_id']
return None

@app.route('/')
def home():
return render_template('home.html')

@app.route('/admin_login', methods=['GET', 'POST'])


def admin_login():
if request.method == 'POST':
username = request.form['username']
password = request.form['password']
conn = get_db_connection()

if conn is None:
print("Not Connected to MySQL DB")
cursor = conn.cursor()

cursor.execute("SELECT * FROM admin WHERE username = %s AND password =


%s", (username, password))
user = cursor.fetchone()
cursor.close()
conn.close() # Always close the connection

if user:
session['username'] = username
return redirect(url_for('admin_dashboard')) # Redirect to admin dashboard
else:
flash('Invalid credentials. Please try again.', 'danger') # Flash message for invalid
login
return redirect(url_for('admin_login')) # Redirect back to login page

return render_template('admin_login.html')

@app.route('/admin_dashboard')
def admin_dashboard():
if 'username' in session:
return render_template('admin_dashboard.html')
return redirect(url_for('login'))

# Route to add new members


@app.route('/add_member', methods=['GET', 'POST'])
def add_member():
if 'username' in session:

cursor = conn.cursor()

if request.method == 'POST':
# Retrieve the maximum member ID
cursor.execute("SELECT MAX(Member_id) FROM member")
max_id = cursor.fetchone()[0]
new_member_id = max_id + 1 if max_id is not None else 1 # Start from 1 if there are
no member

username = request.form['username']
password = request.form['password']
name = request.form['name']
phone_number = request.form['phone_number']
date_of_birth = request.form['date_of_birth']
gender = request.form['gender']

# Construct the address from individual fields


address_line1 = request.form['address_line1']
address_line2 = request.form['address_line2']
street = request.form['street']
city = request.form['city']
state = request.form['state']
pincode = request.form['pincode']
Plan_chosen = request.form['Plan_chosen']
address = f"{address_line1}, {address_line2}, {street}, {city}, {state}, {pincode}"

date_of_joining = datetime.now().date() # Get current date

cursor.execute(
"INSERT INTO member (Member_id, Username, Password, Name,
Phone_number, Date_of_birth, Gender, Address, Date_of_joining, Plan_chosen) VALUES
(%s, %s, %s, %s, %s, %s, %s, %s, %s,%s)",
(new_member_id, username, password, name, phone_number, date_of_birth,
gender, address, date_of_joining, Plan_chosen)
)

conn.commit()
cursor.close()
return redirect(url_for('add_member'))

return render_template('add_member.html')

return redirect(url_for('admin_login'))

# Route to modify existing members


@app.route('/modify_member', methods=['GET', 'POST'])
def modify_member():
if 'username' in session:
connection = get_db_connection() # Create a database connection
cursor = connection.cursor(dictionary=True)

if request.method == 'POST':
# Get the member_id from the form input
member_id = request.form.get('member_id')
print("Selected member_id:", member_id)

if member_id:
# Retrieve current details of the member to be modified
query = "SELECT * FROM member WHERE Member_id = %s"
cursor.execute(query, (member_id,))
current_member = cursor.fetchone()

# If member is found, update details with form inputs


if current_member:
# Retrieve form data for updates
name = request.form.get('name', current_member.get('name', ''))
phone_number = request.form.get('phone_number',
current_member.get('phone_number', ''))

# Construct the address from individual fields


address_line1 = request.form.get('address_line1', '')
address_line2 = request.form.get('address_line2', '')
street = request.form.get('street', '')
city = request.form.get('city', '')
state = request.form.get('state', '')
pincode = request.form.get('pincode', '')
address = f"{address_line1}, {address_line2}, {street}, {city}, {state},
{pincode}"

# Execute the update query


cursor.execute(
"UPDATE member SET name = %s, address = %s, phone_number = %s
WHERE member_id = %s",
(name, address, phone_number, member_id)
)

connection.commit()
flash("Member details updated successfully", "success")
return redirect(url_for('modify_member'))
else:
flash("Member not found", "danger")
else:
flash("Member ID is required to modify details", "warning")

# Fetch all members to display in the modify member form


cursor.execute("SELECT * FROM member")
members = cursor.fetchall()
cursor.close()
connection.close()

return render_template('modify_member.html', members=members)


return redirect(url_for('admin_login'))

# Route to manage supplements


@app.route('/manage_supplements', methods=['GET', 'POST'])
def manage_supplements():
if 'username' in session:
conn = get_db_connection()

if conn is None:
print("Not Connected to MySQL DB")

cursor = conn.cursor()

if request.method == 'POST':
supplement_id = request.form['supplement_id']
name = request.form['supplement_name']
quantity = request.form['quantity']
cost = request.form['cost']
cursor.execute(
"INSERT INTO supplements (supplement_id, supplement_name, quantity, cost)
VALUES (%s, %s,%s, %s) ON DUPLICATE KEY UPDATE quantity=%s, cost = %s",
(supplement_id, name, quantity, cost, quantity, cost)
)
conn.commit()
cursor.close()
return redirect(url_for('manage_supplements'))
cursor.execute("SELECT * FROM supplements")
supplements = cursor.fetchall()
cursor.close()

return render_template('manage_supplements.html', supplements=supplements)

return redirect(url_for('admin_login'))

@app.route('/admin/update_supplement', methods=['POST'])
def update_supplement():
if 'username' in session:
supplement_id = request.form['id']
name = request.form['name']
cost = request.form['cost']

conn = get_db_connection() # Create a database connection

if conn is None:
print("Not Connected to MySQL DB")
cursor = conn.cursor()
cursor.execute("INSERT INTO supplements (id, name, cost) VALUES (%s, %s, %s)
ON DUPLICATE KEY UPDATE name = %s, cost = %s",
(supplement_id, name, cost, name, cost))
conn.commit()
cursor.close()
return redirect(url_for('admin_dashboard'))
return redirect(url_for('login'))

@app.route('/member_login', methods=['GET', 'POST'])


def member_login():
if request.method == 'POST':
username=request.form['username']
password=request.form['password']

conn = get_db_connection() # Create a database connection

if conn is None:
return 'Failed to connect to database',500

cursor = conn.cursor()
cursor.execute("SELECT * FROM member WHERE username = %s AND password =
%s", (username,password))
user = cursor.fetchone()
cursor.close
conn.close()

if user:
session['username'] = username
return redirect(url_for('member_dashboard')) # Redirect to admin dashboard
else:
flash('Invalid credentials. Please try again.', 'danger') # Flash message for invalid
login
return redirect(url_for('member_login')) # Redirect back to login page
return render_template('member_login.html')

@app.route('/member_dashboard')
def member_dashboard():
if 'username' in session:
return render_template('member_dashboard.html')
return redirect(url_for('home'))

app.route('/view_plan', methods=['GET', 'POST'])


def view_plan():
if 'username' in session:
conn = get_db_connection()
if conn is None:
print("Not Connected to MySQL DB")
return redirect(url_for('member_dashboard'))

cursor = conn.cursor(dictionary=True)

# Query to fetch all supplements


if request.method == 'POST':
search_query = request.form.get('search_query', '')
cursor.execute("SELECT plan_id, plan, amount FROM plan WHERE plan_name
LIKE %s", (f"%{search_query}%",))
else:
cursor.execute("SELECT plan_id, plan, amount FROM plan")

# Fetch all results


plan = cursor.fetchall()
cursor.close()
conn.close()

return render_template('view_plan.html', plan=plan)


return redirect(url_for('member_login'))

@app.route('/track_plan')
def track_plan():
if 'username' in session:
return render_template('track_plan.html') # Make sure track_plan.html exists
return redirect(url_for('member_login'))

@app.route('/view_supplements', methods=['GET', 'POST'])


def view_supplements():
if 'username' in session:
conn = get_db_connection()
if conn is None:
print("Not Connected to MySQL DB")
return redirect(url_for('member_dashboard'))

cursor = conn.cursor(dictionary=True)

# Query to fetch all supplements


if request.method == 'POST':
search_query = request.form.get('search_query', '')
cursor.execute("SELECT Supplement_ID, Supplement_Name, Cost FROM
supplements WHERE Supplement_Name LIKE %s", (f"%{search_query}%",))
else:
cursor.execute("SELECT Supplement_ID, Supplement_Name, Cost FROM
supplements")

# Fetch all results


supplements = cursor.fetchall()
cursor.close()
conn.close()

return render_template('view_supplements.html', supplements=supplements)


return redirect(url_for('member_login'))

def add_transaction(member_id, amount, transaction_type, description):


connection = get_db_connection()
if connection:
cursor = connection.cursor()
try:
query = """
INSERT INTO transactions (Member_ID, Amount, Transaction_Type,
Description)
VALUES (%s, %s, %s, %s)
"""
cursor.execute(query, (member_id, amount, transaction_type, description))
connection.commit()
print("Transaction added successfully.")
except Error as e:
print(f"Error inserting transaction: {e}")
finally:
cursor.close()
connection.close()

@app.route('/view_transactions')
def view_transactions():
if 'username' in session:
cursor = conn.cursor(dictionary=True)
member_id = get_member_id_from_username(session['username'])

if member_id:
cursor.execute(
"SELECT transaction_id, transaction_date, amount, description "
"FROM transactions WHERE member_id = %s ORDER BY transaction_date
DESC", (member_id,)
)
transactions = cursor.fetchall()
cursor.close()
return render_template('view_transactions.html', transactions=transactions)

cursor.close()
flash("Member not found!", "error")
return redirect(url_for('member_dashboard'))
return redirect(url_for('member_login'))

@app.route('/add_transaction', methods=['POST'])
def add_transaction_route():
if 'username' in session:
member_id = get_member_id_from_username(session['username']) # Retrieve the
member ID from session info
amount = request.form['amount']
transaction_type = request.form['transaction_type']
description = request.form['description']
add_transaction(member_id, amount, transaction_type, description)
flash("Transaction added successfully", "success")
return redirect(url_for('view_transactions'))
return redirect(url_for('login'))

@app.route('/coach_login', methods=['GET', 'POST'])


def coach_login():
if request.method == 'POST':
username=request.form['username']
password=request.form['password']

conn = get_db_connection()

if conn is None:
print("Not Connected to MySQL DB")

cursor = conn.cursor()
cursor.execute("SELECT * FROM coach WHERE username = %s AND password =
%s", (username,password))
user = cursor.fetchone()
cursor.close
conn.close()

if user:
session['username'] = username
return redirect(url_for('coach_dashboard')) # Redirect to admin dashboard
else:
flash('Invalid credentials. Please try again.', 'danger') # Flash message for invalid
login
return redirect(url_for('coach_login')) # Redirect back to login page
return render_template('coach_login.html')

@app.route('/coach_dashboard')
def coach_dashboard():
if 'username' in session:
return render_template('coach_dashboard.html')

@app.route('/coach/leave', methods=['POST'])
def coach_leave():
if 'username' in session:
leave_date = request.form['leave_date']

conn = get_db_connection()

if conn is None:
print("Not Connected to MySQL DB")

cursor = conn.cursor()
cursor.execute("INSERT INTO leaves (coach_id, leave_date) VALUES (%s, %s)",
(session['username'], leave_date))

conn.commit()
cursor.close()
return redirect(url_for('admin_dashboard'))
return redirect(url_for('login'))

@app.route('/buy_supplements/<int:supplement_id>', methods=['GET', 'POST'])


def buy_supplements(supplement_id):
if 'username' in session:
cursor = conn.cursor(dictionary=True)
cursor.execute("SELECT Supplement_Name, Cost FROM supplements WHERE
Supplement_ID = %s", (supplement_id,))
supplement = cursor.fetchone()
cursor.close()

if request.method == 'POST':
# Proceed to purchase
return redirect(url_for('proceed_to_purchase', item_id=supplement_id,
item_type='supplement'))

return render_template('buy_supplements.html', supplement=supplement)


return redirect(url_for('member_login'))

@app.route('/buy_plan/<int:plan_id>', methods=['GET', 'POST'])


def buy_plan(plan_id):
if 'username' in session:
cursor = conn.cursor(dictionary=True)
cursor.execute("SELECT Plan, Amount FROM plans WHERE Plan_ID = %s",
(plan_id,))
plan = cursor.fetchone()
cursor.close()

if request.method == 'POST':
# Proceed to purchase
return redirect(url_for('proceed_to_purchase', item_id=plan_id, item_type='plan'))

return render_template('buy_plan.html', plan=plan)


return redirect(url_for('member_login'))

def generate_qr_code(amount, upi_id):


# Define the UPI payment string for the QR code
upi_string = f"upi://pay?pa={upi_id}&pn=GymManagement&am={amount}&cu=INR"

# Generate and save the QR code


qr = qrcode.make(upi_string)
qr_path = f"static/qr_codes/qr_{datetime.now().strftime('%Y%m%d%H%M%S')}.png"
os.makedirs(os.path.dirname(qr_path), exist_ok=True)
qr.save(qr_path)
return qr_path

@app.route('/proceed_to_purchase/<item_type>/<int:item_id>', methods=['GET', 'POST'])


def proceed_to_purchase(item_type, item_id):
if 'username' in session:
cursor = conn.cursor(dictionary=True)
member_id = get_member_id_from_username(session['username'])
upi_id = "8143233886@ybl" # Replace with your actual UPI ID

if item_type == 'supplement':
cursor.execute("SELECT Supplement_Name AS Name, Cost FROM supplements
WHERE Supplement_ID = %s", (item_id,))
item = cursor.fetchone()
description = f"Supplement Purchase: {item['Name']} (ID: {item_id})"
elif item_type == 'plan':
cursor.execute("SELECT Plan AS Name, Amount FROM plans WHERE Plan_ID =
%s", (item_id,))
item = cursor.fetchone()
description = f"Plan Purchase: {item['Name']} (ID: {item_id})"

qr_code_path = generate_qr_code(item['Cost'], upi_id) # Generate QR code

if request.method == 'POST':
cursor.execute(
"INSERT INTO transactions (member_id, transaction_date, amount, description)
VALUES (%s, %s, %s, %s)",
(member_id, datetime.now(), item['Cost'], description)
)
conn.commit()
flash("Transaction successful!", "success")
return redirect(url_for('member_dashboard'))

cursor.close()
return render_template('proceed_to_purchase.html', item=item, item_type=item_type,
qr_code_path=qr_code_path)
return redirect(url_for('member_login'))

@app.route('/logout')
def logout():
session.pop('username', None)
return redirect(url_for('home'))

if name == 'main':
app.run(debug=True)
PYTHON CODE FOR FRONT END

<home.html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management System</title>

<style>
body {
margin: 0;
font-family: Arial, sans-serif;
height: 100vh;
background-size: cover;
background-position: center center;
overflow: hidden;
}

nav {
background-color: rgba(0, 0, 0, 0.8);
padding: 1rem;
display: flex;
align-items: center; /* Align items vertically */
justify-content: space-between; /* Space between left and right blocks */
}
nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}
.nav-left,
.nav-right {
display: flex; /* Display links in a row */
}

.nav-left a,
.nav-right a {
color: white;
margin-left: 20px;
text-decoration: none;
font-size: 1rem;
}

nav a:hover {
color: rgb(255, 107, 107);
}

.container{
width: 100%;
max-width: 400px;
margin: 50px auto;
padding: 20px;
background: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
margin-bottom: 200px;
margin-right: 100px;

.container a:hover {
color: rgb(1, 1, 1);
}

.container_center {
position: relative;
height: 100vh;
display: flex;
align-items: center;
justify-content: space-between;
}

.left-image {
width: 40%;
height: 100vh;
background-image: url('left-image.jpg'); /* Replace with actual image path */
background-size: cover;
background-position: center;
}

.center-content {
flex: 1;
display: flex;
justify-content: center;
align-items: flex-end; /* Align items to the bottom */
position: relative;
height: 100%; /* Ensure it takes full height */
}

.center-image {
width: 60%;
height: 50%;
background-image: url('center-image.jpg'); /* Replace with actual image path */
background-size: cover;
background-position: center;
border-radius: 15px;
}

button {
width: 100%;
margin: 5px;
padding: 10px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

button:hover {
background-color: #333;
}

</style>
</head>
<body>

<!-- Navigation Bar -->


<nav>
<div class="nav-left">
<img src="/static/images/gym_laidy_logo.png" alt="Logo" style="height: 40px;">
</div>
<div class="nav-right">
<a href="#" onclick="navigateToPage('Admin')">Admin Login</a>
<a href="#" onclick="navigateToPage('Coach')">Coach Login</a>
<a href="#" onclick="navigateToPage('Member')">Member Login</a>

</div>
</nav>

<!-- Main Container -->


<div class="container_center">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320" style="position:
absolute; bottom: 0; left: 0; width: 100%; height: auto;">
<!-- First Curve -->
<path fill="rgba(0, 150, 136, 0.758)"
d="M0,96L30,101.3C60,107,120,117,180,128C240,139,300,149,360,128C420,107,480,53,5
40,48C600,43,660,85,720,96C780,107,840,85,900,74.7C960,64,1020,64,1080,85.3C1140,10
7,1200,149,1260,154.7C1320,160,1380,128,1410,112L1440,96L1440,320L1410,320C1380,
320,1320,320,1260,320C1200,320,1140,320,1080,320C1020,320,960,320,900,320C840,320,
780,320,720,320C660,320,600,320,540,320C480,320,420,320,360,320C300,320,240,320,18
0,320C120,320,60,320,30,320H0Z"></path>

<!-- Second Curve -->


<path fill="rgb(255, 107, 107)"
d="M0,128L30,133.3C60,139,120,149,180,160C240,171,300,181,360,160C420,139,480,85,
540,80C600,75,660,117,720,128C780,139,840,117,900,106.7C960,96,1020,96,1080,117.3C
1140,139,1200,181,1260,186.7C1320,192,1380,160,1410,144L1440,128L1440,320L1410,32
0C1380,320,1320,320,1260,320C1200,320,1140,320,1080,320C1020,320,960,320,900,320C
840,320,780,320,720,320C660,320,600,320,540,320C480,320,420,320,360,320C300,320,24
0,320,180,320C120,320,60,320,30,320H0Z"></path>
</svg>

<!-- Left Side Image -->


<div class="left-image">
<img src="/static/images/left_image_gym_logo2.png">
</div>

<div class="container">
<button onclick="navigateToPage('Admin')">Admin Login</button>
<button onclick="navigateToPage('Coach')">Coach Login</button>
<button onclick="navigateToPage('Member')">Member Login</button>
</div>

<!-- Center Image and Content -->


<div class="center-content">
<div class="center-image"></div>
<div class="curve-layer"></div> <!-- Curve layer moved inside center-content -->
</div>

</div>

<script>
function navigateToPage(role) {
if (role === 'Member') {
window.location.href = '/member_login';
} else if (role === 'Admin') {
window.location.href = '/admin_login';
} else if (role === 'Coach') {
window.location.href = '/coach_login';
}
}
</script>

</body>
</html>
<admin login>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management System</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}
nav {
background-color: #333;
padding: 1rem;
text-align: center;
}
nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}
nav a:hover {
color: #ff6b6b;
}
.container {
width: 100%;
max-width: 400px;
margin: 50px auto;
padding: 10px;
background: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
color: #333;
}
input {
width: 95%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
width: 100%;
padding: 10px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #333;
}
</style>
</head>
<body>
<nav>
<a href="/">Home</a>
<a href="/about">About Us</a>
<a href="/contact">Contact</a>
</nav>

<div class="container">
<h1>Admin Login</h1>
<form action="/admin_login" method="POST">
<input type="text" id="username" name="username" placeholder="Username"
required>
<input type="password" id="password" name="password" placeholder="Password"
required>
<button type="submit">Login</button>
</form>
<div>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<ul>
{% for category, message in messages %}
<li class="{{ category }}">{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</div>
</div>
</body>
</html>

<coach.html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management System</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}

nav {
background-color: rgba(0, 0, 0, 0.8);
padding: 1rem;
display: flex;
align-items: center; /* Align items vertically */
justify-content: space-between; /* Space between left and right blocks */
}
nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}
.nav-left,
.nav-right {
display: flex; /* Display links in a row */
}

.nav-left a,
.nav-right a {
color: white;
margin-left: 20px;
text-decoration: none;
font-size: 1rem;
}

nav a:hover {
color: rgb(255, 107, 107);
}
.container {
width: 100%;
max-width: 400px;
margin: 50px auto;
padding: 20px;
background: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
color: #333;
}
input {
width: 95%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
width: 100%;
padding: 10px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #333;
}
</style>
</head>
<body>
<nav>
<a href="/">Home</a>
<a href="/about">About Us</a>
<a href="/contact">Contact</a>
</nav>

<div class="container">
<h1>Coach Login</h1>
<form action="/coach_login" method="POST">
<input type="text" id="username" name="username" placeholder="Username"
required>
<input type="password" id="password" name="password" placeholder="Password"
required>
<button type="submit">Login</button>
</form>

<div>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<ul>
{% for category, message in messages %}
<li class="{{ category }}">{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</div>
</div>
</body>
</html>
<member.html>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management System</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}

nav {
background-color: #333;
padding: 1rem;
text-align: center;
}

nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}

nav a:hover {
color: #ff6b6b;
}

.container {
width: 100%;
max-width: 400px;
margin: 50px auto;
padding: 20px;
background: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
text-align: center;
color: #333;
}

input {
width: 95%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
}

button {
width: 100%;
padding: 10px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

button:hover {
background-color: #333;
}
</style>
</head>

<body>
<nav>
<a href="/">Home</a>
<a href="/about">About Us</a>
<a href="/contact">Contact</a>
</nav>

<div class="container">
<h1>Member Login</h1>
<form action="/member_login" method="POST">
<input type="text" id="username" name="username" placeholder="Username"
required>
<input type="password" id="password" name="password" placeholder="Password"
required>
<button type="submit">Login</button>
</form>
<div>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<ul>
{% for category, message in messages %}
<li class="{{ category }}">{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</div>
</div>
</body>
</html>
Add members
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management Sysytem</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}
nav {
background-color: #333;
padding: 1rem;
text-align: center;
}
nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}
nav a:hover {
color: #ff6b6b;
}
.container {
text-align: center;
padding: 50px;
}
input, select {
display: block;
margin: 10px auto;
padding: 10px;
width: 80%;
max-width: 300px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 1rem;
}
.btn {
padding: 10px 20px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1rem;
}
.btn:hover {
background-color: #333;
}
</style>
</head>
<body>
<nav>
<a href="/">Home</a>
<a href="/admin_dashboard">Admin Dashboard</a>
<a href="/modify_member">Modify Existing Member</a>
<a href="/modify_member">Manage Supplements</a>
<a href="/logout" style="float: right;">Log Out</a>
</nav>
<div class="container">
<h1>Add New Member</h1>
<form action="/add_member" method="POST">
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<input type="text" name="name" placeholder="Member Name" required>
<input type="text" name="phone_number" placeholder="Phone Number" required>
<input type="date" name="date_of_birth" placeholder="Date of Birth" required>
<select name="gender" required>
<option value="" disabled selected>Select Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
</select>
<input type="text" name="address_line1" placeholder="Address Line 1" required>
<input type="text" name="address_line2" placeholder="Address Line 2">
<input type="text" name="street" placeholder="Street" required>
<input type="text" name="city" placeholder="City" required>
<input type="text" name="state" placeholder="State" required>
<input type="text" name="pincode" placeholder="Pincode" required>
<select name="Plan_chosen" required>
<option value="" disabled selected>Select plan</option>
<option value="Monthly">Monthly</option>
<option value="Quaterly">Quaterly</option>
<option value="Half">Half</option>
<option value="Annualy">Annualy</option>
</select>
<button type="submit" class="btn">Add Member</button>
</form>
</div>
</body>
</html>
Modifying existing member

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management System</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}
nav {
background-color: #333;
padding: 1rem;
text-align: center;
}
nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}
nav a:hover {
color: #ff6b6b;
}
.container {
text-align: center;
padding: 50px;
}
input, select {
display: block;
margin: 10px auto;
padding: 10px;
width: 80%;
max-width: 300px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 1rem;
}
.btn {
padding: 10px 20px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1rem;
}
.btn:hover {
background-color: #333;
}
</style>
</head>
<nav>

<img scr="/static/images/gym_laidy_logo.png" alt="Logo" style="height: 40px;">

<a href="/">Home</a>
<a href="/admin_dashboard">Admin Dashboard</a>
<a href="/add_member">Add Member</a>
<a href="/manage_supplements">Manage Supplements</a>
<a href="/logout" style="float: right;">Log Out</a>
</nav>
<body>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<ul class="flashes">
{% for category, message in messages %}
<li class="flash {{ category }}">{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
<div class="container">
<h1>Modify Existing Members</h1>
<form method="POST">
<label for="member_id">Select Member:</label>
<select name="member_id" id="member_id" required>
<option value="" disabled selected>Select a member</option>
{% for member in members %}
<option value="{{ member.member_id }}">{{ member.name }} (ID:
{{ member.member_id }})</option>
{% endfor %}
</select>

<input type="text" name="name" placeholder="Member Name" >


<input type="text" name="phone_number" placeholder="Phone Number" >
<input type="text" name="address_line1" placeholder="Address Line 1" >
<input type="text" name="address_line2" placeholder="Address Line 2">
<input type="text" name="street" placeholder="Street" >
<input type="text" name="city" placeholder="City" >
<input type="text" name="state" placeholder="State" >
<input type="text" name="pincode" placeholder="Pincode" >
<button type="submit" class="btn">Modify Member</button>
</form>
</div>
</body> </html>
Manage supplements
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management Sysytem</title>
<style>
body {
font-family: Arial, sans-serif;
height : 100vh;
background-color: #f4f4f4;
margin: 0;
overflow: hidden;

nav {
background-color: rgba(0, 0, 0, 0.8);
padding: 1rem;
display: flex;
align-items: center; /* Align items vertically */
justify-content: space-between; /* Space between left and right blocks */
}
nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}
.nav-left,
.nav-right {
display: flex; /* Display links in a row */
}

.nav-left a,
.nav-right a {
color: white;
margin-left: 20px;
text-decoration: none;
font-size: 1rem;
}

nav a:hover {
color: rgb(255, 107, 107);
}

.container {
width: 100%;
max-width: 500px;
margin: 20px auto;
padding: 50px;
background: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}

table{
flex-wrap: wrap;
}

input, select {
display: block;
margin: 10px auto;
padding: 10px;
width: 80%;
max-width: 300px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 1rem;
}

.btn {
padding: 10px 20px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1rem;
}

.btn:hover {
background-color: #333;
} </style>
</head>
<body>
<nav>
<div class="nav-left">
<img src="/static/images/gym_laidy_logo.png" alt="Logo"style="height: 40px;">
</div>
<a href="/">Home</a>
<a href="admin_dashboard">Admin Dashboard</a>
<a href="/add_member">Add Member</a>
<a href="/modify_member">Modify Existing Member</a>
<a href="/logout" style="float: right;">Logout</a>
</nav>
<div class="container">
<h1>Manage Supplements</h1>
<form action="/manage_supplements" method="POST">
<input type="text" name="supplement_id" placeholder="Supplement ID" required>
<input type="text" name="supplement_name" placeholder="Supplement Name"
required>
<input type="text" name="quantity" placeholder="Quantity" required>
<input type="text" name="cost" placeholder="Supplement Cost" required>
<button type="submit" class="btn">Add/Update Supplement</button>
</form>

<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Quantity</th>
<th>Cost</th>
</tr>
</thead>
<tbody>
{% for supplement in supplements %}
<tr>
<td>{{ supplement[0] }}</td>
<td>{{ supplement[1] }}</td>
<td>{{ supplement[2] }}</td>
<td>{{ supplement[3] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</body>
</html>

View plan
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management System - View Supplements</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}

nav {
background-color: #333;
padding: 1rem;
text-align: center;
}

nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}

nav a:hover {
color: #ff6b6b;
}

.container {
text-align: center;
padding: 50px 0;
}

h1 {
color: #333;
}

.supplement-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
}

.supplement-card {
background-color: white;
padding: 20px;
margin: 15px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 250px;
text-align: center;
}

.supplement-card h3 {
color: #333;
}

.btn {
padding: 10px 20px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

.btn:hover {
background-color: #333;
}
</style>
</head>

<body>

<nav>
<a href="/">Home</a>
<a href="/member_dashboard">Member Dashboard</a>
<a href="/buy_subscription">Buy Subscription</a>
<a href="/track_plan">Track Plan</a>
<a href="/view_transactions">View Transactions</a>
<a href="/logout" style="float: right;">Logout</a>
</nav>

<div class="container">
<h1>Available Plans</h1>
<div class="supplement-list">
{% for plan in plan %}
<div class="supplement-card">
<h3>{{ plan.plan }}</h3>
<p>Cost: ₹{{ plan.amount }}</p>
<a href="{{ url_for('buy_plan', plan_id=plan['plan_ID']) }}"
class="btn btn-primary">Buy Now</a>

</a>
</div>
{% endfor %}
</div>
</div>

</body> </html>

Buy plan

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management Sysytem</title>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="favicon-32x32/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="favicon-16x16/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="stylesheet" href="styles.css"> <!-- Link to your CSS file -->
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}

nav {
background-color: #333;
padding: 1rem;
text-align: center;
}

nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}

nav a:hover {
color: #ff6b6b;
}

.nav-left,
.nav-right {
display: flex; /* Display links in a row */
}

.container {
text-align: center;
padding: 50px 0;
}

h1 {
color: #333;
}

.subscription_type-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
}

.subscription_card {
background-color: white;
padding: 20px;
margin: 15px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 250px;
text-align: center;
}

.supplement-card h3 {
color: #333;
}

.btn {
padding: 10px 20px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

.btn:hover {
background-color: #333;
}
</style>
</head>
<body>
<header>
<nav>
<div class="nav-left">
<img src="/static/images/gym_logo.png" alt="Logo">
</div>
<a href="/member_dashboard">Dashboard</a>
<a href="/view_plan">Buy Plan</a>
<a href="/buy_supplements">Buy Supplements</a>
<a href="/logout" style="float: right;">Logout</a>
</nav>
</header>
<main>
<div class="container">
<h1>Buy Subscription</h1>
<div class="subscription_type-list">
<p>Cost: ₹{{ plan.Amount }}</p>

<form action="" method="POST">


<button type="submit">Proceed to Purchase</button>
</form>
</div>
</main>
</body>
</html>
View supplements
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management System - View Supplements</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}

nav {
background-color: #333;
padding: 1rem;
text-align: center;
}

nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}

nav a:hover {
color: #ff6b6b;
}

.container {
text-align: center;
padding: 50px 0;
}

h1 {
color: #333;
}

.supplement-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
}

.supplement-card {
background-color: white;
padding: 20px;
margin: 15px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 250px;
text-align: center;
}

.supplement-card h3 {
color: #333;
}

.btn {
padding: 10px 20px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

.btn:hover {
background-color: #333;
}
</style>
</head>

<body>

<nav>
<a href="/">Home</a>
<a href="/member_dashboard">Member Dashboard</a>
<a href="/buy_subscription">Buy Subscription</a>
<a href="/track_plan">Track Plan</a>
<a href="/view_transactions">View Transactions</a>
<a href="/logout" style="float: right;">Logout</a>
</nav>

<div class="container">
<h1>Available Supplements</h1>
<div class="supplement-list">
{% for supplement in supplements %}
<div class="supplement-card">
<h3>{{ supplement.Supplement_Name }}</h3>
<p>Cost: ₹{{ supplement.Cost }}</p>
<a href="{{ url_for('buy_supplements',
supplement_id=supplement['Supplement_ID']) }}"
class="btn btn-primary">Buy Now</a>

</a>
</div>
{% endfor %}
</div>
</div>
</body> </html>

Buy supplements
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management System - Buy Supplement</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}

nav {
background-color: #333;
padding: 1rem;
text-align: center;
}

nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}

nav a:hover {
color: #ff6b6b;
}

.container {
text-align: center;
padding: 50px 0;
}

h1 {
color: #333;
}

.supplement-card {
background-color: white;
padding: 20px;
margin: auto;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 300px;
text-align: center;
}

.supplement-card h3 {
color: #333;
}

.btn {
padding: 10px 20px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

.btn:hover {
background-color: #333;
}
</style>
</head>

<body>

<nav>
<a href="/">Home</a>
<a href="/member_login">Member Dashboard</a>
<a href="/view_supplements">View Supplements</a>
<a href="/logout" style="float: right;">Logout</a>
</nav>

<div class="container">
<h1>Buy Supplement</h1>
<div class="supplement-card">
<h3>{{ supplement.Supplement_Name }}</h3>
<p>Cost: ₹{{ supplement.Cost }}</p>
<form action="" method="POST">
<button class="btn" type="submit">Proceed to Purchase</button>
</form>
</div>
</div>

</body>

</html>
View transactions
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>View Transactions</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}

nav {
background-color: #333;
padding: 1rem;
text-align: center;
}

nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}

nav a:hover {
color: #ff6b6b;
}

.container {
text-align: center;
padding: 50px 0;
}

h1 {
color: #333;
}

table {
width: 80%;
margin: 0 auto;
border-collapse: collapse;
background-color: white;
}

table th,
table td {
padding: 10px;
border: 1px solid #ddd;
}

table th {
background-color: #333;
color: white;
}

.btn {
padding: 10px 20px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

.btn:hover {
background-color: #333;
}
</style>
</head>

<body>
<nav>
<a href="/">Home</a>
<a href="/member_dashboard">Member Dashboard</a>
<a href="/buy_subscription">Buy Subscription</a>
<a href="/track_plan">Track Membership Plan</a>
<a href="/view_supplements">Buy Supplements</a>
</nav>

<div class="container">
<h1>Transaction History</h1>

<!-- Transaction Table -->


<table>
<thead>
<tr>
<th>Transaction ID</th>
<th>Date</th>
<th>Description</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
{% for transaction in transactions %}
<tr>
<td>{{ transaction.transaction_id }}</td>
<td>{{ transaction.transaction_date.strftime('%Y-%m-%d %H:%M:%S')
}}</td>
<td>{{ transaction.description }}</td>
<td>₹{{ transaction.amount }}</td>
</tr>
{% endfor %}
</tbody>
</table>

<br>

<!-- Back to Dashboard Button -->


<button class="btn" onclick="window.location.href='/member_dashboard'">Back to
Dashboard</button>
</div>
</body> </html>

Proceed to purchase
<!DOCTYPE html>
<html lang="en">
<head>
<title>Proceed to Purchase</title>
</head>
<body>
<h1>Confirm Purchase: {{ item.Name }}</h1>
<p>Cost: ₹{{ item.Cost }}</p>
<p>UPI ID: <strong>8143233886@ybl</strong></p>
<img src="{{ url_for('static', filename=qr_code_path.split('static/')[1]) }}" alt="QR Code
for Payment">
<form action="" method="POST">
<button type="submit">Confirm and Pay</button>
</form>
</body>
</html>

Admin dashboard
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management System</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}
nav {
background-color: #333;
padding: 1rem;
text-align: center;
}
nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}
nav a:hover {
color: #ff6b6b;
}
.container{
width: 100%;
max-width: 400px;
margin: 50px auto;
padding: 20px;
background: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
h1 {
text-align: center;
color: #333;
}
.btn {
padding: 10px 20px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
margin: 10px;
cursor: pointer;
}
.btn:hover {
background-color: #333;
}
</style>
</head>
<body>
<nav>

<img scr ="/static/images/gym_laidy_logo.png" alt="Logo" style="height: 40px; align-


items: start;">

<a href="/">Home</a>
<a href="/add_member">Add Member</a>
<a href="/modify_member">Modify Existing Member</a>
<a href="/manage_supplements">Manage Supplements</a>
<a href="/logout" style="float: right;">Log Out</a>
</nav>

<div class="container">
<h1>Admin Dashboard</h1>
<button class="btn" onclick="window.location.href='/add_member'">Add
Member</button>
<button class="btn" onclick="window.location.href='/modify_member'">Modify
Existing Member</button>
<button class="btn" onclick="window.location.href='/manage_supplements'">Manage
Supplements</button>
<!-- Add more Admin-specific functionalities here -->
</div>
</body>
</html>

Coach dashboard
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management System</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}
nav {
background-color: #333;
padding: 1rem;
text-align: center;
}
nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}
nav a:hover {
color: #ff6b6b;
}
.container {
width: 100%;
max-width: 400px;
margin: 0px auto;
padding: 20px;
background: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
padding: 50px 0;
}
h1 {
color: #333;
}
.btn {
padding: 10px 20px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
margin: 10px;
cursor: pointer;
}
.btn:hover {
background-color: #333;
}
.hero {
width: 100%;
height: 300px;
background-image: url('coach-dashboard.jpg'); /* Replace with actual image path */
background-size: cover;
background-position: center;
}
</style>
</head>
<body>
<nav>
<a href="/">Home</a>

<a href="/view_sessions">View Sessions</a>


<a href="/apply_leave">Apply for Leave</a>
<a href="/logout" style="float: right;">Log Out</a>

</nav>

<div class="hero"></div>

<div class="container">
<h1>Coach Dashboard</h1>
<button class="btn" onclick="window.location.href='/view_sessions'">View
Sessions</button>
<button class="btn" onclick="window.location.href='/apply_leave'">Apply for
Leave</button>
<!-- Add more Coach-specific functionalities here -->
</div>
</body> </html>
Member dashboard
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GYM Management System</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
}
nav {
background-color: #333;
padding: 1rem;
text-align: center;
}
nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-size: 1.2rem;
}
nav a:hover {
color: #ff6b6b;
}
.container {
text-align: center;
padding: 50px 0;
}
h1 {
color: #333;
}
.btn {
padding: 10px 20px;
background-color: #ff6b6b;
color: white;
border: none;
border-radius: 5px;
margin: 10px;
cursor: pointer;
}
.btn:hover {
background-color: #333;
}
</style>
</head>
<body>
<nav>
<a href="/">Home</a>
<a href="/member_login">Member Dashboard</a>
<a href="/view_plan">Buy Plan</a>
<a href="/track_plan">Track Membership Plan</a>
<a href="/view_transactions">View Transactions</a>
<a href="/view_supplements">Buy Supplements</a>
</nav>

<div class="container">
<h1>Member Dashboard</h1>
<button class="btn" onclick="window.location.href='/buy_plan'">Buy Plan</button>
<button class="btn" onclick="window.location.href='/track_plan'">Track Membership
Plan</button>
<button class="btn" onclick="window.location.href='/view_transactions'">View
Transactions</button>
<button class="btn" onclick="window.location.href='/view_supplements'">Buy
Supplements</button>
</div>
</body>
</html>
OUTPUT SCREENSHOTS WITH FRONT-END
IMPLEMENTATION:
CERTIFICATES :

N. Dinakar Nisank:
Jacob :

Krisha:

You might also like