You are here

function uc_recurring_order_information in UC Recurring Payments and Subscriptions 7.2

Same name and namespace in other branches
  1. 6.2 uc_recurring.admin.inc \uc_recurring_order_information()

Display recurring information about this order.

1 string reference to 'uc_recurring_order_information'
uc_recurring_menu in ./uc_recurring.module
Implements hook_menu().

File

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

Code

function uc_recurring_order_information($order_id) {
  $order = uc_order_load($order_id);
  $order_id = db_query("SELECT original_order_id FROM {uc_recurring_orders} WHERE renewal_order_id = :renewal_order_id", array(
    ':renewal_order_id' => $order_id,
  ))
    ->fetchField();
  if (!empty($order_id)) {
    $order = uc_order_load($order_id);
  }

  // Recurring fee details.
  $output = '';
  if (!empty($order)) {
    $fees = uc_recurring_get_fees($order);
    $output .= '<h2>' . t('Original order ID: @order_id', array(
      '@order_id' => $order->order_id,
    )) . '</h2>';
    $output .= theme('uc_recurring_admin_table', array(
      'fees' => $fees,
    ));
    $output .= '<h2>' . t('Renewals') . '</h2>';
    module_load_include('inc', 'uc_order', 'uc_order.admin');

    // We can't use a subquery here because they don't play nice with extenders
    // and this will be a pager query. See http://drupal.org/node/753084
    // So just pass in the order ID's.
    $renewal_orders = db_query("SELECT renewal_order_id FROM {uc_recurring_orders} WHERE original_order_id = :order_id", array(
      ':order_id' => $order->order_id,
    ))
      ->fetchCol();

    // Because of the way this works if we don't have any orders we need to
    // make sure no orders show up in the results. We can't send an empty array.
    if (empty($renewal_orders)) {
      $renewal_orders[] = -1;
    }
    $condition = db_and();
    $condition
      ->condition('o.order_id', $renewal_orders, 'IN');
    $output .= drupal_render(uc_recurring_order_admin($condition, TRUE));
  }
  else {
    $output = t('No recurring fees associated with this order');
  }
  return $output;
}