You are here

function theme_uc_recurring_user_table in UC Recurring Payments and Subscriptions 6.2

Same name and namespace in other branches
  1. 7.2 uc_recurring.module \theme_uc_recurring_user_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.

1 theme call to theme_uc_recurring_user_table()
uc_recurring_user_fees in ./uc_recurring.module
Display users recurring fees.

File

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

Code

function theme_uc_recurring_user_table($uid) {
  drupal_add_css(drupal_get_path('module', 'uc_recurring') . '/uc_recurring.css');

  // Set up a header array for the table.
  $header = array(
    t('Order'),
    t('Amount'),
    t('Interval'),
    t('Next charge'),
    t('Status'),
    t('Remaining'),
    t('Options'),
  );
  $context = array(
    'revision' => 'themed-original',
    'location' => 'recurring-user-table',
  );
  $recurring_states = uc_recurring_fee_status_label();

  // Build an array of rows representing the user's fees.
  $rows = array();
  foreach (uc_recurring_get_user_fees($uid) as $fee) {

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

    // Add the row to the table for display.
    $rows[] = array(
      'data' => array(
        l($fee->order_id, 'user/' . $uid . '/order/' . $fee->order_id),
        uc_price($fee->fee_amount, $context),
        array(
          'data' => check_plain($fee->regular_interval),
          'nowrap' => 'nowrap',
        ),
        format_date($fee->next_charge, 'small'),
        '<span class="recurring-status-' . intval($fee->status) . '">' . $recurring_states[$fee->status] . '</span>',
        $fee->remaining_intervals < 0 ? t('Until cancelled') : $fee->remaining_intervals,
        array(
          'data' => implode(' | ', $ops),
          'nowrap' => 'nowrap',
        ),
      ),
    );
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('Your account has no recurring fees.'),
        'colspan' => 7,
      ),
    );
  }
  return theme('table', $header, $rows);
}