3 * FusionForge : Project Management Facility
5 * Copyright 1999-2001 (c) VA Linux Systems, Tim Perdue
6 * Copyright 2002 GForge, LLC, Tim Perdue
7 * Copyright 2010, FusionForge Team
8 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
9 * Copyright 2014, Franck Villaume - TrivialDev
10 * http://fusionforge.org
12 * This file is part of FusionForge. FusionForge is free software;
13 * you can redistribute it and/or modify it under the terms of the
14 * GNU General Public License as published by the Free Software
15 * Foundation; either version 2 of the Licence, or (at your option)
18 * FusionForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 require_once $gfcommon.'include/UserManager.class.php';
29 require_once $gfcommon.'pm/ProjectTaskFactory.class.php';
30 //build page title to make bookmarking easier
31 //if a user was selected, add the user_name to the title
34 $pagename = "pm_browse_custom";
36 $offset = getIntFromRequest('offset');
40 $max_rows = getIntFromRequest('max_rows');
42 $ptf = new ProjectTaskFactory($pg);
43 if (!$ptf || !is_object($ptf)) {
44 exit_error(_('Could Not Get ProjectTaskFactory'),'pm');
45 } elseif ($ptf->isError()) {
46 exit_error($ptf->getErrorMessage(),'pm');
49 $_order = getStringFromRequest('_order');
50 $set = getStringFromRequest('set');
51 $_assigned_to = getIntFromRequest('_assigned_to');
52 $_status = getStringFromRequest('_status');
53 $_category_id = getIntFromRequest('_category_id');
54 $_view = getStringFromRequest('_view');
57 if (session_loggedin()) {
58 $u = UserManager::instance()->getCurrentUser();
59 if (getStringFromRequest('setpaging')) {
60 /* store paging preferences */
61 $paging = getIntFromRequest('nres');
65 $u->setPreference("paging", $paging);
67 $paging = $u->getPreference("paging");
73 $ptf->setup($offset,$_order,$paging,$set,$_assigned_to,$_status,$_category_id,$_view);
74 if ($ptf->isError()) {
75 exit_error($ptf->getErrorMessage(),'pm');
77 $pt_arr =& $ptf->getTasks(true);
78 if ($ptf->isError()) {
79 exit_error($ptf->getErrorMessage(),'pm');
82 $_assigned_to=$ptf->assigned_to;
83 $_status=$ptf->status;
85 $_category_id=$ptf->category;
86 $_view=$ptf->view_type;
88 html_use_coolfieldset();
90 pm_header(array('title'=>_('Browse tasks'),'group_project_id'=>$group_project_id));
93 creating a custom technician box which includes "any" and "unassigned"
95 $engine = RBACEngine::getInstance () ;
96 $techs = $engine->getUsersByAllowedAction ('pm', $pg->getID(), 'tech') ;
98 $tech_id_arr = array () ;
99 $tech_name_arr = array () ;
101 foreach ($techs as $tech) {
102 $tech_id_arr[] = $tech->getID() ;
103 $tech_name_arr[] = $tech->getRealName() ;
106 $tech_name_arr[]=_('Any');
108 $tech_box=html_build_select_box_from_arrays ($tech_id_arr,$tech_name_arr,'_assigned_to',$_assigned_to,true,_('Unassigned'));
111 creating a custom category box which includes "any" and "none"
113 $res_cat=$pg->getCategories();
114 $cat_id_arr=util_result_column_to_array($res_cat,0);
115 $cat_id_arr[]='0'; //this will be the 'any' row
116 $cat_name_arr=util_result_column_to_array($res_cat,1);
117 $cat_name_arr[]=_('Any');
118 $cat_box=html_build_select_box_from_arrays ($cat_id_arr,$cat_name_arr,'_category_id',$_category_id,true,'none');
121 Creating a custom sort box
123 $order_title_arr=array();
124 $order_title_arr[]=_('Task Id');
125 $order_title_arr[]=_('Task Summary');
126 $order_title_arr[]=_('Start Date');
127 $order_title_arr[]=_('End Date');
128 $order_title_arr[]=_('Percent Complete');
129 $order_title_arr[]=_('Priority');
131 $order_col_arr=array();
132 $order_col_arr[]='project_task_id';
133 $order_col_arr[]='summary';
134 $order_col_arr[]='start_date';
135 $order_col_arr[]='end_date';
136 $order_col_arr[]='percent_complete';
137 $order_col_arr[]='priority';
138 $order_box=html_build_select_box_from_arrays ($order_col_arr,$order_title_arr,'_order',$_order,false);
144 $view_arr[]=_('Summary');
145 $view_arr[]=_('Detailed');
146 $order_col_arr=array();
147 $view_col_arr[]='summary';
148 $view_col_arr[]='detail';
149 $view_box=html_build_select_box_from_arrays ($view_col_arr,$view_arr,'_view',$_view,false);
152 Show the new pop-up boxes to select assigned to and/or status
154 echo ' <form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&group_project_id='.$group_project_id.'" method="post">
155 <input type="hidden" name="set" value="custom" />
158 <td>'._('Assignee').'<br />'. $tech_box .'</td>
159 <td>'._('Status').'<br />'. $pg->statusBox('_status',$_status,true, _('Any')) .'</td>
160 <td>'._('Category').'<br />'. $cat_box .'</td>
161 <td>'._('Sort On').'<br />'. $order_box .'</td>
162 <td>'._('Detail View').'<br />'. $view_box .'</td>
163 <td><input type="submit" name="submit" value="'._('Browse').'" /></td>
164 </tr></table></form>';
166 $rows=count($pt_arr);
170 <p class="feedback">'._('No Matching Tasks found').'</p>
172 <div class="warning">'._('Add tasks using the link above').'</div>';
175 if (session_loggedin()) {
176 /* logged in users get configurable paging */
177 echo '<form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&group_project_id='.$pg->getID().'&offset='.$offset.'" method="post">'."\n";
180 printf('<p>' . _('Displaying results %1$d‒%2$d.'), $offset + 1, $offset + $rows);
182 if (session_loggedin()) {
183 printf(' ' . _('Displaying %2$s results.') . "\n\t<input " .
184 'type="submit" name="setpaging" value="%1$s" />' .
185 "\n</p>\n</form>\n", _('Change'),
186 html_build_select_box_from_array(array(
187 '10', '25', '50', '100', '1000'), 'nres', $paging, 1));
192 //create a new $set string to be used for next/prev button
193 if ($set=='custom') {
194 $set .= '&_assigned_to='.$_assigned_to.'&_status='.$_status;
198 Now display the tasks in a table with priority colors
200 $IS_ADMIN = forge_check_perm ('pm', $pg->getID(), 'manager') ;
204 <form name="taskList" action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&group_project_id='.$pg->getID().'" method="post">
205 <input type="hidden" name="func" value="massupdate" />';
208 <a href="javascript:checkAllTasks(1)">'._('Check all').'</a>
210 <a href="javascript:checkAllTasks(0)">'._('Clear all').'</a>';
215 //this array can be customized to display whichever columns you want
216 //it could be built by querying a table on a per-user basis as well
217 $display_col=array('summary'=>1,
220 'percent_complete'=>1,
227 $title_arr[]=_('Task Id');
228 if ($display_col['summary'])
229 $title_arr[]=_('Task Summary');
230 if ($display_col['start_date'])
231 $title_arr[]=_('Start Date');
232 if ($display_col['end_date'])
233 $title_arr[]=_('End Date');
234 if ($display_col['percent_complete'])
235 $title_arr[]=_('Percent Complete');
236 if ($display_col['category'])
237 $title_arr[]=_('Category');
238 if ($display_col['assigned_to'])
239 $title_arr[]=_('Assigned to');
240 if ($display_col['priority'])
241 $title_arr[]=_('Priority');
243 echo $GLOBALS['HTML']->listTableTop ($title_arr);
247 for ($i=0; $i < $rows; $i++) {
248 $url = getStringFromServer('PHP_SELF')."?func=detailtask&project_task_id=".$pt_arr[$i]->getID()."&group_id=".$group_id."&group_project_id=".$group_project_id;
251 <tr class="priority'.$pt_arr[$i]->getPriority().'"><td style="width:16px; background-color:#FFFFFF">' .
252 util_make_link("/export/rssAboTask.php?tid=" .
253 $pt_arr[$i]->getID(), html_image('ic/rss.png',
254 16, 16, array('border' => '0'))
257 ($IS_ADMIN?'<input type="checkbox" name="project_task_id_list[]" value="'.
258 $pt_arr[$i]->getID() .'" /> ':'').
259 $pt_arr[$i]->getID() ."</td>\n";
260 if ($display_col['summary'])
261 echo '<td><a href="'.$url.'">'.$pt_arr[$i]->getSummary() ."</a></td>\n";
262 if ($display_col['start_date'])
263 echo '<td>'.date(_('Y-m-d H:i'), $pt_arr[$i]->getStartDate() )."</td>\n";
264 if ($display_col['end_date'])
266 if ($now>$pt_arr[$i]->getEndDate() && $pt_arr[$i]->getStatusId() != 2 ) {
273 echo date(_('Y-m-d H:i'), $pt_arr[$i]->getEndDate()) .
275 if ($display_col['percent_complete'])
276 echo '<td>'. $pt_arr[$i]->getPercentComplete() ."%</td>\n";
277 if ($display_col['category'])
278 echo '<td>'. $pt_arr[$i]->getCategoryName() ."</td>\n";
279 if ($display_col['assigned_to'])
280 echo '<td>'. $pg->renderAssigneeList($pt_arr[$i]->getAssignedTo()) ."</td>\n";
281 if ($display_col['priority'])
282 echo '<td>'. $pt_arr[$i]->getPriority() ."</td>\n";
287 if ($_view=="detail") {
289 <tr class="priority'.$pt_arr[$i]->getPriority() .'">
290 <td> </td><td colspan="'.(count($title_arr)-1).'">'. nl2br( $pt_arr[$i]->getDetails() ) .'</td>
297 Show extra rows for <-- Prev / Next -->
299 echo '<tr><td colspan="2">';
301 echo util_make_link ('/pm/task.php?func=browse&group_project_id='.$group_project_id.'&group_id='.$group_id.'&offset='.($offset-$paging),'<strong>← '._('previous').'</strong>');
305 echo '</td><td> </td><td colspan="2">';
307 // currently pm knows only 4 status_id : 100, 1, 2, 3 (any, open, closed, deleted)
310 $totalTasks = $pg->getTotalCount();
314 $totalTasks = $pg->getOpenCount();
319 $totalTasks = $pg->getCount($_status);
323 if ($totalTasks > $offset + $paging) {
324 echo util_make_link ('/pm/task.php?func=browse&group_project_id='.$group_project_id.'&group_id='.$group_id.'&offset='.($offset+$paging),'<strong>'._('next').' →</strong></a>');
330 echo $GLOBALS['HTML']->listTableBottom();
332 echo '<div style="display:table;width:100%">';
333 echo '<div style="display:table-row">';
335 echo '<div style="display:table-cell">';
336 echo _('* Denotes overdue tasks');
339 echo '<div style="display:table-cell;text-align:right">';
340 show_priority_colors_key();
345 echo '<div style="display:table-row">';
347 echo '<div style="display:table-cell">'.$check_all.'</div>';
348 // echo '<div style="display:table-cell;text-align:right">'.$pager.'</div>'."\n";
355 creating a custom technician box which includes "No Change" and "Nobody"
358 $engine = RBACEngine::getInstance () ;
359 $techs = $engine->getUsersByAllowedAction ('pm', $pg->getID(), 'tech') ;
361 $tech_id_arr = array () ;
362 $tech_name_arr = array () ;
364 foreach ($techs as $tech) {
365 $tech_id_arr[] = $tech->getID() ;
366 $tech_name_arr[] = $tech->getRealName() ;
368 $tech_id_arr[]='100.1';
369 $tech_name_arr[]=_('Unassigned');
371 $tech_box=html_build_select_box_from_arrays ($tech_id_arr,$tech_name_arr,'assigned_to',
372 '100',true,_('No Change'));
374 echo '<fieldset id="fieldset1_closed" class="coolfieldset">
375 <legend>'._('Mass Update').'</legend>
377 <table class="fullwidth">
380 <span class="important">'._('If you wish to apply changes to all items selected above, use these controls to change their properties and click once on “Mass Update”.').'</span>
385 <td><strong>'._('Category').
386 '</strong><br />'. $pg->categoryBox ('category_id','xzxz',true,
387 _('No Change')) .'</td>
388 <td><strong>'._('Priority').
390 build_priority_select_box ('priority', '100', true);
395 <td><strong>'._('Assigned to').
396 '</strong><br />'. $tech_box .'</td>
397 <td><strong>'._('State').
398 '</strong><br />'. $pg->statusBox ('status_id','xzxz',true,_('No Change')) .'</td>
401 <tr><td><strong>'._('Subproject').'</strong><br />
402 '.$pg->groupProjectBox('new_group_project_id',$group_project_id,false).'</td>
403 <td><input type="submit" name="submit" value="'.
404 _('Mass Update').'" /></td></tr>
417 // c-file-style: "bsd"