-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_out.py
More file actions
129 lines (109 loc) · 5.27 KB
/
check_out.py
File metadata and controls
129 lines (109 loc) · 5.27 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
from twilio.rest import Client
import mysql.connector
import smtplib
import phonenumbers
from phonenumbers import carrier
from phonenumbers.phonenumberutil import number_type
from validate_email import validate_email
from sql_data import *
from checkout_screen import *
# Establishing the connection
mydb = mysql.connector.connect(host="localhost", user=str(username), passwd=str(sql_password), database="details")
# The function that wil work for checking-out
def check_out1(vmail):
vmail_info = vmail.get()
# Validating non-empty entries
if(validate_email(vmail_info,verify = True)):
cursor3 = mydb.cursor()
qry = "select * from Office where vis_mail = %s"
cursor3.execute(qry, (vmail_info,))
fe = cursor3.fetchall()
temp = 1
for i in fe:
nm = i[0]
em = i[1]
no = i[2]
nm1= i[5]
em1= i[6]
no1= i[7]
cin= i[3]
cout= i[4]
# Validating that the user has checked-in
if em == vmail_info:
temp = 2
if(temp==1):
tkinter.messagebox.showerror("ERROR!","Please check-in first")
else:
# Validating that user has not been checked-out
if cout:
tkinter.messagebox.showerror("ERROR!","You have already checked out")
else:
# Validating Correct Visitor email-id
if(validate_email(vmail_info,verify = True)):
txt = "The details of your last meeting.\n"
#Updating the check-out time of the user who has checked out
sql1 = "update Office set check_out = NOW() where vis_mail = %s and check_out is NULL"
cursor3.execute(sql1,(vmail_info,))
#Saving the changes made in the database
mydb.commit()
# Retrieving details of the user who has checked-out
# Name of the visitor
qry1 = "select vis_name from Office where vis_mail=%s"
cursor3.execute(qry1, (vmail_info,))
dis_name = ""
for i in cursor3:
dis_name = str(i[0])
# Contact No. of the Visitor
qry2 = "select vis_mob from Office where vis_mail=%s"
cursor3.execute(qry2, (vmail_info,))
dis_mob = ""
for i in cursor3:
dis_mob = str(i[0])
# Check-in time of the visitor
qry3 = "select check_in from Office where vis_mail=%s"
cursor3.execute(qry3, (vmail_info,))
cin_time = ""
for i in cursor3:
cin_time = str(i[0])
# Check-out time of the visitor
qry4 = "select check_out from Office where vis_mail=%s"
cursor3.execute(qry4, (vmail_info,))
cout_time = ""
for i in cursor3:
cout_time = str(i[0])
# Host name with whom Visiter mate
qry5 = "select host_name from Office where vis_mail=%s"
cursor3.execute(qry5, (vmail_info,))
host_nm = ""
for i in cursor3:
host_nm = str(i[0])
# Host e-mail with whom Visiter mate
qry6 = "select host_mail from Office where vis_mail=%s"
cursor3.execute(qry6, (vmail_info,))
host_ml = ""
for i in cursor3:
host_ml = str(i[0])
# Host contact no. with whom Visiter mate
qry7 = "select host_mob from Office where vis_mail=%s"
cursor3.execute(qry7, (vmail_info,))
host_mb = ""
for i in cursor3:
host_mb = str(i[0])
# Message displayed in the e-mail
info = "Name: " + dis_name + "\nPhone No.: " + dis_mob + "\nCheck In time: " + cin_time + "\n" \
"Check Out time: " + cout_time + "\nHost Name: " + host_nm + "\nHost E-mail: " + host_ml + "\n" \
"Host Mobile No.: " + host_mb + "\nAddress: Innovacer Office"
# Sending e-mail to the visitor about the details of the meeting
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login(gmailid, password)
txt += info
server.sendmail(gmailid, vmail_info, txt)
# Showing confirmation of check-out
tkinter.messagebox.showinfo("SAVED", "Your have successfully checked-out!")
# Handling all the exceptions
else:
tkinter.messagebox.showerror("ERROR!","Please enter correct visitor e-mail id")
else:
tkinter.messagebox.showerror("ERROR!","Please enter correct visitor email-id")