You are here

function commerce_registration_registration_page in Commerce Registration 7

Same name and namespace in other branches
  1. 7.2 commerce_registration.module \commerce_registration_registration_page()

Registration page callback for all registrations for a given product display.

1 string reference to 'commerce_registration_registration_page'
commerce_registration_menu in ./commerce_registration.module
Implements hook_menu().

File

./commerce_registration.module, line 60
Commerce Registration module code.

Code

function commerce_registration_registration_page($node) {
  $prodids = array();
  foreach ($node->field_commerce_product[LANGUAGE_NONE] as $product) {
    $prodids[] = (int) $product['product_id'];
  }
  $header = array(
    t('Order'),
    t('Date'),
    t('Product'),
    t('Registrant'),
  );
  $rows = array();
  foreach ($prodids as $product_id) {
    $reg = db_select('registration', 'r')
      ->fields('r', array(
      'registration_id',
      'order_id',
      'created',
      'author_uid',
      'user_uid',
    ));
    $reg
      ->condition('r.entity_type', 'commerce_product')
      ->condition('r.eid', $product_id)
      ->condition('r.status', 1)
      ->condition('r.order_id', 0, '!=')
      ->orderBy('r.created', 'DESC');
    $reg = $reg
      ->execute();
    foreach ($reg as $row) {
      $prod = commerce_product_load($product_id);
      $registrant = user_load($row->user_uid);
      $rows[] = array(
        l(t('Order #') . $row->order_id, 'user/' . $row->author_uid . '/orders/' . $row->order_id),
        date("F j, Y - g:i:s a", $row->created),
        $prod->title,
        l('#' . $row->registration_id . ': ' . $registrant->name, 'registration/' . $row->registration_id),
      );
    }
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('There are no registrations for any products for this node yet.'),
        'colspan' => 4,
      ),
    );
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
}