forked from andrew867/timeclock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeclock.php
190 lines (156 loc) · 10 KB
/
timeclock.php
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
<?php
session_start();
include 'config.inc.php';
include 'header.php';
if (!isset($_GET['printer_friendly'])) {
if (isset($_SESSION['valid_user'])) {
$set_logout = "1";
}
include 'topmain.php';
include 'leftmain.php';
}
echo "<title>$title</title>\n";
$current_page = "timeclock.php";
if (!isset($_GET['printer_friendly'])) {
echo " <td align=left class=right_main scope=col>\n";
echo " <table width=100% height=100% border=0 cellpadding=5 cellspacing=1>\n";
echo " <tr class=right_main_text>\n";
echo " <td valign=top>\n";
}
// code to allow sorting by Name, In/Out, Date, Notes //
if ($show_display_name == "yes") {
if (!isset($_GET['sortcolumn'])) {
$sortcolumn = "displayname";
} else {
$sortcolumn = $_GET['sortcolumn'];
}
} else {
if (!isset($_GET['sortcolumn'])) {
$sortcolumn = "fullname";
} else {
$sortcolumn = $_GET['sortcolumn'];
}
}
if (!isset($_GET['sortdirection'])) {
$sortdirection = "asc";
} else {
$sortdirection = $_GET['sortdirection'];
}
if ($sortdirection == "asc") {
$sortnewdirection = "desc";
} else {
$sortnewdirection = "asc";
}
// determine what users, office, and/or group will be displayed on main page //
if (($display_current_users == "yes") && ($display_office == "all") && ($display_group == "all")) {
$current_users_date = strtotime(date($datefmt));
$calc = 86400;
$a = $current_users_date + $calc - @$tzo;
$b = $current_users_date - @$tzo;
$query = "select " . $db_prefix . "info.*, " . $db_prefix . "employees.*, " . $db_prefix . "punchlist.*
from " . $db_prefix . "info, " . $db_prefix . "employees, " . $db_prefix . "punchlist
where " . $db_prefix . "info.timestamp = " . $db_prefix . "employees.tstamp and " . $db_prefix . "info.fullname = " . $db_prefix . "employees.empfullname
and " . $db_prefix . "info.`inout` = " . $db_prefix . "punchlist.punchitems and ((" . $db_prefix . "info.timestamp < '" . $a . "') and
(" . $db_prefix . "info.timestamp >= '" . $b . "')) and " . $db_prefix . "employees.disabled <> '1' and " . $db_prefix . "employees.empfullname <> 'admin'
order by `$sortcolumn` $sortdirection";
$result = mysql_query($query);
} elseif (($display_current_users == "yes") && ($display_office != "all") && ($display_group == "all")) {
$current_users_date = strtotime(date($datefmt));
$calc = 86400;
$a = $current_users_date + $calc - @$tzo;
$b = $current_users_date - @$tzo;
$query = "select " . $db_prefix . "info.*, " . $db_prefix . "employees.*, " . $db_prefix . "punchlist.*
from " . $db_prefix . "info, " . $db_prefix . "employees, " . $db_prefix . "punchlist
where " . $db_prefix . "info.timestamp = " . $db_prefix . "employees.tstamp and " . $db_prefix . "info.fullname = " . $db_prefix . "employees.empfullname
and " . $db_prefix . "info.`inout` = " . $db_prefix . "punchlist.punchitems and " . $db_prefix . "employees.office = '" . $display_office . "'
and ((" . $db_prefix . "info.timestamp < '" . $a . "') and (" . $db_prefix . "info.timestamp >= '" . $b . "'))
and " . $db_prefix . "employees.disabled <> '1' and " . $db_prefix . "employees.empfullname <> 'admin'
order by `$sortcolumn` $sortdirection";
$result = mysql_query($query);
} elseif (($display_current_users == "yes") && ($display_office == "all") && ($display_group != "all")) {
$current_users_date = strtotime(date($datefmt));
$calc = 86400;
$a = $current_users_date + $calc - @$tzo;
$b = $current_users_date - @$tzo;
$query = "select " . $db_prefix . "info.*, " . $db_prefix . "employees.*, " . $db_prefix . "punchlist.*
from " . $db_prefix . "info, " . $db_prefix . "employees, " . $db_prefix . "punchlist
where " . $db_prefix . "info.timestamp = " . $db_prefix . "employees.tstamp and " . $db_prefix . "info.fullname = " . $db_prefix . "employees.empfullname
and " . $db_prefix . "info.`inout` = " . $db_prefix . "punchlist.punchitems and " . $db_prefix . "employees.groups = '" . $display_group . "'
and ((" . $db_prefix . "info.timestamp < '" . $a . "') and (" . $db_prefix . "info.timestamp >= '" . $b . "'))
and " . $db_prefix . "employees.disabled <> '1' and " . $db_prefix . "employees.empfullname <> 'admin'
order by `$sortcolumn` $sortdirection";
$result = mysql_query($query);
} elseif (($display_current_users == "yes") && ($display_office != "all") && ($display_group != "all")) {
$current_users_date = strtotime(date($datefmt));
$calc = 86400;
$a = $current_users_date + $calc - @$tzo;
$b = $current_users_date - @$tzo;
$query = "select " . $db_prefix . "info.*, " . $db_prefix . "employees.*, " . $db_prefix . "punchlist.*
from " . $db_prefix . "info, " . $db_prefix . "employees, " . $db_prefix . "punchlist
where " . $db_prefix . "info.timestamp = " . $db_prefix . "employees.tstamp and " . $db_prefix . "info.fullname = " . $db_prefix . "employees.empfullname
and " . $db_prefix . "info.`inout` = " . $db_prefix . "punchlist.punchitems and " . $db_prefix . "employees.office = '" . $display_office . "'
and " . $db_prefix . "employees.groups = '" . $display_group . "' and ((" . $db_prefix . "info.timestamp < '" . $a . "')
and (" . $db_prefix . "info.timestamp >= '" . $b . "')) and " . $db_prefix . "employees.disabled <> '1'
and " . $db_prefix . "employees.empfullname <> 'admin'
order by `$sortcolumn` $sortdirection";
$result = mysql_query($query);
} elseif (($display_current_users == "no") && ($display_office == "all") && ($display_group == "all")) {
$query = "select " . $db_prefix . "info.*, " . $db_prefix . "employees.*, " . $db_prefix . "punchlist.*
from " . $db_prefix . "info, " . $db_prefix . "employees, " . $db_prefix . "punchlist
where " . $db_prefix . "info.timestamp = " . $db_prefix . "employees.tstamp and " . $db_prefix . "info.fullname = " . $db_prefix . "employees.empfullname
and " . $db_prefix . "info.`inout` = " . $db_prefix . "punchlist.punchitems and " . $db_prefix . "employees.disabled <> '1'
and " . $db_prefix . "employees.empfullname <> 'admin'
order by `$sortcolumn` $sortdirection";
$result = mysql_query($query);
} elseif (($display_current_users == "no") && ($display_office != "all") && ($display_group == "all")) {
$query = "select " . $db_prefix . "info.*, " . $db_prefix . "employees.*, " . $db_prefix . "punchlist.*
from " . $db_prefix . "info, " . $db_prefix . "employees, " . $db_prefix . "punchlist
where " . $db_prefix . "info.timestamp = " . $db_prefix . "employees.tstamp and " . $db_prefix . "info.fullname = " . $db_prefix . "employees.empfullname
and " . $db_prefix . "info.`inout` = " . $db_prefix . "punchlist.punchitems and " . $db_prefix . "employees.office = '" . $display_office . "'
and " . $db_prefix . "employees.disabled <> '1' and " . $db_prefix . "employees.empfullname <> 'admin'
order by `$sortcolumn` $sortdirection";
$result = mysql_query($query);
} elseif (($display_current_users == "no") && ($display_office == "all") && ($display_group != "all")) {
$query = "select " . $db_prefix . "info.*, " . $db_prefix . "employees.*, " . $db_prefix . "punchlist.*
from " . $db_prefix . "info, " . $db_prefix . "employees, " . $db_prefix . "punchlist
where " . $db_prefix . "info.timestamp = " . $db_prefix . "employees.tstamp and " . $db_prefix . "info.fullname = " . $db_prefix . "employees.empfullname
and " . $db_prefix . "info.`inout` = " . $db_prefix . "punchlist.punchitems and " . $db_prefix . "employees.groups = '" . $display_group . "'
and " . $db_prefix . "employees.disabled <> '1' and " . $db_prefix . "employees.empfullname <> 'admin'
order by `$sortcolumn` $sortdirection";
$result = mysql_query($query);
} elseif (($display_current_users == "no") && ($display_office != "all") && ($display_group != "all")) {
$query = "select " . $db_prefix . "info.*, " . $db_prefix . "employees.*, " . $db_prefix . "punchlist.*
from " . $db_prefix . "info, " . $db_prefix . "employees, " . $db_prefix . "punchlist
where " . $db_prefix . "info.timestamp = " . $db_prefix . "employees.tstamp and " . $db_prefix . "info.fullname = " . $db_prefix . "employees.empfullname
and " . $db_prefix . "info.`inout` = " . $db_prefix . "punchlist.punchitems and " . $db_prefix . "employees.office = '" . $display_office . "'
and " . $db_prefix . "employees.groups = '" . $display_group . "' and " . $db_prefix . "employees.disabled <> '1'
and " . $db_prefix . "employees.empfullname <> 'admin'
order by `$sortcolumn` $sortdirection";
$result = mysql_query($query);
}
$time = time();
$tclock_hour = gmdate('H', $time);
$tclock_min = gmdate('i', $time);
$tclock_sec = gmdate('s', $time);
$tclock_month = gmdate('m', $time);
$tclock_day = gmdate('d', $time);
$tclock_year = gmdate('Y', $time);
$tclock_stamp = mktime($tclock_hour, $tclock_min, $tclock_sec, $tclock_month, $tclock_day, $tclock_year);
$tclock_stamp = $tclock_stamp + @$tzo;
$tclock_time = date($timefmt, $tclock_stamp);
$tclock_date = date($datefmt, $tclock_stamp);
$report_name = "Current Status Report";
echo " <table width=100% align=center class=misc_items border=0 cellpadding=3 cellspacing=0>\n";
if (!isset($_GET['printer_friendly'])) {
echo " <tr class=display_hide>\n";
} else {
echo " <tr>\n";
}
echo " <td nowrap style='font-size:9px;color:#000000;padding-left:10px;'>$report_name ----> As of: $tclock_time,
$tclock_date</td></tr>\n";
echo " </table>\n";
include 'display.php';
if (!isset($_GET['printer_friendly'])) {
include 'footer.php';
}
?>