PageRenderTime 59ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/catalog/YOUR_ADMIN/orders.php

https://github.com/numinix/numinix_barcodes
PHP | 1040 lines | 923 code | 71 blank | 46 comment | 189 complexity | 28d4984abf230bae9e66a897e64905c1 MD5 | raw file
Possible License(s): GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * @package admin
  4. * @copyright Copyright 2003-2007 Zen Cart Development Team
  5. * @copyright Portions Copyright 2003 osCommerce
  6. * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  7. * @version $Id: orders.php 6864 2007-08-27 16:15:20Z drbyte $
  8. */
  9. require('includes/application_top.php');
  10. require(DIR_WS_CLASSES . 'currencies.php');
  11. $currencies = new currencies();
  12. if (isset($_GET['oID'])) $_GET['oID'] = (int)$_GET['oID'];
  13. if (isset($_GET['download_reset_on'])) $_GET['download_reset_on'] = (int)$_GET['download_reset_on'];
  14. if (isset($_GET['download_reset_off'])) $_GET['download_reset_off'] = (int)$_GET['download_reset_off'];
  15. include(DIR_WS_CLASSES . 'order.php');
  16. // prepare order-status pulldown list
  17. $orders_statuses = array();
  18. $orders_status_array = array();
  19. $orders_status = $db->Execute("select orders_status_id, orders_status_name
  20. from " . TABLE_ORDERS_STATUS . "
  21. where language_id = '" . (int)$_SESSION['languages_id'] . "' order by orders_status_id");
  22. while (!$orders_status->EOF) {
  23. $orders_statuses[] = array('id' => $orders_status->fields['orders_status_id'],
  24. 'text' => $orders_status->fields['orders_status_name'] . ' [' . $orders_status->fields['orders_status_id'] . ']');
  25. $orders_status_array[$orders_status->fields['orders_status_id']] = $orders_status->fields['orders_status_name'];
  26. $orders_status->MoveNext();
  27. }
  28. $action = (isset($_GET['action']) ? $_GET['action'] : '');
  29. $order_exists = false;
  30. if (isset($_GET['oID']) && trim($_GET['oID']) == '') unset($_GET['oID']);
  31. if ($action == 'edit' && !isset($_GET['oID'])) $action = '';
  32. $oID = FALSE;
  33. if (isset($_POST['oID'])) {
  34. $oID = zen_db_prepare_input(trim($_POST['oID']));
  35. } elseif (isset($_GET['oID'])) {
  36. $oID = zen_db_prepare_input(trim($_GET['oID']));
  37. }
  38. if ($oID) {
  39. $orders = $db->Execute("select orders_id from " . TABLE_ORDERS . "
  40. where orders_id = '" . (int)$oID . "'");
  41. $order_exists = true;
  42. if ($orders->RecordCount() <= 0) {
  43. $order_exists = false;
  44. if ($action != '') $messageStack->add_session(ERROR_ORDER_DOES_NOT_EXIST . ' ' . $oID, 'error');
  45. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')), 'NONSSL'));
  46. }
  47. }
  48. if (zen_not_null($action) && $order_exists == true) {
  49. switch ($action) {
  50. case 'edit':
  51. // reset single download to on
  52. if ($_GET['download_reset_on'] > 0) {
  53. // adjust download_maxdays based on current date
  54. $check_status = $db->Execute("select customers_name, customers_email_address, orders_status,
  55. date_purchased from " . TABLE_ORDERS . "
  56. where orders_id = '" . $_GET['oID'] . "'");
  57. $zc_max_days = date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + DOWNLOAD_MAX_DAYS;
  58. // check for existing product attribute download days and max
  59. $chk_products_download_query = "SELECT orders_products_id, orders_products_filename, products_prid from " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " WHERE orders_products_download_id='" . $_GET['download_reset_on'] . "'";
  60. $chk_products_download = $db->Execute($chk_products_download_query);
  61. $chk_products_download_time_query = "SELECT pa.products_attributes_id, pa.products_id, pad.products_attributes_filename, pad.products_attributes_maxdays, pad.products_attributes_maxcount
  62. from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
  63. WHERE pa.products_attributes_id = pad.products_attributes_id
  64. and pad.products_attributes_filename = '" . $chk_products_download->fields['orders_products_filename'] . "'
  65. and pa.products_id = '" . (int)$chk_products_download->fields['products_prid'] . "'";
  66. $chk_products_download_time = $db->Execute($chk_products_download_time_query);
  67. if ($chk_products_download_time->EOF) {
  68. $zc_max_days = (DOWNLOAD_MAX_DAYS == 0 ? 0 : zen_date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + DOWNLOAD_MAX_DAYS);
  69. $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays='" . $zc_max_days . "', download_count='" . DOWNLOAD_MAX_COUNT . "' where orders_id='" . $_GET['oID'] . "' and orders_products_download_id='" . $_GET['download_reset_on'] . "'";
  70. } else {
  71. $zc_max_days = ($chk_products_download_time->fields['products_attributes_maxdays'] == 0 ? 0 : zen_date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + $chk_products_download_time->fields['products_attributes_maxdays']);
  72. $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays='" . $zc_max_days . "', download_count='" . $chk_products_download_time->fields['products_attributes_maxcount'] . "' where orders_id='" . $_GET['oID'] . "' and orders_products_download_id='" . $_GET['download_reset_on'] . "'";
  73. }
  74. $db->Execute($update_downloads_query);
  75. unset($_GET['download_reset_on']);
  76. $messageStack->add_session(SUCCESS_ORDER_UPDATED_DOWNLOAD_ON, 'success');
  77. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
  78. }
  79. // reset single download to off
  80. if ($_GET['download_reset_off'] > 0) {
  81. // adjust download_maxdays based on current date
  82. // *** fix: adjust count not maxdays to cancel download
  83. // $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays='0', download_count='0' where orders_id='" . $_GET['oID'] . "' and orders_products_download_id='" . $_GET['download_reset_off'] . "'";
  84. $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_count='0' where orders_id='" . $_GET['oID'] . "' and orders_products_download_id='" . $_GET['download_reset_off'] . "'";
  85. $db->Execute($update_downloads_query);
  86. unset($_GET['download_reset_off']);
  87. $messageStack->add_session(SUCCESS_ORDER_UPDATED_DOWNLOAD_OFF, 'success');
  88. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
  89. }
  90. break;
  91. case 'update_order':
  92. // demo active test
  93. if (zen_admin_demo()) {
  94. $_GET['action']= '';
  95. $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  96. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
  97. }
  98. $oID = zen_db_prepare_input($_GET['oID']);
  99. $comments = zen_db_prepare_input($_POST['comments']);
  100. $status = (int)zen_db_prepare_input($_POST['status']);
  101. if ($status < 1) break;
  102. $order_updated = false;
  103. $check_status = $db->Execute("select customers_name, customers_email_address, orders_status,
  104. date_purchased from " . TABLE_ORDERS . "
  105. where orders_id = '" . (int)$oID . "'");
  106. if ( ($check_status->fields['orders_status'] != $status) || zen_not_null($comments)) {
  107. $db->Execute("update " . TABLE_ORDERS . "
  108. set orders_status = '" . zen_db_input($status) . "', last_modified = now()
  109. where orders_id = '" . (int)$oID . "'");
  110. $customer_notified = '0';
  111. if (isset($_POST['notify']) && ($_POST['notify'] == '1')) {
  112. $notify_comments = '';
  113. if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on') && zen_not_null($comments)) {
  114. $notify_comments = EMAIL_TEXT_COMMENTS_UPDATE . $comments . "\n\n";
  115. }
  116. //send emails
  117. $message =
  118. EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n\n" .
  119. EMAIL_TEXT_INVOICE_URL . ' ' . zen_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n\n" .
  120. EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($check_status->fields['date_purchased']) . "\n\n" .
  121. strip_tags($notify_comments) .
  122. EMAIL_TEXT_STATUS_UPDATED . sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ) .
  123. EMAIL_TEXT_STATUS_PLEASE_REPLY;
  124. $html_msg['EMAIL_CUSTOMERS_NAME'] = $check_status->fields['customers_name'];
  125. $html_msg['EMAIL_TEXT_ORDER_NUMBER'] = EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID;
  126. $html_msg['EMAIL_TEXT_INVOICE_URL'] = '<a href="' . zen_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') .'">'.str_replace(':','',EMAIL_TEXT_INVOICE_URL).'</a>';
  127. $html_msg['EMAIL_TEXT_DATE_ORDERED'] = EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($check_status->fields['date_purchased']);
  128. $html_msg['EMAIL_TEXT_STATUS_COMMENTS'] = nl2br($notify_comments);
  129. $html_msg['EMAIL_TEXT_STATUS_UPDATED'] = str_replace('\n','', EMAIL_TEXT_STATUS_UPDATED);
  130. $html_msg['EMAIL_TEXT_STATUS_LABEL'] = str_replace('\n','', sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ));
  131. $html_msg['EMAIL_TEXT_NEW_STATUS'] = $orders_status_array[$status];
  132. $html_msg['EMAIL_TEXT_STATUS_PLEASE_REPLY'] = str_replace('\n','', EMAIL_TEXT_STATUS_PLEASE_REPLY);
  133. $html_msg['EMAIL_PAYPAL_TRANSID'] = '';
  134. zen_mail($check_status->fields['customers_name'], $check_status->fields['customers_email_address'], EMAIL_TEXT_SUBJECT . ' #' . $oID, $message, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status');
  135. $customer_notified = '1';
  136. // PayPal Trans ID, if any
  137. $sql = "select txn_id, parent_txn_id from " . TABLE_PAYPAL . " where order_id = :orderID order by last_modified DESC, date_added DESC, parent_txn_id DESC, paypal_ipn_id DESC ";
  138. $sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
  139. $result = $db->Execute($sql);
  140. if ($result->RecordCount() > 0) {
  141. $message .= "\n\n" . ' PayPal Trans ID: ' . $result->fields['txn_id'];
  142. $html_msg['EMAIL_PAYPAL_TRANSID'] = $result->fields['txn_id'];
  143. }
  144. //send extra emails
  145. if (SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_STATUS == '1' and SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO != '') {
  146. zen_mail('', SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO, SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_SUBJECT . ' ' . EMAIL_TEXT_SUBJECT . ' #' . $oID, $message, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status_extra');
  147. }
  148. } elseif (isset($_POST['notify']) && ($_POST['notify'] == '-1')) {
  149. // hide comment
  150. $customer_notified = '-1';
  151. }
  152. $db->Execute("insert into " . TABLE_ORDERS_STATUS_HISTORY . "
  153. (orders_id, orders_status_id, date_added, customer_notified, comments)
  154. values ('" . (int)$oID . "',
  155. '" . zen_db_input($status) . "',
  156. now(),
  157. '" . zen_db_input($customer_notified) . "',
  158. '" . zen_db_input($comments) . "')");
  159. $order_updated = true;
  160. }
  161. // trigger any appropriate updates which should be sent back to the payment gateway:
  162. $order = new order((int)$oID);
  163. if ($order->info['payment_module_code']) {
  164. if (file_exists(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php')) {
  165. require_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
  166. require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
  167. $module = new $order->info['payment_module_code'];
  168. if (method_exists($module, '_doStatusUpdate')) {
  169. $response = $module->_doStatusUpdate($oID, $status, $comments, $customer_notified, $check_status->fields['orders_status']);
  170. }
  171. }
  172. }
  173. if ($order_updated == true) {
  174. if ($status == DOWNLOADS_ORDERS_STATUS_UPDATED_VALUE) {
  175. // adjust download_maxdays based on current date
  176. $chk_downloads_query = "SELECT opd.*, op.products_id from " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd, " . TABLE_ORDERS_PRODUCTS . " op
  177. WHERE op.orders_id='" . (int)$oID . "'
  178. and opd.orders_products_id = op.orders_products_id";
  179. $chk_downloads = $db->Execute($chk_downloads_query);
  180. while (!$chk_downloads->EOF) {
  181. $chk_products_download_time_query = "SELECT pa.products_attributes_id, pa.products_id, pad.products_attributes_filename, pad.products_attributes_maxdays, pad.products_attributes_maxcount
  182. from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
  183. WHERE pa.products_attributes_id = pad.products_attributes_id
  184. and pad.products_attributes_filename = '" . $chk_downloads->fields['orders_products_filename'] . "'
  185. and pa.products_id = '" . $chk_downloads->fields['products_id'] . "'";
  186. $chk_products_download_time = $db->Execute($chk_products_download_time_query);
  187. if ($chk_products_download_time->EOF) {
  188. $zc_max_days = (DOWNLOAD_MAX_DAYS == 0 ? 0 : zen_date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + DOWNLOAD_MAX_DAYS);
  189. $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays='" . $zc_max_days . "', download_count='" . DOWNLOAD_MAX_COUNT . "' where orders_id='" . (int)$oID . "' and orders_products_download_id='" . $_GET['download_reset_on'] . "'";
  190. } else {
  191. $zc_max_days = ($chk_products_download_time->fields['products_attributes_maxdays'] == 0 ? 0 : zen_date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + $chk_products_download_time->fields['products_attributes_maxdays']);
  192. $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays='" . $zc_max_days . "', download_count='" . $chk_products_download_time->fields['products_attributes_maxcount'] . "' where orders_id='" . (int)$oID . "' and orders_products_download_id='" . $chk_downloads->fields['orders_products_download_id'] . "'";
  193. }
  194. $db->Execute($update_downloads_query);
  195. $chk_downloads->MoveNext();
  196. }
  197. }
  198. $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
  199. } else {
  200. $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');
  201. }
  202. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
  203. break;
  204. case 'deleteconfirm':
  205. // demo active test
  206. if (zen_admin_demo()) {
  207. $_GET['action']= '';
  208. $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  209. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')), 'NONSSL'));
  210. }
  211. $oID = zen_db_prepare_input($_POST['oID']);
  212. zen_remove_order($oID, $_POST['restock']);
  213. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')), 'NONSSL'));
  214. break;
  215. case 'delete_cvv':
  216. $delete_cvv = $db->Execute("update " . TABLE_ORDERS . " set cc_cvv = '" . TEXT_DELETE_CVV_REPLACEMENT . "' where orders_id = '" . (int)$_GET['oID'] . "'");
  217. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
  218. break;
  219. case 'mask_cc':
  220. $result = $db->Execute("select cc_number from " . TABLE_ORDERS . " where orders_id = '" . (int)$_GET['oID'] . "'");
  221. $old_num = $result->fields['cc_number'];
  222. $new_num = substr($old_num, 0, 4) . str_repeat('*', (strlen($old_num) - 8)) . substr($old_num, -4);
  223. $mask_cc = $db->Execute("update " . TABLE_ORDERS . " set cc_number = '" . $new_num . "' where orders_id = '" . (int)$_GET['oID'] . "'");
  224. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
  225. break;
  226. case 'doRefund':
  227. $order = new order($oID);
  228. if ($order->info['payment_module_code']) {
  229. if (file_exists(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php')) {
  230. require_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
  231. require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
  232. $module = new $order->info['payment_module_code'];
  233. if (method_exists($module, '_doRefund')) {
  234. $module->_doRefund($oID);
  235. }
  236. }
  237. }
  238. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
  239. break;
  240. case 'doAuth':
  241. $order = new order($oID);
  242. if ($order->info['payment_module_code']) {
  243. if (file_exists(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php')) {
  244. require_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
  245. require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
  246. $module = new $order->info['payment_module_code'];
  247. if (method_exists($module, '_doAuth')) {
  248. $module->_doAuth($oID, $order->info['total'], $order->info['currency']);
  249. }
  250. }
  251. }
  252. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
  253. break;
  254. case 'doCapture':
  255. $order = new order($oID);
  256. if ($order->info['payment_module_code']) {
  257. if (file_exists(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php')) {
  258. require_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
  259. require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
  260. $module = new $order->info['payment_module_code'];
  261. if (method_exists($module, '_doCapt')) {
  262. $module->_doCapt($oID, 'Complete', $order->info['total'], $order->info['currency']);
  263. }
  264. }
  265. }
  266. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
  267. break;
  268. case 'doVoid':
  269. $order = new order($oID);
  270. if ($order->info['payment_module_code']) {
  271. if (file_exists(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php')) {
  272. require_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
  273. require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
  274. $module = new $order->info['payment_module_code'];
  275. if (method_exists($module, '_doVoid')) {
  276. $module->_doVoid($oID);
  277. }
  278. }
  279. }
  280. zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
  281. break;
  282. }
  283. }
  284. ?>
  285. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  286. <html <?php echo HTML_PARAMS; ?>>
  287. <head>
  288. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  289. <title><?php echo TITLE; ?></title>
  290. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  291. <link rel="stylesheet" type="text/css" media="print" href="includes/stylesheet_print.css">
  292. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  293. <script language="javascript" src="includes/menu.js"></script>
  294. <script language="javascript" src="includes/general.js"></script>
  295. <script type="text/javascript">
  296. <!--
  297. function init()
  298. {
  299. cssjsmenu('navbar');
  300. if (document.getElementById)
  301. {
  302. var kill = document.getElementById('hoverJS');
  303. kill.disabled = true;
  304. }
  305. }
  306. // -->
  307. </script>
  308. <script language="javascript" type="text/javascript"><!--
  309. function couponpopupWindow(url) {
  310. window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')
  311. }
  312. //--></script>
  313. </head>
  314. <body onLoad="init()">
  315. <!-- header //-->
  316. <div class="header-area">
  317. <?php
  318. require(DIR_WS_INCLUDES . 'header.php');
  319. ?>
  320. </div>
  321. <!-- header_eof //-->
  322. <!-- body //-->
  323. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  324. <!-- body_text //-->
  325. <?php if ($action == '') { ?>
  326. <!-- search -->
  327. <tr>
  328. <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  329. <tr>
  330. <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  331. <tr><?php echo zen_draw_form('search', FILENAME_ORDERS, '', 'get', '', true); ?>
  332. <td width="65%" class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
  333. <td colspan="2" class="smallText" align="right">
  334. <?php
  335. // show reset search
  336. if ((isset($_GET['search']) && zen_not_null($_GET['search'])) or $_GET['cID'] !='') {
  337. echo '<a href="' . zen_href_link(FILENAME_ORDERS, '', 'NONSSL') . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a><br />';
  338. }
  339. ?>
  340. <?php
  341. echo HEADING_TITLE_SEARCH_DETAIL . ' ' . zen_draw_input_field('search') . zen_hide_session_id();
  342. if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  343. $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
  344. echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER . $keywords;
  345. }
  346. ?>
  347. </td>
  348. </form>
  349. <?php echo zen_draw_form('search_orders_products', FILENAME_ORDERS, '', 'get', '', true); ?>
  350. <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
  351. <td colspan="2" class="smallText" align="right">
  352. <?php
  353. // show reset search orders_products
  354. if ((isset($_GET['search_orders_products']) && zen_not_null($_GET['search_orders_products'])) or $_GET['cID'] !='') {
  355. echo '<a href="' . zen_href_link(FILENAME_ORDERS, '', 'NONSSL') . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a><br />';
  356. }
  357. ?>
  358. <?php
  359. echo HEADING_TITLE_SEARCH_DETAIL_ORDERS_PRODUCTS . ' ' . zen_draw_input_field('search_orders_products') . zen_hide_session_id();
  360. if (isset($_GET['search_orders_products']) && zen_not_null($_GET['search_orders_products'])) {
  361. $keywords_orders_products = zen_db_input(zen_db_prepare_input($_GET['search_orders_products']));
  362. echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER_ORDERS_PRODUCTS . zen_db_prepare_input($keywords_orders_products);
  363. }
  364. ?>
  365. </td>
  366. </form>
  367. </table></td>
  368. </tr>
  369. <!-- search -->
  370. <?php } ?>
  371. <?php
  372. if (($action == 'edit') && ($order_exists == true)) {
  373. $order = new order($oID);
  374. if ($order->info['payment_module_code']) {
  375. if (file_exists(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php')) {
  376. require(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
  377. require(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
  378. $module = new $order->info['payment_module_code'];
  379. // echo $module->admin_notification($oID);
  380. }
  381. }
  382. // fec dropdown
  383. if (MODULE_BARCODE_ORDERS_SWITCH == 'true') {
  384. $barcode = $db->Execute("SELECT orders_barcode FROM " . TABLE_ORDERS . " WHERE orders_id = " . $oID . " LIMIT 1");
  385. $barcode = $barcode->fields['orders_barcode'];
  386. if ($barcode == '') {
  387. // create barcode and store in db
  388. $barcode = MODULE_BARCODE_ORDERS_DEFAULT + $oID;
  389. $db->Execute("UPDATE " . TABLE_ORDERS . " SET orders_barcode = '" . $barcode . "' WHERE orders_id = " . $oID . " LIMIT 1");
  390. }
  391. }
  392. ?>
  393. <tr>
  394. <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  395. <tr>
  396. <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  397. <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
  398. <td class="pageHeading" align="right"><?php echo '<a href="javascript:history.back()">' . zen_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
  399. </tr>
  400. </table></td>
  401. </tr>
  402. <tr>
  403. <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
  404. <tr>
  405. <td colspan="3"><?php echo zen_draw_separator(); ?></td>
  406. </tr>
  407. <tr>
  408. <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
  409. <tr>
  410. <td class="main" valign="top"><strong><?php echo ENTRY_CUSTOMER; ?></strong></td>
  411. <td class="main"><?php echo zen_address_format($order->customer['format_id'], $order->customer, 1, '', '<br />'); ?></td>
  412. </tr>
  413. <tr>
  414. <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
  415. </tr>
  416. <tr>
  417. <td class="main"><strong><?php echo ENTRY_TELEPHONE_NUMBER; ?></strong></td>
  418. <td class="main"><?php echo $order->customer['telephone']; ?></td>
  419. </tr>
  420. <tr>
  421. <td class="main"><strong><?php echo ENTRY_EMAIL_ADDRESS; ?></strong></td>
  422. <td class="main"><?php echo '<a href="mailto:' . $order->customer['email_address'] . '">' . $order->customer['email_address'] . '</a>'; ?></td>
  423. </tr>
  424. <tr>
  425. <td class="main"><strong><?php echo TEXT_INFO_IP_ADDRESS; ?></strong></td>
  426. <td class="main"><?php echo $order->info['ip_address']; ?></td>
  427. </tr>
  428. </table></td>
  429. <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
  430. <tr>
  431. <td class="main" valign="top"><strong><?php echo ENTRY_SHIPPING_ADDRESS; ?></strong></td>
  432. <td class="main"><?php echo zen_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br />'); ?></td>
  433. </tr>
  434. <!-- bof FEC v1.24 drop down -->
  435. <?php if (MODULE_BARCODE_ORDERS_SWITCH == 'true') { ?>
  436. <tr>
  437. <td class="main" valign="top"><strong><?php echo ENTRY_BARCODE; ?></strong></td>
  438. <td class="main"><?php echo '<img src="' . DIR_WS_CATALOG . 'barcode/barcode.php?code=' . $barcode . '&scale=' . (int)MODULE_BARCODE_SCALE . '">'; ?></td>
  439. </tr>
  440. <?php } ?>
  441. <!-- eof dropdown -->
  442. </table></td>
  443. <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
  444. <tr>
  445. <td class="main" valign="top"><strong><?php echo ENTRY_BILLING_ADDRESS; ?></strong></td>
  446. <td class="main"><?php echo zen_address_format($order->billing['format_id'], $order->billing, 1, '', '<br />'); ?></td>
  447. </tr>
  448. </table></td>
  449. </tr>
  450. </table></td>
  451. </tr>
  452. <tr>
  453. <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  454. </tr>
  455. <tr>
  456. <td class="main"><strong><?php echo ENTRY_ORDER_ID . $oID; ?></strong></td>
  457. </tr>
  458. <tr>
  459. <td><table border="0" cellspacing="0" cellpadding="2">
  460. <tr>
  461. <td class="main"><strong><?php echo ENTRY_DATE_PURCHASED; ?></strong></td>
  462. <td class="main"><?php echo zen_date_long($order->info['date_purchased']); ?></td>
  463. </tr>
  464. <tr>
  465. <td class="main"><strong><?php echo ENTRY_PAYMENT_METHOD; ?></strong></td>
  466. <td class="main"><?php echo $order->info['payment_method']; ?></td>
  467. </tr>
  468. <?php
  469. if (zen_not_null($order->info['cc_type']) || zen_not_null($order->info['cc_owner']) || zen_not_null($order->info['cc_number'])) {
  470. ?>
  471. <tr>
  472. <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  473. </tr>
  474. <tr>
  475. <td class="main"><?php echo ENTRY_CREDIT_CARD_TYPE; ?></td>
  476. <td class="main"><?php echo $order->info['cc_type']; ?></td>
  477. </tr>
  478. <tr>
  479. <td class="main"><?php echo ENTRY_CREDIT_CARD_OWNER; ?></td>
  480. <td class="main"><?php echo $order->info['cc_owner']; ?></td>
  481. </tr>
  482. <tr>
  483. <td class="main"><?php echo ENTRY_CREDIT_CARD_NUMBER; ?></td>
  484. <td class="main"><?php echo $order->info['cc_number'] . (zen_not_null($order->info['cc_number']) && !strstr($order->info['cc_number'],'X') && !strstr($order->info['cc_number'],'********') ? '&nbsp;&nbsp;<a href="' . zen_href_link(FILENAME_ORDERS, '&action=mask_cc&oID=' . $oID, 'NONSSL') . '" class="noprint">' . TEXT_MASK_CC_NUMBER . '</a>' : ''); ?><td>
  485. </tr>
  486. <?php if (zen_not_null($order->info['cc_cvv'])) { ?>
  487. <tr>
  488. <td class="main"><?php echo ENTRY_CREDIT_CARD_CVV; ?></td>
  489. <td class="main"><?php echo $order->info['cc_cvv'] . (zen_not_null($order->info['cc_cvv']) && !strstr($order->info['cc_cvv'],TEXT_DELETE_CVV_REPLACEMENT) ? '&nbsp;&nbsp;<a href="' . zen_href_link(FILENAME_ORDERS, '&action=delete_cvv&oID=' . $oID, 'NONSSL') . '" class="noprint">' . TEXT_DELETE_CVV_FROM_DATABASE . '</a>' : ''); ?><td>
  490. </tr>
  491. <?php } ?>
  492. <tr>
  493. <td class="main"><?php echo ENTRY_CREDIT_CARD_EXPIRES; ?></td>
  494. <td class="main"><?php echo $order->info['cc_expires']; ?></td>
  495. </tr>
  496. <?php
  497. }
  498. ?>
  499. </table></td>
  500. </tr>
  501. <?php
  502. if (method_exists($module, 'admin_notification')) {
  503. ?>
  504. <tr>
  505. <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  506. </tr>
  507. <tr>
  508. <?php echo $module->admin_notification($oID); ?>
  509. </tr>
  510. <tr>
  511. <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  512. </tr>
  513. <?php
  514. }
  515. ?>
  516. <tr>
  517. <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  518. <tr class="dataTableHeadingRow">
  519. <td class="dataTableHeadingContent" colspan="2"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
  520. <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
  521. <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TAX; ?></td>
  522. <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRICE_EXCLUDING_TAX; ?></td>
  523. <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRICE_INCLUDING_TAX; ?></td>
  524. <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_EXCLUDING_TAX; ?></td>
  525. <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_INCLUDING_TAX; ?></td>
  526. </tr>
  527. <?php
  528. for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
  529. if (DISPLAY_PRICE_WITH_TAX_ADMIN == 'true')
  530. {
  531. $priceIncTax = $currencies->format(zen_round(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']),$currencies->get_decimal_places($order->info['currency'])) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']);
  532. } else
  533. {
  534. $priceIncTax = $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']);
  535. }
  536. echo ' <tr class="dataTableRow">' . "\n" .
  537. ' <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . '&nbsp;x</td>' . "\n" .
  538. ' <td class="dataTableContent" valign="top">' . $order->products[$i]['name'];
  539. if (isset($order->products[$i]['attributes']) && (sizeof($order->products[$i]['attributes']) > 0)) {
  540. for ($j = 0, $k = sizeof($order->products[$i]['attributes']); $j < $k; $j++) {
  541. echo '<br /><nobr><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value']));
  542. if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')';
  543. if ($order->products[$i]['attributes'][$j]['product_attribute_is_free'] == '1' and $order->products[$i]['product_is_free'] == '1') echo TEXT_INFO_ATTRIBUTE_FREE;
  544. echo '</i></small></nobr>';
  545. }
  546. }
  547. echo ' </td>' . "\n" .
  548. ' <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n" .
  549. ' <td class="dataTableContent" align="right" valign="top">' . zen_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n" .
  550. ' <td class="dataTableContent" align="right" valign="top"><strong>' .
  551. $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) .
  552. ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format($order->products[$i]['onetime_charges'], true, $order->info['currency'], $order->info['currency_value']) : '') .
  553. '</strong></td>' . "\n" .
  554. ' <td class="dataTableContent" align="right" valign="top"><strong>' .
  555. $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) .
  556. ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '') .
  557. '</strong></td>' . "\n" .
  558. ' <td class="dataTableContent" align="right" valign="top"><strong>' .
  559. $currencies->format(zen_round($order->products[$i]['final_price'], $currencies->get_decimal_places($order->info['currency'])) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) .
  560. ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format($order->products[$i]['onetime_charges'], true, $order->info['currency'], $order->info['currency_value']) : '') .
  561. '</strong></td>' . "\n" .
  562. ' <td class="dataTableContent" align="right" valign="top"><strong>' .
  563. $priceIncTax .
  564. ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '') .
  565. '</strong></td>' . "\n";
  566. echo ' </tr>' . "\n";
  567. }
  568. ?>
  569. <tr>
  570. <td align="right" colspan="8"><table border="0" cellspacing="0" cellpadding="2">
  571. <?php
  572. for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
  573. echo ' <tr>' . "\n" .
  574. ' <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Text">' . $order->totals[$i]['title'] . '</td>' . "\n" .
  575. ' <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount">' . $currencies->format($order->totals[$i]['value'], false) . '</td>' . "\n" .
  576. ' </tr>' . "\n";
  577. }
  578. ?>
  579. </table></td>
  580. </tr>
  581. </table></td>
  582. </tr>
  583. <?php
  584. // show downloads
  585. require(DIR_WS_MODULES . 'orders_download.php');
  586. ?>
  587. <tr>
  588. <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  589. </tr>
  590. <tr>
  591. <td class="main"><table border="1" cellspacing="0" cellpadding="5">
  592. <tr>
  593. <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_DATE_ADDED; ?></strong></td>
  594. <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_CUSTOMER_NOTIFIED; ?></strong></td>
  595. <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_STATUS; ?></strong></td>
  596. <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_COMMENTS; ?></strong></td>
  597. </tr>
  598. <?php
  599. $orders_history = $db->Execute("select orders_status_id, date_added, customer_notified, comments
  600. from " . TABLE_ORDERS_STATUS_HISTORY . "
  601. where orders_id = '" . zen_db_input($oID) . "'
  602. order by date_added");
  603. if ($orders_history->RecordCount() > 0) {
  604. while (!$orders_history->EOF) {
  605. echo ' <tr>' . "\n" .
  606. ' <td class="smallText" align="center">' . zen_datetime_short($orders_history->fields['date_added']) . '</td>' . "\n" .
  607. ' <td class="smallText" align="center">';
  608. if ($orders_history->fields['customer_notified'] == '1') {
  609. echo zen_image(DIR_WS_ICONS . 'tick.gif', TEXT_YES) . "</td>\n";
  610. } else if ($orders_history->fields['customer_notified'] == '-1') {
  611. echo zen_image(DIR_WS_ICONS . 'locked.gif', TEXT_HIDDEN) . "</td>\n";
  612. } else {
  613. echo zen_image(DIR_WS_ICONS . 'unlocked.gif', TEXT_VISIBLE) . "</td>\n";
  614. }
  615. echo ' <td class="smallText">' . $orders_status_array[$orders_history->fields['orders_status_id']] . '</td>' . "\n";
  616. echo ' <td class="smallText">' . nl2br(zen_db_output($orders_history->fields['comments'])) . '&nbsp;</td>' . "\n" .
  617. ' </tr>' . "\n";
  618. $orders_history->MoveNext();
  619. }
  620. } else {
  621. echo ' <tr>' . "\n" .
  622. ' <td class="smallText" colspan="5">' . TEXT_NO_ORDER_HISTORY . '</td>' . "\n" .
  623. ' </tr>' . "\n";
  624. }
  625. ?>
  626. </table></td>
  627. </tr>
  628. <tr>
  629. <td class="main noprint"><br /><strong><?php echo TABLE_HEADING_COMMENTS; ?></strong></td>
  630. </tr>
  631. <tr>
  632. <td class="noprint"><?php echo zen_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
  633. </tr>
  634. <tr><?php echo zen_draw_form('status', FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=update_order', 'post', '', true); ?>
  635. <td class="main noprint"><?php echo zen_draw_textarea_field('comments', 'soft', '60', '5'); ?></td>
  636. </tr>
  637. <tr>
  638. <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  639. </tr>
  640. <tr>
  641. <td><table border="0" cellspacing="0" cellpadding="2" class="noprint">
  642. <tr>
  643. <td><table border="0" cellspacing="0" cellpadding="2">
  644. <tr>
  645. <td class="main"><strong><?php echo ENTRY_STATUS; ?></strong> <?php echo zen_draw_pull_down_menu('status', $orders_statuses, $order->info['orders_status']); ?></td>
  646. </tr>
  647. <tr>
  648. <td class="main"><strong><?php echo ENTRY_NOTIFY_CUSTOMER; ?></strong> [<?php echo zen_draw_radio_field('notify', '1', true) . '-' . TEXT_EMAIL . ' ' . zen_draw_radio_field('notify', '0', FALSE) . '-' . TEXT_NOEMAIL . ' ' . zen_draw_radio_field('notify', '-1', FALSE) . '-' . TEXT_HIDE; ?>]&nbsp;&nbsp;&nbsp;</td>
  649. <td class="main"><strong><?php echo ENTRY_NOTIFY_COMMENTS; ?></strong> <?php echo zen_draw_checkbox_field('notify_comments', '', true); ?></td>
  650. </tr>
  651. <tr><td><br /></td></tr>
  652. </table></td>
  653. <td valign="top"><?php echo zen_image_submit('button_update.gif', IMAGE_UPDATE); ?></td>
  654. </tr>
  655. </table></td>
  656. </form></tr>
  657. <tr>
  658. <td colspan="2" align="right" class="noprint"><?php echo '<a href="' . zen_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $_GET['oID']) . '" TARGET="_blank">' . zen_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . zen_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $_GET['oID']) . '" TARGET="_blank">' . zen_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a> <a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action'))) . '">' . zen_image_button('button_orders.gif', IMAGE_ORDERS) . '</a>'; ?></td>
  659. </tr>
  660. <?php
  661. // check if order has open gv
  662. $gv_check = $db->Execute("select order_id, unique_id
  663. from " . TABLE_COUPON_GV_QUEUE ."
  664. where order_id = '" . $_GET['oID'] . "' and release_flag='N' limit 1");
  665. if ($gv_check->RecordCount() > 0) {
  666. $goto_gv = '<a href="' . zen_href_link(FILENAME_GV_QUEUE, 'order=' . $_GET['oID']) . '">' . zen_image_button('button_gift_queue.gif',IMAGE_GIFT_QUEUE) . '</a>';
  667. echo ' <tr><td align="right"><table width="225"><tr>';
  668. echo ' <td align="center">';
  669. echo $goto_gv . '&nbsp;&nbsp;';
  670. echo ' </td>';
  671. echo ' </tr></table></td></tr>';
  672. }
  673. ?>
  674. <?php
  675. } else {
  676. ?>
  677. <tr>
  678. <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  679. <tr>
  680. <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  681. <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
  682. <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  683. <tr><?php echo zen_draw_form('orders', FILENAME_ORDERS, '', 'get', '', true); ?>
  684. <td class="smallText" align="right"><?php echo HEADING_TITLE_SEARCH . ' ' . zen_draw_input_field('oID', '', 'size="12"') . zen_draw_hidden_field('action', 'edit') . zen_hide_session_id(); ?></td>
  685. </form></tr>
  686. <tr><?php echo zen_draw_form('status', FILENAME_ORDERS, '', 'get', '', true); ?>
  687. <td class="smallText" align="right">
  688. <?php
  689. echo HEADING_TITLE_STATUS . ' ' . zen_draw_pull_down_menu('status', array_merge(array(array('id' => '', 'text' => TEXT_ALL_ORDERS)), $orders_statuses), $_GET['status'], 'onChange="this.form.submit();"');
  690. echo zen_hide_session_id();
  691. ?>
  692. </td>
  693. </form></tr>
  694. </table></td>
  695. </tr>
  696. </table></td>
  697. </tr>
  698. <tr>
  699. <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  700. <tr>
  701. <td class="smallText"><?php echo TEXT_LEGEND . ' ' . zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', TEXT_BILLING_SHIPPING_MISMATCH, 10, 10) . ' ' . TEXT_BILLING_SHIPPING_MISMATCH; ?>
  702. </td>
  703. <tr>
  704. <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  705. <tr class="dataTableHeadingRow">
  706. <?php
  707. // Sort Listing
  708. switch ($_GET['list_order']) {
  709. case "id-asc":
  710. $disp_order = "c.customers_id";
  711. break;
  712. case "firstname":
  713. $disp_order = "c.customers_firstname";
  714. break;
  715. case "firstname-desc":
  716. $disp_order = "c.customers_firstname DESC";
  717. break;
  718. case "lastname":
  719. $disp_order = "c.customers_lastname, c.customers_firstname";
  720. break;
  721. case "lastname-desc":
  722. $disp_order = "c.customers_lastname DESC, c.customers_firstname";
  723. break;
  724. case "company":
  725. $disp_order = "a.entry_company";
  726. break;
  727. case "company-desc":
  728. $disp_order = "a.entry_company DESC";
  729. break;
  730. default:
  731. $disp_order = "c.customers_id DESC";
  732. }
  733. ?>
  734. <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_ORDERS_ID; ?></td>
  735. <td class="dataTableHeadingContent" align="left" width="50"><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></td>
  736. <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMERS; ?></td>
  737. <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ORDER_TOTAL; ?></td>
  738. <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_DATE_PURCHASED; ?></td>
  739. <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td>
  740. <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_CUSTOMER_COMMENTS; ?></td>
  741. <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  742. </tr>
  743. <?php
  744. // Only one or the other search
  745. // create search_orders_products filter
  746. $search = '';
  747. $new_table = '';
  748. $new_fields = '';
  749. if (isset($_GET['search_orders_products']) && zen_not_null($_GET['search_orders_products'])) {
  750. $new_fields = '';
  751. $search_distinct = ' distinct ';
  752. $new_table = " left join " . TABLE_ORDERS_PRODUCTS . " op on (op.orders_id = o.orders_id) ";
  753. $keywords = zen_db_input(zen_db_prepare_input($_GET['search_orders_products']));
  754. $search = " and (op.products_model like '%" . $keywords . "%' or op.products_name like '" . $keywords . "%')";
  755. if (substr(strtoupper($_GET['search_orders_products']), 0, 3) == 'ID:') {
  756. $keywords = TRIM(substr($_GET['search_orders_products'], 3));
  757. $search = " and op.products_id ='" . (int)$keywords . "'";
  758. }
  759. } else {
  760. ?>
  761. <?php
  762. // create search filter
  763. $search = '';
  764. if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  765. $search_distinct = ' ';
  766. $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
  767. $search = " and (o.customers_city like '%" . $keywords . "%' or o.customers_postcode like '%" . $keywords . "%' or o.date_purchased like '%" . $keywords . "%' or o.billing_name like '%" . $keywords . "%' or o.billing_company like '%" . $keywords . "%' or o.billing_street_address like '%" . $keywords . "%' or o.delivery_city like '%" . $keywords . "%' or o.delivery_postcode like '%" . $keywords . "%' or o.delivery_name like '%" . $keywords . "%' or o.delivery_company like '%" . $keywords . "%' or o.delivery_street_address like '%" . $keywords . "%' or o.billing_city like '%" . $keywords . "%' or o.billing_postcode like '%" . $keywords . "%' or o.customers_email_address like '%" . $keywords . "%' or o.customers_name like '%" . $keywords . "%' or o.customers_company like '%" . $keywords . "%' or o.customers_street_address like '%" . $keywords . "%' or o.customers_telephone like '%" . $keywords . "%' or o.ip_address like '%" . $keywords . "%')";
  768. $new_table = '';
  769. // $new_fields = ", o.customers_company, o.customers_email_address, o.customers_street_address, o.delivery_company, o.delivery_name, o.delivery_street_address, o.billing_company, o.billing_name, o.billing_street_address, o.payment_module_code, o.shipping_module_code, o.ip_address ";
  770. }
  771. } // eof: search orders or orders_products
  772. $new_fields = ", o.customers_company, o.customers_email_address, o.customers_street_address, o.delivery_company, o.delivery_name, o.delivery_street_address, o.billing_company, o.billing_name, o.billing_street_address, o.payment_module_code, o.shipping_module_code, o.ip_address ";
  773. ?>
  774. <?php
  775. if (isset($_GET['cID'])) {
  776. $cID = zen_db_prepare_input($_GET['cID']);
  777. $orders_query_raw = "select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.shipping_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total" .
  778. $new_fields . "
  779. from (" . TABLE_ORDERS_STATUS . " s, " .
  780. TABLE_ORDERS . " o " .
  781. $new_table . ")
  782. left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id and ot.class = 'ot_total') " . "
  783. where o.customers_id = '" . (int)$cID . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$_SESSION['languages_id'] . "' order by orders_id DESC";
  784. //echo '<BR><BR>I SEE A: ' . $orders_query_raw . '<BR><BR>';
  785. } elseif ($_GET['stat…

Large files files are truncated, but you can click here to view the full file