Replace internal column names with descriptive names for study groups in csv report
This commit is contained in:
@@ -636,23 +636,40 @@ function booking_csv_report() {
|
||||
$enclosure = '"';
|
||||
$encloseAll = true;
|
||||
$nullToMysqlNull = true;
|
||||
$delimiter_esc = preg_quote($delimiter, '/');
|
||||
$enclosure_esc = preg_quote($enclosure, '/');
|
||||
$delimiter_esc = preg_quote($delimiter, '/');
|
||||
$enclosure_esc = preg_quote($enclosure, '/');
|
||||
|
||||
$readinggroup = "session" . variable_get('booking_readinggroup_id','7');
|
||||
|
||||
/*
|
||||
$fields_to_skip = array('booking_payment_id', 'booking_event_id', 'booking_skills_childminding', 'booking_passport_issue_date',
|
||||
'booking_passport_expiry_date', 'booking_passport_num', 'booking_passport_num', 'booking_mission_experience_details',
|
||||
'booking_passport_issue_location', 'booking_passport_issue_name', 'booking_skills_builder', 'booking_skills_cooking',
|
||||
'booking_skills_language', 'booking_skills_language_details', 'booking_skills_other', 'booking_skills_other_details');
|
||||
*/
|
||||
//$readinggroup = "session" . variable_get('booking_readinggroup_id','7');
|
||||
|
||||
//calculate fields to ignore in the output csv file
|
||||
$builtin_fields_to_skip = array('booking_event_id');
|
||||
$custom_fields_to_skip = explode(";", variable_get('booking_csv_exclude_fields', ''));
|
||||
$fields_to_skip = array_merge($builtin_fields_to_skip, $custom_fields_to_skip);
|
||||
|
||||
//keep a list of any fields that we need to handle as dates
|
||||
$datetime_fields = array('booking_outflight_origin_ts', 'booking_outflight_destination_ts', 'booking_rtrnflight_origin_ts',
|
||||
'booking_rtrnflight_destination_ts', 'booking_timestamp', 'booking_flight_datetime_inbound', 'booking_flight_datetime_outbound');
|
||||
|
||||
//look up the titles of the study groups and add to array for updating in the header
|
||||
$studygroup_descriptions = array();
|
||||
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid",
|
||||
array(':eid' => $event->eid));
|
||||
$studygroups = $studygroups_query->fetchAllAssoc('sid');
|
||||
foreach ($studygroups as $studygroup)
|
||||
{
|
||||
//calculate the session references
|
||||
$sessionid = "session" . $studygroup->sid;
|
||||
$roleid = $sessionid . "_role";
|
||||
$description = $studygroup->booking_studygroup_descrip;
|
||||
|
||||
$studygroup_descriptions[$sessionid] = $description;
|
||||
$studygroup_descriptions[$roleid] = $description . " Role";
|
||||
|
||||
if ($studygroup->booking_is_readinggroup == 'Y')
|
||||
{
|
||||
$readinggroup_id = $sessionid;
|
||||
}
|
||||
}
|
||||
|
||||
//query the db
|
||||
/*
|
||||
@@ -694,6 +711,14 @@ function booking_csv_report() {
|
||||
{
|
||||
if (in_array($key, $fields_to_skip))
|
||||
continue;
|
||||
|
||||
//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))
|
||||
{
|
||||
$header_array[] = $studygroup_descriptions[$key];
|
||||
continue;
|
||||
}
|
||||
|
||||
$header_array[] = $key;
|
||||
//add in a special column for a processed version of the date of birth
|
||||
if (strcmp($key,"booking_dob") == 0)
|
||||
@@ -772,7 +797,7 @@ function booking_csv_report() {
|
||||
}
|
||||
|
||||
//reading group team colour
|
||||
if ($key == $readinggroup) {
|
||||
if ($key == $readinggroup_id) {
|
||||
$output[] = _booking_readinggroup_colour_lookup($value);
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user