$vamTemplate = new vamTemplate(); // include boxes require DIR_FS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/source/boxes.php'; // include needed functions require_once DIR_FS_INC . 'vam_count_customer_orders.inc.php'; require_once DIR_FS_INC . 'vam_date_long.inc.php'; require_once DIR_FS_INC . 'vam_image_button.inc.php'; require_once DIR_FS_INC . 'vam_get_all_get_params.inc.php'; if (!isset($_SESSION['customer_id'])) { vam_redirect(vam_href_link(FILENAME_LOGIN, '', 'SSL')); } $breadcrumb->add(NAVBAR_TITLE_1_ACCOUNT_HISTORY, vam_href_link(FILENAME_ACCOUNT, '', 'SSL')); $breadcrumb->add(NAVBAR_TITLE_2_ACCOUNT_HISTORY, vam_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL')); require DIR_WS_INCLUDES . 'header.php'; $module_content = array(); if (($orders_total = vam_count_customer_orders()) > 0) { $history_query_raw = "select o.orders_id, o.date_purchased, o.delivery_name, o.billing_name, ot.text as order_total, s.orders_status_name from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_TOTAL . " ot, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int) $_SESSION['customer_id'] . "' and o.orders_id = ot.orders_id and ot.class = 'ot_total' and o.orders_status = s.orders_status_id and s.language_id = '" . (int) $_SESSION['languages_id'] . "' order by orders_id DESC"; $history_split = new splitPageResults($history_query_raw, $_GET['page'], MAX_DISPLAY_ORDER_HISTORY); $history_query = vam_db_query($history_split->sql_query); while ($history = vam_db_fetch_array($history_query)) { $products_query = vam_db_query("select count(*) as count from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . $history['orders_id'] . "'"); $products = vam_db_fetch_array($products_query); if (vam_not_null($history['delivery_name'])) { $order_type = TEXT_ORDER_SHIPPED_TO; $order_name = $history['delivery_name']; } else { $order_type = TEXT_ORDER_BILLED_TO; $order_name = $history['billing_name']; } $module_content[] = array('ORDER_ID' => $history['orders_id'], 'ORDER_STATUS' => $history['orders_status_name'], 'ORDER_DATE' => vam_date_long($history['date_purchased']), 'ORDER_PRODUCTS' => $products['count'], 'ORDER_TOTAL' => strip_tags($history['order_total']), 'ORDER_BUTTON' => '<a class="button" href="' . vam_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'page=' . (empty($_GET['page']) ? "1" : (int) $_GET['page']) . '&order_id=' . $history['orders_id'], 'SSL') . '">' . vam_image_button('view.png', SMALL_IMAGE_BUTTON_VIEW) . '</a>'); }
$vamTemplate->assign('error_message', $messageStack->output('account')); } $i = 0; $max = count($_SESSION['tracking']['products_history']); while ($i < $max) { $product_history_query = vamDBquery("select * from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id=pd.products_id and pd.language_id='" . (int) $_SESSION['languages_id'] . "' and p.products_status = '1' and p.products_id = '" . $_SESSION['tracking']['products_history'][$i] . "'"); $history_product = vam_db_fetch_array($product_history_query, true); $cpath = vam_get_product_path($_SESSION['tracking']['products_history'][$i]); if ($history_product['products_status'] != 0) { $history_product = array_merge($history_product, array('cat_url' => vam_href_link(FILENAME_DEFAULT, 'cat=' . $cpath))); $products_history[] = $product->buildDataArray($history_product); } $i++; } $order_content = ''; if (vam_count_customer_orders() > 0) { $orders_query = vam_db_query("select\n\t o.orders_id,\n\t o.date_purchased,\n\t o.delivery_name,\n\t o.delivery_country,\n\t o.billing_name,\n\t o.billing_country,\n\t ot.text as order_total,\n\t s.orders_status_name\n\t from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_TOTAL . "\n\t ot, " . TABLE_ORDERS_STATUS . " s\n\t where o.customers_id = '" . (int) $_SESSION['customer_id'] . "'\n\t and o.orders_id = ot.orders_id\n\t and ot.class = 'ot_total'\n\t and o.orders_status = s.orders_status_id\n\t and s.language_id = '" . (int) $_SESSION['languages_id'] . "'\n\t order by orders_id desc limit 3"); while ($orders = vam_db_fetch_array($orders_query)) { if (vam_not_null($orders['delivery_name'])) { $order_name = $orders['delivery_name']; $order_country = $orders['delivery_country']; } else { $order_name = $orders['billing_name']; $order_country = $orders['billing_country']; } $order_content[] = array('ORDER_ID' => $orders['orders_id'], 'ORDER_DATE' => vam_date_short($orders['date_purchased']), 'ORDER_STATUS' => $orders['orders_status_name'], 'ORDER_TOTAL' => $orders['order_total'], 'ORDER_LINK' => vam_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL'), 'ORDER_BUTTON' => '<a class="button" href="' . vam_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL') . '">' . vam_image_button('view.png', SMALL_IMAGE_BUTTON_VIEW) . '</a>'); } } $vamTemplate->assign('LINK_EDIT', vam_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL')); $vamTemplate->assign('LINK_ADDRESS', vam_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL')); $vamTemplate->assign('LINK_PASSWORD', vam_href_link(FILENAME_ACCOUNT_PASSWORD, '', 'SSL'));