forked from b1naryth1ef/Checkin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
145 lines (135 loc) · 2.84 KB
/
main.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
from time import *
import time
import random
import db, ui
import os, sys
def chky(uid):
x = db.checky(uid)
if x == None:
return False
else:
return True
def clear(numlines="100"):
if os.name == "posix":
# Unix/Linux/MacOS/BSD/etc
os.system('clear')
elif os.name in ("nt", "dos", "ce"):
# DOS/Windows
os.system('CLS')
else:
# Fallback for other operating systems.
print '\n' * numlines
def checkinmode():
clear()
ui.chk()
iny = raw_input("NAME: ")
if iny == ":EXIT":
home()
else:
pass
def markin(uid):
db.checkin(uid)
try:
x = db.find_user("name",iny)
if chky(x.id) is False:
markin(x.id)
ui.ok()
time.sleep(1)
checkinmode()
elif chky(x.id) is True:
ui.chkold()
time.sleep(1)
checkinmode()
else: #@error 003
ui.err("#003")
time.sleep(1)
checkinmode()
except AttributeError: #@Error 001
ui.fail()
time.sleep(1)
checkinmode()
except: #@error 002
#print sys.exc_info()[0]
ui.err("#002")
time.sleep(1)
sys.exit()
def home_newuser():
print "====================="
print "--->NEW USER MENU<---"
print "====================="
newfname = raw_input("NEW USER FIRST NAME: ")
if newfname == ":EXIT":
home()
else:
pass
newlname = raw_input("NEW USER LAST NAME: ")
today = raw_input("MARK PRESENT FOR TODAY [Y/N] ")
if today in ("Y","y"):
db.add_user(newfname,newlname,"1")
print "USER ADDED... PRESS [ENTER] TO GOTO HOMESCREEN"
raw_input()
elif today == ":EXIT":
home()
else:
db.add_user(newfname,newlname,"0")
print "USER ADDED... PRESS [ENTER] TO GOTO HOMESCREEN"
raw_input()
home()
def home_list():
print "====================="
print "--->LIST ALL MENU<---"
print "====================="
print "NAME CHECK-INS"
x = db.get_users()
for i in x:
z = len(i[2])
f = 14-z
l = " "*f
print i[2], l, i[4]
raw_input("Press [enter] to goto homescreen")
home()
def home_search():
def outy(iny):
print "NAME CHECK-INS"
y = 14 - len(iny.name)
l = " "*y
print iny.name, l, iny.checkins
print "====================="
print "---> SEARCH MENU <---"
print "====================="
do = raw_input("Search by [N]ame or [I]D ")
if do in ("N", "n"):
x = raw_input("Search by Full Name: ")
z = db.find_user("name",x)
outy(z)
elif do in ("I","i"):
x = raw_input("Search by ID: ")
z = db.find_user("id",x)
outy(z)
raw_input("Press [enter] to go home")
home()
def home_checkin():
checkinmode()
def home_edituser():
pass
def home():
clear()
print "[N]ew User"
print "[L]ist Users"
print "[S]earch"
print "[C]heck-in mode"
print "[E]dit user"
print "[Q]uit"
d = {'n': home_newuser,
'l': home_list,
's': home_search,
'c': home_checkin,
'e': home_edituser,
'q': sys.exit}
xin = raw_input("Input: ").lower()
if xin in d:
d[xin]()
else:
raw_input("Whoops... Didnt get that. Press [enter] to try again.")
home()
home()