You are here

function theme_webform_results_analysis in Webform 7.3

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

Output the content of the Analysis page.

See also

webform_results_analysis()

1 theme call to theme_webform_results_analysis()
webform_results_analysis in includes/webform.report.inc
Provides a simple analysis of all submissions to a webform.

File

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

Code

function theme_webform_results_analysis($variables) {
  $node = $variables['node'];
  $data = $variables['data'];
  $sids = $variables['sids'];
  $analysis_component = $variables['component'];
  $rows = array();
  $question_number = 0;
  $single = isset($analysis_component);
  $header = array(
    $single ? $analysis_component['name'] : t('Q'),
    array(
      'data' => $single ? ' ' : t('responses'),
      'colspan' => '10',
    ),
  );
  foreach ($data as $cid => $row_data) {
    $question_number++;
    if (is_array($row_data)) {
      $row = array();
      if (!$single) {
        $row['data'][] = array(
          'data' => '<strong>' . $question_number . '</strong>',
          'rowspan' => count($row_data) + 1,
          'valign' => 'top',
        );
        $row['data'][] = array(
          'data' => '<strong>' . check_plain($node->webform['components'][$cid]['name']) . '</strong>',
          'colspan' => '10',
        );
        $row['class'][] = 'webform-results-question';
      }
      $rows = array_merge($rows, array_merge(array(
        $row,
      ), $row_data));
    }
  }
  if (count($rows) == 0) {
    $rows[] = array(
      array(
        'data' => t('There are no submissions for this form. <a href="!url">View this form</a>.', array(
          '!url' => url('node/' . $node->nid),
        )),
        'colspan' => 20,
      ),
    );
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'class' => array(
        'webform-results-analysis',
      ),
    ),
  ));
}