mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 15:05:42 +00:00
BUGFIX: remove the extra last empty column. ENHANCEMENT: add Submitted column for submission export at the end.
This commit is contained in:
parent
3d9b764987
commit
7ca3371fa1
@ -113,26 +113,25 @@ class SubmittedFormReportField extends FormField {
|
|||||||
foreach($index as $idx) {
|
foreach($index as $idx) {
|
||||||
$rows[$i][$idx] = $column->Value;
|
$rows[$i][$idx] = $column->Value;
|
||||||
}
|
}
|
||||||
|
$rows[$i]['Submitted'] = $submission->Created;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CSV header row
|
// CSV header row
|
||||||
$csvData = '"' . implode('","', $csvHeaderTitle) . '"' . "\n";
|
$csvData = '"' . implode('","', $csvHeaderTitle) . '"' . ',"Submitted"'."\n";
|
||||||
|
|
||||||
// For every row of data (one form submission = one row)
|
// For every row of data (one form submission = one row)
|
||||||
foreach($rows as $row) {
|
foreach($rows as $row) {
|
||||||
|
|
||||||
// Loop over all the names we can use
|
// Loop over all the names we can use
|
||||||
for($i=0;$i<count($csvHeaderNames);$i++) {
|
for($i=0;$i<count($csvHeaderNames);$i++) {
|
||||||
if(!isset($row[$i]) || !$row[$i]) $csvData .= '"",'; // If there is no data for this column, output it as blank instead
|
if(!isset($row[$i]) || !$row[$i]) $csvData .= '"",'; // If there is no data for this column, output it as blank instead
|
||||||
else $csvData .= '"'.str_replace('"', '\"', $row[$i]).'",';
|
else $csvData .= '"'.str_replace('"', '\"', $row[$i]).'",';
|
||||||
}
|
}
|
||||||
// Start a new row for each submission
|
// Start a new row for each submission
|
||||||
$csvData .= "\n";
|
$csvData .= '"'.$row['Submitted'].'"'."\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
user_error("No submissions to export.", E_USER_ERROR);
|
user_error("No submissions to export.", E_USER_ERROR);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user