You are here

function theme_uc_recurring_admin_table in UC Recurring Payments and Subscriptions 7.2

Same name and namespace in other branches
  1. 6.2 uc_recurring.module \theme_uc_recurring_admin_table()

Displays a table for users to administer their recurring fees.

TODO: This theme function should receive as an argument the fees to be included in the table, not simply a user ID. All the logic to load fees should be taken care of in the function that calls this theme function.

2 theme calls to theme_uc_recurring_admin_table()
uc_recurring_admin in ./uc_recurring.admin.inc
Displays a table for the administration of recurring fees.
uc_recurring_order_information in ./uc_recurring.admin.inc
Display recurring information about this order.

File

./uc_recurring.module, line 1066
Allows you to add a recurring fee to a product/SKU to handle subscription type services.

Code

function theme_uc_recurring_admin_table($variables) {
  $fees = $variables['fees'];

  // Build the table header.
  $header = array(
    array(
      'data' => t('ID'),
      'field' => 'ru.rfid',
    ),
    array(
      'data' => t('Order'),
      'field' => 'ru.order_id',
    ),
    array(
      'data' => t('Status'),
      'field' => 'ru.status',
    ),
    array(
      'data' => t('Account'),
    ),
    array(
      'data' => t('Next'),
      'field' => 'ru.next_charge',
      'sort' => 'asc',
    ),
    array(
      'data' => t('Amount'),
    ),
    array(
      'data' => t('Interval'),
    ),
    array(
      'data' => t('Left'),
    ),
    array(
      'data' => t('Total'),
    ),
    array(
      'data' => t('Operations'),
    ),
  );
  $recurring_states = uc_recurring_fee_status_label();
  $rows = array();
  foreach ($fees as $fee) {
    if ($fee->remaining_intervals < 0) {
      $fee_remaining = t('Until cancelled');
    }
    elseif ($fee->remaining_intervals == 0) {
      $fee_remaining = '-';
    }
    else {
      $fee_remaining = $fee->remaining_intervals;
    }

    // Get the administrator operations links for the current fee.
    $ops = uc_recurring_get_fee_ops('fee_admin', $fee);

    // Add a row for the current fee to the table.
    $rows[] = array(
      l($fee->rfid, 'admin/store/orders/recurring/view/fee/' . $fee->rfid),
      l($fee->order_id, 'admin/store/orders/' . $fee->order_id),
      $recurring_states[$fee->status],
      l($fee->name, 'user/' . $fee->uid),
      format_date($fee->next_charge, 'short'),
      $fee->fee_amount != '0.00' ? $fee->fee_amount : t('Same as product price'),
      //$fee->fee_amount != '0.00' ? theme('uc_price', array('price' => $fee->fee_amount)) : t('Same as product price'),
      array(
        'data' => check_plain($fee->regular_interval),
        'nowrap' => 'nowrap',
      ),
      $fee_remaining,
      $fee->remaining_intervals < 0 ? $fee->charged_intervals : $fee->remaining_intervals + $fee->charged_intervals,
      array(
        'data' => implode(' | ', $ops),
        'nowrap' => 'nowrap',
      ),
    );
  }

  // Add the table and pager to the page output.
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
  $output .= theme('pager', array(
    'tags' => NULL,
    'element' => 0,
  ));
  return $output;
}