3 * Project Management Facility
5 * Copyright 1999/2000, Sourceforge.net 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('../env.inc.php');
28 require_once $gfcommon.'include/pre.php';
29 require_once $gfwww.'pm/include/ProjectGroupHTML.class.php';
30 require_once $gfcommon.'pm/ProjectGroupFactory.class.php';
32 $group_id = getIntFromRequest('group_id');
37 $g = group_get_object($group_id);
38 if (!$g || !is_object($g)) {
40 } elseif ($g->isError()) {
41 exit_error($g->getErrorMessage(),'pm');
44 $pgf = new ProjectGroupFactory($g);
45 if (!$pgf || !is_object($pgf)) {
46 exit_error(_('Could Not Get Factory'),'pm');
47 } elseif ($pgf->isError()) {
48 exit_error($pgf->getErrorMessage(),'pm');
51 $pg_arr = $pgf->getProjectGroups();
52 if ($pg_arr && $pgf->isError()) {
53 exit_error($pgf->getErrorMessage(),'pm');
56 pm_header(array('title'=>sprintf(_('Subprojects for %1$s'), $g->getPublicName())));
58 plugin_hook("blocks", "tasks index");
60 if (count($pg_arr) < 1 || $pg_arr == false) {
61 echo '<p class="warning_msg">'._('No Subprojects Found').'</p>';
62 echo '<p>'._('No subprojects have been set up, or you cannot view them.').'</p>';
63 echo '<p class="important">'._('The Admin for this project will have to set up subprojects using the admin page.').'</p>';
66 <p>'._('Choose a Subproject and you can browse/edit/add tasks to it.').'</p>';
69 Put the result set (list of projects for this group) into a column with folders
72 $sortcol = util_ensure_value_in_set (getStringFromRequest ('sortcol'),
74 'project_description',
78 $sortorder = util_ensure_value_in_set (getStringFromRequest ('sortorder'),
82 function build_column_sort_header ($group_id, $title, $val) {
83 global $sortcol, $sortorder ;
85 if ($sortcol != $val) {
86 return util_make_link ("/pm/?group_id=$group_id&sortcol=$val",
88 } elseif ($sortorder == 'a') {
89 return util_make_link ("/pm/?group_id=$group_id&sortcol=$val&sortorder=d",
92 return util_make_link ("/pm/?group_id=$group_id&sortcol=$val&sortorder=a",
97 $tablearr = array () ;
98 $tablearr[] = build_column_sort_header ($group_id, _('ID'), 'project_id') ;
99 $tablearr[] = build_column_sort_header ($group_id, _('Subproject Name'), 'project_name') ;
100 $tablearr[] = build_column_sort_header ($group_id, _('Description'), 'project_description') ;
101 $tablearr[] = build_column_sort_header ($group_id, _('Open'), 'open_count') ;
102 $tablearr[] = build_column_sort_header ($group_id, _('Total'), 'total_count') ;
103 echo $HTML->listTableTop($tablearr);
105 function project_group_comparator ($a, $b) {
106 global $sortcol, $sortorder ;
111 $va = $a->getName() ;
112 $vb = $b->getName() ;
114 case 'project_description':
116 $va = $a->getDescription() ;
117 $vb = $b->getDescription() ;
126 $va = $a->getOpenCount();
127 $vb = $b->getOpenCount();
131 $va = $a->getTotalCount();
132 $vb = $b->getTotalCount();
140 $tmp = strcoll ($va, $vb) ;
145 } elseif ($va > $vb) {
155 if ($sortorder == 'd') {
162 usort ($pg_arr, 'project_group_comparator') ;
164 for ($j = 0; $j < count($pg_arr); $j++) {
165 if (!is_object($pg_arr[$j])) {
167 } elseif ($pg_arr[$j]->isError()) {
168 echo $pg_arr[$j]->getErrorMessage();
171 <tr '. $HTML->boxGetAltRowStyle($j) . '>
172 <td><a href="'.util_make_url ('/pm/task.php?group_project_id='. $pg_arr[$j]->getID().'&group_id='.$group_id.'&func=browse').'">' .
173 html_image("ic/taskman20w.png","20","20") . ' '.$pg_arr[$j]->getID() .'</a></td>
174 <td><a href="'.util_make_url ('/pm/task.php?group_project_id='. $pg_arr[$j]->getID().'&group_id='.$group_id.'&func=browse').'">' .
175 $pg_arr[$j]->getName() .'</a></td>
176 <td>'.$pg_arr[$j]->getDescription() .'</td>
177 <td style="text-align:right">'. (int) $pg_arr[$j]->getOpenCount().'</td>
178 <td style="text-align:right">'. (int) $pg_arr[$j]->getTotalCount().'</td>
182 echo $HTML->listTableBottom();