You are here

function theme_webform_results_submissions in Webform 6.2

Same name and namespace in other branches
  1. 5.2 webform_report.inc \theme_webform_results_submissions()
  2. 5 webform_report.inc \theme_webform_results_submissions()

Theme the submissions tab of the webform results page.

Parameters

$node: The node whose results are being displayed.

$submissions: An array of all submissions for this webform.

$total_count: The total number of submissions to this webform.

$pager_count: The number of results to be shown per page.

1 theme call to theme_webform_results_submissions()
webform_results_submissions in ./webform_report.inc
Retrieve lists of submissions for a given webform.

File

./webform_report.inc, line 115
This file includes helper functions for creating reports for webform.module

Code

function theme_webform_results_submissions($node, $submissions, $total_count = 0, $pager_count = 0) {
  global $user;
  drupal_add_css(drupal_get_path('module', 'webform') . '/webform.css');

  // This header has to be generated separately so we can add the SQL necessary
  // to sort the results.
  $header = theme('webform_results_submissions_header', $node);
  $rows = array();
  foreach ($submissions as $sid => $submission) {
    $row = array(
      $sid,
      format_date($submission->submitted, 'small'),
    );
    if (user_access('access webform results')) {
      $row[] = theme('username', $submission);
      $row[] = $submission->remote_addr;
    }
    $row[] = l(t('View'), "node/{$node->nid}/submission/{$sid}");
    if (user_access('edit own webform submissions') && $user->uid == $submission->uid || user_access('edit webform submissions')) {
      $row[] = l(t('Edit'), "node/{$node->nid}/submission/{$sid}/edit");
      $row[] = l(t('Delete'), "node/{$node->nid}/submission/{$sid}/delete", array(
        'query' => drupal_get_destination(),
      ));
    }
    else {
      $row[count($row) - 1] = array(
        'data' => $row[count($row) - 1],
        'colspan' => 3,
      );
    }
    $rows[] = $row;
  }
  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' => 7,
      ),
    );
  }
  $output = '';
  $output .= theme('webform_results_per_page', $total_count, $pager_count);
  $output .= theme('table', $header, $rows);
  if (arg(2) == 'submissions') {
    $output .= theme('links', array(
      'webform' => array(
        'title' => t('Go back to the form'),
        'href' => 'node/' . $node->nid,
      ),
    ));
  }
  if ($pager_count) {
    $output .= theme('pager', NULL, $pager_count, 0);
  }
  return $output;
}