-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo.py
More file actions
1281 lines (1107 loc) · 57.3 KB
/
demo.py
File metadata and controls
1281 lines (1107 loc) · 57.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import mysql.connector as mysql
import pymysql;
import maskpass
import re
from colored import fg, bg, attr
from tabulate import tabulate
from pyfiglet import Figlet
print(f"{fg(148)}Enter Username: " )
username = input()
# print( f"{fg(148)}Enter Password: " )
password = maskpass.askpass(mask="*")
try:
conn = pymysql.connect( host='localhost',
user=username,
password=password,
db='marino' )
except Exception as e:
print(f"{fg(1)} Invalid Credentials, Try again",e)
print("")
print("")
command_handler = conn.cursor()
# db = mysql.connect(host ="localhost",user = lines[0], password=lines[1],database="marino")
# command_handler = db.cursor(buffered=True)
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
Pattern = re.compile(r"(?:\+\d{3})?\d{3}\D?\d{4}")
#Admin Session
def admin_session():
# print("Login successfully, Welcome Admin!")
while 1:
print("")
print(f"{fg(23)}Welcome to Admin Panel")
print("")
print(f"{fg(148)}1.Staff Panel")
print(f"{fg(148)}2.Student Panel")
print(f"{fg(148)}3.Back")
print("")
user_option = input(str(f"{fg(99)}Option : "))
if user_option == "1":
while 1:
print("")
print("Staff Panel")
print("")
print(f"{fg(148)}1. Register new staff")
print(f"{fg(148)}2. Delete existing staff")
print(f"{fg(148)}3. Read existing staff")
print(f"{fg(148)}4. Update existing staff")
print("5. Back")
admin_user_option = input(str(f"{fg(99)}Option : "))
if admin_user_option == "1":
print("")
print(f"{fg(73)}Register New Staff")
print("")
# idstaff = input(str("ID: "))
emailid = input(str("Staff emailid: "))
if(re.fullmatch(regex, emailid)):
password = input(str("Staff password: "))
staff_name = input(str("Staff Name: "))
staff_age = input(str("Staff Age: "))
phone_number = input(str("Staff Phone Number: "))
if Pattern.match(phone_number):
# print("Valid")
query_vals = (staff_name,staff_age,phone_number,emailid,password)
command_handler.execute("call staff_reg(%s,%s,%s,%s,%s)",query_vals)
conn.commit()
print(emailid + f"{fg(2)} has been registered as a staff")
print("")
print(f"{fg(148)}Updated Staff Details")
print("")
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
command_handler.execute("Select * from staff")
# fetch all the matching rows
result = command_handler.fetchall()
columns = ['Staff ID', 'Staff name', 'Staff Age', 'Phone Number', "Email ID","Password"]
print(tabulate(result,headers=columns,tablefmt="grid"))
else:
print("Invalid Phone Number, Try again!")
break
# command_handler.execute("INSERT INTO marino.staff (staff_name,staff_age,phone_number,emailid,password) VALUES (%s,%s,%s,%s,%s)",query_vals)
else:
print("Invalid Email format, Try again")
break
elif admin_user_option == "2":
print("")
print(f"{fg(148)}Delete Existing Staff Account")
print("")
print("")
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
command_handler.execute("Select * from staff")
# fetch all the matching rows
result = command_handler.fetchall()
columns = ['Staff ID', 'Staff name', 'Staff Age', 'Phone Number', "Email ID","Password"]
print(tabulate(result,headers=columns,tablefmt="grid"))
emailid = input(str("Email ID: "))
password = input(str("Password: "))
query_vals = (emailid,password)
# command_handler.execute("DELETE FROM staff WHERE emailid = %s AND password = %s",query_vals)
command_handler.execute("call staff_del(%s,%s)",query_vals)
conn.commit()
if command_handler.rowcount < 1:
print("Staff not found")
else:
print("")
print(emailid + f"{fg(1)} has been deleted!")
print("")
print(f"{fg(148)}Updated Staff Details")
print("")
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
command_handler.execute("Select * from staff")
# fetch all the matching rows
result = command_handler.fetchall()
columns = ['Staff ID', 'Staff name', 'Staff Age', 'Phone Number', "Email ID","Password"]
print(tabulate(result,headers=columns,tablefmt="grid"))
elif admin_user_option == "3":
print("")
print(f"{fg(148)}All Existing Staff Details")
print("")
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
command_handler.execute("Select * from staff")
# fetch all the matching rows
result = command_handler.fetchall()
columns = ['Staff ID', 'Staff name', 'Staff Age', 'Phone Number', "Email ID","Password"]
print(tabulate(result,headers=columns,tablefmt="grid"))
# loop through the rows
# for row in result:
# print(f"{fg(5)}")
# print(row)
# print("\n")
conn.commit()
if command_handler.rowcount < 1:
print("")
print("No Staff found")
elif admin_user_option == "4":
print("")
print(f"{fg(148)}Update Existing Staff Details")
print("")
command_handler.execute("Select * from staff")
# fetch all the matching rows
result = command_handler.fetchall()
columns = ['Staff ID', 'Staff name', 'Staff Age', 'Phone Number', "Email ID","Password"]
print(tabulate(result,headers=columns,tablefmt="grid"))
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
update_idstaff = input(str("Staff ID to be updated: "))
staff_name = input(str("Staff Name: "))
staff_age = input(str("Staff Age: "))
phone_number = input(str("Staff Phone Number: "))
query_vals = (staff_name,staff_age,phone_number,update_idstaff)
command_handler.execute("Update staff SET staff_name = %s,staff_age=%s,phone_number=%s where idstaff=%s",query_vals)
conn.commit()
print("Updated Successfully!")
print("")
print(f"{fg(148)}Updated Staff Details")
print("")
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
command_handler.execute("Select * from staff")
# fetch all the matching rows
result = command_handler.fetchall()
columns = ['Staff ID', 'Staff name', 'Staff Age', 'Phone Number', "Email ID","Password"]
print(tabulate(result,headers=columns,tablefmt="grid"))
if command_handler.rowcount < 1:
print("")
print("No Staff found")
elif admin_user_option == "5":
break
else:
print("")
print("Invalid option!")
if user_option == "2":
while 1:
print("")
print(f"{fg(148)}User Panel")
print("")
print(f"{fg(148)}1. Register new user")
print(f"{fg(148)}2. Delete existing user")
print(f"{fg(148)}3. Read existing user")
print(f"{fg(148)}4. Update existing user")
print("5. Back")
client_user_option = input(str(f"{fg(99)}Option : "))
if client_user_option == "1":
print("")
print(f"{fg(148)}Register New User")
print("")
# idstaff = input(str("ID: "))
emailid = input(str("user emailid: "))
if(re.fullmatch(regex, emailid)):
password = input(str("user password: "))
first_name = input(str("First Name: "))
last_name = input(str("Last Name: "))
age = input(str("user Age: "))
phone_number = input(str("user Phone Number: "))
query_vals = (first_name,last_name,age,phone_number,emailid,password)
# command_handler.execute("INSERT INTO marino.user(first_name,last_name,age,phone_number,emailid,password) VALUES (%s,%s,%s,%s,%s,%s)",query_vals)
command_handler.execute("call user_reg(%s,%s,%s,%s,%s,%s)",query_vals)
conn.commit()
print(first_name + f"{fg(2)} has been registered as a User")
print("")
print(f"{fg(148)}Updated User Details")
print("")
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
command_handler.execute("Select * from user")
# fetch all the matching rows
result = command_handler.fetchall()
columns = ['User ID', 'First Name','Last Name', 'User Age', 'Phone Number', "Email ID","Password"]
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
else:
print("Invalid Email format, Try again")
break
elif client_user_option == "2":
print("")
print(f"{fg(148)}Delete Existing User Account")
print("")
emailid = input(str("Email ID: "))
password = input(str("Password: "))
query_vals = (emailid,password)
# command_handler.execute("DELETE FROM user WHERE emailid = %s AND password = %s",query_vals)
command_handler.execute("call user_del(%s,%s)",query_vals)
conn.commit()
if command_handler.rowcount < 1:
print("")
print("User not found")
else:
print(emailid + f"{fg(1)} has been deleted!")
print("")
print(f"{fg(148)}Updated User Details")
print("")
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
command_handler.execute("Select * from user")
# fetch all the matching rows
result = command_handler.fetchall()
columns = ['User ID', 'First Name','Last Name', 'User Age', 'Phone Number', "Email ID","Password"]
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
elif client_user_option == "3":
print("")
print(f"{fg(148)}All Existing User Details")
print("")
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
command_handler.execute("Select * from user")
# fetch all the matching rows
result = command_handler.fetchall()
columns = ['User ID', 'First Name','Last Name', 'User Age', 'Phone Number', "Email ID","Password"]
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
# loop through the rows
# for row in result:
# print(f"{fg(5)}")
# print(row)
# print("\n")
conn.commit()
if command_handler.rowcount < 1:
print("")
print("No User found")
elif client_user_option == "4":
print("")
print(f"{fg(148)}Update Existing User Details")
print("")
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
command_handler.execute("Select * from user")
# fetch all the matching rows
result = command_handler.fetchall()
columns = ['User ID', 'First Name','Last Name', 'User Age', 'Phone Number', "Email ID","Password"]
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
update_iduser = input(str("User ID to be updated: "))
first_name = input(str("User First Name: "))
last_name = input(str("User Last Name: "))
user_age = input(str("User Age: "))
phone_number = input(str("Staff Phone Number: "))
query_vals = (first_name,last_name,user_age,phone_number,update_iduser)
command_handler.execute("Update user SET first_name = %s,last_name=%s,age=%s,phone_number=%s where userid=%s",query_vals)
conn.commit()
print(f"{fg(2)}")
print(first_name + " Updated Successfully!")
print("")
print(f"{fg(148)}Updated User Details")
print("")
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
command_handler.execute("Select * from user")
# fetch all the matching rows
result = command_handler.fetchall()
columns = ['User ID', 'First Name','Last Name', 'User Age', 'Phone Number', "Email ID","Password"]
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
if command_handler.rowcount < 1:
print("")
print("No User found")
elif client_user_option == "5":
break
else:
print("")
print(f"{fg(1)}Invalid Option!")
elif user_option == "3":
break
#Staff Session
def staff_session(id):
while 1:
print("")
print(f"{fg(148)}Welcome to Staff Panel")
print("")
print("1.User Panel")
print("2.Locker Panel")
print("3.Equipment Panel")
print("4.Activity Panel")
print("5.Trainer Panel")
print("6.Back")
user_option = input(str(f"{fg(99)}Option : "))
if user_option == "1":
while 1:
print(" ")
print(f"{fg(73)}Welcome to User Panel")
print(" ")
print("1. Register new user")
print("2. Delete existing user")
print("3. Read existing user")
print("4. Update existing user")
print("5. Back")
u_option = input(str(f"{fg(99)} Option :"))
if u_option == "1":
print("")
print(f"{fg(73)}Register New User")
# idstaff = input(str("ID: "))
emailid = input(str("user emailid: "))
if(re.fullmatch(regex, emailid)):
password = input(str("user password: "))
first_name = input(str("First Name: "))
last_name = input(str("Last Name: "))
age = input(str("user Age: "))
phone_number = input(str("user Phone Number: "))
query_vals = (first_name,last_name,age,phone_number,emailid,password)
command_handler.execute("INSERT INTO marino.user(first_name,last_name,age,phone_number,emailid,password) VALUES (%s,%s,%s,%s,%s,%s)",query_vals)
conn.commit()
print(first_name + " has been registered as a User")
else:
print("Invalid Email format, Try again")
break
elif u_option == "2":
print("")
print(f"{fg(73)}Delete Existing User Account")
print("")
print(f"{fg(73)}All Existing User Details")
command_handler.execute("Select * from user")
columns = ['User ID', 'First Name','Last Name', 'User Age', 'Phone Number', "Email ID","Password"]
# fetch all the matching rows
result = command_handler.fetchall()
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
command_handler.execute ("Select userid, first_name,last_name,age,phone_number from user")
result = command_handler.fetchall()
columns = ['USER ID', 'First Name', 'Last Name','Age','Phone Number']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
userid = input(str("User ID: "))
query_vals = (userid,)
command_handler.execute("DELETE FROM user WHERE userid = %s",query_vals)
conn.commit()
if command_handler.rowcount < 1:
print("User not found")
else:
print(emailid + " has been deleted!")
print(f"{fg(73)}Updated User Details")
command_handler.execute("Select * from user")
columns = ['User ID', 'First Name','Last Name', 'User Age', 'Phone Number', "Email ID","Password"]
# fetch all the matching rows
result = command_handler.fetchall()
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
elif u_option == "3":
print("")
print(f"{fg(73)}All Existing User Details")
command_handler.execute("Select * from user")
columns = ['User ID', 'First Name','Last Name', 'User Age', 'Phone Number', "Email ID","Password"]
# fetch all the matching rows
result = command_handler.fetchall()
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
conn.commit()
if command_handler.rowcount < 1:
print("No User found")
elif u_option == "4":
print("")
print(f"{fg(148)}Update Existing User Details")
print("")
command_handler.execute ("Select userid, first_name,last_name,age,phone_number from user")
result = command_handler.fetchall()
columns = ['User ID', 'First Name', 'Last Name','Age','Phone Number']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
update_iduser = input(str("User ID to be updated: "))
first_name = input(str("User First Name: "))
last_name = input(str("User Last Name: "))
user_age = input(str("User Age: "))
phone_number = input(str("User Phone Number: "))
query_vals = (first_name,last_name,user_age,phone_number,update_iduser)
command_handler.execute("Update user SET first_name = %s,last_name=%s,age=%s,phone_number=%s where userid=%s",query_vals)
conn.commit()
if command_handler.rowcount < 1:
print("")
print("No User found")
else:
print(f"{fg(2)}")
print(first_name + " Updated Successfully!")
print(f"{fg(73)}All Existing User Details")
command_handler.execute("Select * from user")
columns = ['User ID', 'First Name','Last Name', 'User Age', 'Phone Number', "Email ID","Password"]
# fetch all the matching rows
result = command_handler.fetchall()
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
elif u_option == "5":
break
else:
print("")
print(f"{fg(1)}Invaliid Selection!")
elif user_option == "2":
while 1:
print(" ")
print(f"{fg(73)}Welcome to Locker Panel")
print("1. Create new locker")
print("2. Delete locker")
print("3. Assign a locker")
print("4. View all lockers")
print("5. Back")
l_option = input(str(f"{fg(99)}Option :"))
if l_option == "1":
print("")
print(f"{fg(73)}Create a new locker")
print(f"{fg(73)}Viewing a Locker")
command_handler.execute ("Select idlocker, type_of_locker,userid from locker")
result = command_handler.fetchall()
columns = ['Locker ID', 'Type of Locker', 'User ID']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
type_of_locker = input(str("Enter the type of Locker (Personal/Standard): "))
idstaff = id
# userid = input(str("Enter the user ID : "))
query_vals = (type_of_locker,idstaff)
# command_handler.execute("Insert into marino.locker(type_of_locker,idstaff,userid) values(%s,%s,0)",query_vals)
command_handler.execute("call locker_reg(%s,%s,0)",query_vals)
conn.commit()
print("New locker has been created!")
print(f"{fg(73)}Updated Locker")
command_handler.execute ("Select idlocker, type_of_locker,userid from locker")
result = command_handler.fetchall()
columns = ['Locker ID', 'Type of Locker', 'User ID']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
elif l_option == "2":
print("")
print(f"{fg(73)}Delete a locker")
command_handler.execute ("Select idlocker,type_of_locker from locker")
result = command_handler.fetchall()
columns = ['Locker ID', 'Type of Locker']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
idlocker = input(str("Enter the locker ID : "))
query_vals = (idlocker,)
# command_handler.execute("Delete from locker where idlocker = %s",query_vals)
command_handler.execute("call locker_del(%s)",query_vals)
conn.commit()
if command_handler.rowcount < 1:
print("Locker Not found")
else:
print(idlocker + " locker has been deleted successfully")
print(f"{fg(73)}Viewing a Locker")
command_handler.execute ("Select idlocker, type_of_locker,userid from locker")
result = command_handler.fetchall()
columns = ['Locker ID', 'Type of Locker', 'User ID']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
elif l_option == "3":
print("")
print(f"{fg(148)}Assign locker to a User")
print("")
print("Available Lockers")
command_handler.execute ("Select idlocker,type_of_locker,userid from locker where userid=0 ")
result = command_handler.fetchall()
columns = ['Locker ID', 'Type of Locker','user_id']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
update_iduser = input(str("User ID to be updated: "))
idlocker = input(str("Enter Locker ID : "))
query_vals = (update_iduser,idlocker)
command_handler.execute("Update locker SET userid=%s where idlocker=%s",query_vals)
conn.commit()
print(idlocker + " Updated Successfully!")
print(f"{fg(73)}Viewing a Locker")
command_handler.execute ("Select idlocker, type_of_locker,userid from locker")
result = command_handler.fetchall()
columns = ['Locker ID', 'Type of Locker', 'User ID']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
# todo add condition to handle incorrect value
# if command_handler.rowcount < 1:
# print("")
# print("No User found")
# else:
# print(f"{fg(2)}")
# print(idlocker + " Updated Successfully!")
elif l_option == "4":
print("")
print(f"{fg(73)}Viewing a Locker")
command_handler.execute ("Select idlocker, type_of_locker,userid from locker")
result = command_handler.fetchall()
columns = ['Locker ID', 'Type of Locker', 'User ID']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
# for row in result:
# print(row)
# print("\n")
conn.commit()
if command_handler.rowcount < 1:
print("Lockers not found!")
else:
print("Invalid option!")
elif l_option == "5":
break
else:
print(f"{fg(1)}Invaliid Selection!")
elif user_option == "3":
while 1:
print(" ")
print(f"{fg(73)}Welcome to Equipment Panel")
print("1. Add an equipment")
print("2. Delete an equipment")
print("3. View all equipments")
print("4. Assign an equipment")
print("5. Back")
e_option = input(str(f"{fg(99)}Option : "))
if e_option == "1":
print("")
print(f"{fg(73)}Add a new Equipment")
name = input(str("Name of the equipment: "))
idstaff = id
idactivity = 0
query_vals = (name,idstaff,idactivity)
# command_handler.execute("Insert into marino.equipment(name,idstaff,idactivity) values(%s,%s,%s)",query_vals)
command_handler.execute("call equipment_reg(%s,%s,%s)",query_vals)
conn.commit()
print("New equipment has been added!")
print("")
print(f"{fg(73)}Viewing all Equipments")
command_handler.execute ("Select idequipment,name,idactivity from equipment")
result = command_handler.fetchall()
columns = ['Equipment ID', 'Name of Equipment', 'Activity ID']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
elif e_option == "2":
print("")
print(f"{fg(73)}Remove an equipment")
command_handler.execute ("Select idequipment,name from equipment")
result = command_handler.fetchall()
columns = ['Equipment ID', 'Name of Equipment']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
idequipment = input(str("Enter the Equipment ID : "))
query_vals = (idequipment,)
# command_handler.execute("Delete from equipment where idequipment = %s",query_vals)
command_handler.execute("call equipment_del(%s)",query_vals)
conn.commit()
if command_handler.rowcount < 1:
print("Equipment Not found")
else:
print(idequipment + " equipment has been deleted successfully")
print(f"{fg(73)}Updated all Equipments")
command_handler.execute ("Select idequipment,name,idactivity from equipment")
result = command_handler.fetchall()
columns = ['Equipment ID', 'Name of Equipment', 'Activity ID']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
elif e_option == "3":
print("")
print(f"{fg(73)}Viewing all Equipments")
command_handler.execute ("Select idequipment,name,idactivity from equipment")
result = command_handler.fetchall()
columns = ['Equipment ID', 'Name of Equipment', 'Activity ID']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
# for row in result:
# print(row)
# print("\n")
conn.commit()
if command_handler.rowcount < 1:
print("Equipments not found!")
elif e_option == "4":
print("")
print(f"{fg(148)}Assign Equipment to a Activity")
print("")
command_handler.execute ("Select idequipment,name from equipment")
result_eqp = command_handler.fetchall()
columns = ['Equipment ID', 'Name of Equipment']
print(f"{fg(109)}")
print(tabulate(result_eqp,headers=columns,tablefmt="grid"))
command_handler.execute ("Select * from activity")
result_act = command_handler.fetchall()
columns = ['Activity ID', 'Name of Activity','Alloted Room']
print(f"{fg(109)}")
print(tabulate(result_act,headers=columns,tablefmt="grid"))
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
idactivity = input(str("Activity ID: "))
idequipment = input(str("Enter Equipment ID : "))
query_vals = (idactivity,idequipment)
command_handler.execute("Update equipment SET idactivity=%s where idequipment=%s",query_vals)
conn.commit()
print(idequipment + " Updated Successfully!")
print(f"{fg(73)}Viewing all Equipments")
command_handler.execute ("Select idequipment,name,idactivity from equipment")
result = command_handler.fetchall()
columns = ['Equipment ID', 'Name of Equipment', 'Activity ID']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
# todo add condition to handle incorrect value
# if command_handler.rowcount < 1:
# print("")
# print("No User found")
# else:
# print(f"{fg(2)}")
# print(idlocker + " Updated Successfully!")
elif e_option == "5":
break
else:
print(f"{fg(1)}Invaliid Selection!")
elif user_option == "4":
while 1:
print(" ")
print(f"{fg(73)}Welcome to Activity Panel")
print("1. Create an activity")
print("2. Delete an activity")
print("3. View all activity")
print("4. Update an activity")
print("5. Back")
a_option = input(str(f"{fg(99)}Option : "))
if a_option == "1":
print("")
print(f"{fg(73)}Create an activity")
name = input(str("Enter the name of the activity: "))
room_no = input(str("Enter the room number for the activity: "))
price = input(str('Enter activity rate: '))
query_vals = (name,room_no,price)
# command_handler.execute("Insert into marino.activity (name,room_no) values (%s,%s)",query_vals)
command_handler.execute("call activity_reg(%s,%s,%s)",query_vals)
conn.commit()
print("New Activity has been created!")
print(f"{fg(73)}Updated all activity")
command_handler.execute("SELECT idactivity,name,room_no,price from activity")
# command_handler.execute("SELECT a.idactivity,a.name,a.room_no,e.idequipment,e.name from activity as a JOIN equipment as e ON a.idactivity=e.idactivity;")
# query_vals = ()
# command_handler.execute("call activity_Equip_table()",query_vals)
result = command_handler.fetchall()
columns = ['Activity ID', 'Activity Name','Room Number',"Rate"]
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
elif a_option == "2":
print("")
print(f"{fg(55)}Delete an activity")
command_handler.execute ("Select idactivity,name,room_no,price from activity")
result_act = command_handler.fetchall()
columns = ['Activity ID', 'Name of Activity','Alloted Room','Rate']
print(f"{fg(109)}")
print(tabulate(result_act,headers=columns,tablefmt="grid"))
idactivity = input(str("Enter the acitvity ID: "))
query_vals = (idactivity,)
# command_handler.execute("Delete from activity where idactivity = %s", query_vals)
command_handler.execute("call activity_del(%s)",query_vals)
conn.commit()
if command_handler.rowcount < 1:
print("Activity doesn't exist")
else:
print("Activity has been deleted successfully!")
print(f"{fg(73)}Updated all activity")
command_handler.execute("SELECT idactivity,name,room_no,price from activity")
# command_handler.execute("SELECT a.idactivity,a.name,a.room_no,e.idequipment,e.name from activity as a JOIN equipment as e ON a.idactivity=e.idactivity;")
# query_vals = ()
# command_handler.execute("call activity_Equip_table()",query_vals)
result = command_handler.fetchall()
columns = ['Activity ID', 'Activity Name','Room Number',"Rate"]
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
elif a_option == "3":
print("")
print(f"{fg(73)}View all activity")
command_handler.execute("SELECT idactivity,name,room_no,price from activity")
# command_handler.execute("SELECT a.idactivity,a.name,a.room_no,e.idequipment,e.name from activity as a JOIN equipment as e ON a.idactivity=e.idactivity;")
# query_vals = ()
# command_handler.execute("call activity_Equip_table()",query_vals)
result = command_handler.fetchall()
columns = ['Activity ID', 'Activity Name','Room Number',"Rate"]
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
# for row in result:
# print (row)
conn.commit()
if command_handler.rowcount <1:
print("No details found")
elif a_option == "4":
print("")
print(f"{fg(148)}Assign Activity to a User")
print("")
command_handler.execute ("Select idactivity,name,room_no,price from activity")
result_act = command_handler.fetchall()
columns = ['Activity ID', 'Name of Activity','Alloted Room',"Rate"]
print(f"{fg(109)}")
print(tabulate(result_act,headers=columns,tablefmt="grid"))
# emailid = input(str("Email ID: "))
# query_vals = (emailid)
idactivity = input(str("Activity ID: "))
name = input(str("activity Name: "))
room_no = input(str("Enter Room ID : "))
query_vals = (room_no,name,idactivity)
command_handler.execute("Update activity SET room_no=%s,name=%s where idactivity=%s",query_vals)
conn.commit()
print(name + " Updated Successfully!")
print("")
print(f"{fg(73)}Updated all activity")
command_handler.execute("SELECT idactivity,name,room_no,price from activity")
# command_handler.execute("SELECT a.idactivity,a.name,a.room_no,e.idequipment,e.name from activity as a JOIN equipment as e ON a.idactivity=e.idactivity;")
# query_vals = ()
# command_handler.execute("call activity_Equip_table()",query_vals)
result = command_handler.fetchall()
columns = ['Activity ID', 'Activity Name','Room Number',"Rate"]
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
# todo add condition to handle incorrect value
# if command_handler.rowcount < 1:
# print("")
# print("No User found")
# else:
# print(f"{fg(2)}")
# print(idlocker + " Updated Successfully!")
elif a_option == "5":
break
else:
print("")
print(f"{fg(1)}Invaliid Selection!")
elif user_option == "5":
while 1:
print(" ")
print(f"{fg(73)}Welcome to Trainer Panel")
print("1. Create new trainer")
print("2. Remove trainer")
print("3. Assign a trainer")
print("4. View all trainers")
print("5. Back")
l_option = input(str(f"{fg(99)}Option :"))
if l_option == "1":
print("")
print(f"{fg(73)}Create a new trainer")
trainer_name = input(str("Enter Trainer name: "))
trainer_age = input(str("Enter Trainer age: "))
trainer_phoneNumber = input(str("Enter Trainer phone Number: "))
# userid = input(str("Enter the user ID : "))
query_vals = (trainer_name,trainer_age,trainer_phoneNumber)
# command_handler.execute("Insert into marino.locker(type_of_locker,idstaff,userid) values(%s,%s,0)",query_vals)
command_handler.execute("call trainer_reg(%s,%s,%s)",query_vals)
conn.commit()
print("New Trainer has been created!")
elif l_option == "2":
print("")
print(f"{fg(73)}Remove a Trainer")
print("")
print(f"{fg(73)}Viewing all Trainer")
command_handler.execute ("Select * from trainer")
result = command_handler.fetchall()
columns = ['Trainer ID', 'Trainer Name',"Trainer Age", 'Trainer Phone Number']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
trainer_id = input(str("Enter the Trainer ID : "))
query_vals = (trainer_id,)
# command_handler.execute("Delete from locker where trainer_id = %s",query_vals)
command_handler.execute("Delete from trainer where idtrainer = %s;",query_vals)
conn.commit()
if command_handler.rowcount < 1:
print("Trainer Not found")
else:
print(trainer_id + " trainer has been deleted successfully")
print("")
print(f"{fg(73)}Viewing all Trainer")
command_handler.execute ("Select * from trainer")
result = command_handler.fetchall()
columns = ['Trainer ID', 'Trainer Name',"Trainer Age", 'Trainer Phone Number']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
elif l_option == "3":
print("")
print(f"{fg(148)}Assign Trainer to a Activity")
print("")
print("Available Trainers")
command_handler.execute ("Select * from trainer")
result = command_handler.fetchall()
columns = ['Trainer ID', 'Trainer Name',"Trainer Age", 'Trainer Phone Number']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
# query_vals = (emailid)
update_iduser = input(str("Activity ID to be updated: "))
trainer_id = input(str("Enter Trainer ID : "))
query_vals = (update_iduser,trainer_id)
command_handler.execute("Update trainer SET idtrainer=%s where idactivity=%s",query_vals)
conn.commit()
print(update_iduser + " Updated Successfully!")
print("")
print(f"{fg(73)}Viewing Updated Trainer Data")
command_handler.execute ("Select * from trainer")
result = command_handler.fetchall()
columns = ['Trainer ID', 'Trainer Name',"Trainer Age", 'Trainer Phone Number']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
# todo add condition to handle incorrect value
# if command_handler.rowcount < 1:
# print("")
# print("No User found")
# else:
# print(f"{fg(2)}")
# print(idlocker + " Updated Successfully!")
elif l_option == "4":
print("")
print(f"{fg(73)}Viewing all Trainer")
command_handler.execute ("Select * from trainer")
result = command_handler.fetchall()
columns = ['Trainer ID', 'Trainer Name',"Trainer Age", 'Trainer Phone Number']
print(f"{fg(109)}")
print(tabulate(result,headers=columns,tablefmt="grid"))
# for row in result:
# print(row)
# print("\n")
conn.commit()
if command_handler.rowcount < 1:
print("Trainer not found!")
else:
print("Invalid option!")
elif l_option == "5":
break
else:
print(f"{fg(1)}Invalid Selection!")
elif user_option == "6":
break
else:
print(f"{fg(1)}Invalid Selection!")
#User session
def user_session(id):
while 1:
print(" ")
print(f"{fg(73)}Welcome to User Panel")
print(" ")
print(f"{fg(208)}1. Register new Activity")
print(f"{fg(208)}2. Delete existing activity")
print(f"{fg(208)}3. View your locker")
print(f"{fg(208)}4. View Bill")
print(f"{fg(208)}5. Update User details")
print(f"{fg(208)}9. Logout")
user_option = input(str("Option : "))
if user_option == "1":