You are here

function uc_recurring_admin in UC Recurring Payments and Subscriptions 6.2

Same name and namespace in other branches
  1. 6 uc_recurring.admin.inc \uc_recurring_admin()
  2. 7.2 uc_recurring.admin.inc \uc_recurring_admin()

Displays a table for the administration of recurring fees.

1 string reference to 'uc_recurring_admin'
uc_recurring_menu in ./uc_recurring.module
Implementation of hook_menu().

File

./uc_recurring.admin.inc, line 11
Recurring payments administration page callbacks and form builder functions.

Code

function uc_recurring_admin($filter = NULL, $id = NULL) {
  $item = menu_get_item();

  // Add the filter form to the top of the table.
  $output .= drupal_get_form('uc_recurring_admin_filter_form', $item);

  // Build an array of fees to include in the admin table.
  $fees = array();
  $footer_link = TRUE;
  $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'),
    ),
  );

  // If we're on the overview page listing all fees...
  if (empty($filter)) {

    // Get all recurring fees in the system.
    $order = tablesort_sql($header);
    $fees = uc_recurring_get_all_fees(TRUE, $order);
    $footer_link = FALSE;
  }
  elseif ($filter == 'order') {

    // Get all recurring fees in a specific order if it is valid.
    if ($order = uc_order_load($id)) {
      $fees = uc_recurring_get_fees($order);
    }
  }
  elseif ($fee = uc_recurring_fee_user_load($id)) {

    // Get a single recurring fee.
    $fees[] = $fee;
  }

  // If we actually found fees to display...
  if (!empty($fees)) {
    $output .= theme('uc_recurring_admin_table', $fees);
  }

  // Display a link back to the full list if necessary.
  if ($footer_link) {
    $output .= l(t('Back to the full list'), 'admin/store/orders/recurring');
  }
  return $output;
}