Execute($order_sql);
while ($order = $order_result->fields) {
$productstable = $oostable['products'];
$dbconn->Execute("UPDATE $productstable
SET products_quantity = products_quantity + " . $order['products_quantity'] . ",
products_ordered = products_ordered - " . $order['products_quantity'] . "
WHERE products_id = '" . $order['products_id'] . "'");
// Move that ADOdb pointer!
$order_result->MoveNext();
}
}
$orderstable = $oostable['orders'];
$dbconn->Execute("DELETE FROM $orderstable WHERE orders_id = '" . oos_db_input($order_id) . "'");
$orders_productstable = $oostable['orders_products'];
$dbconn->Execute("DELETE FROM $orders_productstable WHERE orders_id = '" . oos_db_input($order_id) . "'");
$orders_products_attributesstable = $oostable['orders_products_attributes'];
$dbconn->Execute("DELETE FROM $orders_products_attributesstable WHERE orders_id = '" . oos_db_input($order_id) . "'");
$orders_status_historytable = $oostable['orders_status_history'];
$dbconn->Execute("DELETE FROM $orders_status_historytable WHERE orders_id = '" . oos_db_input($order_id) . "'");
$orders_totaltable = $oostable['orders_total'];
$dbconn->Execute("DELETE FROM $orders_totaltable WHERE orders_id = '" . oos_db_input($order_id) . "'");
}
}
function oos_get_languages_id ($iso_639_2) {
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$languagestable = $oostable['languages'];
$languages_result = $dbconn->Execute("SELECT languages_id, iso_639_2 FROM $languagestable WHERE iso_639_2 = '" . oos_db_input($iso_639_2) . "'");
if (!$languages_result->RecordCount()) {
$LangID = $_SESSION['language_id'];
} else {
$LangID = $languages_result->fields['languages_id'];
}
return $LangID;
}
require 'includes/classes/class_currencies.php';
$currencies = new currencies();
$orders_statuses = array();
$orders_status_array = array();
$orders_statustable = $oostable['orders_status'];
$orders_status_result = $dbconn->Execute("SELECT orders_status_id, orders_status_name FROM $orders_statustable WHERE orders_languages_id = '" . intval($_SESSION['language_id']) . "'");
while ($orders_status = $orders_status_result->fields) {
$orders_statuses[] = array('id' => $orders_status['orders_status_id'],
'text' => $orders_status['orders_status_name']);
$orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name'];
// Move that ADOdb pointer!
$orders_status_result->MoveNext();
}
$nPage = (!isset($_GET['page']) || !is_numeric($_GET['page'])) ? 1 : intval($_GET['page']);
$action = (isset($_GET['action']) ? $_GET['action'] : '');
if (!empty($action)) {
switch ($action) {
case 'update_order':
$oID = oos_db_prepare_input($_GET['oID']);
$order_updated = false;
$orderstable = $oostable['orders'];
$check_status_result = $dbconn->Execute("SELECT customers_name, customers_email_address, orders_status, date_purchased, orders_language FROM $orderstable WHERE orders_id = '" . oos_db_input($oID) . "'");
$check_status = $check_status_result->fields;
if ($check_status['orders_status'] != $status || $comments != '' ) {
$orderstable = $oostable['orders'];
$dbconn->Execute("UPDATE $orderstable SET orders_status = '" . oos_db_input($status) . "', last_modified = now() WHERE orders_id = '" . oos_db_input($oID) . "'");
$orderstable = $oostable['orders'];
$check_status_result2 = $dbconn->Execute("SELECT customers_name, customers_email_address, orders_status, date_purchased FROM $orderstable WHERE orders_id = '" . oos_db_input($oID) . "'");
$check_status2 = $check_status_result2->fields;
$orders_products_downloadtable = $oostable['orders_products_download'];
$dbconn->Execute("UPDATE $orders_products_downloadtable SET download_maxdays = '" . oos_db_input(DOWNLOAD_MAX_DAYS) . "', download_count = '" . oos_db_input(DOWNLOAD_MAX_COUNT) . "' WHERE orders_id = '" . oos_db_input($oID) . "'");
$customer_notified = '0';
if (isset($_POST['notify']) && ($_POST['notify'] == 'on')) {
if (oos_is_not_null($check_status['orders_language'])) {
include 'includes/languages/' . $check_status['orders_language'] . '/email_orders.php';
$nLangID = oos_get_languages_id($check_status['orders_language']);
$orders_statustable = $oostable['orders_status'];
$orders_status_result = $dbconn->Execute("SELECT orders_status_id, orders_status_name FROM $orders_statustable WHERE orders_languages_id = '" . intval($nLangID) . "'");
} else {
$orders_statustable = $oostable['orders_status'];
include 'includes/languages/' . $_SESSION['language'] . '/email_orders.php';
$orders_status_result = $dbconn->Execute("SELECT orders_status_id, orders_status_name FROM $orders_statustable WHERE orders_languages_id = '" . intval($_SESSION['language_id']) . "'");
}
$orders_statuses = array();
$orders_status_array = array();
while ($orders_status = $orders_status_result->fields) {
$orders_statuses[] = array('id' => $orders_status['orders_status_id'],
'text' => $orders_status['orders_status_name']);
$orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name'];
// Move that ADOdb pointer!
$orders_status_result->MoveNext();
}
// status query
$orders_statustable = $oostable['orders_status'];
$orders_status_result = $dbconn->Execute("SELECT orders_status_name FROM $orders_statustable WHERE orders_languages_id = '" . intval($_SESSION['language_id']) . "' AND orders_status_id = '" . oos_db_input($status) . "'");
$o_status = $orders_status_result->fields;
$o_status = $o_status['orders_status_name'];
$notify_comments = '';
if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on')) {
if (isset($comments)) {
$notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $comments) . "\n\n";
}
}
$email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . oos_catalog_link($aCatalog['account_history_info'], 'order_id=' . $oID) . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . oos_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]);
oos_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, nl2br($email), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
$customer_notified = '1';
}
$orders_status_historytable = $oostable['orders_status_history'];
$dbconn->Execute("INSERT INTO $orders_status_historytable (orders_id, orders_status_id, date_added, customer_notified, comments) VALUES ('" . oos_db_input($oID) . "', '" . oos_db_input($status) . "', now(), '" . $customer_notified . "', '" . oos_db_input($comments) . "')");
$order_updated = true;
}
if ($order_updated) {
$messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
} else {
$messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');
}
oos_redirect_admin(oos_href_link_admin($aContents['orders'], oos_get_all_get_params(array('action')) . 'action=edit'));
break;
case 'update_serial':
$oID = oos_db_prepare_input($_GET['oID']);
$serial_number = oos_db_prepare_input($_POST['serial_number']);
$serial = oos_db_prepare_input($_GET['serial']);
$orders_productstable = $oostable['orders_products'];
$dbconn->Execute("UPDATE $orders_productstable SET products_serial_number = '" . oos_db_input($serial_number) . "' WHERE orders_id = '" . oos_db_input($oID) . "' AND orders_products_id = '" . oos_db_input($serial) . "'");
$messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
oos_redirect_admin(oos_href_link_admin($aContents['orders'], oos_get_all_get_params(array('action')) . 'action=edit&serial_updated=1'));
break;
case 'deleteconfirm':
$oID = oos_db_prepare_input($_GET['oID']);
oos_remove_order($oID, $_POST['restock']);
oos_redirect_admin(oos_href_link_admin($aContents['orders'], oos_get_all_get_params(array('oID', 'action'))));
break;
}
}
if (($action == 'edit') && isset($_GET['oID'])) {
$oID = oos_db_prepare_input($_GET['oID']);
$orderstable = $oostable['orders'];
$orders_result = $dbconn->Execute("SELECT orders_id FROM $orderstable WHERE orders_id = '" . oos_db_input($oID) . "'");
$order_exists = true;
if (!$orders_result->RecordCount()) {
$order_exists = false;
$messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error');
}
}
include '../includes/classes/class_order.php';
require 'includes/header.php';
?>
customer['id'];
?>
' . HEADER_TITLE_TOP . ''; ?>
' . BOX_HEADING_CUSTOMERS . ''; ?>
' . oos_button(BUTTON_EDIT) . ' '; ?>
' . oos_button(IMAGE_BACK) . ''; ?>
customer['format_id'], $order->customer, 1, ' ', ' '); ?>
customer['telephone']; ?>
customer['email_address'] . '">' . $order->customer['email_address'] . ' '; ?>
delivery['format_id'], $order->delivery, 1, ' ', ' '); ?>
billing['format_id'], $order->billing, 1, ' ', ' '); ?>
info['date_purchased']); ?>
info['payment_method']; ?>
products); $i < $n; $i++) {
echo ' ' . "\n" .
' ' . $order->products[$i]['qty'] . ' x ' . "\n" .
' ' . $order->products[$i]['name'];
if (isset($order->products[$i]['attributes']) && (count($order->products[$i]['attributes']) > 0)) {
for ($j = 0, $k = count($order->products[$i]['attributes']); $j < $k; $j++) {
echo ' - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
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']) . ')';
echo ' ';
}
}
echo ' ' . "\n";
$serial_number = "Add Serial #";
if (oos_is_not_null($order->products[$i]['serial_number'])) $serial_number = $order->products[$i]['serial_number'];
echo ' ' . $serial_number . ' ' . "\n" .
' ' . $order->products[$i]['model'] . ' ' . "\n" .
' ' . oos_display_tax_value($order->products[$i]['tax']) . '% ' . "\n" .
' ' . $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) . ' ' . "\n" .
' ' . $currencies->format(oos_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . ' ' . "\n" .
' ' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ' ' . "\n" .
' ' . $currencies->format(oos_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ' ' . "\n";
echo ' ' . "\n";
if (oos_is_not_null($_GET['serial']) && ($_GET['serial'] == $i) && ($_GET['serial_updated'] <> 1)) {
echo ' ' . "\n" .
' Enter Serial #: ' . "\n";
echo ' ' .
oos_draw_form('id', 'serial_form', $aContents['orders'], 'action=update_serial&oID=' . $oID . '&serial=' . $order->products[$i]['id'], 'post', FALSE) .
oos_draw_input_field('serial_number', $serial_number, '', false, 'text', true) . ' ' . oos_submit_button(IMAGE_UPDATE) . ' ' . "\n" .
' ' . "\n";
}
}
?>
totals); $i < $n; $i++) {
echo ' ' . "\n" .
' ' . $order->totals[$i]['title'] . ' ' . "\n" .
' ' . $order->totals[$i]['text'] . ' ' . "\n" .
' ' . "\n";
}
?>
Execute("SELECT orders_status_id, date_added, customer_notified, comments FROM $orders_status_historytable WHERE orders_id = '" . oos_db_input($oID) . "' ORDER BY date_added");
if ($orders_history_result->RecordCount()) {
while ($orders_history = $orders_history_result->fields) {
echo ' ' . "\n" .
' ' . oos_datetime_short($orders_history['date_added']) . ' ' . "\n" .
' ';
if ($orders_history['customer_notified'] == '1') {
echo oos_image(OOS_IMAGES . 'icons/tick.gif', ICON_TICK) . " \n";
} else {
echo oos_image(OOS_IMAGES . 'icons/cross.gif', ICON_CROSS) . "\n";
}
echo ' ' . $orders_status_array[$orders_history['orders_status_id']] . ' ' . "\n" .
' ' . nl2br(htmlspecialchars($orders_history['comments'])) . ' ' . "\n" .
' ' . "\n";
// Move that ADOdb pointer!
$orders_history_result->MoveNext();
}
} else {
echo ' ' . "\n" .
' ' . TEXT_NO_ORDER_HISTORY . ' ' . "\n" .
' ' . "\n";
}
?>
info['orders_status']); ?>
' . oos_button(IMAGE_ORDERS_INVOICE) . ' ' . oos_button(IMAGE_ORDERS_PACKINGSLIP) . ' ' . oos_button(IMAGE_BACK) . ' '; ?>
' . HEADER_TITLE_TOP . ''; ?>
' . BOX_HEADING_CUSTOMERS . ''; ?>
'', 'text' => TEXT_ALL_ORDERS)), $orders_statuses), '', 'onChange="this.form.submit();"'); ?>
Execute($orders_result_raw);
while ($orders = $orders_result->fields) {
if ((!isset($_GET['oID']) || (isset($_GET['oID']) && ($_GET['oID'] == $orders['orders_id']))) && !isset($oInfo)) {
$oInfo = new objectInfo($orders);
}
if (isset($oInfo) && is_object($oInfo) && ($orders['orders_id'] == $oInfo->orders_id)) {
echo ' ' . "\n";
} else {
echo ' ' . "\n";
}
?>
' . $orders['customers_name']; ?>
orders_id) ) { echo ' '; } else { echo ' '; } ?>
MoveNext();
}
?>
display_count($orders_result_numrows, MAX_DISPLAY_SEARCH_RESULTS, $nPage, TEXT_DISPLAY_NUMBER_OF_ORDERS); ?>
display_links($orders_result_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $nPage, oos_get_all_get_params(array('page', 'oID', 'action'))); ?>
'' . TEXT_INFO_HEADING_DELETE_ORDER . ' ');
$contents = array('form' => oos_draw_form('id', 'orders', $aContents['orders'], oos_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=deleteconfirm', 'post', FALSE));
$contents[] = array('text' => TEXT_INFO_DELETE_INTRO . '' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . ' ');
$contents[] = array('text' => ' ' . oos_draw_checkbox_field('restock') . ' ' . TEXT_INFO_RESTOCK_PRODUCT_QUANTITY);
$contents[] = array('align' => 'center', 'text' => ' ' . oos_submit_button(BUTTON_DELETE) . ' ' . BUTTON_CANCEL . ' ');
break;
default:
if (isset($oInfo) && is_object($oInfo)) {
$heading[] = array('text' => '[' . $oInfo->orders_id . '] ' . oos_datetime_short($oInfo->date_purchased) . ' ');
$contents[] = array('align' => 'center', 'text' => '' . oos_button(BUTTON_EDIT) . ' ' . oos_button(BUTTON_DELETE) . ' ');
$contents[] = array('align' => 'center', 'text' => '' . oos_button(IMAGE_ORDERS_INVOICE) . ' ' . oos_button(IMAGE_ORDERS_PACKINGSLIP) . ' ');
$contents[] = array('text' => ' ' . TEXT_DATE_ORDER_CREATED . ' ' . oos_date_short($oInfo->date_purchased));
if (oos_is_not_null($oInfo->last_modified)) $contents[] = array('text' => TEXT_DATE_ORDER_LAST_MODIFIED . ' ' . oos_date_short($oInfo->last_modified));
$contents[] = array('text' => ' ' . TEXT_INFO_PAYMENT_METHOD . ' ' . $oInfo->payment_method);
}
break;
}
if ( (oos_is_not_null($heading)) && (oos_is_not_null($contents)) ) {
?>
infoBox($heading, $contents);
?>