From 7847afcf5daa7212d83143aef077307c2073d6fe Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 22 Jun 2016 23:03:21 +1000 Subject: [PATCH] add human-readable studygroup names for CSV headings if option is enabled in admin page --- booking.admin.inc | 8 ++++++++ booking.reports.inc | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/booking.admin.inc b/booking.admin.inc index 8fbda9a..aae3fdc 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -231,6 +231,14 @@ function booking_admin() ), '#default_value' => variable_get('booking_publish_readinggroups', 0) ); + + $form['features']['booking_friendly_csv_groupnames'] = array( + '#type' => 'radios', + '#title' => t('Use human-friendly study group names in CSV export?'), + '#description' => t('Select whether to use descriptions for study group columns when exporting CSV. If No, internal database field names are used.'), + '#options' => array(0 => t('No'), t('Yes')), + '#default_value' => variable_get('booking_friendly_csv_groupnames', 0), + ); $form['misc'] = array( '#type' => 'fieldset', diff --git a/booking.reports.inc b/booking.reports.inc index 22eaf41..c04d1ca 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -677,7 +677,7 @@ function booking_csv_report() { } //Replace headings for study group sessions and roles with the name of the study group rather than just sessionN and sessionN_role etc - if (array_key_exists($key, $studygroup_descriptions)) { + if (variable_get('booking_friendly_csv_groupnames','0') == 1 && array_key_exists($key, $studygroup_descriptions)) { $header_array[] = $studygroup_descriptions[$key]; continue; } @@ -687,7 +687,7 @@ function booking_csv_report() { if (strcmp($key,"booking_dob") == 0) { $header_array[] = "booking_dob_processed"; } - + //add in a calculated field for amount owing if (strcmp($key, "nid") == 0) { $header_array[] = "booking_amount_owing_gross";