/
lillystats.py
117 lines (98 loc) · 1.92 KB
/
lillystats.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
import sys
import json
import MySQLdb
import utils
def index(req):
grand_total = utils.select('''
SELECT total, dtotal
FROM nd_tots
WHERE dat = date(now());''',
incursor=None,
label=False
)
seven_day_total1 = utils.select('''
SELECT sum(total) night, sum(dtotal) lunch
FROM nd_tots
WHERE dat > now() - INTERVAL '7' DAY''',
incursor=None,
label=False
)
seven_day_total2 = utils.select('''
SELECT sum(total) night, sum(dtotal) lunch
FROM nd_tots
WHERE dat > now() - INTERVAL '8' DAY''',
incursor=None,
label=False
)
in_out1 = utils.select('''
SELECT last_name,
time_in,
time_out
from hours_worked
where date(intime) = date(now())
order by intime;''',
incursor=None,
label=False
)
in_out2 = utils.select('''
SELECT last_name,
time_in,
time_out
from hours_worked
where date(intime) = date(now() - INTERVAL '1' DAY)
order by intime;''',
incursor=None,
label=False
)
fw_stats = utils.select('''
SELECT dname, dat,
comped,
wine_tot,
n_tot,
wine_pct
from fw_tots_and_staff
WHERE dat > now() - INTERVAL '7' DAY
ORDER by dat desc;''',
incursor=None,
label=False
)
html = (
'''
<html>
<body>
''' +
utils.tohtml(
"Nightly Total",
('Dinner','Lunch'),
grand_total
) +
utils.tohtml(
'7 Day Total today',
('Night', 'Lunch'),
seven_day_total1
) +
utils.tohtml(
'7 Day Total yesterday',
('Night', 'Lunch'),
seven_day_total2
) +
utils.tohtml(
'Clocked in today',
('Name', 'In', 'Out'),
in_out1
) +
utils.tohtml(
'Clocked in yesterday',
('Name', 'In', 'Out'),
in_out2
) +
utils.tohtml(
'FW Stats',
('Day', 'Date', 'Comped', 'Wine', 'Total','Percentage'),
fw_stats
) +
'''</body></html>'''
)
return html
if __name__ == '__main__':
print 'hi'