You are here

function uc_recurring_order_information in UC Recurring Payments and Subscriptions 6.2

Same name and namespace in other branches
  1. 7.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
Implementation of hook_menu().

File

./uc_recurring.admin.inc, line 431
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_result(db_query("SELECT original_order_id FROM {uc_recurring_orders} WHERE renewal_order_id = %d", $order_id));
  if (!empty($order_id)) {
    $order = uc_order_load($order_id);
  }

  // Recurring fee details.
  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', $fees);
    $header = array(
      array(
        'data' => t('Actions'),
      ),
      array(
        'data' => t('Order ID'),
        'field' => 'o.order_id',
        'sort' => 'desc',
      ),
      array(
        'data' => t('Customer'),
      ),
      array(
        'data' => t('Total'),
        'align' => 'center',
        'field' => 'o.order_total',
      ),
      array(
        'data' => t('Purchase date'),
        'align' => 'center',
        'field' => 'o.created',
      ),
      array(
        'data' => t('Status'),
        'field' => 'os.title',
      ),
    );
    $output .= '<h2>' . t('Renewals') . '</h2>';
    module_load_include('inc', 'uc_order', 'uc_order.admin');
    $sql = 'SELECT o.order_id, o.uid, o.billing_first_name, o.billing_last_name, o.order_total, o.order_status, o.created, os.title
            FROM {uc_orders} o
              LEFT JOIN {uc_order_statuses} os ON o.order_status = os.order_status_id
              LEFT JOIN {uc_recurring_orders} ro ON ro.renewal_order_id=o.order_id
            WHERE ro.original_order_id = %d ' . tablesort_sql($header);
    $output .= uc_order_admin($sql, array(
      $order->order_id,
    ), TRUE);
  }
  else {
    $output = t('No recurring fees associated with this order');
  }
  return $output;
}