/
projectOverview.php
279 lines (219 loc) · 6.58 KB
/
projectOverview.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
278
279
<?php
require_once('includes/globals.inc');
session_start('keywords');
$keyname = 'FALSE';
$columns = array();
if(isset($_SESSION['words']))
{
$keywords = $_SESSION['words'];
$keyowner = $_SESSION['owner'];
$keyname = $_SESSION['keyname'];
}
if(isset($_GET['keyname']))
{
$keyerr = 0;
$keyname = $_GET['keyname'];
if($keyname == 'FALSE')
{
unset($_SESSION['words']);
unset($_SESSION['owner']);
unset($_SESSION['keyname']);
$keywords = '';
$keyowner = '';
}
else
{
if($keyname == '+ADDNEW')
{
session_write_close();
print('<script type="text/javascript">document.location="projectNewSearch.php"</script>');
}
$mKeyname = mysql_escape_string($keyname);
mysqlSetup();
$sqlquery = "SELECT `terms`,`owner` FROM `pb_searches` WHERE `name` = "
. "'$mKeyname' LIMIT 1";
$result = mysql_query($sqlquery) or die('Invalid query: ' . mysql_error());
if(!($row = mysql_fetch_row($result)))
{
$keyerr = 1;
}
else
{
$keywords = $row[0];
$keyowner = $row[1];
$_SESSION['keyname'] = $keyname;
$_SESSION['owner'] = $keyowner;
$_SESSION['words'] = $keywords;
$sqlquery = "UPDATE `pb_searches` SET `lastused` = NOW() WHERE `name` "
. " = '$mKeyname' LIMIT 1";
$result = mysql_query($sqlquery) or die('Invalid query: ' . mysql_error());
}
mysql_close();
}
}
session_write_close();
emitTop('Peanut Butter -> Projects -> Overview', $_SERVER['PHP_SELF']);
$noStatus = TRUE;
$statusSelected = array();
foreach($statusEnum as $status)
{
if(isset($_GET[str_replace(' ','_',$status)]))
{
$noStatus = FALSE;
$statusSelected[] = $status;
}
}
if($noStatus)
$statusSelected = $statusEnum;
if($keyerr)
{
print('<p><em>Keyword search name not found.</em></p>');
}
$selOwner = (isset($_GET['owner'])) ? $_GET['owner'] : '+ALL';
$urlOwner = urlencode($selOwner);
/*
$showAll = '<a href="'.$_SERVER['PHP_SELF'].'?owner='.$urlOwner.'">Show All</a>';
$linkString = array();
$linkString[] = $_GET['hidec'] == 1 ? $showAll :
'<a href="'.$_SERVER['PHP_SELF'].'?hidec=1&owner='.$urlOwner. '">Hide Cancelled/Completed</a>';
$linkString[] = $_GET['hidec'] == 2 ? $showAll :
'<a href="'.$_SERVER['PHP_SELF'].'?hidec=2&owner='.$urlOwner.'">Show Only \'In Progress\'</a>';
$linkString[] = $_GET['hidec'] == 3 ? $showAll :
'<a href="'.$_SERVER['PHP_SELF'].'?hidec=3&owner='.$urlOwner.'">Show Only \'On Hold\' and \'Pending\'</a>';
print('<p>'.implode(' ',$linkString).'</p>');
*/
?>
<form name="selectStatus" method="get" action="<?php echo $_SERVER['PHP_SELF'];?>">
<input type="hidden" name="keyname" value="<?php echo $keyname;?>" />
<input type="hidden" name="owner" value="<?php echo $selOwner;?>" />
<h4>View projects with a status of:</h4>
<?php
foreach($statusEnum as $status)
{
$specStatus = preg_replace('/[][\s()+-]/', '', $status);
$checked = '';
if(in_array($status, $statusSelected))
$checked = ' checked="checked"';
print("<input type=\"checkbox\" name=\"$status\" id=\"$specStatus\" value=\"1\"$checked /><a onClick='"
. "document.getElementById(\"$specStatus\").checked = !document.getElementById(\"$specStatus\").checked'"
. " style=\"cursor: pointer\">$status</a> ");
}
?>
<input type="submit" value="Update Table" />
</form>
<?php
mysqlSetup();
$sqlquery = "SELECT DISTINCT `owner` FROM `pb_projects` ORDER BY `owner` ASC";
$result = mysql_query($sqlquery) or die('Invalid query: ' . mysql_error());
?>
<table>
<tr>
<td>
<form name="selectOwner" method="get" action="<?php echo $_SERVER['PHP_SELF'];?>">
<?php
foreach($statusSelected as $status)
print("<input type=\"hidden\" name=\"$status\" value=\"1\" />\n");
?>
<input type="hidden" name="keyname" value="<?php echo $keyname;?>" />
Select Owner:
<select name="owner" onchange="document.selectOwner.submit()">
<option value="+ALL">+ALL</option>
<?php
while($row = mysql_fetch_row($result))
{
$owner = $row[0];
$selected = '';
if($selOwner == $owner)
$selected = " selected=\"selected\"";
print("<option value=\"$owner\"$selected>$owner</option>\n");
}
?>
</select>
</form>
</td>
<td>
</td>
<td>
<?php
$sqlquery = "SELECT `name` FROM `pb_searches` ORDER BY `name` ASC";
$result = mysql_query($sqlquery) or die('Invalid query: ' . mysql_error());
?>
<form name="selectSearch" method="get" action="<?php echo $_SERVER['PHP_SELF'];?>">
<?php
foreach($statusSelected as $status)
print("<input type=\"hidden\" name=\"$status\" value=\"1\" />\n");
?>
<input type="hidden" name="owner" value="<?php echo $selOwner;?>" />
Select Search:
<select name="keyname" onchange="document.selectSearch.submit()">
<option value="FALSE">No Search</option>
<?php
while($row = mysql_fetch_row($result))
{
$search = $row[0];
$selected = '';
if($search == $keyname)
$selected = " selected=\"selected\"";
print("<option value=\"$search\"$selected>$search</option>\n");
}
?>
<option value="+ADDNEW">Add New Search</option>
</select>
</form>
</td></tr></table>
<table id="projectlist" class="list">
<tr>
<th>Project Name</th>
<th>Owner</th>
<th>Status</th>
<th>Progress</th>
<th>Priority</th>
<th>Description</th>
</tr>
<?php
$where = '';
$matchColl = new MatchCollection("AND");
$statiMC = new MatchCollection("OR");
foreach($statusSelected as $status)
{
$statiMC->addMatch(new Match('Status',$status));
}
$matchColl->addMatch($statiMC);
if(isset($_GET['owner']) && $_GET['owner'] != '+ALL')
{
$mOwner = mysql_escape_string($_GET['owner']);
$matchColl->addMatch(new Match('owner',$mOwner));
}
if($keyname != '')
{
$words = explode(',',$keywords);
foreach($words as $word)
$matchColl->addMatch(new Match('Keywords','%'.mysql_escape_string($word).'%','LIKE'));
}
$whereSQL = $matchColl->toSQL();
$sqlquery = "SELECT `name`, LEFT(`description`,80),`status`,`progress`,`priority`,`owner`,`id` FROM "
. "`pb_projects` WHERE $whereSQL ORDER BY `priority` DESC";
$result = mysql_query($sqlquery) or die('Invalid query: ' . mysql_error());
$rownum = 0;
while($row = mysql_fetch_row($result))
{
$urlid = urlencode($row[6]);
$style = '';
if($rownum++ % 2 == 0)
$style = ' class="greyed"';
?>
<tr>
<td<?php echo $style;?>><a href="projectInfo.php?projid=<?php echo $urlid;?>"><?php echo $row[0]?></a></td>
<td<?php echo $style;?>><?php echo $row[5]?></td>
<td<?php echo $style;?>><?php echo $row[2]?></td>
<td<?php echo $style;?>><img src="pngbar.php?rating=<?php echo $row[3]?>$amp;type=progress" alt="<?php echo $row[3]?>%" /></td>
<td<?php echo $style;?>><img src="pngbar.php?rating=<?php echo $row[4]?>&type=priority" alt="<?php echo $row[4]?>" /></td>
<td<?php echo $style;?>><?php echo $row[1]?>...</td>
</tr>
<?php
}
mysql_close();
?>
</table>
<?php emitBottom();?>