0% found this document useful (0 votes)
9 views41 pages

Source Code 1

The document outlines a Hotel Management System implemented in Python using MySQL, which includes functionalities for managing customers, rooms, bookings, staff, and food orders. It features a database schema for various entities, methods for adding and viewing records, and a main menu for user interaction. Additionally, it includes an admin login module for authentication and management of admin users.

Uploaded by

alwina9310
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)
9 views41 pages

Source Code 1

The document outlines a Hotel Management System implemented in Python using MySQL, which includes functionalities for managing customers, rooms, bookings, staff, and food orders. It features a database schema for various entities, methods for adding and viewing records, and a main menu for user interaction. Additionally, it includes an admin login module for authentication and management of admin users.

Uploaded by

alwina9310
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

001 import mysql.

connector
002 from datetime import datetime
003
004 #
=========================================
=====
005 # HOTEL MANAGEMENT SYSTEM - MYSQL VERSION
006 # SINGLE FILE PROJECT WITH NUMBERED LINES
007 #
=========================================
=====
008
009 db = [Link](
010 host='localhost',
011 user='root',
012 password='your_password',
013 database='hotel_management'
014 )
015
016 cursor = [Link]()
017
018 #
=========================================
=====
019 # DATABASE TABLE CREATION
020 #
=========================================
=====
021
022 [Link]('''
023 CREATE TABLE IF NOT EXISTS customers(
024 customer_id INT AUTO_INCREMENT PRIMARY KEY,
025 name VARCHAR(100),
026 phone VARCHAR(20),
027 email VARCHAR(100),
028 address VARCHAR(255)
029 )
030 ''')
031
032 [Link]('''
033 CREATE TABLE IF NOT EXISTS rooms(
034 room_no INT PRIMARY KEY,
035 room_type VARCHAR(50),
036 price INT,
037 status VARCHAR(20)
038 )
039 ''')
040
041 [Link]('''
042 CREATE TABLE IF NOT EXISTS bookings(
043 booking_id INT AUTO_INCREMENT PRIMARY KEY,
044 customer_id INT,
045 room_no INT,
046 check_in DATE,
047 check_out DATE,
048 days INT,
049 total_amount INT
050 )
051 ''')
052
053 [Link]('''
054 CREATE TABLE IF NOT EXISTS staff(
055 staff_id INT AUTO_INCREMENT PRIMARY KEY,
056 name VARCHAR(100),
057 role VARCHAR(50),
058 salary INT
059 )
060 ''')
061
062 [Link]()
063
064 #
=========================================
=====
065 # ROOM INITIALIZATION
066 #
=========================================
=====
067
068 def initialize_rooms():
069 room_data = [
070 (101, 'Single', 1000, 'Available'),
071 (102, 'Single', 1000, 'Available'),
072 (201, 'Double', 2000, 'Available'),
073 (202, 'Double', 2000, 'Available'),
074 (301, 'Suite', 4000, 'Available')
075 ]
076
077 for room in room_data:
078 try:
079 [Link]('INSERT INTO rooms VALUES (%s,%s,%s,%s)',
room)
080 except:
081 pass
082
083 [Link]()
084
085 #
=========================================
=====
086 # CUSTOMER MODULE
087 #
=========================================
=====
088
089 def add_customer():
090 name = input('Enter Name: ')
091 phone = input('Enter Phone: ')
092 email = input('Enter Email: ')
093 address = input('Enter Address: ')
094
095 sql = 'INSERT INTO customers(name, phone, email, address)
VALUES (%s,%s,%s,%s)'
096 val = (name, phone, email, address)
097 [Link](sql, val)
098 [Link]()
099 print('Customer added successfully')
100
101 def view_customers():
102 [Link]('SELECT * FROM customers')
103 rows = [Link]()
104 for row in rows:
105 print(row)
106
107 def search_customer():
108 cid = input('Enter Customer ID: ')
109 [Link]('SELECT * FROM customers WHERE
customer_id=%s', (cid,))
110 row = [Link]()
111 print(row if row else 'Customer not found')
112
113 #
=========================================
=====
114 # ROOM MODULE
115 #
=========================================
=====
116
117 def view_rooms():
118 [Link]('SELECT * FROM rooms')
119 for row in [Link]():
120 print(row)
121
122 def available_rooms():
123 [Link]("SELECT * FROM rooms WHERE
status='Available'")
124 for row in [Link]():
125 print(row)
126
127 #
=========================================
=====
128 # BOOKING MODULE
129 #
=========================================
=====
130
131 def book_room():
132 customer_id = input('Enter Customer ID: ')
133 room_no = input('Enter Room No: ')
134 check_in = input('Enter Check-in Date (YYYY-MM-DD): ')
135 check_out = input('Enter Check-out Date (YYYY-MM-DD): ')
136
137 [Link]('SELECT price,status FROM rooms WHERE
room_no=%s', (room_no,))
138 room = [Link]()
139
140 if not room:
141 print('Room not found')
142 return
143
144 if room[1] == 'Booked':
145 print('Room already booked')
146 return
147
148 d1 = [Link](check_in, '%Y-%m-%d')
149 d2 = [Link](check_out, '%Y-%m-%d')
150 days = (d2 - d1).days
151 total = days * room[0]
152
153 sql = '''INSERT INTO
bookings(customer_id,room_no,check_in,check_out,days,total_amou
nt)
154 VALUES (%s,%s,%s,%s,%s,%s)'''
155 val = (customer_id, room_no, check_in, check_out, days, total)
156 [Link](sql, val)
157
158 [Link]("UPDATE rooms SET status='Booked' WHERE
room_no=%s", (room_no,))
159 [Link]()
160 print('Booking successful. Total bill:', total)
161
162 def view_bookings():
163 [Link]('SELECT * FROM bookings')
164 for row in [Link]():
165 print(row)
166
167 def checkout():
168 room_no = input('Enter Room No: ')
169 [Link]('SELECT * FROM bookings WHERE room_no=%s',
(room_no,))
170 booking = [Link]()
171 if booking:
172 print('Bill:', booking)
173 [Link]("UPDATE rooms SET status='Available' WHERE
room_no=%s", (room_no,))
174 [Link]('DELETE FROM bookings WHERE room_no=%s',
(room_no,))
175 [Link]()
176 print('Checkout complete')
177 else:
178 print('No booking found')
179
180 #
=========================================
=====
181 # STAFF MODULE
182 #
=========================================
=====
183
184 def add_staff():
185 name = input('Staff Name: ')
186 role = input('Role: ')
187 salary = input('Salary: ')
188 [Link]('INSERT INTO staff(name,role,salary) VALUES
(%s,%s,%s)', (name, role, salary))
189 [Link]()
190 print('Staff added')
191
192 def view_staff():
193 [Link]('SELECT * FROM staff')
194 for row in [Link]():
195 print(row)
196
197 #
=========================================
=====
198 # REPORT MODULE
199 #
=========================================
=====
200
201 def total_revenue():
202 [Link]('SELECT SUM(total_amount) FROM bookings')
203 value = [Link]()[0]
204 print('Revenue:', value if value else 0)
205
206 def room_status_report():
207 [Link]('SELECT status, COUNT(*) FROM rooms GROUP
BY status')
208 for row in [Link]():
209 print(row)
210
211 #
=========================================
=====
212 # MAIN MENU
213 #
=========================================
=====
214
215 def main_menu():
216 while True:
217 print('\n===== HOTEL MANAGEMENT SYSTEM =====')
218 print('1. Add Customer')
219 print('2. View Customers')
220 print('3. Search Customer')
221 print('4. View Rooms')
222 print('5. Available Rooms')
223 print('6. Book Room')
224 print('7. View Bookings')
225 print('8. Checkout')
226 print('9. Add Staff')
227 print('10. View Staff')
228 print('11. Revenue Report')
229 print('12. Room Status Report')
230 print('13. Exit')
231
232 choice = input('Enter choice: ')
233
234 if choice == '1':
235 add_customer()
236 elif choice == '2':
237 view_customers()
238 elif choice == '3':
239 search_customer()
240 elif choice == '4':
241 view_rooms()
242 elif choice == '5':
243 available_rooms()
244 elif choice == '6':
245 book_room()
246 elif choice == '7':
247 view_bookings()
248 elif choice == '8':
249 checkout()
250 elif choice == '9':
251 add_staff()
252 elif choice == '10':
253 view_staff()
254 elif choice == '11':
255 total_revenue()
256 elif choice == '12':
257 room_status_report()
258 elif choice == '13':
259 break
260 else:
261 print('Invalid choice')
262
263 initialize_rooms()
264 main_menu()
265 [Link]()
266
267 #
=========================================
=====
268 # MODULE 1 - LOGIN AND ADMIN AUTHENTICATION
269 #
=========================================
=====
270
271 [Link]('''
272 CREATE TABLE IF NOT EXISTS admin_users(
273 admin_id INT AUTO_INCREMENT PRIMARY KEY,
274 username VARCHAR(100),
275 password VARCHAR(100),
276 role VARCHAR(50)
277 )
278 ''')
279 [Link]()
280
281 def initialize_admin():
282 try:
283 [Link]("INSERT INTO
admin_users(username,password,role) VALUES (%s,%s,%s)",
284 ('admin','admin123','Manager'))
285 [Link]()
286 except:
287 pass
288
289 def admin_login():
290 print('
===== ADMIN LOGIN =====')
291 username = input('Enter Username: ')
292 password = input('Enter Password: ')
293
294 [Link]('SELECT * FROM admin_users WHERE
username=%s AND password=%s',
295 (username, password))
296 user = [Link]()
297
298 if user:
299 print('Login Successful')
300 print('Welcome', user[1])
301 print('Role:', user[3])
302 return True
303 else:
304 print('Invalid credentials')
305 return False
306
307 def change_password():
308 username = input('Enter Username: ')
309 old_password = input('Enter Old Password: ')
310 new_password = input('Enter New Password: ')
311
312 [Link]('SELECT * FROM admin_users WHERE
username=%s AND password=%s',
313 (username, old_password))
314 user = [Link]()
315
316 if user:
317 [Link]('UPDATE admin_users SET password=%s
WHERE username=%s',
318 (new_password, username))
319 [Link]()
320 print('Password changed successfully')
321 else:
322 print('Invalid current password')
323
324 def add_admin_user():
325 username = input('Enter New Username: ')
326 password = input('Enter Password: ')
327 role = input('Enter Role: ')
328
329 [Link]('INSERT INTO
admin_users(username,password,role) VALUES (%s,%s,%s)',
330 (username, password, role))
331 [Link]()
332 print('Admin user added successfully')
333
334 def view_admin_users():
335 [Link]('SELECT * FROM admin_users')
336 rows = [Link]()
337 print('
===== ADMIN USERS =====')
338 for row in rows:
339 print('ID:', row[0])
340 print('Username:', row[1])
341 print('Role:', row[3])
342 print('---------------------')
343
344 def delete_admin_user():
345 admin_id = input('Enter Admin ID to delete: ')
346 [Link]('DELETE FROM admin_users WHERE admin_id=
%s', (admin_id,))
347 [Link]()
348 print('Admin deleted successfully')
349
350 def login_menu():
351 while True:
352 print('
===== LOGIN MODULE =====')
353 print('1. Admin Login')
354 print('2. Change Password')
355 print('3. Add Admin User')
356 print('4. View Admin Users')
357 print('5. Delete Admin User')
358 print('6. Exit Login Module')
359
360 choice = input('Enter choice: ')
361
362 if choice == '1':
363 if admin_login():
364 break
365 elif choice == '2':
366 change_password()
367 elif choice == '3':
368 add_admin_user()
369 elif choice == '4':
370 view_admin_users()
371 elif choice == '5':
372 delete_admin_user()
373 elif choice == '6':
374 break
375 else:
376 print('Invalid choice')
377
378 initialize_admin()
379 login_menu()
380
381 #
=========================================
=====
382 # END OF MODULE 1
383 #
=========================================
=====
384
385 #
=========================================
=====
386 # MODULE 2 - FOOD ORDERING SYSTEM
387 #
=========================================
=====
388
389 [Link]('''
390 CREATE TABLE IF NOT EXISTS food_menu(
391 item_id INT AUTO_INCREMENT PRIMARY KEY,
392 item_name VARCHAR(100),
393 price INT
394 )
395 ''')
396
397 [Link]('''
398 CREATE TABLE IF NOT EXISTS food_orders(
399 order_id INT AUTO_INCREMENT PRIMARY KEY,
400 room_no INT,
401 item_name VARCHAR(100),
402 quantity INT,
403 total_price INT
404 )
405 ''')
406 [Link]()
407
408 def initialize_food_menu():
409 food_items = [
410 ('Tea', 20),
411 ('Coffee', 30),
412 ('Sandwich', 80),
413 ('Meals', 150),
414 ('Juice', 50)
415 ]
416
417 for item in food_items:
418 try:
419 [Link]('INSERT INTO food_menu(item_name,price)
VALUES (%s,%s)', item)
420 except:
421 pass
422
423 [Link]()
424
425 def view_food_menu():
426 [Link]('SELECT * FROM food_menu')
427 rows = [Link]()
428 print('
===== FOOD MENU =====')
429 for row in rows:
430 print('Item ID:', row[0])
431 print('Name:', row[1])
432 print('Price:', row[2])
433 print('---------------------')
434
435 def order_food():
436 room_no = input('Enter Room No: ')
437 item_id = input('Enter Item ID: ')
438 quantity = int(input('Enter Quantity: '))
439
440 [Link]('SELECT item_name, price FROM food_menu
WHERE item_id=%s', (item_id,))
441 item = [Link]()
442
443 if item:
444 item_name = item[0]
445 total_price = item[1] * quantity
446
447 [Link]('''INSERT INTO
food_orders(room_no,item_name,quantity,total_price)
448 VALUES (%s,%s,%s,%s)''',
449 (room_no, item_name, quantity, total_price))
450 [Link]()
451
452 print('Food order placed successfully')
453 print('Total Amount:', total_price)
454 else:
455 print('Food item not found')
456
457 def view_food_orders():
458 [Link]('SELECT * FROM food_orders')
459 rows = [Link]()
460 print('
===== FOOD ORDERS =====')
461 for row in rows:
462 print('Order ID:', row[0])
463 print('Room No:', row[1])
464 print('Item:', row[2])
465 print('Quantity:', row[3])
466 print('Total:', row[4])
467 print('---------------------')
468
469 def room_food_bill():
470 room_no = input('Enter Room No: ')
471 [Link]('SELECT SUM(total_price) FROM food_orders
WHERE room_no=%s', (room_no,))
472 total = [Link]()[0]
473
474 if total:
475 print('Food Bill for Room', room_no, ':', total)
476 else:
477 print('No food orders found')
478
479 def delete_food_order():
480 order_id = input('Enter Order ID to delete: ')
481 [Link]('DELETE FROM food_orders WHERE order_id=
%s', (order_id,))
482 [Link]()
483 print('Food order deleted successfully')
484
485 def food_menu_module():
486 while True:
487 print('
===== FOOD ORDER MODULE =====')
488 print('1. View Food Menu')
489 print('2. Order Food')
490 print('3. View Food Orders')
491 print('4. Room Food Bill')
492 print('5. Delete Food Order')
493 print('6. Exit Food Module')
494
495 choice = input('Enter choice: ')
496
497 if choice == '1':
498 view_food_menu()
499 elif choice == '2':
500 order_food()
501 elif choice == '3':
502 view_food_orders()
503 elif choice == '4':
504 room_food_bill()
505 elif choice == '5':
506 delete_food_order()
507 elif choice == '6':
508 break
509 else:
510 print('Invalid choice')
511
512 initialize_food_menu()
513 food_menu_module()
514
515 #
=========================================
=====
516 # END OF MODULE 2
517 #
=========================================
=====
518
519 #
=========================================
=====
520 # MODULE 1 EXTENSION - LOGIN VALIDATION HELPERS
521 #
=========================================
=====
522
523 def validate_username(username):
524 if len(username) < 4:
525 print('Username must contain at least 4 characters')
526 return False
527 return True
528
529 def validate_password(password):
530 if len(password) < 6:
531 print('Password must contain at least 6 characters')
532 return False
533 return True
534
535 def reset_admin_password():
536 username = input('Enter Username for reset: ')
537 new_password = input('Enter New Password: ')
538
539 if validate_password(new_password):
540 [Link]('UPDATE admin_users SET password=%s
WHERE username=%s',
541 (new_password, username))
542 [Link]()
543 print('Password reset completed')
544
545 def admin_exists(username):
546 [Link]('SELECT * FROM admin_users WHERE
username=%s', (username,))
547 user = [Link]()
548 return user is not None
549
550 def safe_add_admin():
551 username = input('Enter Username: ')
552 password = input('Enter Password: ')
553 role = input('Enter Role: ')
554
555 if not validate_username(username):
556 return
557
558 if not validate_password(password):
559 return
560
561 if admin_exists(username):
562 print('Username already exists')
563 return
564
565 [Link]('INSERT INTO
admin_users(username,password,role) VALUES (%s,%s,%s)',
566 (username, password, role))
567 [Link]()
568 print('Validated admin added successfully')
569
570 def login_audit(username, status):
571 print('Audit Log -> User:', username, '| Status:', status)
572
573 def secured_admin_login():
574 username = input('Username: ')
575 password = input('Password: ')
576
577 [Link]('SELECT * FROM admin_users WHERE
username=%s AND password=%s',
578 (username, password))
579 user = [Link]()
580
581 if user:
582 login_audit(username, 'Success')
583 print('Secure login success')
584 else:
585 login_audit(username, 'Failed')
586 print('Secure login failed')
587
588 #
=========================================
=====
589 # MODULE 2 EXTENSION - FOOD INVENTORY AND BILLING
590 #
=========================================
=====
591
592
593
594 def add_food_item():
595 item_name = input('Enter Food Item Name: ')
596 price = input('Enter Price: ')
597 [Link]('INSERT INTO food_menu(item_name,price)
VALUES (%s,%s)',
598 (item_name, price))
599 [Link]()
600 print('Food item added successfully')
601
602 def update_food_price():
603 item_id = input('Enter Item ID: ')
604 new_price = input('Enter New Price: ')
605 [Link]('UPDATE food_menu SET price=%s WHERE
item_id=%s',
606 (new_price, item_id))
607 [Link]()
608 print('Price updated successfully')
609
610 def delete_food_item():
611 item_id = input('Enter Item ID to delete: ')
612 [Link]('DELETE FROM food_menu WHERE item_id=%s',
(item_id,))
613 [Link]()
614 print('Food item deleted successfully')
615
616 def food_sales_report():
617 [Link]('SELECT item_name, SUM(quantity),
SUM(total_price) FROM food_orders GROUP BY item_name')
618 rows = [Link]()
619 print('===== FOOD SALES REPORT =====')
620 for row in rows:
621 print('Item:', row[0])
622 print('Quantity Sold:', row[1])
623 print('Revenue:', row[2])
624 print('----------------------')
625
626 def highest_selling_food():
627 [Link]('SELECT item_name, SUM(quantity) as total_qty
FROM food_orders GROUP BY item_name ORDER BY total_qty DESC
LIMIT 1')
628 row = [Link]()
629 if row:
630 print('Highest Selling Item:', row[0])
631 print('Quantity:', row[1])
632 else:
633 print('No sales data available')
634
635 def clear_room_food_orders():
636 room_no = input('Enter Room No: ')
637 [Link]('DELETE FROM food_orders WHERE room_no=
%s', (room_no,))
638 [Link]()
639 print('Room food orders cleared')
640
641 def food_inventory_module():
642 while True:
643 print('===== FOOD INVENTORY MODULE =====')
644 print('1. Add Food Item')
645 print('2. Update Food Price')
646 print('3. Delete Food Item')
647 print('4. Food Sales Report')
648 print('5. Highest Selling Food')
649 print('6. Clear Room Orders')
650 print('7. Exit Food Inventory Module')
651
652 choice = input('Enter choice: ')
653
654 if choice == '1':
655 add_food_item()
656 elif choice == '2':
657 update_food_price()
658 elif choice == '3':
659 delete_food_item()
660 elif choice == '4':
661 food_sales_report()
662 elif choice == '5':
663 highest_selling_food()
664 elif choice == '6':
665 clear_room_food_orders()
666 elif choice == '7':
667 break
668 else:
669 print('Invalid choice')
670
671 food_inventory_module()
672
673 #
=========================================
=====
674 # RESERVED LINES FOR NUMBER CONTINUITY
675 #
=========================================
=====
676
677
678
679 #
=========================================
=====
680 # MODULE 3 - LAUNDRY MANAGEMENT SYSTEM
681 #
=========================================
=====
682
683 [Link]('''
684 CREATE TABLE IF NOT EXISTS laundry(
685 laundry_id INT AUTO_INCREMENT PRIMARY KEY,
686 room_no INT,
687 cloth_type VARCHAR(100),
688 quantity INT,
689 price INT,
690 total INT
691 )
692 ''')
693 [Link]()
694
695 def add_laundry_order():
696 room_no = input('Enter Room No: ')
697 cloth_type = input('Enter Cloth Type: ')
698 quantity = int(input('Enter Quantity: '))
699 price = int(input('Enter Price per Cloth: '))
700 total = quantity * price
701
702 [Link]('INSERT INTO
laundry(room_no,cloth_type,quantity,price,total) VALUES (%s,%s,
%s,%s,%s)',
703 (room_no, cloth_type, quantity, price, total))
704 [Link]()
705 print('Laundry order added successfully')
706
707 def view_laundry_orders():
708 [Link]('SELECT * FROM laundry')
709 rows = [Link]()
710 print('===== LAUNDRY ORDERS =====')
711 for row in rows:
712 print(row)
713
714 def room_laundry_bill():
715 room_no = input('Enter Room No: ')
716 [Link]('SELECT SUM(total) FROM laundry WHERE
room_no=%s', (room_no,))
717 total = [Link]()[0]
718 print('Laundry Bill:', total if total else 0)
719
720 def delete_laundry_order():
721 laundry_id = input('Enter Laundry ID to delete: ')
722 [Link]('DELETE FROM laundry WHERE laundry_id=%s',
(laundry_id,))
723 [Link]()
724 print('Laundry order deleted')
725
726 def laundry_report():
727 [Link]('SELECT cloth_type, SUM(quantity), SUM(total)
FROM laundry GROUP BY cloth_type')
728 rows = [Link]()
729 print('===== LAUNDRY REPORT =====')
730 for row in rows:
731 print('Cloth:', row[0])
732 print('Total Quantity:', row[1])
733 print('Revenue:', row[2])
734 print('-------------------')
735
736 def laundry_module():
737 while True:
738 print('===== LAUNDRY MODULE =====')
739 print('1. Add Laundry Order')
740 print('2. View Laundry Orders')
741 print('3. Room Laundry Bill')
742 print('4. Delete Laundry Order')
743 print('5. Laundry Report')
744 print('6. Exit Laundry Module')
745
746 choice = input('Enter choice: ')
747
748 if choice == '1':
749 add_laundry_order()
750 elif choice == '2':
751 view_laundry_orders()
752 elif choice == '3':
753 room_laundry_bill()
754 elif choice == '4':
755 delete_laundry_order()
756 elif choice == '5':
757 laundry_report()
758 elif choice == '6':
759 break
760 else:
761 print('Invalid choice')
762
763 laundry_module()
764
765 #
=========================================
=====
766 # RESERVED LINES FOR NUMBER CONTINUITY
767 #
=========================================
=====
768
769
770 #
=========================================
=====
771 # MODULE 4 - INVOICE AND FINAL BILLING SYSTEM
772 #
=========================================
=====
773
774 def final_bill():
775 room_no = input('Enter Room No: ')
776
777 [Link]('SELECT total_amount FROM bookings WHERE
room_no=%s', (room_no,))
778 room_bill = [Link]()
779
780 [Link]('SELECT SUM(total_price) FROM food_orders
WHERE room_no=%s', (room_no,))
781 food_bill = [Link]()[0]
782
783 [Link]('SELECT SUM(total) FROM laundry WHERE
room_no=%s', (room_no,))
784 laundry_bill = [Link]()[0]
785
786 room_total = room_bill[0] if room_bill else 0
787 food_total = food_bill if food_bill else 0
788 laundry_total = laundry_bill if laundry_bill else 0
789
790 grand_total = room_total + food_total + laundry_total
791
792 print('===== FINAL BILL =====')
793 print('Room Charge:', room_total)
794 print('Food Charge:', food_total)
795 print('Laundry Charge:', laundry_total)
796 print('Grand Total:', grand_total)
797
798 def invoice_details():
799 room_no = input('Enter Room No: ')
800 [Link]('SELECT * FROM bookings WHERE room_no=%s',
(room_no,))
801 booking = [Link]()
802
803 if booking:
804 print('Booking ID:', booking[0])
805 print('Customer ID:', booking[1])
806 print('Room No:', booking[2])
807 print('Check In:', booking[3])
808 print('Check Out:', booking[4])
809 print('Days:', booking[5])
810 print('Room Amount:', booking[6])
811 else:
812 print('No booking found')
813
814 def paid_checkout():
815 room_no = input('Enter Room No: ')
816 final_bill()
817 [Link]("UPDATE rooms SET status='Available' WHERE
room_no=%s", (room_no,))
818 [Link]('DELETE FROM bookings WHERE room_no=%s',
(room_no,))
819 [Link]('DELETE FROM food_orders WHERE room_no=
%s', (room_no,))
820 [Link]('DELETE FROM laundry WHERE room_no=%s',
(room_no,))
821 [Link]()
822 print('Checkout completed with payment')
823
824 def billing_summary():
825 [Link]('SELECT SUM(total_amount) FROM bookings')
826 room_revenue = [Link]()[0]
827
828 [Link]('SELECT SUM(total_price) FROM food_orders')
829 food_revenue = [Link]()[0]
830
831 [Link]('SELECT SUM(total) FROM laundry')
832 laundry_revenue = [Link]()[0]
833
834 print('===== BILLING SUMMARY =====')
835 print('Room Revenue:', room_revenue if room_revenue else 0)
836 print('Food Revenue:', food_revenue if food_revenue else 0)
837 print('Laundry Revenue:', laundry_revenue if laundry_revenue
else 0)
838
839 def invoice_module():
840 while True:
841 print('===== INVOICE MODULE =====')
842 print('1. Final Bill')
843 print('2. Invoice Details')
844 print('3. Paid Checkout')
845 print('4. Billing Summary')
846 print('5. Exit Invoice Module')
847
848 choice = input('Enter choice: ')
849
850 if choice == '1':
851 final_bill()
852 elif choice == '2':
853 invoice_details()
854 elif choice == '3':
855 paid_checkout()
856 elif choice == '4':
857 billing_summary()
858 elif choice == '5':
859 break
860 else:
861 print('Invalid choice')
862
863 invoice_module()
864
865 #
=========================================
=====
866 # RESERVED LINES FOR NUMBER CONTINUITY
867 #
=========================================
=====
868
869
870 #
=========================================
=====
871 # MODULE 5 - EMPLOYEE ATTENDANCE SYSTEM
872 #
=========================================
=====
873
874 [Link]('''
875 CREATE TABLE IF NOT EXISTS attendance(
876 attendance_id INT AUTO_INCREMENT PRIMARY KEY,
877 staff_id INT,
878 staff_name VARCHAR(100),
879 date VARCHAR(20),
880 status VARCHAR(20)
881 )
882 ''')
883 [Link]()
884
885 def mark_attendance():
886 staff_id = input('Enter Staff ID: ')
887 staff_name = input('Enter Staff Name: ')
888 date = input('Enter Date: ')
889 status = input('Enter Status (Present/Absent): ')
890
891 [Link]('INSERT INTO
attendance(staff_id,staff_name,date,status) VALUES (%s,%s,%s,
%s)',
892 (staff_id, staff_name, date, status))
893 [Link]()
894 print('Attendance marked successfully')
895
896 def view_attendance():
897 [Link]('SELECT * FROM attendance')
898 rows = [Link]()
899 print('===== ATTENDANCE RECORDS =====')
900 for row in rows:
901 print(row)
902
903 def staff_attendance_report():
904 staff_id = input('Enter Staff ID: ')
905 [Link]('SELECT * FROM attendance WHERE staff_id=
%s', (staff_id,))
906 rows = [Link]()
907 print('===== STAFF ATTENDANCE REPORT =====')
908 for row in rows:
909 print(row)
910
911 def present_count():
912 [Link]("SELECT COUNT(*) FROM attendance WHERE
status='Present'")
913 total = [Link]()[0]
914 print('Total Present Employees:', total)
915
916 def absent_count():
917 [Link]("SELECT COUNT(*) FROM attendance WHERE
status='Absent'")
918 total = [Link]()[0]
919 print('Total Absent Employees:', total)
920
921 def attendance_module():
922 while True:
923 print('===== ATTENDANCE MODULE =====')
924 print('1. Mark Attendance')
925 print('2. View Attendance')
926 print('3. Staff Attendance Report')
927 print('4. Present Count')
928 print('5. Absent Count')
929 print('6. Exit Attendance Module')
930
931 choice = input('Enter choice: ')
932
933 if choice == '1':
934 mark_attendance()
935 elif choice == '2':
936 view_attendance()
937 elif choice == '3':
938 staff_attendance_report()
939 elif choice == '4':
940 present_count()
941 elif choice == '5':
942 absent_count()
943 elif choice == '6':
944 break
945 else:
946 print('Invalid choice')
947
948 attendance_module()
949
950 #
=========================================
=====
951 # MODULE 6 - BACKUP AND REPORT SYSTEM
952 #
=========================================
=====
953
954 def backup_customers():
955 [Link]('SELECT * FROM customers')
956 rows = [Link]()
957 print('===== CUSTOMER BACKUP =====')
958 for row in rows:
959 print(row)
960
961 def backup_bookings():
962 [Link]('SELECT * FROM bookings')
963 rows = [Link]()
964 print('===== BOOKING BACKUP =====')
965 for row in rows:
966 print(row)
967
968 def backup_staff():
969 [Link]('SELECT * FROM staff')
970 rows = [Link]()
971 print('===== STAFF BACKUP =====')
972 for row in rows:
973 print(row)
974
975 def full_revenue_report():
976 [Link]('SELECT SUM(total_amount) FROM bookings')
977 room_total = [Link]()[0]
978
979 [Link]('SELECT SUM(total_price) FROM food_orders')
980 food_total = [Link]()[0]
981
982 [Link]('SELECT SUM(total) FROM laundry')
983 laundry_total = [Link]()[0]
984
985 grand = (room_total if room_total else 0) + (food_total if
food_total else 0) + (laundry_total if laundry_total else 0)
986
987 print('===== FULL REVENUE REPORT =====')
988 print('Room Revenue:', room_total if room_total else 0)
989 print('Food Revenue:', food_total if food_total else 0)
990 print('Laundry Revenue:', laundry_total if laundry_total else 0)
991 print('Grand Revenue:', grand)
992
993 def occupied_rooms_report():
994 [Link]("SELECT * FROM rooms WHERE
status='Booked'")
995 rows = [Link]()
996 print('===== OCCUPIED ROOMS =====')
997 for row in rows:
998 print(row)
999
1000 def backup_module():
1001 while True:
1002 print('===== BACKUP MODULE =====')
1003 print('1. Backup Customers')
1004 print('2. Backup Bookings')
1005 print('3. Backup Staff')
1006 print('4. Full Revenue Report')
1007 print('5. Occupied Rooms Report')
1008 print('6. Exit Backup Module')
1009
1010 choice = input('Enter choice: ')
1011
1012 if choice == '1':
1013 backup_customers()
1014 elif choice == '2':
1015 backup_bookings()
1016 elif choice == '3':
1017 backup_staff()
1018 elif choice == '4':
1019 full_revenue_report()
1020 elif choice == '5':
1021 occupied_rooms_report()
1022 elif choice == '6':
1023 break
1024 else:
1025 print('Invalid choice')
1026
1027 backup_module()
1028
1029
1030 #
=========================================
=====
1031 # MODULE 7 - CUSTOMER FEEDBACK SYSTEM
1032 #
=========================================
=====
1033
1034 [Link]('''
1035 CREATE TABLE IF NOT EXISTS feedback(
1036 feedback_id INT AUTO_INCREMENT PRIMARY KEY,
1037 customer_name VARCHAR(100),
1038 room_no INT,
1039 rating INT,
1040 comments VARCHAR(255)
1041 )
1042 ''')
1043 [Link]()
1044
1045 def add_feedback():
1046 customer_name = input('Enter Customer Name: ')
1047 room_no = input('Enter Room No: ')
1048 rating = input('Enter Rating (1-5): ')
1049 comments = input('Enter Comments: ')
1050
1051 [Link]('INSERT INTO
feedback(customer_name,room_no,rating,comments) VALUES (%s,
%s,%s,%s)',
1052 (customer_name, room_no, rating, comments))
1053 [Link]()
1054 print('Feedback added successfully')
1055
1056 def view_feedback():
1057 [Link]('SELECT * FROM feedback')
1058 rows = [Link]()
1059 print('===== CUSTOMER FEEDBACK =====')
1060 for row in rows:
1061 print(row)
1062
1063 def average_rating():
1064 [Link]('SELECT AVG(rating) FROM feedback')
1065 avg = [Link]()[0]
1066 print('Average Rating:', avg if avg else 0)
1067
1068 def feedback_by_room():
1069 room_no = input('Enter Room No: ')
1070 [Link]('SELECT * FROM feedback WHERE room_no=
%s', (room_no,))
1071 rows = [Link]()
1072 for row in rows:
1073 print(row)
1074
1075 def delete_feedback():
1076 feedback_id = input('Enter Feedback ID to delete: ')
1077 [Link]('DELETE FROM feedback WHERE feedback_id=
%s', (feedback_id,))
1078 [Link]()
1079 print('Feedback deleted successfully')
1080
1081 def feedback_module():
1082 while True:
1083 print('===== FEEDBACK MODULE =====')
1084 print('1. Add Feedback')
1085 print('2. View Feedback')
1086 print('3. Average Rating')
1087 print('4. Feedback by Room')
1088 print('5. Delete Feedback')
1089 print('6. Exit Feedback Module')
1090
1091 choice = input('Enter choice: ')
1092
1093 if choice == '1':
1094 add_feedback()
1095 elif choice == '2':
1096 view_feedback()
1097 elif choice == '3':
1098 average_rating()
1099 elif choice == '4':
1100 feedback_by_room()
1101 elif choice == '5':
1102 delete_feedback()
1103 elif choice == '6':
1104 break
1105 else:
1106 print('Invalid choice')
1107
1108 feedback_module()
1109
1110 #
=========================================
=====
1111 # MODULE 8 - ANALYTICS DASHBOARD
1112 #
=========================================
=====
1113
1114 def monthly_booking_count():
1115 [Link]('SELECT COUNT(*) FROM bookings')
1116 total = [Link]()[0]
1117 print('Total Active Bookings:', total)
1118
1119 def total_customers_count():
1120 [Link]('SELECT COUNT(*) FROM customers')
1121 total = [Link]()[0]
1122 print('Total Customers:', total)
1123
1124 def total_staff_count():
1125 [Link]('SELECT COUNT(*) FROM staff')
1126 total = [Link]()[0]
1127 print('Total Staff:', total)
1128
1129 def room_type_analysis():
1130 [Link]('SELECT room_type, COUNT(*) FROM rooms
GROUP BY room_type')
1131 rows = [Link]()
1132 print('===== ROOM TYPE ANALYSIS =====')
1133 for row in rows:
1134 print('Type:', row[0], 'Count:', row[1])
1135
1136 def feedback_analysis():
1137 [Link]('SELECT rating, COUNT(*) FROM feedback
GROUP BY rating')
1138 rows = [Link]()
1139 print('===== FEEDBACK ANALYSIS =====')
1140 for row in rows:
1141 print('Rating:', row[0], 'Count:', row[1])
1142
1143 def analytics_module():
1144 while True:
1145 print('===== ANALYTICS MODULE =====')
1146 print('1. Monthly Booking Count')
1147 print('2. Total Customers Count')
1148 print('3. Total Staff Count')
1149 print('4. Room Type Analysis')
1150 print('5. Feedback Analysis')
1151 print('6. Exit Analytics Module')
1152
1153 choice = input('Enter choice: ')
1154
1155 if choice == '1':
1156 monthly_booking_count()
1157 elif choice == '2':
1158 total_customers_count()
1159 elif choice == '3':
1160 total_staff_count()
1161 elif choice == '4':
1162 room_type_analysis()
1163 elif choice == '5':
1164 feedback_analysis()
1165 elif choice == '6':
1166 break
1167 else:
1168 print('Invalid choice')
1169
1170 analytics_module()
1171
1172
1173
1174
1175 #
=========================================
=====
1176 # MODULE 9 - SECURITY LOG SYSTEM
1177 #
=========================================
=====
1178
1179 [Link]('''
1180 CREATE TABLE IF NOT EXISTS security_logs(
1181 log_id INT AUTO_INCREMENT PRIMARY KEY,
1182 username VARCHAR(100),
1183 activity VARCHAR(100),
1184 log_time VARCHAR(50)
1185 )
1186 ''')
1187 [Link]()
1188
1189 def add_security_log():
1190 username = input('Enter Username: ')
1191 activity = input('Enter Activity: ')
1192 log_time = input('Enter Time: ')
1193
1194 [Link]('INSERT INTO
security_logs(username,activity,log_time) VALUES (%s,%s,%s)',
1195 (username, activity, log_time))
1196 [Link]()
1197 print('Security log added successfully')
1198
1199 def view_security_logs():
1200 [Link]('SELECT * FROM security_logs')
1201 rows = [Link]()
1202 print('===== SECURITY LOGS =====')
1203 for row in rows:
1204 print(row)
1205
1206 def search_security_log():
1207 username = input('Enter Username: ')
1208 [Link]('SELECT * FROM security_logs WHERE
username=%s', (username,))
1209 rows = [Link]()
1210 for row in rows:
1211 print(row)
1212
1213 def delete_security_log():
1214 log_id = input('Enter Log ID to delete: ')
1215 [Link]('DELETE FROM security_logs WHERE log_id=
%s', (log_id,))
1216 [Link]()
1217 print('Security log deleted')
1218
1219 def security_summary():
1220 [Link]('SELECT COUNT(*) FROM security_logs')
1221 total = [Link]()[0]
1222 print('Total Security Logs:', total)
1223
1224 def security_module():
1225 while True:
1226 print('===== SECURITY MODULE =====')
1227 print('1. Add Security Log')
1228 print('2. View Security Logs')
1229 print('3. Search Security Log')
1230 print('4. Delete Security Log')
1231 print('5. Security Summary')
1232 print('6. Exit Security Module')
1233
1234 choice = input('Enter choice: ')
1235
1236 if choice == '1':
1237 add_security_log()
1238 elif choice == '2':
1239 view_security_logs()
1240 elif choice == '3':
1241 search_security_log()
1242 elif choice == '4':
1243 delete_security_log()
1244 elif choice == '5':
1245 security_summary()
1246 elif choice == '6':
1247 break
1248 else:
1249 print('Invalid choice')
1250
1251 security_module()
1252
1253
1254
1255
1256
1257
1258
1259
1260 #
=========================================
=====
1261 # MODULE 10, 11, 12 - ACCESS CONTROL, NOTIFICATION,
AUDIT
1262 #
=========================================
=====
1263
1264 [Link]('''
1265 CREATE TABLE IF NOT EXISTS departments(
1266 dept_id INT AUTO_INCREMENT PRIMARY KEY,
1267 dept_name VARCHAR(100),
1268 access_level VARCHAR(50)
1269 )
1270 ''')
1271
1272 [Link]('''
1273 CREATE TABLE IF NOT EXISTS notifications(
1274 notify_id INT AUTO_INCREMENT PRIMARY KEY,
1275 message VARCHAR(255)
1276 )
1277 ''')
1278 [Link]()
1279
1280 def add_department():
1281 dept_name = input('Enter Department Name: ')
1282 access_level = input('Enter Access Level: ')
1283 [Link]('INSERT INTO
departments(dept_name,access_level) VALUES (%s,%s)',
1284 (dept_name, access_level))
1285 [Link]()
1286 print('Department added successfully')
1287
1288 def view_departments():
1289 [Link]('SELECT * FROM departments')
1290 for row in [Link]():
1291 print(row)
1292
1293 def send_notification():
1294 message = input('Enter Notification Message: ')
1295 [Link]('INSERT INTO notifications(message) VALUES
(%s)', (message,))
1296 [Link]()
1297 print('Notification sent')
1298
1299 def view_notifications():
1300 [Link]('SELECT * FROM notifications')
1301 for row in [Link]():
1302 print(row)
1303
1304 def audit_report():
1305 print('===== AUDIT REPORT =====')
1306 [Link]('SELECT COUNT(*) FROM customers')
1307 print('Customers:', [Link]()[0])
1308 [Link]('SELECT COUNT(*) FROM bookings')
1309 print('Bookings:', [Link]()[0])
1310 [Link]('SELECT COUNT(*) FROM feedback')
1311 print('Feedback Entries:', [Link]()[0])
1312
1313 def final_admin_module():
1314 while True:
1315 print('===== FINAL ADMIN MODULE =====')
1316 print('1. Add Department')
1317 print('2. View Departments')
1318 print('3. Send Notification')
1319 print('4. View Notifications')
1320 print('5. Audit Report')
1321 print('6. Exit Final Module')
1322
1323 choice = input('Enter choice: ')
1324
1325 if choice == '1':
1326 add_department()
1327 elif choice == '2':
1328 view_departments()
1329 elif choice == '3':
1330 send_notification()
1331 elif choice == '4':
1332 view_notifications()
1333 elif choice == '5':
1334 audit_report()
1335 elif choice == '6':
1336 break
1337 else:
1338 print('Invalid choice')
1339
1340 final_admin_module()

You might also like