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");
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');
122 Creating a custom sort box
124 $order_title_arr=array();
125 $order_title_arr[]=_('Task Id');
126 $order_title_arr[]=_('Task Summary');
127 $order_title_arr[]=_('Start Date');
128 $order_title_arr[]=_('End Date');
129 $order_title_arr[]=_('Percent Complete');
130 $order_title_arr[]=_('Priority');
132 $order_col_arr=array();
133 $order_col_arr[]='project_task_id';
134 $order_col_arr[]='summary';
135 $order_col_arr[]='start_date';
136 $order_col_arr[]='end_date';
137 $order_col_arr[]='percent_complete';
138 $order_col_arr[]='priority';
139 $order_box=html_build_select_box_from_arrays ($order_col_arr,$order_title_arr,'_order',$_order,false);
145 $view_arr[]=_('Summary');
146 $view_arr[]=_('Detailed');
147 $order_col_arr=array();
148 $view_col_arr[]='summary';
149 $view_col_arr[]='detail';
150 $view_box=html_build_select_box_from_arrays ($view_col_arr,$view_arr,'_view',$_view,false);
153 Show the new pop-up boxes to select assigned to and/or status
155 echo ' <form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&group_project_id='.$group_project_id.'" method="post">
156 <input type="hidden" name="set" value="custom" />
159 <td>'._('Assignee').'<br />'. $tech_box .'</td>
160 <td>'._('Status').'<br />'. $pg->statusBox('_status',$_status,true, _('Any')) .'</td>
161 <td>'._('Category').'<br />'. $cat_box .'</td>
162 <td>'._('Sort On').'<br />'. $order_box .'</td>
163 <td>'._('Detail View').'<br />'. $view_box .'</td>
164 <td><input type="submit" name="submit" value="'._('Browse').'" /></td>
165 </tr></table></form><p />';
168 $rows=count($pt_arr);
172 <p class="feedback">'._('No Matching Tasks found').'</p>
174 <div class="warning">'._('Add tasks using the link above').'</div>';
177 if (session_loggedin()) {
178 /* logged in users get configurable paging */
179 echo '<form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&group_project_id='.$pg->getID().'&offset='.$offset.'" method="post">'."\n";
182 printf('<p>' . _('Displaying results %1$dā%2$d.'), $offset + 1, $offset + $rows);
184 if (session_loggedin()) {
185 printf(' ' . _('Displaying %2$s results.') . "\n\t<input " .
186 'type="submit" name="setpaging" value="%1$s" />' .
187 "\n</p>\n</form>\n", _('Change'),
188 html_build_select_box_from_array(array(
189 '10', '25', '50', '100', '1000'), 'nres', $paging, 1));
194 //create a new $set string to be used for next/prev button
195 if ($set=='custom') {
196 $set .= '&_assigned_to='.$_assigned_to.'&_status='.$_status;
200 Now display the tasks in a table with priority colors
202 $IS_ADMIN = forge_check_perm ('pm', $pg->getID(), 'manager') ;
206 <form name="taskList" action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&group_project_id='.$pg->getID().'" method="post">
207 <input type="hidden" name="func" value="massupdate" />';
210 <a href="javascript:checkAllTasks(1)">'._('Check all').'</a>
212 <a href="javascript:checkAllTasks(0)">'._('Clear all').'</a>';
217 //this array can be customized to display whichever columns you want
218 //it could be built by querying a table on a per-user basis as well
219 $display_col=array('summary'=>1,
222 'percent_complete'=>1,
229 $title_arr[]=_('Task Id');
230 if ($display_col['summary'])
231 $title_arr[]=_('Task Summary');
232 if ($display_col['start_date'])
233 $title_arr[]=_('Start Date');
234 if ($display_col['end_date'])
235 $title_arr[]=_('End Date');
236 if ($display_col['percent_complete'])
237 $title_arr[]=_('Percent Complete');
238 if ($display_col['category'])
239 $title_arr[]=_('Category');
240 if ($display_col['assigned_to'])
241 $title_arr[]=_('Assigned to');
242 if ($display_col['priority'])
243 $title_arr[]=_('Priority');
245 echo $GLOBALS['HTML']->listTableTop ($title_arr);
249 for ($i=0; $i < $rows; $i++) {
250 $url = getStringFromServer('PHP_SELF')."?func=detailtask&project_task_id=".$pt_arr[$i]->getID()."&group_id=".$group_id."&group_project_id=".$group_project_id;
253 <tr class="priority'.$pt_arr[$i]->getPriority().'"><td style="width:16px; background-color:#FFFFFF">' .
254 util_make_link("/export/rssAboTask.php?tid=" .
255 $pt_arr[$i]->getID(), html_image('ic/rss.png',
256 16, 16, array('border' => '0'))
259 ($IS_ADMIN?'<input type="checkbox" name="project_task_id_list[]" value="'.
260 $pt_arr[$i]->getID() .'" /> ':'').
261 $pt_arr[$i]->getID() ."</td>\n";
262 if ($display_col['summary'])
263 echo '<td><a href="'.$url.'">'.$pt_arr[$i]->getSummary() ."</a></td>\n";
264 if ($display_col['start_date'])
265 echo '<td>'.date(_('Y-m-d H:i'), $pt_arr[$i]->getStartDate() )."</td>\n";
266 if ($display_col['end_date'])
268 if ($now>$pt_arr[$i]->getEndDate() && $pt_arr[$i]->getStatusId() != 2 ) {
275 echo date(_('Y-m-d H:i'), $pt_arr[$i]->getEndDate()) .
277 if ($display_col['percent_complete'])
278 echo '<td>'. $pt_arr[$i]->getPercentComplete() ."%</td>\n";
279 if ($display_col['category'])
280 echo '<td>'. $pt_arr[$i]->getCategoryName() ."</td>\n";
281 if ($display_col['assigned_to'])
282 echo '<td>'. $pg->renderAssigneeList($pt_arr[$i]->getAssignedTo()) ."</td>\n";
283 if ($display_col['priority'])
284 echo '<td>'. $pt_arr[$i]->getPriority() ."</td>\n";
289 if ($_view=="detail") {
291 <tr class="priority'.$pt_arr[$i]->getPriority() .'">
292 <td> </td><td colspan="'.(count($title_arr)-1).'">'. nl2br( $pt_arr[$i]->getDetails() ) .'</td>
299 Show extra rows for <-- Prev / Next -->
301 echo '<tr><td colspan="2">';
303 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>');
307 echo '</td><td> </td><td colspan="2">';
310 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>');
316 echo $GLOBALS['HTML']->listTableBottom();
318 echo '<div style="display:table;width:100%">';
319 echo '<div style="display:table-row">';
321 echo '<div style="display:table-cell">';
322 echo _('* Denotes overdue tasks');
325 echo '<div style="display:table-cell;text-align:right">';
326 show_priority_colors_key();
331 echo '<div style="display:table-row">';
333 echo '<div style="display:table-cell">'.$check_all.'</div>';
334 // echo '<div style="display:table-cell;text-align:right">'.$pager.'</div>'."\n";
341 creating a custom technician box which includes "No Change" and "Nobody"
344 $engine = RBACEngine::getInstance () ;
345 $techs = $engine->getUsersByAllowedAction ('pm', $pg->getID(), 'tech') ;
347 $tech_id_arr = array () ;
348 $tech_name_arr = array () ;
350 foreach ($techs as $tech) {
351 $tech_id_arr[] = $tech->getID() ;
352 $tech_name_arr[] = $tech->getRealName() ;
354 $tech_id_arr[]='100.1';
355 $tech_name_arr[]=_('Unassigned');
357 $tech_box=html_build_select_box_from_arrays ($tech_id_arr,$tech_name_arr,'assigned_to',
358 '100',true,_('No Change'));
360 echo '<fieldset id="fieldset1_closed" class="coolfieldset">
361 <legend>'._('Mass Update').'</legend>
363 <table class="fullwidth">
366 <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".').'</span>
371 <td><strong>'._('Category').
372 '</strong><br />'. $pg->categoryBox ('category_id','xzxz',true,
373 _('No Change')) .'</td>
374 <td><strong>'._('Priority').
376 echo build_priority_select_box ('priority', '100', true);
381 <td><strong>'._('Assigned to').
382 '</strong><br />'. $tech_box .'</td>
383 <td><strong>'._('State').
384 '</strong><br />'. $pg->statusBox ('status_id','xzxz',true,_('No Change')) .'</td>
387 <tr><td><strong>'._('Subproject').'</strong><br />
388 '.$pg->groupProjectBox('new_group_project_id',$group_project_id,false).'</td>
389 <td><input type="submit" name="submit" value="'.
390 _('Mass Update').'" /></td></tr>
403 // c-file-style: "bsd"