-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_maint.php
More file actions
277 lines (253 loc) · 8.36 KB
/
Copy pathtask_maint.php
File metadata and controls
277 lines (253 loc) · 8.36 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
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/task_maint.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");
exit;
}
// Connect to database.
$dbh = dbConnect();
//define the command menu & we get these variables from $_REQUEST:
// $month $day $year $client_id $proj_id $task_id
include("timesheet_menu.inc");
$contextUser = strtolower($_SESSION['contextUser']);
if (empty($proj_id))
$proj_id = 1;
//make sure the selected project is valid for this client
if ($client_id != 0) {
if (!isValidProjectForClient($proj_id, $client_id))
$proj_id = getValidProjectForClient($client_id);
}
if (isset($_REQUEST['page']) && $_REQUEST['page'] != 0) { $page = $_REQUEST['page']; } else { $page=1; };
$results_per_page = $tsx_config->get('task_items_per_page');
$start_from = ($page-1) * $results_per_page;
//set up the required queries
$query_task = "SELECT DISTINCT task_id, name, description,status, ".
"DATE_FORMAT(assigned, '%M %d, %Y') as assigned,".
"DATE_FORMAT(started, '%M %d, %Y') as started,".
"DATE_FORMAT(suspended, '%M %d, %Y') as suspended,".
"DATE_FORMAT(completed, '%M %d, %Y') as completed ".
"FROM $TASK_TABLE ".
"WHERE $TASK_TABLE.proj_id=$proj_id ".
"ORDER BY $TASK_TABLE.task_id ".
"LIMIT $start_from, $results_per_page";
$query_project = "SELECT DISTINCT title, description,".
"DATE_FORMAT(start_date, '%M %d, %Y') as start_date,".
"DATE_FORMAT(deadline, '%M %d, %Y') as deadline,".
"proj_status, proj_leader ".
"FROM $PROJECT_TABLE ".
"WHERE $PROJECT_TABLE.proj_id=$proj_id";
function writePageLinks($page, $results_per_page, $num_task_page)
{
//echo "num_task_page: ".$num_task_page.", results_per_page: ".$results_per_page.", page: ".$page;
if (($num_task_page/$results_per_page) == (int)($num_task_page/$results_per_page))
$numberOfPages = ($num_task_page/$results_per_page);
else
$numberOfPages = 1+(int)($num_task_page/$results_per_page);
//echo $numberOfPages." =< 1 or ".$num_task_page." equals 0";
if($numberOfPages > 1 && $num_task_page != 0)
{
//echo '<td width="16em" align="right">';
if($page > 1)
echo '<a href="javascript:change_page(\''.($page-1).'\')">Previous Page</a>';
else
echo 'Previous Page';
echo ' / ';
//echo '</td><td width="19em>"';
if ($numberOfPages > $page)
echo '<a href="javascript:change_page('.($page+1).')">Next Page</a>';
else
echo 'Next Page';
echo ' ( <b>';
echo $page." of ";
echo $numberOfPages;
echo '</b> )';
//echo '</td>';
}
}
$query_task_page = "SELECT DISTINCT task_id, name, description,status, ".
"DATE_FORMAT(assigned, '%M %d, %Y') as assigned,".
"DATE_FORMAT(started, '%M %d, %Y') as started,".
"DATE_FORMAT(suspended, '%M %d, %Y') as suspended,".
"DATE_FORMAT(completed, '%M %d, %Y') as completed ".
"FROM $TASK_TABLE ".
"WHERE $TASK_TABLE.proj_id=$proj_id ".
"ORDER BY $TASK_TABLE.task_id ";
list($qh_task_page, $num_task_page) = dbQuery($query_task_page);
?>
<html>
<head>
<title>Tasks</title>
<?php
include ("header.inc");
?>
<script type="text/javascript">
function delete_task(projectId, taskId) {
if (confirm('Deleting a task which has been used in the past will make those timesheet ' +
'entries invalid, and may cause errors. This action is not recommended. ' +
'Are you sure you want to delete this task?'))
location.href = 'task_action.php?proj_id=' + projectId + '&task_id=' + taskId + '&action=delete';
}
function change_page(newPageValue)
{
document.changeForm.page.value = newPageValue;
document.changeForm.submit();
}
</script>
</head>
<body <?php include ("body.inc"); ?> >
<?php
include ("banner.inc");
?>
<form name="changeForm" action="<?php echo $_SERVER["PHP_SELF"]; ?>" style="margin-bottom: 0px;">
<input type="hidden" name="page" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" class="face_padding_cell">
<!-- include the timesheet face up until the heading start section -->
<?php include("timesheet_face_part_1.inc"); ?>
<table width="100%" border="0">
<tr>
<td align="left" nowrap>
<table width="100%" height="100%" border="0" cellpadding="1" cellspacing="2">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="50"><tr><td>Client:</td></tr></table></td>
<td width="100%"><?php client_select_list($client_id, 0, false, false, true, false, "submit();", false); ?></td>
</tr>
<tr>
<td height="1"></td>
<td height="1"><img src="images/spacer.gif" width="150" height="1" alt="" /></td>
</tr>
</table>
</td>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="50"><tr><td>Project:</td></tr></table></td>
<td width="100%"><?php project_select_list($client_id, false, $proj_id, 0, false, false, "submit();", false); ?></td>
</tr>
<tr>
<td height="1"></td>
<td height="1"><img src="images/spacer.gif" width="150" height="1" alt="" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td align="center" class="outer_table_heading" nowrap>
Tasks
</td>
<td>
<?php writePageLinks($page, $results_per_page, $num_task_page); ?>
</td>
<td align="right" nowrap>
<?php if ($proj_id != 0) { ?>
<a href="task_add.php?proj_id=<?php echo $proj_id; ?>">Add new task</a>
<?php } else { ?>
<span class="disabledLink">Add new task</span>
<?php } ?>
<br /><br />
<a href="assign-proj-mbrs-to-all-tasks.php">Assign Mbrs all tasks</a>
</td>
</tr>
</table>
<!-- include the timesheet face up until the heading start section -->
<?php include("timesheet_face_part_2.inc"); ?>
<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="outer_table">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_body">
<?php
//execute query
list($qh_task, $num_task) = dbQuery($query_task);
//were there any results
if ($num_task == 0) {
if ($proj_id == 0) {
print " <tr>\n";
print " <td align=\"center\">\n";
print " <i><br />Please select a client with projects, or 'All Clients'.<br /><br /></i>\n";
print " </td>\n";
print " </tr>\n";
}
else {
print " <tr>\n";
print " <td align=\"center\">\n";
print " <i><br />There are no tasks for this project.<br /><br /></i>\n";
print " </td>\n";
print " </tr>\n";
}
}
else {
//iterate through tasks
for ($j=0; $j<$num_task; $j++) {
$data_task = dbResult($qh_task);
//start the row
?>
<tr>
<td>
<table width="100%" border="0"<?php if ($j+1<$num_task) print "class=\"section_body\""; ?>>
<tr>
<td valign="center">
<span class="project_title"><?php echo stripslashes($data_task["name"]); ?></span>
<span class="project_status"><<?php echo $data_task["status"]; ?>></span><br />
<?php echo stripslashes($data_task["description"]); ?>
</td>
<td align="right" valign="top" nowrap>
<span class="label">Actions:</span>
<a href="task_edit.php?task_id=<?php echo $data_task["task_id"]; ?>">Edit</a>,
<a href="javascript:delete_task(<?php echo $proj_id; ?>,<?php echo $data_task["task_id"]; ?>);">Delete</a>
</td>
</tr>
<tr>
<td align="left" colspan="2" align="top">
<span class="label">Assigned persons:</span><br />
<?php
//get assigned users
list($qh3, $num_3) = dbQuery("SELECT username, task_id FROM $TASK_ASSIGNMENTS_TABLE WHERE task_id=$data_task[task_id]");
if ($num_3 > 0) {
while ($data_3 = dbResult($qh3)) {
print "$data_3[username] ";
}
}
else {
print "<i>None</i>";
}
?>
</td>
<tr>
</table>
</td>
</tr>
<?php
}
}
?>
</table>
</td>
</tr>
<tr>
<td>
<center><?php writePageLinks($page, $results_per_page, $num_task_page); ?></center>
</td>
</tr>
</table>
<!-- include the timesheet face up until the end -->
<?php include("timesheet_face_part_3.inc"); ?>
</td>
</tr>
</table>
</form>
<?php
include ("footer.inc");
?>
</body>
</HTML>
<?php
// vim:ai:ts=4:sw=4
?>