3 * Copyright (C) 2009 Alain Peyrat, Alcatel-Lucent
5 * This file is part of FusionForge. FusionForge is free software;
6 * you can redistribute it and/or modify it under the terms of the
7 * GNU General Public License as published by the Free Software
8 * Foundation; either version 2 of the Licence, or (at your option)
11 * FusionForge is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * Standard Alcatel-Lucent disclaimer for contributing to open source
24 * "The provided file ("Contribution") has not been tested and/or
25 * validated for release as or in products, combinations with products or
26 * other commercial use. Any use of the Contribution is entirely made at
27 * the user's own responsibility and the user can not rely on any features,
28 * functionalities or performances Alcatel-Lucent has attributed to the
31 * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
32 * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
33 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
34 * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
35 * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
36 * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
37 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
38 * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
39 * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
44 Record description for .csv file format
46 project_task_id This is the ID in gforge database
47 external_task_id The equivalent of project_task_id but determined by
48 external application, such as MS Project
49 parent_id The project_task_id of the parent task, if any
50 external_parent_id The equivalent of parent project_task_id but
51 determined by external application, such as MS Project
52 title Name ********may contain , characters???
58 priority low, medium, high
59 notes Details ********may contain , characters???
65 dependenton1_project_task_id
66 dependenton1_external_task_id
67 dependenton1_linktype SS SF FS FF
68 dependenton2_project_task_id
69 dependenton2_external_task_id
71 dependenton3_project_task_id
72 dependenton3_external_task_id
74 dependenton4_project_task_id
75 dependenton4_external_task_id
77 dependenton5_project_task_id
78 dependenton5_external_task_id
82 require_once $gfcommon.'include/User.class.php';
83 require_once $gfcommon.'pm/ProjectTaskFactory.class.php';
85 $headers = getIntFromRequest('headers');
86 $full = getIntFromRequest('full');
87 $sep = getStringFromRequest('sep', ',');
89 $date = date('Y-m-d');
91 header('Content-type: text/csv');
92 header('Content-disposition: filename="tasks-'.$date.'.csv"');
94 $ptf = new ProjectTaskFactory($pg);
95 if (!$ptf || !is_object($ptf)) {
96 exit_error(_('Could Not Get ProjectTaskFactory'),'pm');
97 } elseif ($ptf->isError()) {
98 exit_error($ptf->getErrorMessage(),'pm');
100 $ptf->order='external_id';
101 $pt_arr =& $ptf->getTasks();
102 if ($ptf->isError()) {
103 exit_error($ptf->getErrorMessage(),'pm');
107 // Iterate the array of tasks and dump them out to a comma-separated file
110 $arrRemove = array("\r\n", "\n", $sep);
116 'external_parent_id',
125 'resource1_unixname',
126 'resource2_unixname',
127 'resource3_unixname',
128 'resource4_unixname',
129 'resource5_unixname',
130 'dependenton1_project_task_id',
131 'dependenton1_external_task_id',
132 'dependenton1_linktype',
133 'dependenton2_project_task_id',
134 'dependenton2_external_task_id',
135 'dependenton2_linktype',
136 'dependenton3_project_task_id',
137 'dependenton3_external_task_id',
138 'dependenton3_linktype',
139 'dependenton4_project_task_id',
140 'dependenton4_external_task_id',
141 'dependenton4_linktype',
142 'dependenton5_project_task_id',
143 'dependenton5_external_task_id',
144 'dependenton5_linktype');
151 'external_parent_id',
161 'resource1_unixname',
162 'resource2_unixname',
163 'resource3_unixname',
164 'resource4_unixname',
165 'resource5_unixname',
166 'dependenton1_project_task_id',
167 'dependenton1_external_task_id',
168 'dependenton1_linktype',
169 'dependenton2_project_task_id',
170 'dependenton2_external_task_id',
171 'dependenton2_linktype',
172 'dependenton3_project_task_id',
173 'dependenton3_external_task_id',
174 'dependenton3_linktype',
175 'dependenton4_project_task_id',
176 'dependenton4_external_task_id',
177 'dependenton4_linktype',
178 'dependenton5_project_task_id',
179 'dependenton5_external_task_id',
180 'dependenton5_linktype');
184 echo join($sep, $header)."\n";
187 for ($i=0; $i<count($pt_arr); $i++) {
189 echo $pt_arr[$i]->getID().$sep.
190 $pt_arr[$i]->getExternalID().$sep.
191 $pt_arr[$i]->getParentID().$sep.
193 str_replace($arrRemove, ' ', $pt_arr[$i]->getSummary()).$sep;
195 echo $pt_arr[$i]->getCategoryName().$sep;
197 echo $pt_arr[$i]->getDuration().$sep.
198 $pt_arr[$i]->getHours().$sep.
199 date('Y-m-d H:i:s',$pt_arr[$i]->getStartDate()).$sep.
200 date('Y-m-d H:i:s',$pt_arr[$i]->getEndDate()).$sep.
201 $pt_arr[$i]->getPercentComplete().$sep.
202 $pt_arr[$i]->getPriority().$sep.
203 str_replace($arrRemove, ' ', $pt_arr[$i]->getDetails()).$sep;
205 $users =& user_get_objects($pt_arr[$i]->getAssignedTo());
206 for ($j=0; $j<5; $j++) {
207 if ($j < count($users)) {
208 if ($users[$j]->getUnixName() != 'none') {
209 echo $users[$j]->getUnixName();
215 $dependentOn = $pt_arr[$i]->getDependentOn();
216 $keys=array_keys($dependentOn);
217 for ($j=0; $j<5; $j++) {
218 if ($j < count($keys)) {
219 echo $keys[$j].$sep.$sep.$dependentOn[$keys[$j]];