You are here

function uc_recurring_user_table in Ubercart 5

1 call to uc_recurring_user_table()
uc_recurring_user in payment/uc_recurring/uc_recurring.module
Implementation of hook_user().

File

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

Code

function uc_recurring_user_table($uid) {
  $rows = array();
  $output = '';

  // Setup a header array for the table.
  $header = array(
    t('Order'),
    t('Amount'),
    t('Interval'),
    t('Next charge'),
    t('Remaining'),
    t('Operations'),
  );

  // Loop through the fees sorted by the order ID descending.
  $result = db_query("SELECT * FROM {uc_recurring_users} WHERE uid = %d AND remaining_intervals > 0 ORDER BY order_id DESC", $uid);
  while ($fee = db_fetch_array($result)) {
    $ops = array();

    // Get the $ops from the module implementing the handler.
    $callback = $fee['fee_handler'] . '_recurring_fee_ops';
    if (function_exists($callback)) {
      $ops = $callback('user', $fee);
    }

    // Add the row to the table for display.
    $rows[] = array(
      l($fee['order_id'], 'user/' . $uid . '/order/' . $fee['order_id']),
      uc_currency_format($fee['fee_amount']),
      array(
        'data' => check_plain($fee['regular_interval']),
        'nowrap' => 'nowrap',
      ),
      $fee['remaining_intervals'] == 0 ? '-' : format_date($fee['next_charge'], 'small'),
      $fee['remaining_intervals'],
      array(
        'data' => implode(' ', $ops),
        'nowrap' => 'nowrap',
      ),
    );
  }

  // Only display the table if fees were found.
  if (count($rows) > 0) {
    $output = theme('table', $header, $rows);
  }
  return $output;
}