You are here

function uc_recurring_admin in UC Recurring Payments and Subscriptions 6

Same name and namespace in other branches
  1. 6.2 uc_recurring.admin.inc \uc_recurring_admin()
  2. 7.2 uc_recurring.admin.inc \uc_recurring_admin()
1 string reference to 'uc_recurring_admin'
uc_recurring_menu in ./uc_recurring.module
Implementation of hook_menu().

File

./uc_recurring.admin.inc, line 10
Recurring payments administration menu items.

Code

function uc_recurring_admin() {
  $output = drupal_get_form('uc_recurring_admin_filter_form');
  $header = array(
    array(
      'data' => t('ID'),
      'field' => 'ru.rfid',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Order'),
      'field' => 'ru.order_id',
    ),
    array(
      'data' => t('Amount'),
      'field' => 'ru.fee_amount',
    ),
    array(
      'data' => t('Next'),
      'field' => 'ru.next_charge',
    ),
    array(
      'data' => t('Interval'),
      'field' => 'ru.regular_interval',
    ),
    array(
      'data' => t('Left'),
      'field' => 'ru.remaining_intervals',
    ),
    array(
      'data' => t('Total'),
    ),
    array(
      'data' => t('Operations'),
    ),
  );
  if (arg(4) == 'view' && intval(arg(6)) > 0) {
    if (arg(5) == 'fee') {
      $result = db_query("SELECT * FROM {uc_recurring_users} AS ru WHERE ru.rfid = %d", arg(6));
    }
    elseif (arg(5) == 'order') {
      $result = db_query("SELECT * FROM {uc_recurring_users} AS ru WHERE ru.order_id = %d", arg(6));
    }
  }
  else {
    $result = pager_query("SELECT * FROM {uc_recurring_users} AS ru" . tablesort_sql($header), 30);
  }
  $context = array(
    'revision' => 'themed-original',
    'location' => 'recurring-admin',
  );
  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('fee_admin', $fee);
    }
    $rows[] = array(
      l($fee['rfid'], 'admin/store/orders/recurring/view/fee/' . $fee['rfid']),
      l($fee['order_id'], 'admin/store/orders/' . $fee['order_id']),
      uc_price($fee['fee_amount'], $context),
      $fee['remaining_intervals'] == 0 ? '-' : format_date($fee['next_charge'], 'small'),
      array(
        'data' => check_plain($fee['regular_interval']),
        'nowrap' => 'nowrap',
      ),
      $fee['remaining_intervals'],
      $fee['remaining_intervals'] + $fee['charged_intervals'],
      array(
        'data' => implode(' ', $ops),
        'nowrap' => 'nowrap',
      ),
    );
  }
  $output .= theme('table', $header, $rows);
  $output .= theme('pager', NULL, 30, 0);
  if (arg(4) == 'view') {
    $output .= l(t('Back to the full list.'), 'admin/store/orders/recurring');
  }
  return $output;
}