You are here

function theme_webform_results_download_range in Webform 7.4

Same name and namespace in other branches
  1. 6.3 includes/webform.report.inc \theme_webform_results_download_range()
  2. 7.3 includes/webform.report.inc \theme_webform_results_download_range()

Theme the output of the export range fieldset.

1 theme call to theme_webform_results_download_range()
webform_results_download_form in includes/webform.report.inc
Form to configure the download of CSV files.

File

includes/webform.report.inc, line 750
This file includes helper functions for creating reports for webform.module.

Code

function theme_webform_results_download_range($variables) {
  drupal_add_library('webform', 'admin');
  $element = $variables['element'];
  $download_info = $element['#webform_download_info'];

  // Set description for total of all submissions.
  $element['range_type']['all']['#theme_wrappers'] = array(
    'webform_inline_radio',
  );
  $element['range_type']['all']['#title'] .= ' (' . t('@count total', array(
    '@count' => $download_info['total'],
  )) . ')';

  // Set description for "New submissions since last download".
  $format = webform_date_format('short');
  $requested_date = format_date($download_info['requested'], 'custom', $format);
  $element['range_type']['new']['#theme_wrappers'] = array(
    'webform_inline_radio',
  );
  if (isset($download_info['new_draft'])) {
    $args = array(
      '@new_draft' => $download_info['new_draft'],
      '@new' => $download_info['new'],
      '@date' => $requested_date,
    );
    $element['range_type']['new']['#title'] .= ' (' . t('@new_draft new drafts, @new new finished since @date', $args) . ')';
    $total_count = $download_info['new_draft'] + $download_info['new'];
  }
  else {
    $args = array(
      '@count' => $download_info['new'],
      '@date' => $requested_date,
    );
    $element['range_type']['new']['#title'] .= ' (' . t('@count new since @date', $args) . ')';
    $total_count = $download_info['new'];
  }

  // Disable option if there are no new submissions.
  if ($total_count == 0) {
    $element['range_type']['new']['#attributes']['disabled'] = 'disabled';
  }

  // Render latest x submissions option.
  $element['latest']['#attributes']['class'][] = 'webform-set-active';
  $element['latest']['#theme_wrappers'] = array();
  $element['range_type']['latest']['#theme_wrappers'] = array(
    'webform_inline_radio',
  );
  $element['range_type']['latest']['#title'] = t('Only the latest !number submissions', array(
    '!number' => drupal_render($element['latest']),
  ));

  // Render Start-End submissions option.
  $element['start']['#attributes']['class'][] = 'webform-set-active';
  $element['end']['#attributes']['class'][] = 'webform-set-active';
  $element['start']['#theme_wrappers'] = array();
  $element['end']['#theme_wrappers'] = array();
  $element['start_date']['#attributes']['class'] = array(
    'webform-set-active',
  );
  $element['end_date']['#attributes']['class'] = array(
    'webform-set-active',
  );
  $element['start_date']['#theme_wrappers'] = array();
  $element['end_date']['#theme_wrappers'] = array();
  $element['range_type']['range_serial']['#theme_wrappers'] = array(
    'webform_inline_radio',
  );
  $last_serial = $download_info['serial'] ? $download_info['serial'] : drupal_placeholder(t('none'));
  $element['range_type']['range_serial']['#title'] = t('Submissions by number from !start and optionally to: !end   (Last downloaded: !serial)', array(
    '!start' => drupal_render($element['start']),
    '!end' => drupal_render($element['end']),
    '!serial' => $last_serial,
  ));

  // Date range.
  $element['range_type']['range_date']['#theme_wrappers'] = array(
    'webform_inline_radio',
  );
  $element['range_type']['range_date']['#title'] = t('Submissions by date from !start_date and optionally to: !end_date', array(
    '!start_date' => drupal_render($element['start_date']),
    '!end_date' => drupal_render($element['end_date']),
  ));
  return drupal_render_children($element);
}