diff --git a/uc_order/uc_order.admin.inc b/uc_order/uc_order.admin.inc index ee8cd0c..f7613b3 100644 --- a/uc_order/uc_order.admin.inc +++ b/uc_order/uc_order.admin.inc @@ -434,9 +434,7 @@ function uc_order_admin($sql = NULL, $args = NULL, $search = FALSE) { if (is_null($sql)) { $args = array(); $show_status = 1; - $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 '; - + $sql = 'SELECT o.order_id, os.title FROM {uc_orders} o LEFT JOIN {uc_order_statuses} os ON o.order_status = os.order_status_id '; if (arg(3) == 'sort' && !is_null(arg(4))) { $_SESSION['sort_status'] = arg(4); @@ -456,12 +454,6 @@ function uc_order_admin($sql = NULL, $args = NULL, $search = FALSE) { } $address = variable_get('uc_customer_list_address', 'billing'); - if ($address == 'shipping') { - $sql = str_replace('billing', 'delivery', $sql); - } - else { - $address = 'billing'; - } $context = array( 'revision' => 'themed-original', @@ -471,7 +463,10 @@ function uc_order_admin($sql = NULL, $args = NULL, $search = FALSE) { $rows = array(); $result = pager_query($sql, variable_get('uc_order_number_displayed', 30), 0, NULL, $args); - while ($order = db_fetch_object($result)) { + while ($row = db_fetch_object($result)) { + $order = uc_order_load($row->order_id); + $context['subject']['order'] = &$order; + if ($address == 'shipping') { $order_name = $order->delivery_first_name .' '. $order->delivery_last_name; } @@ -497,7 +492,7 @@ function uc_order_admin($sql = NULL, $args = NULL, $search = FALSE) { array('data' => check_plain($order_name), 'nowrap' => 'nowrap'), array('data' => uc_price($order->order_total, $context), 'align' => 'right', 'nowrap' => 'true'), array('data' => format_date($order->created, 'custom', variable_get('uc_date_format_default', 'm/d/Y')), 'align' => 'center'), - array('data' => $order->title), + array('data' => $row->title), ), 'id' => 'order-'. $order->order_id, ); @@ -737,9 +732,8 @@ function uc_order_usearch() { $args[] = $end_date; } - $sql = 'SELECT o.order_id, 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 WHERE o.order_status NOT IN '. uc_order_status_list('specific', TRUE) + $sql = 'SELECT o.order_id FROM {uc_orders} o ' + . 'WHERE o.order_status NOT IN '. uc_order_status_list('specific', TRUE) . $where .' ORDER BY o.created DESC'; $output .= uc_order_admin($sql, $args, TRUE); @@ -1020,10 +1014,11 @@ function uc_order_history($user) { 'type' => 'amount', ); - $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), $user->uid); + $result = pager_query("SELECT o.order_id, os.title, SUM(op.qty) AS products 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), $user->uid); // Build a table based on the customer's orders. - while ($order = db_fetch_object($result)) { + while ($row = db_fetch_object($result)) { + $order = uc_order_load($row->order_id); $context['subject'] = array('order' => $order); $link = l($order->order_id, 'user/'. $user->uid .'/order/'. $order->order_id); @@ -1035,9 +1030,9 @@ function uc_order_history($user) { $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' => check_plain($order->title)), - array('data' => (!is_null($order->products) ? $order->products : 0), 'align' => 'center'), - array('data' => uc_price($order->total, $context), 'align' => 'right'), + array('data' => check_plain($row->title)), + array('data' => (!is_null($row->products) ? $row->products : 0), 'align' => 'center'), + array('data' => uc_price($order->order_total, $context), 'align' => 'right'), ); }