Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba

User Defined Forms Export - Adding Dates To CSV


Go to End
Reply


1274 Views

Avatar
Usability Counts

Community Member, 5 Posts

31 January 2010 at 7:44am

Edited: 31/01/2010 7:45am

I added this to SubmittedFormReportField.php. Here's the code:

foreach($tmp as $array) {
$csvHeaderNames[] = $array['Name'];
$csvHeaderTitle[] = $array['Title'];
}

// Get the created dates for each record (ADD THIS)

$strCreated = "SELECT DISTINCT Created FROM SubmittedForm WHERE ID IN (" . implode(',', $inClause) . ")";

$tmpCreated = DB::query($strCreated);
foreach($tmpCreated as $array) {
$csvCreated[] = $array['Created'];
}

And...

// For every row of data (one form submission = one row) (SLIGHTLY MODIFFIED)
foreach($rows as $row) {

// Loop over all the names we can use
$csvData .= "\"" . $csvCreated[$j] . "\", ";
$j++;

for($i=0;$i<count($csvHeaderNames);$i++) {
// If there is no data for this column, output it as blank instead
if(!isset($row[$i]) || !$row[$i]) {
$csvData .= '"",';
} else {
$csvData .= '"'.str_replace('"', '\"', $row[$i]).'",';
}
}
// Start a new row for each submission
$csvData .= "\n";
}