You are here

function theme_redhen_registration_list in RedHen CRM 7

Theme function for registration list.

Parameters

$variables:

Return value

string

1 theme call to theme_redhen_registration_list()
redhen_registration_page in modules/redhen_registration/redhen_registration.module
Return a list of registrations for a given contact.

File

modules/redhen_registration/redhen_registration.module, line 102
Module file for RedHen Registration.

Code

function theme_redhen_registration_list($variables) {
  $registrations = $variables['registrations'];
  $header = $variables['header'];
  if (!empty($registrations)) {
    $rows = array();
    foreach ($registrations as $registration) {
      $uri = entity_uri('registration', $registration);
      $actions = array(
        l(t('view'), $uri['path'], array(
          'query' => drupal_get_destination(),
        )),
        l(t('edit'), $uri['path'] . '/edit', array(
          'query' => drupal_get_destination(),
        )),
        l(t('delete'), $uri['path'] . '/delete', array(
          'query' => drupal_get_destination(),
        )),
      );
      $reg_type = registration_type_load($registration->type);
      $wrapper = entity_metadata_wrapper('registration', $registration);
      $entity = $wrapper->entity
        ->value();
      $author = $wrapper->author
        ->value();
      $entity_uri = entity_uri($registration->entity_type, $entity);
      $rows[] = array(
        'data' => array(
          check_plain($reg_type->label),
          l(entity_label($registration->entity_type, $entity), $entity_uri['path']),
          $author ? $author->name : '',
          $registration->count,
          redhen_format_date($registration->updated, 'short'),
          implode(' | ', $actions),
        ),
      );
    }
    $render['table'] = array(
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $rows,
    );
    $render['pager'] = array(
      '#theme' => 'pager',
    );
  }
  else {
    $wrapper = entity_metadata_wrapper('redhen_contact', $variables['contact']);

    // No results, set a message:
    $render['no-result'] = array(
      '#type' => 'markup',
      '#markup' => t('There are no registrations for %name.', array(
        '%name' => $wrapper->full_name
          ->value(),
      )),
    );
  }
  return render($render);
}