function uc_order_history in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_order/uc_order.admin.inc \uc_order_history()
- 7.3 uc_order/uc_order.admin.inc \uc_order_history()
Returns the sortable table listing of a customer's orders.
Parameters
$uid: The user ID whose orders you wish to list.
1 string reference to 'uc_order_history'
- uc_order_menu in uc_order/
uc_order.module - Implementation of hook_menu().
File
- uc_order/
uc_order.module, line 1508
Code
function uc_order_history($uid) {
drupal_set_title(t('Order history'));
$header = array(
array(
'data' => t('Date'),
'field' => 'o.created',
'sort' => 'desc',
),
array(
'data' => t('Order #'),
'field' => 'o.order_id',
),
array(
'data' => t('Status'),
'field' => 'os.title',
),
array(
'data' => t('Products'),
'field' => 'products',
),
array(
'data' => t('Total'),
'field' => 'o.order_total',
),
);
$result = pager_query("SELECT o.order_id, o.created, os.title, SUM(op.qty) AS products, o.order_total AS total FROM {uc_orders} AS o LEFT JOIN {uc_order_statuses} AS os ON o.order_status = os.order_status_id LEFT JOIN {uc_order_products} AS op ON o.order_id = op.order_id WHERE o.uid = %d AND o.order_status IN " . uc_order_status_list('general', TRUE) . " GROUP BY o.order_id, o.created, os.title, o.order_total" . tablesort_sql($header), 20, 0, "SELECT COUNT(*) FROM {uc_orders} WHERE uid = %d AND order_status NOT IN " . uc_order_status_list('specific', TRUE), $uid);
// Build a table based on the customer's orders.
while ($order = db_fetch_object($result)) {
$link = l($order->order_id, 'user/' . $uid . '/order/' . $order->order_id);
if (user_access('view all orders')) {
$link .= '<span class="order-admin-icons">' . uc_order_actions($order, TRUE) . '</span>';
}
$rows[] = array(
array(
'data' => format_date($order->created, 'custom', variable_get('uc_date_format_default', 'm/d/Y')),
),
array(
'data' => $link,
'nowrap' => 'nowrap',
),
array(
'data' => $order->title,
),
array(
'data' => !is_null($order->products) ? $order->products : 0,
'align' => 'center',
),
array(
'data' => uc_currency_format($order->total, TRUE),
'align' => 'right',
),
);
}
$output = theme('table', $header, $rows) . theme('pager', null, 20, 0);
return $output;
}