forked from andrew867/timeclock
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtimeclock.php
103 lines (81 loc) · 2.82 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
<?php
session_start();
require 'common.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 (!isset($_GET['sortcolumn']) or preg_match('/[^\w]/', $_GET['sortcolumn'])) {
$sortcolumn = (($show_display_name == "yes") ? "displayname" : "fullname");
} else {
$sortcolumn = addslashes($_GET['sortcolumn']);
}
if (!isset($_GET['sortdirection']) or preg_match('/[^\w]/', $_GET['sortdirection'])) {
$sortdirection = "asc";
} else {
$sortdirection = addslashes($_GET['sortdirection']);
}
if ($sortdirection == "asc") {
$sortnewdirection = "desc";
} else {
$sortnewdirection = "asc";
}
// determine what users, office, and/or group will be displayed on main page //
$where = array("e.disabled <> '1'", "e.empfullname <> 'admin'");
$qparm = array();
if (yes_no_bool($display_current_users)) {
$current_users_date = strtotime(date($datefmt));
$where[] = "i.timestamp < ?";
$qparm[] = $current_users_date + 86400 - @$tzo;
$where[] = "i.timestamp >= ?";
$qparm[] = $current_users_date - @$tzo;
}
if ($display_office != "all") {
$where[] = "e.office = ?";
$qparm[] = $display_office;
}
if ($display_group != "all") {
$where[] = "e.groups = ?";
$qparm[] = $display_group;
}
$where = implode(" AND ", $where);
$result = tc_query(<<<QUERY
SELECT i.*, e.*, p.*
FROM {$db_prefix}info AS i
JOIN {$db_prefix}employees AS e ON (e.empfullname = i.fullname AND i.timestamp = e.tstamp)
JOIN {$db_prefix}punchlist AS p ON i.inout = p.punchitems
WHERE $where
ORDER BY `$sortcolumn` $sortdirection
QUERY
, $qparm);
$tclock_stamp = time() + @$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';
}
?>