Slight changes

This commit is contained in:
2014-12-01 22:53:45 +11:00
parent e5b825b837
commit 7a0220aa86
12 changed files with 56 additions and 45 deletions

View File

@@ -129,9 +129,9 @@ function booking_report_summary() {
}
//define the row for this person
$this_row[] = l(t('View !id', array('!id' => $person->nid)), t('node/!id', array('!id' => $person->nid)));
$this_row[] = l(t('Edit !id', array('!id' => $person->nid)), t('node/!id/edit', array('!id' => $person->nid)));
$this_row[] = l(t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))),
t('node/!id/edit', array('!id' => $person->nid))
t('node/!id', array('!id' => $person->nid))
);
$this_row[] = _booking_status_generate($person->booking_status);
@@ -586,7 +586,7 @@ function booking_csv_report() {
global $event;
$name = 'bookings-' . format_date(time(), 'custom', 'Y-m-d-His');
$filename = file_directory_temp() . '/' . $name;
$csv = '';
$delimiter = ',';
$enclosure = '"';
$encloseAll = true;
@@ -641,7 +641,7 @@ function booking_csv_report() {
//watchdog('booking', "CSV raw data: @info", array('@info' => var_export($result, TRUE)));
//open the filehandle
$handle = @fopen($filename, 'w');
//$handle = @fopen($filename, 'w');
//write the header based on the first result
$header_array = array();
@@ -660,8 +660,8 @@ function booking_csv_report() {
$header = implode( $delimiter, $header_array );
//watchdog('booking', "CSV header: @info", array('@info' => var_export($header_array, TRUE)));
@fwrite($handle, $header . "\n");
//@fwrite($handle, $header . "\n");
$csv .= $header . "\n";
//each record
foreach ($result as $record) {
@@ -754,16 +754,27 @@ function booking_csv_report() {
$row = implode($delimiter, $output) . "\n";
@fwrite($handle, $row);
//@fwrite($handle, $row);
$csv .= $row;
//$index++;
}
@fclose($handle);
//@fclose($handle);
//see http://stackoverflow.com/questions/4348802/how-can-i-output-a-utf-8-csv-in-php-that-excel-will-read-properly
// but none of these options seem to work
drupal_add_http_header("Content-type", "application/octet-stream; charset=utf-8");
//drupal_add_http_header("Content-type", "application/octet-stream; charset=UTF-16LE");
//drupal_add_http_header("Content-Type: application/vnd.ms-excel");
drupal_add_http_header("Content-Disposition", "attachment; filename=" . $name . ".csv");
@readfile($filename);
@unlink($filename);
// @readfile($filename);
//print chr(255) . chr(254);
//print 'sep=,' . "\n";
print $csv;
//print mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8');
//@unlink($filename);
exit(0);
}