3 * GForge Project Management Facility
5 * Copyright 2002 GForge, LLC
12 By Tim Perdue, Sourceforge, 11/99
13 Heavy rewrite by Tim Perdue April 2000
15 Total rewrite in OO and GForge coding guidelines 12/2002 by Tim Perdue
18 require_once $gfcommon.'pm/ProjectTaskFactory.class.php';
19 //build page title to make bookmarking easier
20 //if a user was selected, add the user_name to the title
23 $pagename = "pm_browse_custom";
25 $offset = getIntFromRequest('offset');
26 $max_rows = getIntFromRequest('max_rows');
28 $ptf = new ProjectTaskFactory($pg);
29 if (!$ptf || !is_object($ptf)) {
30 exit_error('Error','Could Not Get ProjectTaskFactory');
31 } elseif ($ptf->isError()) {
32 exit_error('Error',$ptf->getErrorMessage());
35 $offset = getIntFromRequest('offset');
36 $_order = getStringFromRequest('_order');
37 $set = getStringFromRequest('set');
38 $_assigned_to = getIntFromRequest('_assigned_to');
39 $_status = getStringFromRequest('_status');
40 $_category_id = getIntFromRequest('_category_id');
41 $_view = getStringFromRequest('_view');
43 $ptf->setup($offset,$_order,$max_rows,$set,$_assigned_to,$_status,$_category_id,$_view);
44 if ($ptf->isError()) {
45 exit_error('Error',$ptf->getErrorMessage());
47 $pt_arr =& $ptf->getTasks(true);
48 if ($ptf->isError()) {
49 exit_error('Error',$ptf->getErrorMessage());
52 $_assigned_to=$ptf->assigned_to;
53 $_status=$ptf->status;
55 $_category_id=$ptf->category;
56 $_view=$ptf->view_type;
58 pm_header(array('title'=>_('Browse tasks'),'group_project_id'=>$group_project_id));
61 creating a custom technician box which includes "any" and "unassigned"
63 $res_tech=$pg->getTechnicians();
64 $tech_id_arr=util_result_column_to_array($res_tech,0);
65 $tech_id_arr[]='0'; //this will be the 'any' row
66 $tech_name_arr=util_result_column_to_array($res_tech,1);
67 $tech_name_arr[]=_('Any');
68 $tech_box=html_build_select_box_from_arrays ($tech_id_arr,$tech_name_arr,'_assigned_to',
69 $_assigned_to,true,_('Unassigned'));
72 creating a custom category box which includes "any" and "none"
74 $res_cat=$pg->getCategories();
75 $cat_id_arr=util_result_column_to_array($res_cat,0);
76 $cat_id_arr[]='0'; //this will be the 'any' row
77 $cat_name_arr=util_result_column_to_array($res_cat,1);
78 $cat_name_arr[]=_('Any');
79 $cat_box=html_build_select_box_from_arrays ($cat_id_arr,$cat_name_arr,'_category_id',$_category_id,true,'none');
83 Creating a custom sort box
85 $order_title_arr=array();
86 $order_title_arr[]=_('Task Id');
87 $order_title_arr[]=_('Task Summary');
88 $order_title_arr[]=_('Start Date');
89 $order_title_arr[]=_('End Date');
90 $order_title_arr[]=_('Percent Complete');
91 $order_title_arr[]=_('Priority');
93 $order_col_arr=array();
94 $order_col_arr[]='project_task_id';
95 $order_col_arr[]='summary';
96 $order_col_arr[]='start_date';
97 $order_col_arr[]='end_date';
98 $order_col_arr[]='percent_complete';
99 $order_col_arr[]='priority';
100 $order_box=html_build_select_box_from_arrays ($order_col_arr,$order_title_arr,'_order',$_order,false);
106 $view_arr[]=_('Summary');
107 $view_arr[]=_('Detailed');
108 $order_col_arr=array();
109 $view_col_arr[]='summary';
110 $view_col_arr[]='detail';
111 $view_box=html_build_select_box_from_arrays ($view_col_arr,$view_arr,'_view',$_view,false);
114 Show the new pop-up boxes to select assigned to and/or status
116 echo ' <form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&group_project_id='.$group_project_id.'" method="post">
117 <input type="hidden" name="set" value="custom" />
118 <table width="10%" border="0">
120 <td>'._('Assignee').'<br />'. $tech_box .'</td>
121 <td>'._('Status').'<br />'. $pg->statusBox('_status',$_status,true, _('Any')) .'</td>
122 <td>'._('Category').'<br />'. $cat_box .'</td>
123 <td>'._('Sort On').'<br />'. $order_box .'</td>
124 <td>'._('Detail View').'<br />'. $view_box .'</td>
125 <td><input type="submit" name="submit" value="'._('Browse').'" /></td>
126 </tr></table></form><p />';
129 $rows=count($pt_arr);
133 <span class="feedback">'._('No Matching Tasks found').'</span>
135 <span class="important">'._('Add tasks using the link above').'</span>';
139 //create a new $set string to be used for next/prev button
140 if ($set=='custom') {
141 $set .= '&_assigned_to='.$_assigned_to.'&_status='.$_status;
145 Now display the tasks in a table with priority colors
147 $IS_ADMIN=($pg->userIsAdmin());
151 <form name="taskList" action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&group_project_id='.$pg->getID().'" method="post">
152 <input type="hidden" name="func" value="massupdate" />';
155 //this array can be customized to display whichever columns you want
156 //it could be built by querying a table on a per-user basis as well
157 $display_col=array('summary'=>1,
160 'percent_complete'=>1,
166 $title_arr[]=_('Task Id');
167 if ($display_col['summary'])
168 $title_arr[]=_('Task Summary');
169 if ($display_col['start_date'])
170 $title_arr[]=_('Start Date');
171 if ($display_col['end_date'])
172 $title_arr[]=_('End Date');
173 if ($display_col['percent_complete'])
174 $title_arr[]=_('Percent Complete');
175 if ($display_col['category'])
176 $title_arr[]=_('Category');
177 if ($display_col['assigned_to'])
178 $title_arr[]=_('Assigned to');
179 if ($display_col['priority'])
180 $title_arr[]=_('Priority');
182 echo $GLOBALS['HTML']->listTableTop ($title_arr);
186 for ($i=0; $i < $rows; $i++) {
187 $url = getStringFromServer('PHP_SELF')."?func=detailtask&project_task_id=".$pt_arr[$i]->getID()."&group_id=".$group_id."&group_project_id=".$group_project_id;
190 <tr class="priority'.$pt_arr[$i]->getPriority().'">'.
192 ($IS_ADMIN?'<input type="checkbox" name="project_task_id_list[]" value="'.
193 $pt_arr[$i]->getID() .'" /> ':'').
194 $pt_arr[$i]->getID() .'</td>';
195 if ($display_col['summary'])
196 echo '<td><a href="'.$url.'">'.$pt_arr[$i]->getSummary() .'</a></td>';
197 if ($display_col['start_date'])
198 echo '<td>'.date(_('Y-m-d H:i'), $pt_arr[$i]->getStartDate() ).'</td>';
199 if ($display_col['end_date'])
200 echo '<td>'. (($now>$pt_arr[$i]->getEndDate() && $pt_arr[$i]->getStatusId() != 2 )?'<strong>* ':' ') .
201 date(_('Y-m-d H:i'), $pt_arr[$i]->getEndDate() ).'</strong></td>';
202 if ($display_col['percent_complete'])
203 echo '<td>'. $pt_arr[$i]->getPercentComplete() .'%</td>';
204 if ($display_col['category'])
205 echo '<td>'. $pt_arr[$i]->getCategoryName() .'</td>';
206 if ($display_col['assigned_to'])
207 echo '<td>'. $pg->renderAssigneeList($pt_arr[$i]->getAssignedTo()) .'</td>';
208 if ($display_col['priority'])
209 echo '<td>'. $pt_arr[$i]->getPriority() .'</td>';
214 if ($_view=="detail") {
216 <tr class="priority'.$pt_arr[$i]->getPriority() .'">
217 <td> </td><td colspan="'.(count($title_arr)-1).'">'. nl2br( $pt_arr[$i]->getDetails() ) .'</td>
223 //PLEASE MAKE THIS INTO A SEPARATE PAGE INSTEAD OF doing such a big hack to this one
226 } else if ($_view == "detail") {
228 <tr class="priority'.$pt_arr[$i]->getPriority() .'">'.
230 ($IS_ADMIN?'<input type="checkbox" name="project_task_id_list[]" value="'.
231 $pt_arr[$i]->getID() .'" /> ':'').
232 $pt_arr[$i]->getID() .'</td>'.
233 '<td><a href="'.$url.'">'.$pt_arr[$i]->getSummary() .'</a></td>'.
234 '<td>'.date(_('Y-m-d H:i'), $pt_arr[$i]->getStartDate() ).'</td>'.
235 '<td>'. (($now>$pt_arr[$i]->getEndDate() )?'<strong>* ':' ') .
236 date(_('Y-m-d H:i'), $pt_arr[$i]->getEndDate() ).'</strong></td>'.
237 '<td>'. $pt_arr[$i]->getPercentComplete() .'%</td></tr>';
242 echo nl2br( $pt_arr[$i]->getDetails() );
246 $result=$pt_arr[$i]->getMessages();
247 $rows=db_numrows($result);
251 <h3>'._('Followups').'</h3>
255 $title_arr[]=_('Comment');
256 $title_arr[]=_('Date');
257 $title_arr[]=_('By');
259 echo $GLOBALS['HTML']->listTableTop ($title_arr);
261 for ($j=0; $j < $rows; $j++) {
263 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($j) .'>
264 <td>'. nl2br(db_result($result, $j, 'body')).'</td>
265 <td valign="top">'.date(_('Y-m-d H:i'),db_result($result, $j, 'postdate')).'</td>
266 <td valign="top">'.db_result($result, $j, 'user_name').'</td></tr>';
269 echo $GLOBALS['HTML']->listTableBottom();
273 <h3>'._('No Comments Have Been Added').'</h3>';
276 // End of show details
284 Show extra rows for <-- Prev / Next -->
286 echo '<tr><td colspan="2">';
288 echo util_make_link ('/pm/task.php?func=browse&group_project_id='.$group_project_id.'&group_id='.$group_id.'&offset='.($offset-50),'<strong>'._('previous 50').'<--</strong>');
292 echo '</td><td> </td><td colspan="2">';
295 echo util_make_link ('/pm/task.php?func=browse&group_project_id='.$group_project_id.'&group_id='.$group_id.'&offset='.($offset+50),'<strong>'._('next 50').' --></strong></a>');
301 echo $GLOBALS['HTML']->listTableBottom();
305 creating a custom technician box which includes "No Change" and "Nobody"
308 $res_tech=$pg->getTechnicians();
310 $tech_id_arr=util_result_column_to_array($res_tech,0);
311 $tech_id_arr[]='100.1'; //this will be the 'any' row
313 $tech_name_arr=util_result_column_to_array($res_tech,1);
314 $tech_name_arr[]=_('Unassigned');
316 $tech_box=html_build_select_box_from_arrays ($tech_id_arr,$tech_name_arr,'assigned_to',
317 '100',true,_('No Change'));
319 echo '<script language="JavaScript" type="text/javascript">
321 function checkAll(val) {
322 al=document.taskList;
323 len = al.elements.length;
325 for( i=0 ; i<len ; i++) {
326 if (al.elements[i].name==\'project_task_id_list[]\') {
327 al.elements[i].checked=val;
334 <table width="100%" border="0">
337 <a href="javascript:checkAll(1)">'._('Check all').'</a>
339 <a href="javascript:checkAll(0)">'._('Clear all').'</a>
342 <span class="important">'._('<strong>Admin:</strong> If you wish to apply changes to all items selected above, use these controls to change their properties and click once on "Mass Update".').'
346 <td><strong>'._('Category').
347 '</strong><br />'. $pg->categoryBox ('category_id','xzxz',true,
348 _('No Change')) .'</td>
349 <td><strong>'._('Priority').
351 echo build_priority_select_box ('priority', '100', true);
356 <td><strong>'._('Assigned to').
357 '</strong><br />'. $tech_box .'</td>
358 <td><strong>'._('State').
359 '</strong><br />'. $pg->statusBox ('status_id','xzxz',true,_('No Change')) .'</td>
362 <tr><td><strong>'._('Subproject').'</strong><br />
363 '.$pg->groupProjectBox('new_group_project_id',$group_project_id,false).'</td>
364 <td align="middle"><input type="submit" name="submit" value="'.
365 _('Mass update').'"></td></tr>
371 echo '<p />'._('* Denotes overdue tasks');
372 show_priority_colors_key();