You are here

function registration_checkin_get_registration_table_rows in Entity Registration 7.2

Helper function to build the registrant rows of the checkin table.

Parameters

array $registrations: An array of fully-loaded Registration entities.

Return value

array An array of table rows suitable for use with theme_table.

3 calls to registration_checkin_get_registration_table_rows()
registration_checkin_list_page in modules/registration_checkin/registration_checkin.pages.inc
Page callback: Show a list of active registrations that can be checked in.
registration_checkin_search_form_reset in modules/registration_checkin/registration_checkin.module
AJAX callback to reset the checkin table back to an unfiltered state.
registration_checkin_search_form_submit in modules/registration_checkin/registration_checkin.module
AJAX callback to update the registrant checkin table based on a search query.

File

modules/registration_checkin/registration_checkin.module, line 398
Entity Registration registrant checkin workflow and UI for registration.

Code

function registration_checkin_get_registration_table_rows($registrations) {
  $rows = array();
  foreach ($registrations as $registration) {
    $row = array();

    // Result basics.
    $wrapper = entity_metadata_wrapper('registration', $registration);
    $registrant_type = $wrapper->registrant
      ->type();
    $registrant = $wrapper->registrant
      ->value();

    // Link the registrant name.
    $row['registrant_entry'] = theme('registration_registrant_link', array(
      'registrant_type' => $registrant_type,
      'registrant' => $registrant,
    ));

    // Mailto link the registrant email.
    $row['registrant_mail'] = l($wrapper->registrant_mail
      ->value(), 'mailto:' . $wrapper->registrant_mail
      ->value());

    // Hide state management widgets with access control.
    if (user_access("edit {$registration->type} registration state")) {

      // State dropdown.
      $form = drupal_get_form('registration_checkin_state_form', $registration);
      $row['state_selection'] = render($form);

      // Check-in button.
      $form = drupal_get_form('registration_checkin_checkin_action_form', $registration);
      $row['checkin_button'] = render($form);
    }
    else {
      $row['state_selection'] = ' ';
      $row['checkin_button'] = ' ';
    }

    // Add the row.
    $rows[] = $row;
  }
  return $rows;
}