You are here

function webform_invitation_codes_page in Webform Invitation 7.2

Same name and namespace in other branches
  1. 7 webform_invitation.module \webform_invitation_codes_page()
1 call to webform_invitation_codes_page()
webform_invitation_generate_form in ./webform_invitation.module

File

./webform_invitation.module, line 136

Code

function webform_invitation_codes_page($node) {
  global $base_url;
  $nid = $node->nid;
  $codes = db_select('webform_invitation_codes', 'c')
    ->fields('c')
    ->condition('nid', $nid, '=')
    ->execute()
    ->fetchAll();
  $out = "<h2>" . t('All invitation codes for %node_title', array(
    "%node_title" => $node->title,
  )) . "</h2>";
  $out .= "<p><a href='" . $base_url . "/node/" . $nid . "/webform/invitation-download'>" . t('Download Codes') . "</a></p>";
  if (count($codes) > 0) {
    $out .= "<table><tr><th>" . t('Code') . "</th><th>" . t('used?') . "</th><th>" . t('Submission ID') . "</th></tr>";
    foreach ($codes as $code) {
      $out .= '<tr><td>' . $code->code . '</td><td>' . ($code->used != NULL ? t('yes') : t('no')) . '</td><td>' . ($code->used != NULL ? l($code->sid, 'node/' . $nid . '/submission/' . $code->sid) : '') . '</td></tr>';
    }
    $out .= '</table>';
  }
  else {
    $out .= '<p><em>' . t('No codes present, yet. Click on "Generate" above to create codes.') . '</em></p>';
  }
  return $out;
}