3 * Copyright 2005 (c) GForge Group, LLC
5 * This file is part of GForge.
7 * GForge is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * GForge is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GForge; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
21 require_once $gfcommon.'tracker/ArtifactFactory.class.php';
23 $date = date('Y-m-d');
25 header('Content-type: text/csv');
26 header('Content-disposition: filename="tracker_report-'.$date.'.csv"');
28 if (!$ath->userCanView()) {
29 exit_permission_denied();
32 $af = new ArtifactFactory($ath);
33 if (!$af || !is_object($af)) {
34 exit_error('Error','Could Not Get Factory');
35 } elseif ($af->isError()) {
36 exit_error('Error',$af->getErrorMessage());
39 $offset = getStringFromRequest('offset');
40 $_sort_col = getStringFromRequest('_sort_col');
41 $_sort_ord = getStringFromRequest('_sort_ord');
42 $max_rows = getIntFromRequest('max_rows');
43 $set = getStringFromRequest('set');
44 $_assigned_to = getStringFromRequest('_assigned_to');
45 $_status = getStringFromRequest('_status');
46 $_changed_from = getStringFromRequest('_changed_from');
48 $af->setup($offset,$_sort_col,$_sort_ord,$max_rows,$set,$_assigned_to,$_status,$_changed_from);
50 $at_arr =& $af->getArtifacts();
52 echo 'artifact_id;status_id;status_name;priority;submitter_id;submitter_name;assigned_to_id;assigned_to_name;open_date;close_date;last_modified_date;summary;details';
55 // Show the extra fields
57 $ef =& $ath->getExtraFields();
58 $keys=array_keys($ef);
59 for ($i=0; $i<count($keys); $i++) {
60 echo ';"'.$ef[$keys[$i]]['field_name'].'"';
63 for ($i=0; $i<count($at_arr); $i++) {
65 echo "\n".$at_arr[$i]->getID().';'.
66 $at_arr[$i]->getStatusID().';"'.
67 $at_arr[$i]->getStatusName().'";'.
68 $at_arr[$i]->getPriority().';'.
69 $at_arr[$i]->getSubmittedBy().';"'.
70 $at_arr[$i]->getSubmittedRealName().'";'.
71 $at_arr[$i]->getAssignedTo().';"'.
72 $at_arr[$i]->getAssignedRealName().'";"'.
73 date(_('Y-m-d H:i'),$at_arr[$i]->getOpenDate()).'";"'.
74 date(_('Y-m-d H:i'),$at_arr[$i]->getCloseDate()).'";"'.
75 date(_('Y-m-d H:i'),$at_arr[$i]->getLastModifiedDate()).'";"'.
76 fix4csv($at_arr[$i]->getSummary()).'";"'.
77 fix4csv($at_arr[$i]->getDetails()).'"';
80 // Show the extra fields
82 $efd =& $at_arr[$i]->getExtraFieldDataText();
83 foreach ( $efd as $efd_pair ) {
84 $value = $efd_pair["value"];
85 echo ';"'. fix4csv($value) .'"';
89 function fix4csv ($value) {
90 $value =& util_unconvert_htmlspecialchars( $value );
91 $value =& str_replace("\r\n", "\n", $value);
92 $value =& str_replace('"', '""', $value);