forked from rogermoka/Timesheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.php
277 lines (251 loc) · 10.6 KB
/
popup.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<?php
// $Header: /cvsroot/tsheet/timesheet.php/popup.php,v 1.11 2005/05/17 03:38:37 vexil Exp $
// Authenticate
require("class.AuthenticationManager.php");
require("class.CommandMenu.php");
if (!$authenticationManager->isLoggedIn()) {
Header("Location: login.php?redirect=$_SERVER[PHP_SELF]");
exit;
}
// Connect to database.
$dbh = dbConnect();
$contextUser = strtolower($_SESSION['contextUser']);
if (empty($contextUser))
errorPage("Could not determine the context user");
//load local vars from superglobals
$year = $_REQUEST["year"];
$month = $_REQUEST["month"];
$day = $_REQUEST["day"];
$destination = $_REQUEST["destination"];
$proj_id = isset($_REQUEST["proj_id"]) ? $_REQUEST["proj_id"]: 0;
$task_id = isset($_REQUEST["task_id"]) ? $_REQUEST["task_id"]: 0;
$client_id = isset($_REQUEST["client_id"]) ? $_REQUEST["client_id"]: 0;
//get todays values
$today = time();
$todayYear = date("Y", $today);
$todayMonth = date("n", $today);
$todayDay = date("j", $today);
//check that the client id is valid
if ($client_id == 0 || empty($client_id))
$client_id = getFirstClient();
//check that project id is valid
if ($proj_id == 0)
$task_id = 0;
//calculate tomorrow and yesterday for "prev" & "next" buttons
$yesterday = mktime(0,0,0,$month,$day,$year) - 24*60*60;
$tomorrow = mktime(0,0,0,$month,$day,$year) + 24*60*60;
function getDailyTimes($month, $day, $year, $id, $proj_id) {
include("table_names.inc");
list($qhq, $numq) = dbQuery("select timeformat from $CONFIG_TABLE where config_set_id = '1'");
$configData = dbResult($qhq);
$query = "select date_format(start_time,'%d') as day_of_month, trans_num, ";
if ($configData["timeformat"] == "12")
$query .= "date_format(end_time, '%l:%i%p') as endd, date_format(start_time, '%l:%i%p') as start, ";
else
$query .= "date_format(end_time, '%k:%i') as endd, date_format(start_time, '%k:%i') as start, ";
$query .= "unix_timestamp(end_time) - unix_timestamp(start_time) as diff_sec, " .
"unix_timestamp(start_time) as start_time, " .
"unix_timestamp(end_time) as end_time, " .
"end_time as end_time_str, " .
"start_time as start_time_str, ".
"$PROJECT_TABLE.title as project_title, " .
"$TASK_TABLE.name, $TIMES_TABLE.proj_id, $TIMES_TABLE.task_id " .
"FROM $TIMES_TABLE, $TASK_TABLE, $PROJECT_TABLE " .
"WHERE $TASK_TABLE.proj_id=$PROJECT_TABLE.proj_id AND " .
"uid='$id' AND ";
$query .= "$TASK_TABLE.task_id = $TIMES_TABLE.task_id AND " .
"((start_time >= '$year-$month-$day 00:00:00' AND start_time <= '$year-$month-$day 23:59:59') " .
" OR (end_time >= '$year-$month-$day 00:00:00' AND end_time <= '$year-$month-$day 23:59:59') " .
" OR (start_time < '$year-$month-$day 00:00:00' AND end_time > '$year-$month-$day 23:59:59')) " .
" order by day_of_month, start_time";
list($my_qh, $num) = dbQuery($query);
return array($num, $my_qh);
}
//include date input classes
include "form_input.inc";
list($num, $qh) = getDailyTimes($month, $day, $year, $contextUser, $proj_id);
?>
<html>
<head>
<title>Update timesheet for <? echo $contextUser; ?></title>
<?php
include("header.inc");
include("client_proj_task_javascript.inc");
?>
<script language="Javascript">
function resizePopupWindow() {
//now resize the window
var outerTable = document.getElementById('outer_table');
var newWidth = outerTable.offsetWidth + window.outerWidth - window.innerWidth;
var newHeight = outerTable.offsetHeight + window.outerHeight - window.innerHeight;
window.resizeTo(newWidth, newHeight);
}
</script>
</HEAD>
<body style="margin: 0; padding: 0;" class="face_padding_cell" <? include ("body.inc"); ?> onload="doOnLoad();">
<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" id="outer_table">
<tr>
<td width="100%" class="face_padding_cell">
<!-- include the timesheet face up until the heading start section -->
<? include("timesheet_face_part_1.inc"); ?>
<table width="100%" border="0">
<tr>
<td align="left" nowrap class="outer_table_heading" nowrap>
Clock On / Off
</td>
<td align="right" nowrap class="outer_table_heading">
<? echo strftime("%A %B %d, %Y", mktime(0,0,0,$month, $day, $year)); ?>
</td>
</tr>
</table>
<!-- include the timesheet face up until the next start section -->
<? include("timesheet_face_part_2.inc"); ?>
<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="outer_table">
<form action="action.php" method="post" name="addForm" id="theForm">
<input type="hidden" name="year" value="<?echo $year; ?>">
<input type="hidden" name="month" value="<?echo $month; ?>">
<input type="hidden" name="day" value="<?echo $day; ?>">
<input type="hidden" id="client_id" name="client_id" value="<?echo $client_id; ?>">
<input type="hidden" id="proj_id" name="proj_id" value="<?echo $proj_id; ?>">
<input type="hidden" id="task_id" name="task_id" value="<?echo $task_id; ?>">
<input type="hidden" name="fromPopupWindow" value="true">
<input type="hidden" name="origin" value="<? echo $_SERVER["PHP_SELF"]; ?>">
<input type="hidden" name="destination" value="<? echo $destination; ?>">
<tr>
<td>
<table width="100%" border="0" cellpadding="1" cellspacing="2" class="table_body">
<tr>
<td>
<table width="100%" border="0">
<tr>
<td align="left" width="100%" nowrap>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="50"><tr><td>Client:</td></tr></table></td>
<td width="100%">
<select id="clientSelect" name="clientSelect" onChange="onChangeClientSelect();" style="width: 100%;" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" width="100%" nowrap>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="50"><tr><td>Project:</td></tr></table></td>
<td width="100%">
<select id="projectSelect" name="projectSelect" onChange="onChangeProjectSelect();" style="width: 100%;" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" width="100%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="50"><tr><td>Task:</td></tr></table></td>
<td width="100%">
<select id="taskSelect" name="taskSelect" onChange="onChangeTaskSelect();" style="width: 100%;" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0">
<tr>
<td align="center">
<table width="300" border="0" class="clock_on_box">
<tr>
<td valign="top" align="left" class="clock_on_text">
<input type="checkbox" name="clock_on_check" id="clock_on_check" onclick="enableClockOn();">Clock on at:
</td>
<td valign="middle">
<? // If the current day is today:
if (($year == date('Y')) && ($month == date('m')) && ($day == date('j'))): ?>
<input type="radio" name="clock_on_radio" id="clock_on_radio_date" value="date" onclick="enableClockOn();" checked>
<? endif; ?>
<? $hourInput = new HourInput("clock_on_time_hour");
$hourInput->create(10); ?>
:
<? $minuteInput = new MinuteInput("clock_on_time_min");
$minuteInput->create(); ?>
</td>
<td>
<img src="images/clock-green-sml.gif" border="0">
</td>
</tr>
<? // If the current day is today:
if (($year == date('Y')) && ($month == date('m')) && ($day == date('j'))): ?>
<tr>
<td> </td>
<td valign="middle" align="left" class="clock_on_text">
<input type="radio" name="clock_on_radio" id="clock_on_radio_now" value="now" onclick="enableClockOn();"> now
</td>
<td> </td>
</tr>
<? endif; ?>
</table>
</td>
</tr>
<tr>
<td align="center">
<table width="300" border="0" class="clock_off_box">
<tr>
<td valign="top" align="left" class="clock_off_text">
<input type="checkbox" name="clock_off_check" id="clock_off_check" onclick="enableClockOff();">Clock off at:
</td>
<td valign="middle">
<? // If the current day is today:
if (($year == date('Y')) && ($month == date('m')) && ($day == date('j'))): ?>
<input type="radio" name="clock_off_radio" id="clock_off_radio_date" value="date" onclick="enableClockOff();">
<? endif; ?>
<? $hourInput = new HourInput("clock_off_time_hour");
$hourInput->create(17); ?>
:
<? $minuteInput = new MinuteInput("clock_off_time_min");
$minuteInput->create(); ?>
</td>
<td>
<img src="images/clock-red-sml.gif" border="0">
</td>
</tr>
<? // If the current day is today:
if (($year == date('Y')) && ($month == date('m')) && ($day == date('j'))): ?>
<tr>
<td> </td>
<td valign="middle" align="left" class="clock_off_text">
<input type="radio" name="clock_off_radio" id="clock_off_radio_now" value="now" onclick="enableClockOff();" checked>now
</td>
<td> </td>
</tr>
<? endif; ?>
</table>
</td>
</tr>
<tr>
<td align="center">
<input type="button" value="Clock on and/or off" name="submitButton" id="submitButton" onClick="onSubmit();">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<!-- include the timesheet face up until the end -->
<? include("timesheet_face_part_3.inc"); ?>
</td>
</tr>
</table>
</BODY>
</HTML>