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,2015, Franck Villaume - TrivialDev
10 * Copyright 2014, Stéphane-Eymeric Bredthauer
11 * Copyright 2015, nitendra tripathi
12 * http://fusionforge.org
14 * This file is part of FusionForge. FusionForge is free software;
15 * you can redistribute it and/or modify it under the terms of the
16 * GNU General Public License as published by the Free Software
17 * Foundation; either version 2 of the Licence, or (at your option)
20 * FusionForge is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License along
26 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
27 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 require_once $gfcommon.'include/UserManager.class.php';
31 require_once $gfcommon.'pm/ProjectTaskFactory.class.php';
32 //build page title to make bookmarking easier
33 //if a user was selected, add the user_name to the title
39 $pagename = "pm_browse_custom";
41 $start = getIntFromRequest('start');
46 $ptf = new ProjectTaskFactory($pg);
47 if (!$ptf || !is_object($ptf)) {
48 exit_error(_('Could Not Get ProjectTaskFactory'), 'pm');
49 } elseif ($ptf->isError()) {
50 exit_error($ptf->getErrorMessage(), 'pm');
53 $_order = getStringFromRequest('_order');
54 $_sort_order = getStringFromRequest('_sort_order');
55 $set = getStringFromRequest('set');
56 $_assigned_to = getIntFromRequest('_assigned_to');
57 $_status = getStringFromRequest('_status');
58 $_category_id = getIntFromRequest('_category_id');
59 $_view = getStringFromRequest('_view');
61 if (session_loggedin()) {
62 if (getStringFromRequest('setpaging')) {
63 /* store paging preferences */
64 $paging = getIntFromRequest('nres');
68 $LUSER->setPreference('paging', $paging);
70 $paging = $LUSER->getPreference('paging');
74 if(!isset($paging) || !$paging)
77 $ptf->setup($start, $_order, $paging, $set, $_assigned_to, $_status, $_category_id, $_view, $_sort_order);
78 if ($ptf->isError()) {
79 exit_error($ptf->getErrorMessage(), 'pm');
81 $pt_arr =& $ptf->getTasks(true);
82 if ($ptf->isError()) {
83 exit_error($ptf->getErrorMessage(), 'pm');
86 $_assigned_to = $ptf->assigned_to;
87 $_status = $ptf->status;
88 $_order = $ptf->order;
89 $_sort_order = $ptf->sort_order;
90 $_category_id = $ptf->category;
91 $_view = $ptf->view_type;
93 html_use_coolfieldset();
95 pm_header(array('title' => _('Browse tasks'), 'group_project_id' => $group_project_id));
98 creating a custom technician box which includes "any" and "unassigned"
100 $engine = RBACEngine::getInstance();
101 $techs = $engine->getUsersByAllowedAction('pm', $pg->getID(), 'tech');
103 $tech_select_arr = array();
105 foreach ($techs as $tech) {
106 $tech_select_arr[$tech->getID()] = $tech->getRealName();
108 $tech_select_arr[0] = _('Any');
110 $tech_box = html_build_select_box_from_assoc($tech_select_arr ,'_assigned_to', $_assigned_to, false, true, _('Unassigned'));
113 creating a custom category box which includes "any" and "none"
115 $res_cat = $pg->getCategories();
116 $cat_id_arr = util_result_column_to_array($res_cat, 0);
117 $cat_id_arr[] = '0'; //this will be the 'any' row
118 $cat_name_arr = util_result_column_to_array($res_cat, 1);
119 $cat_name_arr[] = _('Any');
120 $cat_box = html_build_select_box_from_arrays($cat_id_arr, $cat_name_arr, '_category_id', $_category_id, true, 'none');
123 Creating a custom order box
125 $order_select_arr = array();
126 $order_select_arr['project_task_id'] = _('Task Id');
127 $order_select_arr['summary'] = _('Task Summary');
128 $order_select_arr['start_date'] = _('Start Date');
129 $order_select_arr['end_date'] = _('End Date');
130 $order_select_arr['percent_complete'] = _('Percent Complete');
131 $order_select_arr['priority'] = _('Priority');
133 $order_box = html_build_select_box_from_assoc($order_select_arr, '_order', $_order, false, false);
136 Creating a custom sort box
139 $sort_select_arr=array();
140 $sort_select_arr['ASC'] = _('Ascending');
141 $sort_select_arr['DESC'] = _('Descending');
143 $sort_box = html_build_select_box_from_assoc($sort_select_arr, '_sort_order', $_sort_order, false, false);
147 $view_select_arr = array();
148 $view_select_arr['summary'] = _('Summary');
149 $view_select_arr['detail'] = _('Detailed');
150 $view_box = html_build_select_box_from_assoc($view_select_arr, '_view', $_view, false, false);
152 $rows = count($pt_arr);
153 $totalTasks = $pg->getCount($_status, $_category_id);
154 $max = ($rows > ($start + $paging)) ? ($start + $paging) : $rows;
156 echo $HTML->paging_top($start, $paging, $totalTasks, $max, '/pm/task.php?group_id='.$group_id.'&group_project_id='.$pg->getID());
159 Show the new pop-up boxes to select assigned to and/or status
161 echo $HTML->openForm(array('action' => '/pm/task.php?group_id='.$group_id.'&group_project_id='.$group_project_id, 'method' => 'post'));
162 echo ' <input type="hidden" name="set" value="custom" />
165 <td>'._('Assignee')._(': ').'<br />'. $tech_box .'</td>
166 <td>'._('Status')._(': ').'<br />'. $pg->statusBox('_status',$_status,true, _('Any')) .'</td>
167 <td>'._('Category')._(': ').'<br />'. $cat_box .'</td>
168 <td>'._('Sort On')._(': ').'<br />'. $order_box . $sort_box .'</td>
169 <td>'._('Detail View')._(': ').'<br />'. $view_box .'</td>
170 <td style="vertical-align: bottom"><input type="submit" name="submit" value="'._('Browse').'" /></td>
172 echo $HTML->closeForm();
174 echo $HTML->information(_('No Matching Tasks found'));
175 echo '<p class="important">'._('Add tasks using the link above')."</p>\n";
179 //create a new $set string to be used for next/prev button
180 if ($set=='custom') {
181 $set .= '&_assigned_to='.$_assigned_to.'&_status='.$_status;
185 Now display the tasks in a table with priority colors
187 $IS_ADMIN = forge_check_perm('pm', $pg->getID(), 'manager');
190 echo $HTML->openForm(array('name' => 'taskList', 'action' => '/pm/task.php?group_id='.$group_id.'&group_project_id='.$pg->getID(), 'method' => 'post'));
191 echo '<input type="hidden" name="func" value="massupdate" />';
194 <a href="javascript:checkAllTasks(1)">'._('Check all').'</a>
196 <a href="javascript:checkAllTasks(0)">'._('Clear all').'</a>';
201 //this array can be customized to display whichever columns you want
202 //it could be built by querying a table on a per-user basis as well
203 $display_col=array('summary'=>1,
206 'percent_complete'=>1,
215 $title_arr[]=_('Task Id');
216 if ($display_col['summary'])
217 $title_arr[]=_('Task Summary');
218 if ($display_col['status'])
219 $title_arr[]=_('Status');
220 if ($display_col['start_date'])
221 $title_arr[]=_('Start Date');
222 if ($display_col['end_date'])
223 $title_arr[]=_('End Date');
224 if ($display_col['percent_complete'])
225 $title_arr[]=_('Percent Complete');
226 if ($display_col['category'])
227 $title_arr[]=_('Category');
228 if ($display_col['assigned_to'])
229 $title_arr[]=_('Assigned to');
230 if ($display_col['priority'])
231 $title_arr[]=_('Priority');
234 echo $HTML->listTableTop($title_arr, array(), 'full');
238 for ($i=0; $i < $rows; $i++) {
239 $url = '/pm/task.php?func=detailtask&project_task_id='.$pt_arr[$i]->getID().'&group_id='.$group_id.'&group_project_id='.$group_project_id;
242 <tr class="priority'.$pt_arr[$i]->getPriority().'"><td style="width:16px; background-color:#FFFFFF">' .
243 util_make_link('/export/rssAboTask.php?tid=' .
244 $pt_arr[$i]->getID(), html_image('ic/rss.png', 16, 16)) . "</td>\n" .
246 ($IS_ADMIN?'<input type="checkbox" name="project_task_id_list[]" value="'.
247 $pt_arr[$i]->getID() .'" /> ':'').
248 $pt_arr[$i]->getID() ."</td>\n";
249 if ($display_col['summary'])
250 echo '<td>'.util_make_link($url,$pt_arr[$i]->getSummary())."</td>\n";
251 if ($display_col['status'])
252 echo '<td>'. $pt_arr[$i]->getStatusName() ."</td>\n";
253 if ($display_col['start_date'])
254 echo '<td>'.date(_('Y-m-d H:i'), $pt_arr[$i]->getStartDate() )."</td>\n";
255 if ($display_col['end_date'])
257 if ($now>$pt_arr[$i]->getEndDate() && $pt_arr[$i]->getStatusId() != 2 ) {
264 echo date(_('Y-m-d H:i'), $pt_arr[$i]->getEndDate()) .
266 if ($display_col['percent_complete'])
267 echo '<td>'. $pt_arr[$i]->getPercentComplete() ."%</td>\n";
268 if ($display_col['category'])
269 echo '<td>'. $pt_arr[$i]->getCategoryName() ."</td>\n";
270 if ($display_col['assigned_to'])
271 echo '<td>'. $pg->renderAssigneeList($pt_arr[$i]->getAssignedTo()) ."</td>\n";
272 if ($display_col['priority'])
273 echo '<td>'. $pt_arr[$i]->getPriority() ."</td>\n";
278 if ($_view=="detail") {
280 <tr class="priority'.$pt_arr[$i]->getPriority() .'">
281 <td> </td><td colspan="'.(count($title_arr)-1).'">'. nl2br($pt_arr[$i]->getDetails()) .'</td>
286 echo $HTML->listTableBottom();
288 Show extra rows for <-- Prev / Next -->
290 echo $HTML->paging_bottom($start, $paging, $totalTasks, '/pm/task.php?func=browse&group_project_id='.$group_project_id.'&group_id='.$group_id);
292 echo '<div style="display:table;width:100%">';
293 echo '<div style="display:table-row">';
295 echo '<div style="display:table-cell">';
296 echo _('* Denotes overdue tasks');
299 echo '<div style="display:table-cell;text-align:right">';
300 echo $HTML->show_priority_colors_key();
305 echo '<div style="display:table-row">';
307 echo '<div style="display:table-cell">'.$check_all.'</div>';
308 // echo '<div style="display:table-cell;text-align:right">'.$pager.'</div>'."\n";
315 creating a custom technician box which includes "No Change" and "Nobody"
318 $engine = RBACEngine::getInstance();
319 $techs = $engine->getUsersByAllowedAction('pm', $pg->getID(), 'tech');
321 $tech_id_arr = array();
322 $tech_name_arr = array();
324 foreach ($techs as $tech) {
325 $tech_id_arr[] = $tech->getID();
326 $tech_name_arr[] = $tech->getRealName();
328 $tech_id_arr[]='100.1';
329 $tech_name_arr[]=_('Unassigned');
331 $tech_box=html_build_select_box_from_arrays($tech_id_arr,$tech_name_arr,'assigned_to',
332 '100',true,_('No Change'));
334 echo '<fieldset id="fieldset1_closed" class="coolfieldset">
335 <legend>'._('Mass Update').'</legend>
337 echo $HTML->information(_('If you wish to apply changes to all items selected above, use these controls to change their properties and click once on “Mass Update”.'));
338 echo ' <table class="infotable">
341 <td>'._('Category')._(':').'</td>
342 <td>'. $pg->categoryBox('category_id','xzxz',true, _('No Change')) .'</td>
346 <td>'._('Priority')._(':').'</td>
348 echo build_priority_select_box('priority', '100', true);
353 <td>'._('Assigned to')._(':').'</td>
354 <td>'. $tech_box .'</td>
358 <td>'._('State')._(':').'</td>
359 <td>'. $pg->statusBox('status_id','xzxz',true,_('No Change')) .'</td>
363 <td>'._('Subproject')._(':').'</td>
364 <td>'.$pg->groupProjectBox('new_group_project_id',$group_project_id,false).'</td>
368 <td colspan="2"><input type="submit" name="submit" value="'. _('Mass Update').'" /></td>
374 echo $HTML->closeForm();
382 // c-file-style: "bsd"