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