This repository was archived by the owner on Mar 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.template.php
More file actions
135 lines (118 loc) · 4.56 KB
/
class.template.php
File metadata and controls
135 lines (118 loc) · 4.56 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
130
131
132
133
134
135
<?php
class template {
var $month = '';
var $year = '';
function template() {
$this->month = 0;
$this->year = 0;
return true;
}
function set_month($month){
$this->month = $month;
}
function set_year($year){
$this->year = $year;
}
function print_head () {
echo '<!DOCTYPE html>';
echo '<html dir="ltr" lang="en-US">';
echo '<head>';
echo ' <meta charset="UTF-8" />';
echo ' <title> :: timeclock :: </title>';
echo ' <link rel="shortcut icon" href="favicon.ico" >';
echo ' <link rel="stylesheet" type="text/css" media="all" href="style.css" />';
//echo ' <script type="text/javascript"></script>';
echo '</head>';
echo '<body>';
}
function print_header($user, $now) {
echo '<div id="header">';
echo ' <h1>Wibiya Time Clock</h1>';
echo ' <ul id="nav">';
echo ' <li><a class="user" href="#">'.$user.'</a></li>';
echo ' <li><a class="users" href="users.php">Users</a></li>';
echo ' <li><a class="report" href="report.php?month='.date('n', $now).'&year='.date('Y', $now).'">report</a></li>';
echo ' <li><a class="logout" href="logout.php">log out</a></li>';
echo ' </ul>';
echo '</div>';
}
function print_foot () {
echo '</body>';
echo '</html>';
}
function print_month($query){
$data = array();
while ($r = mysql_fetch_assoc($query)) {
$day = explode('-', $r['day']);
$data[(int)$day[2]]['in'] = ($r['time_in'] != 0) ? date('H:i', $r['time_in']) : '';
$data[(int)$day[2]]['out'] = ($r['time_out'] != 0) ? date('H:i', $r['time_out']) : '';
$data[(int)$day[2]]['notes'] = $r['notes'];
}
$month_time = mktime(0, 0, 0, $this->month, 1, $this->year);
$days_in_month = date('t', $month_time);
if ($this->month == date('m') AND $this->year == date('Y')) {
$days_in_month = date('j');
}
echo '<table>';
for ($i=1; $i <= $days_in_month; $i++) {
$day_time = mktime(0, 0, 0, $this->month, $i, $this->year);
if ($i == 1 OR (date('w', $day_time) == 0)) {
echo '<tr><td> </td><td>In</td><td>Out</td><td>Notes</td><td> </td></tr>';
}
echo '<form action="update.php" method="post">';
echo '<input type="hidden" name="date" value="'.$i.'_'.$this->month.'_'.$this->year.'" />';
echo '<tr>';
echo '<td class="date">'.date('l, F jS', $day_time).'</td>';
echo '<td class="in"><input type="text" name="in" value="'.$data[$i]['in'].'" class="time" /></td>';
echo '<td class="out"><input type="text" name="out" value="'.$data[$i]['out'].'" class="time" /></td>';
echo '<td class="notes"><input type="text" name="notes" value="'.$data[$i]['notes'].'" class="remarks" /></td>';
echo '<td class="submit"><input type="submit" name="submit" value="Update" /></td>';
echo '</tr>';
echo '</form>';
}
echo '</table>';
}
function print_month_report($query){
$data = array();
while ($r = mysql_fetch_assoc($query)) {
$day = explode('-', $r['day']);
$data[(int)$day[2]]['in'] = ($r['time_in'] != 0) ? $r['time_in'] : '';
$data[(int)$day[2]]['out'] = ($r['time_out'] != 0) ? $r['time_out'] : '';
$data[(int)$day[2]]['notes'] = $r['notes'];
}
$month_time = mktime(0, 0, 0, $this->month, 1, $this->year);
$days_in_month = date('t', $month_time);
echo '<table border="1">';
echo '<tr><td>Date</td><td>Day</td><td>In</td><td>Out</td><td>Hours</td><td>Remarks</td></tr>';
$total_seconds = 0;
for ($i=1; $i <= $days_in_month; $i++) {
$day_time = mktime(0, 0, 0, $this->month, $i, $this->year);
$hours = '';
if ($data[$i]['in'] != '' AND $data[$i]['out'] != '') {
$seconds = $data[$i]['out'] - $data[$i]['in'];
$total_seconds += $seconds;
$hoursDiff = floor($seconds / 3600); // 60 * 60
$minutesDiffRemainder = ($seconds % 3600) / 60; // 60 * 60
$hours = $hoursDiff . 'h ' . $minutesDiffRemainder . 'm';
}
$_date = date('j-M-Y', $day_time);
$_day = date('l', $day_time);
$_in = ($data[$i]['in'] != '' ? date('g:i A', $data[$i]['in']) : '');
$_out = ($data[$i]['out'] != '' ? date('g:i A', $data[$i]['out']) : '');
echo '<tr>';
echo '<td class="date">'.$_date.'</td>';
echo '<td class="date">'.$_day.'</td>';
echo '<td class="in">'.$_in.'</td>';
echo '<td class="out">'.$_out.'</td>';
echo '<td class="notes">'.$hours.'</td>';
echo '<td class="notes">'.$data[$i]['notes'].'</td>';
echo '</tr>';
}
$hoursDiff = floor($total_seconds / 3600); // 60 * 60
$minutesDiffRemainder = ($total_seconds % 3600) / 60; // 60 * 60
$hours = $hoursDiff . 'h ' . $minutesDiffRemainder . 'm';
echo '<tr><td>Total</td><td> </td><td> </td><td> </td><td>'.$hours.'</td><td> </td></tr>';
echo '</table>';
}
}
?>