From 1f31169ca66150018836db6675b3fbad0ebe92c5 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Thu, 29 Jun 2017 14:49:20 +1000 Subject: [PATCH] fix header array --- booking.earlyaccess_admin.inc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/booking.earlyaccess_admin.inc b/booking.earlyaccess_admin.inc index 334fd72..a5ac305 100644 --- a/booking.earlyaccess_admin.inc +++ b/booking.earlyaccess_admin.inc @@ -129,7 +129,7 @@ function booking_getToken($length) { function booking_earlyaccess_csv_report() { global $event; $data = array(); - + $header_array = array(); //set options for the CSV file $name = 'bookings-earlyaccesscodes-' . format_date(time(), 'custom', 'Y-m-d-His'); $filename = file_directory_temp() . '/' . $name; @@ -148,10 +148,15 @@ function booking_earlyaccess_csv_report() { ->orderBy('cid'); $result = $codelist_query->execute(); + foreach ($result as $record) { + $header_array[] = $record->key; + } + watchdog('booking_debug', "EarlyAccess CSV query result: @info", array('@info' => var_export( $result, TRUE))); - watchdog('booking_debug', "EarlyAccess CSV array keys: @info", array('@info' => var_export( array_keys($result), TRUE))); + watchdog('booking_debug', "EarlyAccess CSV header: @info", array('@info' => var_export($header_array, TRUE))); + //calculate the header row for CSV - $header = implode($delimiter, array_keys($result)); + $header = implode($delimiter, $header_array); $csv .= $header . "\n"; //add the records