Code:
<?php
/**
* @package admin
* @copyright Copyright 2003-2013 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version GIT: $Id: Author: DrByte Wed Nov 6 21:04:33 2013 -0500 Modified in v1.5.2 $
*/
require('includes/application_top.php');
// unset variable which is sometimes tainted by bad plugins like magneticOne tools
if (isset($module)) unset($module);
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
if (isset($_GET['oID'])) $_GET['oID'] = (int)$_GET['oID'];
include(DIR_WS_CLASSES . 'order.php');
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/dispatch.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script type="text/javascript">
<!--
function init()
{
cssjsmenu('navbar');
if (document.getElementById)
{
var kill = document.getElementById('hoverJS');
kill.disabled = true;
}
}
// -->
</script>
<script language="javascript" type="text/javascript"><!--
function couponpopupWindow(url) {
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')
}
//--></script>
</head>
<body onLoad="init()">
<!-- header //-->
<div class="header-area">
<?php
require(DIR_WS_INCLUDES . 'header.php');
?>
</div>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<!-- body_text //-->
<?php
if (($action == 'edit') && ($order_exists == true)) {
$order = new order($oID);
if ($order->info['payment_module_code']) {
if (file_exists(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php')) {
require(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
require(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
$module = new $order->info['payment_module_code'];
}
}
?>
</table></td>
</tr>
<?php
if (is_object($module) && method_exists($module, 'admin_notification')) {
?>
<?php
}
?>
</table></td>
</tr>
</table></td>
</tr>
<?php
} else {
?>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<p>Dispatch Screen</p>
<select name="dropdown">
<?php
$result = $db->Execute("SELECT * FROM " . ZEN_EMPLOYEES);
while (!$result->EOF) {
echo '<option value="' . $result->fields['employee_id'] . '">' . $result->fields['employee_first'] . '</option>';
$result->MoveNext();
}
?>
</select>
<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="dataTableHeadingRow">
<?php
// Sort Listing
switch ($_GET['list_order']) {
case "id-asc":
$disp_order = "c.customers_id";
break;
default:
$disp_order = "c.customers_id DESC";
}
?>
<td class="dataTableHeadingContent" align="center"><?php echo "Dispatch"; ?></td>
<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_ORDERS_ID; ?></td>
<td class="dataTableHeadingContent" align="center"><?php echo "Address"; ?></td>
<td class="dataTableHeadingContent" align="center"><?php echo "Order Age"; ?></td>
<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_ORDER_TOTAL; ?></td>
</tr>
<?php
// Only one or the other search
// create search_orders_products filter
$search = '';
$new_table = '';
$new_fields = '';
if (isset($_GET['search_orders_products']) && zen_not_null($_GET['search_orders_products'])) {
$new_fields = '';
$search_distinct = ' distinct ';
$new_table = " left join " . TABLE_ORDERS_PRODUCTS . " op on (op.orders_id = o.orders_id) ";
$keywords = zen_db_input(zen_db_prepare_input($_GET['search_orders_products']));
$search = " and (op.products_model like '%" . $keywords . "%' or op.products_name like '" . $keywords . "%')";
if (substr(strtoupper($_GET['search_orders_products']), 0, 3) == 'ID:') {
$keywords = TRIM(substr($_GET['search_orders_products'], 3));
$search = " and op.products_id ='" . (int)$keywords . "'";
}
} else {
?>
<?php
// create search filter
$search = '';
if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
$search_distinct = ' ';
$keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
$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 . "%')";
$new_table = '';
// $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 ";
}
} // eof: search orders or orders_products
$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 ";
?>
<?php
if (isset($_GET['cID'])) {
$cID = zen_db_prepare_input($_GET['cID']);
$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" .
$new_fields . "
from (" . TABLE_ORDERS_STATUS . " s, " .
TABLE_ORDERS . " o " .
$new_table . ")
left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id and ot.class = 'ot_total') " . "
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";
//echo '<BR><BR>I SEE A: ' . $orders_query_raw . '<BR><BR>';
} elseif ($_GET['status'] != '') {
$status = zen_db_prepare_input($_GET['status']);
$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" .
$new_fields . "
from (" . TABLE_ORDERS_STATUS . " s, " .
TABLE_ORDERS . " o " .
$new_table . ")
left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id and ot.class = 'ot_total') " . "
where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$_SESSION['languages_id'] . "' and s.orders_status_id = '" . (int)$status . "' " .
$search . " order by o.orders_id DESC";
//echo '<BR><BR>I SEE B: ' . $orders_query_raw . '<BR><BR>';
} else {
$orders_query_raw = "select " . $search_distinct . " 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" .
$new_fields . "
from (" . TABLE_ORDERS_STATUS . " s, " .
TABLE_ORDERS . " o " .
$new_table . ")
left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id and ot.class = 'ot_total') " . "
where (o.orders_status = s.orders_status_id and s.language_id = '" . (int)$_SESSION['languages_id'] . "') " .
$search . " order by o.orders_id DESC";
//echo '<BR><BR>I SEE C: ' . $orders_query_raw . '<BR><BR>';
}
// Split Page
// reset page when page is unknown
if (($_GET['page'] == '' or $_GET['page'] <= 1) and $_GET['oID'] != '') {
$check_page = $db->Execute($orders_query_raw);
$check_count=1;
if ($check_page->RecordCount() > MAX_DISPLAY_SEARCH_RESULTS_ORDERS) {
while (!$check_page->EOF) {
if ($check_page->fields['orders_id'] == $_GET['oID']) {
break;
}
$check_count++;
$check_page->MoveNext();
}
$_GET['page'] = round((($check_count/MAX_DISPLAY_SEARCH_RESULTS_ORDERS)+(fmod_round($check_count,MAX_DISPLAY_SEARCH_RESULTS_ORDERS) !=0 ? .5 : 0)),0);
} else {
$_GET['page'] = 1;
}
}
// $orders_query_numrows = '';
$orders_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS_ORDERS, $orders_query_raw, $orders_query_numrows);
$orders = $db->Execute($orders_query_raw);
while (!$orders->EOF) {
if ((!isset($_GET['oID']) || (isset($_GET['oID']) && ($_GET['oID'] == $orders->fields['orders_id']))) && !isset($oInfo)) {
$oInfo = new objectInfo($orders->fields);
}
?>
<td class="dataTableContent" align="center"><input type="checkbox" name="otd" value="$orders->fields['orders_id']" /></td>
<td class="dataTableContent" align="center"><?php echo $show_difference . $orders->fields['orders_id']; ?></td>
<td class="dataTableContent" align="center"><?php echo $orders->fields['delivery_street_address']; ?></td>
<td class="dataTableContent" align="center"><?php
$purchase_time = strtotime ($orders->fields['date_purchased']);
$difference = time () - $purchase_time;
$difference_in_minutes = ceil ($difference / 60); //-Round up to the next minute
echo gmdate("H:i:s", $difference);
?></td>
<td class="dataTableContent" align="center"><?php echo strip_tags($orders->fields['order_total']); ?></td>
</tr>
<?php
$orders->MoveNext();
}
?>
<tr>
<td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText" valign="top"><?php echo $orders_split->display_count($orders_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_ORDERS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_ORDERS); ?></td>
<td class="smallText" align="right"><?php echo $orders_split->display_links($orders_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_ORDERS, MAX_DISPLAY_PAGE_LINKS, $_GET['page'], zen_get_all_get_params(array('page', 'oID', 'action'))); ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<?php
}
?>
</table></td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>