forked from rogermoka/Timesheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proj_info.php
175 lines (154 loc) · 6.29 KB
/
proj_info.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
<?
// 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']);
//load local vars from superglobals
$proj_id = $_REQUEST['proj_id'];
$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";
$query = "select distinct $PROJECT_TABLE.title, $PROJECT_TABLE.proj_id, $PROJECT_TABLE.client_id, $CLIENT_TABLE.organisation, ".
"$PROJECT_TABLE.description, DATE_FORMAT(start_date, '%M %d, %Y') as start_date, DATE_FORMAT(deadline, '%M %d, %Y') as deadline, ".
"$PROJECT_TABLE.proj_status, http_link ".
"from $PROJECT_TABLE, $CLIENT_TABLE, $USER_TABLE ".
"where $PROJECT_TABLE.proj_id=$proj_id ";
//set up query
$query = "select distinct $PROJECT_TABLE.title, $PROJECT_TABLE.proj_id, $PROJECT_TABLE.client_id, ".
"$CLIENT_TABLE.organisation, $PROJECT_TABLE.description, " .
"DATE_FORMAT(start_date, '%M %d, %Y') as start_date, " .
"DATE_FORMAT(deadline, '%M %d, %Y') as deadline, ".
"$PROJECT_TABLE.proj_status, http_link, proj_leader ".
"FROM $PROJECT_TABLE, $CLIENT_TABLE, $USER_TABLE ".
"WHERE $PROJECT_TABLE.proj_id=$proj_id AND ".
"$CLIENT_TABLE.client_id=$PROJECT_TABLE.client_id ".
"ORDER BY $PROJECT_TABLE.proj_id";
?>
<html>
<head>
<title>Project Info</title>
<?
include ("header.inc");
?>
</head>
<body width="100%" height="100%" style="margin: 0px;" <? include ("body.inc"); ?> >
<table border="0" width="100%" height="100%" align="center" valign="center">
<?
list($qh, $num) = dbQuery($query);
if ($num > 0) {
//get the current record
$data = dbResult($qh);
//strip slashes
$data["title"] = stripslashes($data["title"]);
$data["organisation"] = stripslashes($data["organisation"]);
$data["description"] = stripslashes($data["description"]);
list($billqh, $bill_num) = dbquery("select sum(unix_timestamp(end_time) - unix_timestamp(start_time)) as total_time, ".
"sum(bill_rate * ((unix_timestamp(end_time) - unix_timestamp(start_time))/(60*60))) as billed ".
"from $TIMES_TABLE, $USER_TABLE ".
"where end_time > 0 AND $TIMES_TABLE.proj_id = $data[proj_id] AND $USER_TABLE.username = $TIMES_TABLE.uid ");
$bill_data = dbResult($billqh);
//start the row
?>
<tr>
<td>
<table width="100%" border="0" class="section_body">
<tr>
<td valign="center">
<?php
if ($data["http_link"] != "")
print "<a href=\"$data[http_link]\"><span class=\"project_title\">$data[title]</span></a>";
else
print "<span class=\"project_title\">$data[title]</span>";
print " <span class=\"project_status\"><$data[proj_status]></span>"
?>
</td>
<td align="right">
<?php
if (isset($data["start_date"]) && $data["start_date"] != '' && $data["deadline"] != '')
print "<span class=\"label\">Start:</span> $data[start_date]<br><span class=\"label\">Deadline:</span> $data[deadline]";
else
print " ";
?>
</td>
</tr>
<tr>
<td><?php echo $data["description"]; ?><br></td>
<td valign="top" align="right"><span class="label">Client:</span> <?php echo $data["organisation"]; ?></td>
</tr>
<tr>
<td colspan="2" width="100%">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="70%">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<span class="label">Total time:</span> <?php echo (isset($bill_data["total_time"]) ? formatSeconds($bill_data["total_time"]): "0h 0m"); ?>
<? if ($authenticationManager->hasClearance(CLEARANCE_ADMINISTRATOR)) { ?>
<br><span class="label">Total bill:</span> <b>$<?php echo (isset($bill_data["billed"]) ? $bill_data["billed"]: "0.00"); ?></b>
<? } ?>
</td>
</tr>
<tr><td> </td></tr>
<?php
//display project leader
print "<tr><td><span class=\"label\">Project Leader:</span> $data[proj_leader] </td></tr>";
//display assigned users
list($qh2, $num_workers) = dbQuery("select distinct username from $ASSIGNMENTS_TABLE where proj_id = $data[proj_id]");
if ($num_workers == 0) {
print "<tr><td><font size=\"-1\">Nobody assigned to this project</font></td></tr>\n";
}
else {
$workers = '';
print "<tr><td><span class=\"label\">Assigned Users:</span> ";
for ($k = 0; $k < $num_workers; $k++) {
$worker = dbResult($qh2);
$workers .= "$worker[username], ";
}
$workers = preg_replace("/, $/", "", $workers);
print $workers;
print "</td></tr>";
}
?>
</table>
</td>
<td width="30%">
<div class="project_task_list">
<a href="task_maint.php?proj_id=<?php echo $data["proj_id"]; ?>"><span class="label">Tasks:</span></a> <br>
<?php
//get tasks
list($qh3, $num_tasks) = dbQuery("select name, task_id FROM $TASK_TABLE WHERE proj_id=$data[proj_id]");
//are there any tasks?
if ($num_tasks > 0) {
while ($task_data = dbResult($qh3)) {
$taskName = str_replace(" ", " ", $task_data["name"]);
print "<a href=\"javascript:void(0)\" onclick=window.open(\"task_info.php?proj_id=$data[proj_id]&task_id=$task_data[task_id]\",\"TaskInfo\",\"location=0,directories=no,status=no,menubar=no,resizable=1,width=550,height=220\")>$taskName</a><br>";
}
}
else
print "None.";
?>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<?php
}
?>
</table>
</BODY>
</HTML>