-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestaurant Management System_MySQL_Connector.py
More file actions
1111 lines (836 loc) · 36.8 KB
/
Restaurant Management System_MySQL_Connector.py
File metadata and controls
1111 lines (836 loc) · 36.8 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 ms
import time
con,cur=None,None
name=None
typ=None
diet=''
price=None
side=None
custPhone=None
cnt=0 #variable used to iterate through numbers and printed on screen as serial numbers
dic = {} # WILL BE --> dic = {<order no.> : [<dish name>,<price>,<diet>]}
custOrd = {}#WILL BE --> custOrd = {<order no.> : [[<dish name>,<price>,<diet>],<frequency>]}
#variables for checking orders and used in order function
m=[]
mtemp=[]
#default timings set here
openBreakfast=7
closeBreakfast=12
openLunch=13
closeLunch=17
openDinner=17
closeDinner=24
#variable to check whether items show up on menu list during ordering. if not, then appropriate message will be stored in chk variable
chk=None
def nothing(inpt): # function to check whether no input is entered
if inpt.strip()=='':
return True
def nameF(): # function to input dish name
global name
name = input('Enter dish name: ')
name=name.strip()
name=name.capitalize()
if nothing(name)==True:
print("\nPlease enter a valid input.\nEnter values again!")
nameF()
def typF(): # function to input the type of dish (i.e. whether it is breakfast,lunch,dinner,appetizer or beverage)
global typ
#print(typ)
typ=None
typ = input('Input dish type(s) seperated by a comma without space (breakfast,lunch,dinner,appetizer,beverage)\nEg: breakfast,lunch,dinner (or) lunch,dinner\nEnter: ')
typ = typ.lower()
if nothing(typ)==True:
print("\nPlease enter a valid input.\nEnter values again!")
typF()
n = typ.split(',')# splitting the input string so that it can be iterated through by the below for loop so that it can be checked
l=[]
for i in range(len(n)):
indish = str(n[i])
if indish=='breakfast' or indish=='lunch' or indish=='dinner' or indish=='appetizer' or indish== 'beverage':
continue
else:
print("Invalid input - Enter only given dish types without space")
print("Enter inputs again!")
typF()
#converting the splitted list back into the string after checking
for i in n:
l+=[i.strip()]
typ=''
for i in range(len(l)):
if i==(len(l)-1):
typ=typ+l[i]
else:
typ=typ+l[i]+','
def dietF(): # function to input the dish nature (i.e. whether it is veg or nonveg)
global diet
diet = input("Enter either vegeterian or non-vegeterian (v/nv): ")
diet=diet.strip()
diet=diet.lower()
if nothing(diet)==True:
print("\nPlease enter a valid input.\nEnter values again!")
dietF()
# to check whether entered input is only under the given options (i.e. only veg or nonveg options)
while diet!='v' and diet!='nv':
print("\nInvalid Diet inputs",end='')
print("Enter inputs again!\n")
dietF()
def sideF():# funciton to input whether the dish is sidedish or not
global side
side = input("Enter whether side dish or not (y/n): ")
if nothing(side)==True:
print("\nPlease enter a valid input.\nEnter values again!")
sideF()
# to check whether entered input is only under the given options (i.e. whether it is sidedish or not)
while side!='y' and side!='n':
print("\nInvalid inputs")
print("Enter inputs again!\n")
sideF()
def priceF():#function to input the price of dish
global price
price = input("Enter price: ")
if nothing(price)==True:
print("\nPlease enter a valid input.\nEnter values again!")
priceF()
# ensuring that the given input is only a number
while price.isnumeric()!=True:
print("Invalid Price inputs")
print("Enter inputs again")
priceF()
price=int(price)
def admin():# admin operations function
print('-'*153,'\n1 - Display Dishes\n\n2 - Add Dishes\n\n3 - Remove Dishes\n\n4 - Set Dish availability\n\n5 - Change availability timings\n\n6 - Order Reports\n\n7 - Switch users or to quit application\n\n',sep='')
try:
ask = input("Enter your choice: ") #Asking admin to pick one of the following actions <----------------------------
if nothing(ask)==True:
print("\nPlease enter a valid input.\nEnter values again!")
admin()
#checking whether entered input is only a number
try:
ask = int(ask)
except ValueError:
print("Enter a number only")
print("Enter values again!")
admin()
if ask==1: # Displaying the dishes <---------------------------------
cur.fetchall()#fetching all to discard any results of previous select commands that gives output
cur.execute('select * from custMenu') #checking whether any dishes are available in menu in order to perform the above action
n=cur.fetchall()
if n==[]:
print("\nNo dishes available to display")
print("Add some dishes to be displayed\n")
admin()
print("\nDishes:\n") #Displaying the retrieved records <---------------------------------
for i in n:
print(i[0],' - ',i[1],end=' - ')
if i[2]=='v':
print("vegetarian",end=' ')
else:
print("nonvegetarian",end=' ')
if i[4]==1:
print("side dish",end=' - ')
else:
print("dish",end = ' - ')
print("price:",i[3])
print('\n','-'*153,sep='')
admin()
elif ask ==2: # Adding dishes <--------------------------------------
add()
ask = input("\nPress enter to go back to admin screen")
if ' 'in ask or '' in ask:
admin()
elif ask ==3:#Deleting dishes <--------------------------------------
cur.fetchall()#fetching all to discard any results of previous select commands that gives output
cur.execute('select * from custMenu') #checking whether any dishes are available in menu in order to perform the above action
n=cur.fetchall()
if n==[]:
print("\nNo dishes available to delete")
admin()
delete()
ask = input("\nPress enter to go back to admin screen")
if ' 'in ask or '' in ask:
admin()
elif ask==4:#Changing dish availaiblity <-----------------------------------------
cur.fetchall()#fetching all to discard any results of previous select commands that gives output
cur.execute('select * from custMenu') #checking whether any dishes are available in menu
n=cur.fetchall()
if n==[]:
print("\nNo dishes available to change availability")
print("Add some dishes to change their availability\n")
admin()
set_availability()
ask = input("\nPress enter to go back to admin screen")
if ' 'in ask or '' in ask:
admin()
elif ask==5: #Changing availability timings <--------------------------------------
change_timings()
ask = input("\nPress enter to go back to admin screen")
if ' 'in ask or '' in ask:
admin()
elif ask==6:# ORDER REPORTS HERE <--------------------------------------
orderReport()
ask = input("\nPress enter to go back to admin screen")
if ' 'in ask or '' in ask:
admin()
elif ask==7: #Switching users (admin,customer,delivary) <-----------------------------------------
choose()
ask = input("\nPress enter to switch users or quit application")
if ' 'in ask or '' in ask:
choose()
else:
print("Invalid input\nEnter inputs again!\n",'-'*153,sep='',end='')
admin()
except:
print('Unknown Erorr - admin portal')
print("Enter inputs again!\n",'-'*153,sep='',end='')
admin()
def add():
global name,typ,diet,price,side
print('\n','-'*153,sep='')
try:
# first asking user to enter the inputs <-------------------------------------------
nameF()
#ensuring the length of the dish is not above the length limit according to the table in the database
if len(name)>30:
print("Invalid input - Length of dish too long")
print("Enter inputs again!\n",'-'*153,sep='',end='')
add()
#checking whether the entered input is only alphabetical characters
l=[]
l=name.split()
for i in l:
if i.isalpha()==False:
print("\nPlease enter a text or string")
print("Enter inputs again!\n",'-'*153,sep='',end='')
add()
#checking whether entered dish is already in the database
cur.fetchall()#fetching all to discard any results of previous select commands that gives output
cur.execute("select count(1) from custMenu where dish=%s;",(name,))
rec_cnt=cur.fetchone()
if rec_cnt[0]>0:
print("\nDish already exists")
print("Enter inputs again!\n",'-'*153,sep='',end='')
add()
typF() # asking the availability of dish
dietF()# asking the diet type of dish
#asking for price of dish and checking for proper price inputs
while True:
try:
priceF()
price=round(float(price),2)
break
except:
print("\nInvalid Price inputs",end='')
print("Enter inputs again!\n")
#asking whether dish is side dish or not and converting yes and no into 1 or 0 so it can be a boolean value that can be stored in table of database
sideF()
side=side.lower()
if side=='y':
side=1
else:
side=0
#updating the inputs to the database <-------------------------------------------
cur.execute('insert into custMenu(dish,availability,diet,price,side) values(%s,%s,%s,%s,%s)',(name.capitalize(),typ,diet,price,side))
con.commit() #commiting the values stored in cursor to the database <----------------------------------------
print("Added to database's table!\n",'-'*153,sep='')
ask = input("\nPress enter to go back to admin screen")
if ask.strip()=='':
admin()
except:
print("\nUnknown Error - adding dish")
print("Enter all inputs again!\n")
add()
def delete(): #function to delete a dish from the table of database
print('\n','-'*153,sep='')
nameF()# first asking for dish name to be deleted
cur.fetchall()#fetching all to discard any results of previous select commands that gives output
cur.execute("select dish from custMenu;")
try:
for i in cur.fetchall():
if name in i:
cur.execute("delete from custMenu where dish = %s",(name,))
cur.execute("commit")
print("Dish removed\n",'-'*153,sep='',end='')
break
else:
print("\nDish not found")
print("Enter inputs again!\n",'-'*153,sep='',end='')
delete()
except:
print("\nUnknown Error - deleting dish")
print("Enter inputs again!\n",'-'*153,sep='',end='')
delete()
def set_availability(): #funciton to change the availability of the dish
print('\n','-'*153,sep='')
print('-'*153,"\nEnter name of dish to change the availability",sep='')
nameF()# first asking for name of dish so that availability can be changed
cur.fetchall()#fetching all to discard any results of previous select commands that gives output
cur.execute("select dish from custMenu;")
try:
for i in cur.fetchall():
if name in i:
typF()# secondly asking for new availability of dish
cur.execute("update custMenu set availability=(%s) where dish=%s",(typ,name) )
print('\nDish availability changed!\n','-'*153,sep='',end='')
cur.execute('commit')
break
else:
print("\nDish not found")
print("Enter inputs again!\n",sep='',end='')
set_availability()
except:
print("Unknown Error - setting availability")
print("Enter inputs again!\n",'-'*153,sep='',end='')
set_availability()
def orderAgain():#function to ask whether the customer would like to order again
while True:
ask = input("Would you like to order again (y/n)?: ")
if nothing(ask)==True:
print("\nPlease enter a valid input.\nEnter values again!")
orderAgain()
if ask in 'yY':
customer()
elif ask in 'nN':
bill()
else:
print("\nInvalid inputs")
print("Enter inputs again!\n",'-'*153,sep='')
orderAgain()
break
def anotherOrder():#function to ask whether another order can be taken on device again after an order has been billed
while True:
again = input("\n\nWould you like the device to taken another order again (y/n)?: ")
if nothing(again)==True:
print("\nPlease enter a valid input.\nEnter values again!")
anotherOrder()
if again in 'yY':
print('\n'*50)
customer()
elif again in 'nN':
pass
else:
print("\nInvalid inputs")
print("Enter inputs again!\n",'-'*153,sep='')
anotherOrder()
break
def customer():#function that shows customer view of the menu
global chk
print('\n','-'*153,sep='')
global cnt
cnt=0
menu()
if chk==False:
print("Sorry no dishes available. We apologize for the inconvenience. Please report this to the manager")
ask = input("\nPress enter to go back to main screen")
if ask.strip()=='':
choose()
order()
orderAgain()
anotherOrder()
ask = input("\nPress enter to go back to main screen")
if ask.strip()=='':
choose()
def breakfastTimings():#function to change the breakfast timings
global openBreakfast,closeBreakfast
try:
openBreakfast = input("Enter breakfast open time hour (24 hour time format): ")
if openBreakfast.isnumeric=='False':
print("Enter a number only!")
print("Enter input again\n")
breakfastTimings()
if len(openBreakfast)>2:
print("No. of hours cannot be more than 24!")
print("Enter input again\n")
breakfastTimings()
closeBreakfast = input("Enter breakfast close time hour (24 hour time format): ")
if closeBreakfast.isnumeric=='False':
print("Enter a number only!")
print("Enter input again\n")
breakfastTimings()
if len(closeBreakfast)>2:
print("No. of hours cannot be more than 24!")
print("Enter input again\n")
breakfastTimings()
if int(openBreakfast)>int(closeBreakfast):
print("Opening time cannot be more than closing time! ")
print("Enter input again\n")
breakfastTimings()
except:
print("Unencountered Error occurred! - Changing breakfast timings")
print("Please enter inputs again")
breakfastTimings()
openBreakfast = int(openBreakfast)
closeBreakfast = int(closeBreakfast)
def lunchTimings():#function to change the lunch timings
global openLunch, closeLunch
try:
openLunch = input("Enter lunch open time hour (24 hour time format): ")
if not openLunch.isnumeric():
print("Enter a number only!")
print("Enter input again\n")
lunchTimings()
if len(openLunch) > 2:
print("No. of hours cannot be more than 24!")
print("Enter input again\n")
lunchTimings()
closeLunch = input("Enter lunch close time hour (24 hour time format): ")
if not closeLunch.isnumeric():
print("Enter a number only!")
print("Enter input again\n")
lunchTimings()
if len(closeLunch) > 2:
print("No. of hours cannot be more than 24!")
print("Enter input again\n")
lunchTimings()
if int(openLunch) > int(closeLunch):
print("Opening time cannot be more than closing time! ")
print("Enter input again\n")
lunchTimings()
#breakfast and lunch timings can be coincided because of peculier timing called "brunch" where breakfast and lunch are eaten at once
if int(openLunch) < int(openBreakfast):
print("Lunch Timings are conflicting with breakfast timings!")
print("Enter input again\n")
lunchTimings()
if int(closeLunch) < int(closeBreakfast):
print("Lunch Timings are conflicting with breakfast timings!")
print("Enter input again\n")
lunchTimings()
except:
print("An unexpected error occurred! - Changing lunch timings ")
print("Please enter inputs again")
lunchTimings()
openLunch = int(openLunch)
closeLunch= int(closeLunch)
def dinnerTimings():#function to change the dinner timings
global openDinner, closeDinner
try:
openDinner = input("Enter dinner open time hour (24-hour time format): ")
if not openDinner.isnumeric():
print("Enter a number only!")
print("Enter input again\n")
dinnerTimings()
if len(openDinner) > 2:
print("No. of hours cannot be more than 24!")
print("Enter input again\n")
dinnerTimings()
closeDinner = input("Enter dinner close time hour (24-hour time format): ")
if not closeDinner.isnumeric():
print("Enter a number only!")
print("Enter input again\n")
dinnerTimings()
if len(closeDinner) > 2:
print("No. of hours cannot be more than 24!")
print("Enter input again\n")
dinnerTimings()
if int(openDinner) > int(closeDinner):
print("Opening time cannot be more than closing time! ")
print("Enter input again\n")
dinnerTimings()
if int(openDinner) in range(int(openBreakfast),int(closeBreakfast)):
print("Dinner Timings are conflicting with breakfast timings!")
print("Enter input again\n")
dinnerTimings()
if int(closeDinner) in range(int(openBreakfast),int(closeBreakfast)):
print("Dinner Timings are conflicting with breakfast timings!")
print("Enter input again\n")
dinnerTimings()
if int(openDinner) in range(int(openLunch),int(closeLunch)):
print("Dinner Timings are conflicting with lunch timings!")
print("Enter input again\n")
dinnerTimings()
if int(closeDinner) in range(int(openLunch),int(closeLunch)):
print("Dinner Timings are conflicting with lunch timings!")
print("Enter input again\n")
dinnerTimings()
if int(openDinner) < int(openLunch) or int(openDinner) < int(closeLunch):
print("Lunch Timings are conflicting with breakfast timings!")
print("Enter input again\n")
dinnerTimings()
if int(closeDinner) < int(openBreakfast) or int(closeDinner) < int(closeLunch):
print("Lunch Timings are conflicting with breakfast timings!")
print("Enter input again\n")
dinnerTimings()
except:
print("An unexpected error occurred! - Changing dinner timings")
print("Please enter inputs again")
dinnerTimings()
openDinner = int(openDinner)
closeDinner = int(closeDinner)
def change_timings(): #function to change the timings
print('\n','-'*153,sep='')
breakfastTimings()
lunchTimings()
dinnerTimings()
def breakfast(n):#function to display the breakfast items
global dic
global cnt
global chk
print("BREAKFAST\n")
chk="No breakfast available - We apologize for the inconvenience\n\n"
for i in range(len(n)):
if "breakfast" in n[i][1]:
cnt += 1
print(cnt, '. ', n[i][0], ' - \u20B9', n[i][3], end=' - ')
if n[i][4] == 1:
print("sidedish - ", end='')
if n[i][2] == 'v':
print("veg")
dic[cnt] = [n[i][0], n[i][3], 'veg']
else:
print('nonveg')
dic[cnt] = [n[i][0], n[i][3], 'nonveg']
if i == len(n) - 1:
cnt = i
if "breakfast" in n[i][1]:
chk=None
continue
print()
def lunch(n):# function to display the lunch items
global cnt
global dic
global chk
print("LUNCH\n")
chk="No lunch available - We apologize for the inconvenience\n\n"
for i in range(len(n)):
if "lunch" in n[i][1]:
cnt += 1
print(cnt, '. ', n[i][0], ' - \u20B9', n[i][3], end=' - ')
if n[i][4] == 1:
print("sidedish - ", end='')
if n[i][2] == 'v':
print("veg")
dic[cnt] = [n[i][0], n[i][3], 'veg']
else:
print('nonveg')
dic[cnt] = [n[i][0], n[i][3], 'nonveg']
if i == len(n) - 1:
cnt = i
if "lunch" in n[i][1]:
chk=None
continue
print()
def dinner(n):# function to display the dinner items
global cnt
global dic
global chk
print("DINNER\n")
chk="No dinner available - We apologize for the inconvenience\n\n"
for i in range(len(n)):
if "dinner" in n[i][1]:
cnt += 1
print(cnt, '. ', n[i][0], ' - \u20B9', n[i][3], end=' - ')
if n[i][4] == 1:
print("sidedish - ", end='')
if n[i][2] == 'v':
print("veg")
dic[cnt] = [n[i][0], n[i][3], 'veg']
else:
print('nonveg')
dic[cnt] = [n[i][0], n[i][3], 'nonveg']
if i == len(n) - 1:
cnt = i
if "dinner" in n[i][1]:
chk=None
continue
print()
def appetizer(n):# function to display the appetizer items
global cnt
global dic
global chk
print("APPETIZERS\n")
chk="No appetizers available - We apologize for the inconvenience\n\n"
for i in range(len(n)):
if "appetizer" in n[i][1]:
cnt += 1
print(cnt, '. ', n[i][0], ' - \u20B9', n[i][3], end=' - ')
if n[i][4] == 1:
print("sidedish - ")
if n[i][2] == 'v':
print("veg")
dic[cnt] = [n[i][0], n[i][3], 'veg']
else:
print('nonveg')
dic[cnt] = [n[i][0], n[i][3], 'nonveg']
if i == len(n) - 1:
cnt = i
if "appetizer" in n[i][1]:
chk=None
continue
print()
def beverage(n):#funciton to display the beverage items
global cnt
global dic
global chk
print("BEVERAGES\n")
chk="No beverage available - We apologize for the inconvenience\n\n"
for i in range(len(n)):
if "beverage" in n[i][1]:
cnt += 1
print(cnt, '. ', n[i][0], ' - \u20B9', n[i][3], end=' - ')
if n[i][2] == 'v':
print("veg")
dic[cnt] = [n[i][0], n[i][3], 'veg']
else:
print('nonveg')
dic[cnt] = [n[i][0], n[i][3], 'nonveg']
if i == len(n) - 1:
cnt = i
if "beverage" in n[i][1]:
chk = None
continue
print()
def menu():#function that shows the menu to the customer
cur.fetchall()#fetching all to discard any results of previous select commands that gives output
cur.execute('select * from custMenu')
fetchAll = cur.fetchall()
print("\n------------------------------------------------------------------------MENU------------------------------------------------------------------------\n")
curr_time = time.strftime("%H:%M:%S", time.localtime())
#displaying appropriate availibities at appropriate timings
global chk
count=0
chkCount=0
while True:
if openDinner<=int(curr_time[:2])<=closeDinner :
dinner(fetchAll)
count+=1
if chk==None:
chk=''
else:
chkCount+=1
print(chk)
appetizer(fetchAll)
count+=1
if chk==None:
chk=''
else:
chkCount+=1
print(chk)
beverage(fetchAll)
count+=1
if chk==None:
chk=''
else:
chkCount+=1
print(chk)
break
elif openLunch<=int(curr_time[:2])<closeLunch :
lunch(fetchAll)
count+=1
if chk==None:
chk=''
else:
chkCount+=1
print(chk)
appetizer(fetchAll)
count+=1
if chk==None:
chk=''
else:
chkCount+=1
print(chk)
beverage(fetchAll)
count+=1
if chk==None:
chk=''
else:
chkCount+=1
print(chk)
break
elif closeBreakfast<=int(curr_time[:2])<openLunch :
breakfast(fetchAll)
count+=1
if chk==None:
chk=''
else:
chkCount+=1
print(chk)
lunch(fetchAll)
count+=1
if chk==None:
chk=''
else:
chkCount+=1
print(chk)
appetizer(fetchAll)
count+=1
if chk==None:
chk=''
print(chk)
beverage(fetchAll)
count+=1
if chk==None:
chk=''
else:
chkCount+=1
print(chk)
break
elif openBreakfast<=int(curr_time[:2])<closeBreakfast :
breakfast(fetchAll)
count+=1
if chk==None:
chk=''
else:
chkCount+=1
print(chk)
beverage(fetchAll)
count+=1
if chk==None:
chk=''
else:
chkCount+=1
print(chk)
break
else:
print("No dishes available - We apologize for the inconvenience")
break
if chkCount ==0 and count==0:
pass
elif chkCount==count:
chk=False
def order():#function to store the customer order inputs
global dic
global custOrd
global m,mtemp
mtemp=m.copy()
inp=input("\n-------------------------------------------------------------------------\n\nPlease enter order numbers seperated by a comma without any spacing\nFor more than one item of same order,simply enter the numbers again in the same way!: ")
if nothing(inp)==True:
print("\nPlease enter a valid input.\nEnter values again!")
order()
if inp.strip()=='':
print("\nPlease provide a valid input")
mtemp=[]
order()
#Below code is to verify if the customer entered values are in the menu list from DB
mtemp += inp.split(',')
if mtemp[-1]=='':
mtemp.pop()
x = None
for i in mtemp:
if i=='':
mtemp.remove(i)
if i.isnumeric()==False:
print("\nEnter numbers only seperated by a comma without any spacing! ")
print("Enter values again\n")
mtemp=[]#Check if we to use mtemp later
order()
menuNos = list(dic.keys())
for i in mtemp:
if int(i) not in menuNos:
print("\nDish no. not in menu!")
print("Please enter all inputs again!")
mtemp=[]
order()
m=mtemp.copy()
for i in m:
if m.count(i)>1:
x=dic[int(i)]
custOrd[int(i)]=[x,m.count(i)] #<------------------- takes cares of quantity
continue
x=dic[int(i)]
custOrd[int(i)]=[x,1]
def phone():#function to store customer phone number
global custPhone
custPhone = input("\n\nPlease Enter your Phone Number without any space: ")
if nothing(custPhone)==True:
print("\nPlease enter a valid input.\nEnter values again!")
phone()
if custPhone=='0000000000':
print("Enter a correct phone number")
phone()
if (custPhone.isnumeric and len(custPhone)==10) == False:
print("Enter a correct phone number")
phone()
def bill():# function to bill the customer orders
print('\n','-'*153,sep='')
print('Dishes Ordered Price Quantity Subtotal')
x = 0
for i in custOrd:
x+=1
print(x,'. ',custOrd[i][0][0],' '*(24-len(custOrd[i][0][0])),'\u20B9',custOrd[i][0][1],' '*(28-len(str(custOrd[i][0][1]))),custOrd[i][1],' ','\u20B9',(custOrd[i][0][1])*custOrd[i][1])
phone()
cur.execute('insert into custorder(custPhone) values(%s)',(custPhone,))
cur.fetchall()#fetching all to discard any results of previous select commands that gives output
cur.execute('select max(ordID) from custorder where custPhone=%s and ordDate',(custPhone,))
ordID=cur.fetchone()[0]