diff --git a/includes/webform.report.inc b/includes/webform.report.inc index 4f3726b..cc49fbe 100644 --- a/includes/webform.report.inc +++ b/includes/webform.report.inc @@ -223,6 +223,7 @@ function theme_webform_results_table($variables) { $pager_count = $variables['pager_count']; $header = array(); + $extra_headers = array(); $rows = array(); $cell = array(); @@ -251,8 +252,8 @@ function theme_webform_results_table($variables) { // Generate cells for extra data. if (isset($extra_data[$sid]) && is_array($extra_data[$sid])) { foreach ($extra_data[$sid] as $key => $value) { - $component_headers[] = check_plain($key); - $cell[] = check_plain($value); + $extra_headers[$key] = check_plain($key); + $cell[] = $value; } } @@ -262,6 +263,9 @@ function theme_webform_results_table($variables) { if (!empty($component_headers)) { $header = array_merge($header, $component_headers); } + if (!empty($extra_headers)) { + $header = array_merge($header, $extra_headers); + } if (count($rows) == 0) { $rows[] = array(array('data' => t('There are no submissions for this form. View this form.', array('!url' => url('node/' . $node->nid))), 'colspan' => 4)); @@ -840,15 +844,19 @@ function webform_results_download_headers($node, $options) { } // Add extra data row headers. + $extra_headers = array(); foreach ($submissions as $sid => $submission) { if (isset($extra_data[$sid]) && is_array($extra_data[$sid])) { foreach ($extra_data[$sid] as $label => $data) { - $header[0][] = ''; - $header[1][] = ''; - $header[2][] = $label; + $extra_headers[$label] = $label; } } } + if ($extra_headers) { + $header[0] = array_merge($header[0], array('')); + $header[1] = array_merge($header[1], array('')); + $header[2] = array_merge($header[2], $extra_headers); + } return $header; }