-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfirmation.py
185 lines (139 loc) Β· 5.61 KB
/
confirmation.py
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
from telegram.ext import *
from telegram import *
import DatabaseConnector as db
import datetime
import menu as Menu
import order as Order
import basket as Basket
import location as LOCATION
import time
import restaurantSelection as Restaurant
item = []
quantity = [0]
price = [0]
tableRes = []
id = []
name = []
phoneNumber = []
numberOfOrder = []
def confirmation(update,context):
telegramUserName = update['message']['chat']['first_name']
username = telegramUserName.lower()+" basket"
now = datetime.datetime.now()
formatted_date = now.strftime('%Y-%m-%d %H:%M:%S')
print(formatted_date)
mycursor = db.mydb.cursor()
mycursor.execute(f"SELECT id,fullName,phoneNumber FROM clients WHERE userName='{telegramUserName}'")
result = mycursor.fetchall()
for x in result:
id.append(x[0])
name.append(x[1])
phoneNumber.append(x[2])
mycursor = db.mydb.cursor()
mycursor.execute(f"SELECT food,calculatePrice,price FROM `{username}`")
result = mycursor.fetchall()
for x in result:
numberOfOrder = x[1]
mycursor = db.mydb.cursor()
mycursor.execute(f"SELECT food,calculatePrice,price FROM `{username}`")
history = mycursor.fetchall()
for x in history:
NoOrder = x[1]
quantity[0] = quantity[0] + int(NoOrder[0])
item.append(x[0])
price[0] = price[0] + int(x[2])
newline="\n"
mycursor = db.mydb.cursor()
sql =f"INSERT INTO orders(Customer_Id,Customer_Name,Customer_Phone,Restaurant,Status,Item_Name,Quantity,price,Date,deliveryFee) values ('{id[0]}','{name[0]}','{phoneNumber[0]}','{tableRes[0]}','Pending','{newline.join(str(x) for x in LOCATION.food_holder)}','{quantity[0]}','{price[0]}','{formatted_date}','{LOCATION.deliveryFee[0]}')"
mycursor.execute(sql)
db.mydb.commit()
tableRes.pop()
id.pop()
name.pop()
phoneNumber.pop()
price[0] = 0
quantity[0] = 0
telegramUserName = update['message']['chat']['first_name']
username = telegramUserName.lower()+" basket"
mycursor = db.mydb.cursor()
sql = f"DROP TABLE `{username}`"
mycursor.execute(sql)
db.mydb.commit()
i = 0
while(i < len(Order.food_to_be_added_to_database)):
Order.food_to_be_added_to_database.pop()
while(i<len(Menu.table_forMenu)):
Menu.table_forMenu.pop()
while(i<len(Order.total_food_to_be_ordered)):
Order.total_food_to_be_ordered.pop()
while(i<len(Order.overAllPrice)):
Order.overAllPrice.pop()
while(i<len(LOCATION.food_holder)):
LOCATION.food_holder.pop()
while(i<len(Order.food_to_be_added_to_database)):
Order.food_to_be_added_to_database.pop()
while(i<len(item)):
item.pop()
update.message.reply_text(text="We will call you to confirm your orders.\nUntil then click this π /status to check the status of your order.")
def confirmationAmharic(update,context):
telegramUserName = update['message']['chat']['first_name']
username = telegramUserName.lower()+" basket"
now = datetime.datetime.now()
formatted_date = now.strftime('%Y-%m-%d %H:%M:%S')
mycursor = db.mydb.cursor()
mycursor.execute(f"SELECT id,fullName,phoneNumber FROM clients WHERE userName='{telegramUserName}'")
result = mycursor.fetchall()
for x in result:
id.append(x[0])
name.append(x[1])
phoneNumber.append(x[2])
mycursor = db.mydb.cursor()
mycursor.execute(f"SELECT food,calculatePrice,price FROM `{username}`")
result = mycursor.fetchall()
for x in result:
numberOfOrder = x[1]
mycursor = db.mydb.cursor()
mycursor.execute(f"SELECT food,calculatePrice,price FROM `{username}`")
history = mycursor.fetchall()
for x in history:
NoOrder = x[1]
quantity[0] = quantity[0] + int(NoOrder[0])
item.append(x[0])
price[0] = price[0] + int(x[2])
print(f"Price: {price[0]}")
newline="\n"
mycursor = db.mydb.cursor()
sql =f"INSERT INTO orders(Customer_Id,Customer_Name,Customer_Phone,Restaurant,Status,Item_Name,Quantity,price,Date,deliveryFee) values ('{id[0]}','{name[0]}','{phoneNumber[0]}','{tableRes[0]}','Pending','{newline.join(str(x) for x in LOCATION.food_holder)}','{quantity[0]}','{price[0]}','{formatted_date}','{LOCATION.deliveryFee[0]}')"
mycursor.execute(sql)
db.mydb.commit()
update.message.reply_text(text="α¨α₯αα π€ α¦α΅ α°α α
αα α΅ααα α₯ααα°αααα")
telegramUserName=update['message']['chat']['first_name']
username=telegramUserName.lower()+" basket"
mycursor = db.mydb.cursor()
sql = f"DROP TABLE `{username}`"
mycursor.execute(sql)
db.mydb.commit()
tableRes.pop()
id.pop()
name.pop()
phoneNumber.pop()
price[0] = 0
quantity[0] = 0
i = 0
while(i < len(Order.food_to_be_added_to_database)):
Order.food_to_be_added_to_database.pop()
while(i<len(Menu.table_forMenu)):
Menu.table_forMenu.pop()
while(i<len(Order.total_food_to_be_ordered)):
Order.total_food_to_be_ordered.pop()
while(i<len(Order.overAllPrice)):
Order.overAllPrice.pop()
while(i<len(Basket.food_holder)):
Basket.food_holder.pop()
while(i<len(LOCATION.food_holder)):
LOCATION.food_holder.pop()
# while(i<len(Order.food_to_be_added_to_database)):
# Order.food_to_be_added_to_database.pop()
while(i<len(item)):
item.pop()
Restaurant.restaruntSelectionAmharic(update, context)