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 * http://fusionforge.org
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 require_once $gfcommon.'include/UserManager.class.php';
28 require_once $gfcommon.'pm/ProjectTaskFactory.class.php';
29 //build page title to make bookmarking easier
30 //if a user was selected, add the user_name to the title
33 $pagename = "pm_browse_custom";
35 $offset = getIntFromRequest('offset');
39 $max_rows = getIntFromRequest('max_rows');
41 $ptf = new ProjectTaskFactory($pg);
42 if (!$ptf || !is_object($ptf)) {
43 exit_error(_('Could Not Get ProjectTaskFactory'),'pm');
44 } elseif ($ptf->isError()) {
45 exit_error($ptf->getErrorMessage(),'pm');
48 $_order = getStringFromRequest('_order');
49 $set = getStringFromRequest('set');
50 $_assigned_to = getIntFromRequest('_assigned_to');
51 $_status = getStringFromRequest('_status');
52 $_category_id = getIntFromRequest('_category_id');
53 $_view = getStringFromRequest('_view');
56 if (session_loggedin()) {
57 $u = UserManager::instance()->getCurrentUser();
58 if (getStringFromRequest('setpaging')) {
59 /* store paging preferences */
60 $paging = getIntFromRequest('nres');
64 $u->setPreference("paging", $paging);
66 $paging = $u->getPreference("paging");
72 $ptf->setup($offset,$_order,$paging,$set,$_assigned_to,$_status,$_category_id,$_view);
73 if ($ptf->isError()) {
74 exit_error($ptf->getErrorMessage(),'pm');
76 $pt_arr =& $ptf->getTasks(true);
77 if ($ptf->isError()) {
78 exit_error($ptf->getErrorMessage(),'pm');
81 $_assigned_to=$ptf->assigned_to;
82 $_status=$ptf->status;
84 $_category_id=$ptf->category;
85 $_view=$ptf->view_type;
87 html_use_coolfieldset();
89 pm_header(array('title'=>_('Browse tasks'),'group_project_id'=>$group_project_id));
92 creating a custom technician box which includes "any" and "unassigned"
94 $engine = RBACEngine::getInstance () ;
95 $techs = $engine->getUsersByAllowedAction ('pm', $pg->getID(), 'tech') ;
97 $tech_id_arr = array () ;
98 $tech_name_arr = array () ;
100 foreach ($techs as $tech) {
101 $tech_id_arr[] = $tech->getID() ;
102 $tech_name_arr[] = $tech->getRealName() ;
105 $tech_name_arr[]=_('Any');
107 $tech_box=html_build_select_box_from_arrays ($tech_id_arr,$tech_name_arr,'_assigned_to',$_assigned_to,true,_('Unassigned'));
110 creating a custom category box which includes "any" and "none"
112 $res_cat=$pg->getCategories();
113 $cat_id_arr=util_result_column_to_array($res_cat,0);
114 $cat_id_arr[]='0'; //this will be the 'any' row
115 $cat_name_arr=util_result_column_to_array($res_cat,1);
116 $cat_name_arr[]=_('Any');
117 $cat_box=html_build_select_box_from_arrays ($cat_id_arr,$cat_name_arr,'_category_id',$_category_id,true,'none');
120 Creating a custom sort box
122 $order_title_arr=array();
123 $order_title_arr[]=_('Task Id');
124 $order_title_arr[]=_('Task Summary');
125 $order_title_arr[]=_('Start Date');
126 $order_title_arr[]=_('End Date');
127 $order_title_arr[]=_('Percent Complete');
128 $order_title_arr[]=_('Priority');
130 $order_col_arr=array();
131 $order_col_arr[]='project_task_id';
132 $order_col_arr[]='summary';
133 $order_col_arr[]='start_date';
134 $order_col_arr[]='end_date';
135 $order_col_arr[]='percent_complete';
136 $order_col_arr[]='priority';
137 $order_box=html_build_select_box_from_arrays ($order_col_arr,$order_title_arr,'_order',$_order,false);
143 $view_arr[]=_('Summary');
144 $view_arr[]=_('Detailed');
145 $order_col_arr=array();
146 $view_col_arr[]='summary';
147 $view_col_arr[]='detail';
148 $view_box=html_build_select_box_from_arrays ($view_col_arr,$view_arr,'_view',$_view,false);
151 Show the new pop-up boxes to select assigned to and/or status
153 echo ' <form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&group_project_id='.$group_project_id.'" method="post">
154 <input type="hidden" name="set" value="custom" />
157 <td>'._('Assignee').'<br />'. $tech_box .'</td>
158 <td>'._('Status').'<br />'. $pg->statusBox('_status',$_status,true, _('Any')) .'</td>
159 <td>'._('Category').'<br />'. $cat_box .'</td>
160 <td>'._('Sort On').'<br />'. $order_box .'</td>
161 <td>'._('Detail View').'<br />'. $view_box .'</td>
162 <td><input type="submit" name="submit" value="'._('Browse').'" /></td>
163 </tr></table></form>';
165 $rows=count($pt_arr);
169 <p class="feedback">'._('No Matching Tasks found').'</p>
171 <div class="warning">'._('Add tasks using the link above').'</div>';
174 if (session_loggedin()) {
175 /* logged in users get configurable paging */
176 echo '<form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&group_project_id='.$pg->getID().'&offset='.$offset.'" method="post">'."\n";
179 printf('<p>' . _('Displaying results %1$d‒%2$d.'), $offset + 1, $offset + $rows);
181 if (session_loggedin()) {
182 printf(' ' . _('Displaying %2$s results.') . "\n\t<input " .
183 'type="submit" name="setpaging" value="%1$s" />' .
184 "\n</p>\n</form>\n", _('Change'),
185 html_build_select_box_from_array(array(
186 '10', '25', '50', '100', '1000'), 'nres', $paging, 1));
191 //create a new $set string to be used for next/prev button
192 if ($set=='custom') {
193 $set .= '&_assigned_to='.$_assigned_to.'&_status='.$_status;
197 Now display the tasks in a table with priority colors
199 $IS_ADMIN = forge_check_perm ('pm', $pg->getID(), 'manager') ;
203 <form name="taskList" action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&group_project_id='.$pg->getID().'" method="post">
204 <input type="hidden" name="func" value="massupdate" />';
207 <a href="javascript:checkAllTasks(1)">'._('Check all').'</a>
209 <a href="javascript:checkAllTasks(0)">'._('Clear all').'</a>';
214 //this array can be customized to display whichever columns you want
215 //it could be built by querying a table on a per-user basis as well
216 $display_col=array('summary'=>1,
219 'percent_complete'=>1,
226 $title_arr[]=_('Task Id');
227 if ($display_col['summary'])
228 $title_arr[]=_('Task Summary');
229 if ($display_col['start_date'])
230 $title_arr[]=_('Start Date');
231 if ($display_col['end_date'])
232 $title_arr[]=_('End Date');
233 if ($display_col['percent_complete'])
234 $title_arr[]=_('Percent Complete');
235 if ($display_col['category'])
236 $title_arr[]=_('Category');
237 if ($display_col['assigned_to'])
238 $title_arr[]=_('Assigned to');
239 if ($display_col['priority'])
240 $title_arr[]=_('Priority');
242 echo $GLOBALS['HTML']->listTableTop ($title_arr);
246 for ($i=0; $i < $rows; $i++) {
247 $url = getStringFromServer('PHP_SELF')."?func=detailtask&project_task_id=".$pt_arr[$i]->getID()."&group_id=".$group_id."&group_project_id=".$group_project_id;
250 <tr class="priority'.$pt_arr[$i]->getPriority().'"><td style="width:16px; background-color:#FFFFFF">' .
251 util_make_link("/export/rssAboTask.php?tid=" .
252 $pt_arr[$i]->getID(), html_image('ic/rss.png',
253 16, 16, array('border' => '0'))
256 ($IS_ADMIN?'<input type="checkbox" name="project_task_id_list[]" value="'.
257 $pt_arr[$i]->getID() .'" /> ':'').
258 $pt_arr[$i]->getID() ."</td>\n";
259 if ($display_col['summary'])
260 echo '<td><a href="'.$url.'">'.$pt_arr[$i]->getSummary() ."</a></td>\n";
261 if ($display_col['start_date'])
262 echo '<td>'.date(_('Y-m-d H:i'), $pt_arr[$i]->getStartDate() )."</td>\n";
263 if ($display_col['end_date'])
265 if ($now>$pt_arr[$i]->getEndDate() && $pt_arr[$i]->getStatusId() != 2 ) {
272 echo date(_('Y-m-d H:i'), $pt_arr[$i]->getEndDate()) .
274 if ($display_col['percent_complete'])
275 echo '<td>'. $pt_arr[$i]->getPercentComplete() ."%</td>\n";
276 if ($display_col['category'])
277 echo '<td>'. $pt_arr[$i]->getCategoryName() ."</td>\n";
278 if ($display_col['assigned_to'])
279 echo '<td>'. $pg->renderAssigneeList($pt_arr[$i]->getAssignedTo()) ."</td>\n";
280 if ($display_col['priority'])
281 echo '<td>'. $pt_arr[$i]->getPriority() ."</td>\n";
286 if ($_view=="detail") {
288 <tr class="priority'.$pt_arr[$i]->getPriority() .'">
289 <td> </td><td colspan="'.(count($title_arr)-1).'">'. nl2br( $pt_arr[$i]->getDetails() ) .'</td>
296 Show extra rows for <-- Prev / Next -->
298 echo '<tr><td colspan="2">';
300 echo util_make_link ('/pm/task.php?func=browse&group_project_id='.$group_project_id.'&group_id='.$group_id.'&offset='.($offset-50),'<strong>← '._('previous').'</strong>');
304 echo '</td><td> </td><td colspan="2">';
307 echo util_make_link ('/pm/task.php?func=browse&group_project_id='.$group_project_id.'&group_id='.$group_id.'&offset='.($offset+50),'<strong>'._('next').' →</strong></a>');
313 echo $GLOBALS['HTML']->listTableBottom();
315 echo '<div style="display:table;width:100%">';
316 echo '<div style="display:table-row">';
318 echo '<div style="display:table-cell">';
319 echo _('* Denotes overdue tasks');
322 echo '<div style="display:table-cell;text-align:right">';
323 show_priority_colors_key();
328 echo '<div style="display:table-row">';
330 echo '<div style="display:table-cell">'.$check_all.'</div>';
331 // echo '<div style="display:table-cell;text-align:right">'.$pager.'</div>'."\n";
338 creating a custom technician box which includes "No Change" and "Nobody"
341 $engine = RBACEngine::getInstance () ;
342 $techs = $engine->getUsersByAllowedAction ('pm', $pg->getID(), 'tech') ;
344 $tech_id_arr = array () ;
345 $tech_name_arr = array () ;
347 foreach ($techs as $tech) {
348 $tech_id_arr[] = $tech->getID() ;
349 $tech_name_arr[] = $tech->getRealName() ;
351 $tech_id_arr[]='100.1';
352 $tech_name_arr[]=_('Unassigned');
354 $tech_box=html_build_select_box_from_arrays ($tech_id_arr,$tech_name_arr,'assigned_to',
355 '100',true,_('No Change'));
357 echo '<fieldset id="fieldset1_closed" class="coolfieldset">
358 <legend>'._('Mass Update').'</legend>
360 <table class="fullwidth">
363 <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>
368 <td><strong>'._('Category').
369 '</strong><br />'. $pg->categoryBox ('category_id','xzxz',true,
370 _('No Change')) .'</td>
371 <td><strong>'._('Priority').
373 build_priority_select_box ('priority', '100', true);
378 <td><strong>'._('Assigned to').
379 '</strong><br />'. $tech_box .'</td>
380 <td><strong>'._('State').
381 '</strong><br />'. $pg->statusBox ('status_id','xzxz',true,_('No Change')) .'</td>
384 <tr><td><strong>'._('Subproject').'</strong><br />
385 '.$pg->groupProjectBox('new_group_project_id',$group_project_id,false).'</td>
386 <td><input type="submit" name="submit" value="'.
387 _('Mass Update').'" /></td></tr>
400 // c-file-style: "bsd"