function uc_order_view in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_order/uc_order.admin.inc \uc_order_view()
- 7.3 uc_order/uc_order.module \uc_order_view()
Display the order view screen, constructed via hook_order_pane().
1 string reference to 'uc_order_view'
- uc_order_menu in uc_order/
uc_order.module - Implementation of hook_menu().
File
- uc_order/
uc_order.module, line 1544
Code
function uc_order_view($order_id, $view = 'view') {
$order = uc_order_load($order_id);
if ($view == 'customer' || $view == 'invoice') {
if ($order === FALSE || !user_access('view all orders') && $order->uid != arg(1)) {
drupal_goto('user/' . arg(1));
}
}
if ($view == 'customer') {
$breadcrumb = drupal_get_breadcrumb();
$breadcrumb[2] = l(t('Order history'), 'user/' . arg(1) . '/orders');
drupal_set_breadcrumb($breadcrumb);
}
if ($view == 'invoice') {
$output = uc_order_load_invoice($order, 'print', variable_get('uc_cust_order_invoice_template', 'customer'));
$output .= '<div align="right" style="margin-top: 1em; margin-right: 1em;"><input type="button" value="' . t('Print invoice') . '" onclick="window.print();" /> ' . '<input type="button" value="' . t('Close window') . '" onclick="window.close();" /></div>';
print $output;
exit;
}
if ($order === FALSE) {
drupal_set_message(t('Order @order_id does not exist.', array(
'@order_id' => $order_id,
)));
drupal_goto('admin/store/orders');
}
$panes = _order_pane_list($view);
foreach ($panes as $pane) {
if (in_array($view, $pane['show']) && variable_get('uc_order_pane_' . $pane['id'] . '_show_' . $view, TRUE)) {
$func = $pane['callback'];
if (function_exists($func) && ($contents = $func($view, $order)) != NULL) {
$output .= '<div class="order-pane ' . $pane['class'] . '">';
if ($func('show-title', NULL) !== FALSE) {
$output .= '<div class="order-pane-title">' . $pane['title'] . ': ' . $func('view-title', $order) . '</div>';
}
$output .= $contents . '</div>';
}
}
}
if ($view == 'customer' && variable_get('uc_cust_view_order_invoices', TRUE)) {
uc_add_js("function open_invoice() { window.open(Drupal.settings['base_path'] + '?q=user/" . arg(1) . "/order/" . arg(3) . "/invoice/print', '" . t('Invoice') . "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=480,left=50,top=50'); }", 'inline');
$contents = '<a href="#" onclick="open_invoice();">' . uc_store_get_icon('file:print') . ' ' . t('Click to open a window with a printable invoice.') . '</a>';
$output .= '<div class="order-pane">' . $contents . '</div>';
}
return $output;
}