You are here

function webform_results_table in Webform 7.4

Same name and namespace in other branches
  1. 5.2 webform_report.inc \webform_results_table()
  2. 6.3 includes/webform.report.inc \webform_results_table()
  3. 6.2 webform_report.inc \webform_results_table()
  4. 7.3 includes/webform.report.inc \webform_results_table()

Create a table containing all submitted values for a webform node.

1 string reference to 'webform_results_table'
webform_menu in ./webform.module
Implements hook_menu().

File

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

Code

function webform_results_table($node, $pager_count = 0) {

  // Determine whether views or hard-coded tables should be used for the
  // submissions table.
  if (!webform_variable_get('webform_table')) {

    // Load and preview the results view with a node id argument.
    $view = webform_get_view($node, 'webform_results');
    return $view
      ->preview('default', array(
      $node->nid,
    ));
  }

  // Get all the submissions for the node.
  if (isset($_GET['results']) && is_numeric($_GET['results'])) {
    $pager_count = $_GET['results'];
  }

  // Get all the submissions for the node.
  $header = theme('webform_results_table_header', array(
    'node' => $node,
  ));
  $submissions = webform_get_submissions($node->nid, $header, $pager_count);
  $total_count = webform_get_submission_count($node->nid, NULL, NULL);
  $output[] = array(
    '#theme' => 'webform_results_table',
    '#node' => $node,
    '#components' => $node->webform['components'],
    '#submissions' => $submissions,
    '#total_count' => $total_count,
    '#pager_count' => $pager_count,
  );
  if ($pager_count) {
    $output[] = array(
      '#theme' => 'pager',
    );
  }
  return $output;
}