Ankündigung

Einklappen
Keine Ankündigung bisher.

Affiliates Modul

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Affiliates Modul

    Hallo zusammen,

    ich habe hier ein Affiliates Modul gefunden.

    I'll be submitting this plugin to the Plugins area shortly, based on the similar-named plugin for the v1.3.x series (http://www.zen-cart.com/showthread.php?124461-snap-affiliates). This version (v2.0.0) will run only on Zen Cart v1.5.0 and later and includes the following additional changes: No core-file overwrites! Moved all language-specific text to the language file, both catalog and admin. Moved $_SESSION initialization to /includes/init_includes/init_snap.php and


    Muß so ein Modul speziell für die deutsche ZenCart Version angepasst werden?

    Grüße
    Manfred

    #3
    Ich habe das jetzt mal in meinem "Testshop" eingespielt. Bis auf englischen Wörter im Adminbereich und im Kundenaccount (Frontend) scheint alles so zu laufen wie es soll.

    Ich werde mal weiter testen.

    Grüße
    Manfred

    Kommentar


      #4
      Ich habe da noch ein Problem.

      Ich bekomme diese beieden Dateien einfach nicht zusammen.

      Hier die original orders.php die bei dem Modul dabei ist. Dort sind die Zeilen von 120 bis 191 einfach "ausgeklammert". Ich habe aber in meiner orders.php genau in diesem Bereich Eintragungen von anderen Modulen stehen (Cowa und Pakettracking z.B.).

      Also hier die orders.php die bei dem snap_affiliates-Modul dabei ist:

      Code:
      <?php
      /**
       * @package admin
       * @copyright Copyright 2003-2014 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  Jun 30 2014 Modified in v1.5.4 $
       */
      
        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'];
        if (isset($_GET['download_reset_on'])) $_GET['download_reset_on'] = (int)$_GET['download_reset_on'];
        if (isset($_GET['download_reset_off'])) $_GET['download_reset_off'] = (int)$_GET['download_reset_off'];
      
        include(DIR_WS_CLASSES . 'order.php');
      
        // prepare order-status pulldown list
        $orders_statuses = array();
        $orders_status_array = array();
        $orders_status = $db->Execute("select orders_status_id, orders_status_name
                                       from " . TABLE_ORDERS_STATUS . "
                                       where language_id = '" . (int)$_SESSION['languages_id'] . "' order by orders_status_id");
        while (!$orders_status->EOF) {
          $orders_statuses[] = array('id' => $orders_status->fields['orders_status_id'],
                                     'text' => $orders_status->fields['orders_status_name'] . ' [' . $orders_status->fields['orders_status_id'] . ']');
          $orders_status_array[$orders_status->fields['orders_status_id']] = $orders_status->fields['orders_status_name'];
          $orders_status->MoveNext();
        }
      
        $action = (isset($_GET['action']) ? $_GET['action'] : '');
        $order_exists = false;
        if (isset($_GET['oID']) && trim($_GET['oID']) == '') unset($_GET['oID']);
        if ($action == 'edit' && !isset($_GET['oID'])) $action = '';
      
        $oID = FALSE;
        if (isset($_POST['oID'])) {
          $oID = zen_db_prepare_input(trim($_POST['oID']));
        } elseif (isset($_GET['oID'])) {
          $oID = zen_db_prepare_input(trim($_GET['oID']));
        }
        if ($oID) {
          $orders = $db->Execute("select orders_id from " . TABLE_ORDERS . "
                                    where orders_id = '" . (int)$oID . "'");
          $order_exists = true;
          if ($orders->RecordCount() <= 0) {
            $order_exists = false;
            if ($action != '') $messageStack->add_session(ERROR_ORDER_DOES_NOT_EXIST . ' ' . $oID, 'error');
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')), 'NONSSL'));
          }
        }
      
        if (zen_not_null($action) && $order_exists == true) {
          switch ($action) {
            case 'edit':
            // reset single download to on
              if ($_GET['download_reset_on'] > 0) {
                // adjust download_maxdays based on current date
                $check_status = $db->Execute("select customers_name, customers_email_address, orders_status,
                                            date_purchased from " . TABLE_ORDERS . "
                                            where orders_id = '" . $_GET['oID'] . "'");
      
                // check for existing product attribute download days and max
                $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'] . "'";
                $chk_products_download = $db->Execute($chk_products_download_query);
      
                $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
                from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                WHERE pa.products_attributes_id = pad.products_attributes_id
                and pad.products_attributes_filename = '" . $db->prepare_input($chk_products_download->fields['orders_products_filename']) . "'
                and pa.products_id = '" . (int)$chk_products_download->fields['products_prid'] . "'";
      
                $chk_products_download_time = $db->Execute($chk_products_download_time_query);
      
                if ($chk_products_download_time->EOF) {
                  $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);
                  $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'] . "'";
                } else {
                  $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']);
                  $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'] . "'";
                }
      
                $db->Execute($update_downloads_query);
                unset($_GET['download_reset_on']);
      
                $messageStack->add_session(SUCCESS_ORDER_UPDATED_DOWNLOAD_ON, 'success');
                zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              }
            // reset single download to off
              if ($_GET['download_reset_off'] > 0) {
                // adjust download_maxdays based on current date
                // *** fix: adjust count not maxdays to cancel download
      //          $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'] . "'";
                $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'] . "'";
                $db->Execute($update_downloads_query);
                unset($_GET['download_reset_off']);
      
                $messageStack->add_session(SUCCESS_ORDER_UPDATED_DOWNLOAD_OFF, 'success');
                zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              }
            break;
            case 'update_order':
              // demo active test
              if (zen_admin_demo()) {
                $_GET['action']= '';
                $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
                zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              }
              $oID = zen_db_prepare_input($_GET['oID']);
              $comments = zen_db_prepare_input($_POST['comments']);
              $status = (int)zen_db_prepare_input($_POST['status']);
              if ($status < 1) break;
      
      //-bof-c-snap_affiliates-v2.5.0
      /* ----- Processing now handled by separate function -----
              $order_updated = false;
              $check_status = $db->Execute("select customers_name, customers_email_address, orders_status,
                                            date_purchased from " . TABLE_ORDERS . "
                                            where orders_id = '" . (int)$oID . "'");
      
              if ( ($check_status->fields['orders_status'] != $status) || zen_not_null($comments)) {
                $db->Execute("update " . TABLE_ORDERS . "
                              set orders_status = '" . zen_db_input($status) . "', last_modified = now()
                              where orders_id = '" . (int)$oID . "'");
      
                $customer_notified = '0';
                if (isset($_POST['notify']) && ($_POST['notify'] == '1')) {
      
                  $notify_comments = '';
                  if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on') && zen_not_null($comments)) {
                    $notify_comments = EMAIL_TEXT_COMMENTS_UPDATE . $comments . "\n\n";
                  }
                  //send emails
                  $message =
                  EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n\n" .
                  EMAIL_TEXT_INVOICE_URL . ' ' . zen_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n\n" .
                  EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($check_status->fields['date_purchased']) . "\n\n" .
                  $notify_comments .
                  EMAIL_TEXT_STATUS_UPDATED . sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ) .
                  EMAIL_TEXT_STATUS_PLEASE_REPLY;
      
                  $html_msg['EMAIL_CUSTOMERS_NAME']    = $check_status->fields['customers_name'];
                  $html_msg['EMAIL_TEXT_ORDER_NUMBER'] = EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID;
                  $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>';
                  $html_msg['EMAIL_TEXT_DATE_ORDERED'] = EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($check_status->fields['date_purchased']);
                  $html_msg['EMAIL_TEXT_STATUS_COMMENTS'] = nl2br($notify_comments);
                  $html_msg['EMAIL_TEXT_STATUS_UPDATED'] = str_replace('\n','', EMAIL_TEXT_STATUS_UPDATED);
                  $html_msg['EMAIL_TEXT_STATUS_LABEL'] = str_replace('\n','', sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ));
                  $html_msg['EMAIL_TEXT_NEW_STATUS'] = $orders_status_array[$status];
                  $html_msg['EMAIL_TEXT_STATUS_PLEASE_REPLY'] = str_replace('\n','', EMAIL_TEXT_STATUS_PLEASE_REPLY);
                  $html_msg['EMAIL_PAYPAL_TRANSID'] = '';
      
                  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');
                  $customer_notified = '1';
      
                  // PayPal Trans ID, if any
                  $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 ";
                  $sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
                  $result = $db->Execute($sql);
                  if ($result->RecordCount() > 0) {
                    $message .= "\n\n" . ' PayPal Trans ID: ' . $result->fields['txn_id'];
                    $html_msg['EMAIL_PAYPAL_TRANSID'] = $result->fields['txn_id'];
                  }
      
                  //send extra emails
                  if (SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_STATUS == '1' and SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO != '') {
                    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');
                  }
                } elseif (isset($_POST['notify']) && ($_POST['notify'] == '-1')) {
                  // hide comment
                  $customer_notified = '-1';
                }
                
                $db->Execute("insert into " . TABLE_ORDERS_STATUS_HISTORY . "
                            (orders_id, orders_status_id, date_added, customer_notified, comments) 
                            values ('" . (int)$oID . "',
                            '" . zen_db_input($status) . "',
                            now(),
                            '" . zen_db_input($customer_notified) . "',
                            '" . zen_db_input($comments) . "')");
      
                $order_updated = true;
                
              }
      */
              $check_status = $db->Execute("SELECT orders_status, date_purchased FROM " . TABLE_ORDERS . " WHERE orders_id = '" . (int)$oID . "'");
              $customer_notified = (isset($_POST['notify']) && ($_POST['notify'] == 1 || $_POST['notify'] == -1)) ? $_POST['notify'] : 0;
              $osh_record_added = zen_update_orders_history($oID, $comments, null, $status, $customer_notified, (isset($_POST['notify_comments']) && $_POST['notify_comments'] == 'on'));
              $order_updated = ($osh_record_added == -1) ? false : true;
      
      //-eof-c-snap_affiliates-v2.5.0
      
              // trigger any appropriate updates which should be sent back to the payment gateway:
              $order = new order((int)$oID);
              if ($order->info['payment_module_code']) {
                if (file_exists(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php')) {
                  require_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
                  require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
                  $module = new $order->info['payment_module_code'];
                  if (method_exists($module, '_doStatusUpdate')) {
                    $response = $module->_doStatusUpdate($oID, $status, $comments, $customer_notified, $check_status->fields['orders_status']);
                  }
                }
              }
      
              if ($order_updated == true) {
                if ($status == DOWNLOADS_ORDERS_STATUS_UPDATED_VALUE) {
      
                  // adjust download_maxdays based on current date
                  $chk_downloads_query = "SELECT opd.*, op.products_id from " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd, " . TABLE_ORDERS_PRODUCTS . " op
                                          WHERE op.orders_id='" . (int)$oID . "'
                                          and opd.orders_products_id = op.orders_products_id";
                  $chk_downloads = $db->Execute($chk_downloads_query);
      
                  while (!$chk_downloads->EOF) {
                    $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
                                                          from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                                                          WHERE pa.products_attributes_id = pad.products_attributes_id
                                                          and pad.products_attributes_filename = '" . $db->prepare_input($chk_downloads->fields['orders_products_filename']) . "'
                                                          and pa.products_id = '" . $chk_downloads->fields['products_id'] . "'";
      
                    $chk_products_download_time = $db->Execute($chk_products_download_time_query);
      
                    if ($chk_products_download_time->EOF) {
                      $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);
                      $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'] . "'";
                    } else {
                      $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']);
                      $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'] . "'";
                    }
      
                    $db->Execute($update_downloads_query);
      
                    $chk_downloads->MoveNext();
                  }
                }
                $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
                zen_record_admin_activity('Order ' . $oID . ' updated.', 'info');
              } else {
                $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');
              }
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
            case 'deleteconfirm':
              // demo active test
              if (zen_admin_demo()) {
                $_GET['action']= '';
                $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
                zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')), 'NONSSL'));
              }
              $oID = zen_db_prepare_input($_POST['oID']);
      
              zen_remove_order($oID, $_POST['restock']);
      
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')), 'NONSSL'));
              break;
            case 'delete_cvv':
              $delete_cvv = $db->Execute("update " . TABLE_ORDERS . " set cc_cvv = '" . TEXT_DELETE_CVV_REPLACEMENT . "' where orders_id = '" . (int)$_GET['oID'] . "'");
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
            case 'mask_cc':
              $result  = $db->Execute("select cc_number from " . TABLE_ORDERS . " where orders_id = '" . (int)$_GET['oID'] . "'");
              $old_num = $result->fields['cc_number'];
              $new_num = substr($old_num, 0, 4) . str_repeat('*', (strlen($old_num) - 8)) . substr($old_num, -4);
              $mask_cc = $db->Execute("update " . TABLE_ORDERS . " set cc_number = '" . $new_num . "' where orders_id = '" . (int)$_GET['oID'] . "'");
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
      
            case 'doRefund':
              $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_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
                  require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
                  $module = new $order->info['payment_module_code'];
                  if (method_exists($module, '_doRefund')) {
                    $module->_doRefund($oID);
                  }
                }
              }
              zen_record_admin_activity('Order ' . $oID . ' refund processed. See order comments for details.', 'info');
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
            case 'doAuth':
              $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_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
                  require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
                  $module = new $order->info['payment_module_code'];
                  if (method_exists($module, '_doAuth')) {
                    $module->_doAuth($oID, $order->info['total'], $order->info['currency']);
                  }
                }
              }
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
            case 'doCapture':
              $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_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
                  require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
                  $module = new $order->info['payment_module_code'];
                  if (method_exists($module, '_doCapt')) {
                    $module->_doCapt($oID, 'Complete', $order->info['total'], $order->info['currency']);
                  }
                }
              }
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
            case 'doVoid':
              $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_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
                  require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
                  $module = new $order->info['payment_module_code'];
                  if (method_exists($module, '_doVoid')) {
                    $module->_doVoid($oID);
                  }
                }
              }
              zen_record_admin_activity('Order ' . $oID . ' void processed. See order comments for details.', 'info');
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
          }
        }
      ?>
      <!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/stylesheet.css">
      <link rel="stylesheet" type="text/css" media="print" href="includes/stylesheet_print.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 == '') { ?>
      <!-- search -->
        <tr>
          <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
            <tr>
              <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
               <tr><?php echo zen_draw_form('search', FILENAME_ORDERS, '', 'get', '', true); ?>
                  <td width="65%" class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
                  <td colspan="2" class="smallText" align="right">
      <?php
      // show reset search
        if ((isset($_GET['search']) && zen_not_null($_GET['search'])) or $_GET['cID'] !='') {
          echo '<a href="' . zen_href_link(FILENAME_ORDERS, '', 'NONSSL') . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a><br />';
        }
      ?>
      <?php
        echo HEADING_TITLE_SEARCH_DETAIL . ' ' . zen_draw_input_field('search') . zen_hide_session_id();
        if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
          $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
          echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER . $keywords;
        }
      ?>
                  </td>
                </form>
      
      
               <?php echo zen_draw_form('search_orders_products', FILENAME_ORDERS, '', 'get', '', true); ?>
                  <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
                  <td colspan="2" class="smallText" align="right">
      <?php
      // show reset search orders_products
        if ((isset($_GET['search_orders_products']) && zen_not_null($_GET['search_orders_products'])) or $_GET['cID'] !='') {
          echo '<a href="' . zen_href_link(FILENAME_ORDERS, '', 'NONSSL') . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a><br />';
        }
      ?>
      <?php
        echo HEADING_TITLE_SEARCH_DETAIL_ORDERS_PRODUCTS . ' ' . zen_draw_input_field('search_orders_products') . zen_hide_session_id();
        if (isset($_GET['search_orders_products']) && zen_not_null($_GET['search_orders_products'])) {
          $keywords_orders_products = zen_db_input(zen_db_prepare_input($_GET['search_orders_products']));
          echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER_ORDERS_PRODUCTS . zen_db_prepare_input($keywords_orders_products);
        }
      ?>
                  </td>
                </form>
      
                </tr>
              </table></td>
            </tr>
      <!-- search -->
      <?php } ?>
      
      
      <?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'];
      //        echo $module->admin_notification($oID);
            }
          }
      ?>
            <tr>
              <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
                <tr>
                  <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
                  <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
                  <td class="pageHeading" align="right"><?php echo '<a href="javascript:history.back()">' . zen_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
                <tr>
                  <td colspan="3"><?php echo zen_draw_separator(); ?></td>
                </tr>
                <tr>
                  <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                    <tr>
                      <td class="main" valign="top"><strong><?php echo ENTRY_CUSTOMER; ?></strong></td>
                      <td class="main"><?php echo zen_address_format($order->customer['format_id'], $order->customer, 1, '', '<br />'); ?></td>
                    </tr>
                    <tr>
                      <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
                    </tr>
                    <tr>
                      <td class="main"><strong><?php echo ENTRY_TELEPHONE_NUMBER; ?></strong></td>
                      <td class="main"><?php echo $order->customer['telephone']; ?></td>
                    </tr>
                    <tr>
                      <td class="main"><strong><?php echo ENTRY_EMAIL_ADDRESS; ?></strong></td>
                      <td class="main"><?php echo '<a href="mailto:' . $order->customer['email_address'] . '">' . $order->customer['email_address'] . '</a>'; ?></td>
                    </tr>
                    <tr>
                      <td class="main"><strong><?php echo TEXT_INFO_IP_ADDRESS; ?></strong></td>
                      <td class="main"><?php echo $order->info['ip_address']; ?></td>
                    </tr>
                  </table></td>
                  <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                    <tr>
                      <td class="main" valign="top"><strong><?php echo ENTRY_SHIPPING_ADDRESS; ?></strong></td>
                      <td class="main"><?php echo zen_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br />'); ?></td>
                    </tr>
                  </table></td>
                  <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                    <tr>
                      <td class="main" valign="top"><strong><?php echo ENTRY_BILLING_ADDRESS; ?></strong></td>
                      <td class="main"><?php echo zen_address_format($order->billing['format_id'], $order->billing, 1, '', '<br />'); ?></td>
                    </tr>
                  </table></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
            </tr>
            <tr>
              <td class="main"><strong><?php echo /*-bof-a-snap_affiliates*/ snap_affiliates_image($oID) . /*-eof-a-snap_affiliates */ ENTRY_ORDER_ID . $oID; ?></strong></td>
            </tr>
            <tr>
           <td><table border="0" cellspacing="0" cellpadding="2">
              <tr>
                 <td class="main"><strong><?php echo ENTRY_DATE_PURCHASED; ?></strong></td>
                 <td class="main"><?php echo zen_date_long($order->info['date_purchased']); ?></td>
              </tr>
              <tr>
                 <td class="main"><strong><?php echo ENTRY_PAYMENT_METHOD; ?></strong></td>
                 <td class="main"><?php echo $order->info['payment_method']; ?></td>
              </tr>
      <?php
          if (zen_not_null($order->info['cc_type']) || zen_not_null($order->info['cc_owner']) || zen_not_null($order->info['cc_number'])) {
      ?>
                <tr>
                  <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
                </tr>
                <tr>
                  <td class="main"><?php echo ENTRY_CREDIT_CARD_TYPE; ?></td>
                  <td class="main"><?php echo $order->info['cc_type']; ?></td>
                </tr>
                <tr>
                  <td class="main"><?php echo ENTRY_CREDIT_CARD_OWNER; ?></td>
                  <td class="main"><?php echo $order->info['cc_owner']; ?></td>
                </tr>
                <tr>
                  <td class="main"><?php echo ENTRY_CREDIT_CARD_NUMBER; ?></td>
                  <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>
                </tr>
      <?php if (zen_not_null($order->info['cc_cvv'])) { ?>
                <tr>
                  <td class="main"><?php echo ENTRY_CREDIT_CARD_CVV; ?></td>
                  <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>
                </tr>
      <?php } ?>
                <tr>
                  <td class="main"><?php echo ENTRY_CREDIT_CARD_EXPIRES; ?></td>
                  <td class="main"><?php echo $order->info['cc_expires']; ?></td>
                </tr>
      <?php
          }
      
      ?>
              </table></td>
            </tr>
      <?php
            if (is_object($module) && method_exists($module, 'admin_notification')) {
      ?>
            <tr>
              <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
            </tr>
            <tr>
              <?php echo $module->admin_notification($oID); ?>
            </tr>
            <tr>
              <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
            </tr>
      <?php
      }
      ?>
            <tr>
              <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
                <tr class="dataTableHeadingRow">
                  <td class="dataTableHeadingContent" colspan="2"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TAX; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRICE_EXCLUDING_TAX; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRICE_INCLUDING_TAX; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_EXCLUDING_TAX; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_INCLUDING_TAX; ?></td>
                </tr>
      <?php
          for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
            if (DISPLAY_PRICE_WITH_TAX_ADMIN == 'true')
            {
              $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']);
            } else
            {
              $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']);
            }
            echo '          <tr class="dataTableRow">' . "\n" .
                 '            <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . '&nbsp;x</td>' . "\n" .
                 '            <td class="dataTableContent" valign="top">' . $order->products[$i]['name'];
      
            if (isset($order->products[$i]['attributes']) && (sizeof($order->products[$i]['attributes']) > 0)) {
              for ($j = 0, $k = sizeof($order->products[$i]['attributes']); $j < $k; $j++) {
                echo '<br /><nobr><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($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']) . ')';
                if ($order->products[$i]['attributes'][$j]['product_attribute_is_free'] == '1' and $order->products[$i]['product_is_free'] == '1') echo TEXT_INFO_ATTRIBUTE_FREE;
                echo '</i></small></nobr>';
              }
            }
      
            echo '            </td>' . "\n" .
                 '            <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n" .
                 '            <td class="dataTableContent" align="right" valign="top">' . zen_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n" .
                 '            <td class="dataTableContent" align="right" valign="top"><strong>' .
                                $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) .
                                ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format($order->products[$i]['onetime_charges'], true, $order->info['currency'], $order->info['currency_value']) : '') .
                              '</strong></td>' . "\n" .
                 '            <td class="dataTableContent" align="right" valign="top"><strong>' .
                                $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) .
                                ($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']) : '') .
                              '</strong></td>' . "\n" .
                 '            <td class="dataTableContent" align="right" valign="top"><strong>' .
                                $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']) .
                                ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format($order->products[$i]['onetime_charges'], true, $order->info['currency'], $order->info['currency_value']) : '') .
                              '</strong></td>' . "\n" .
                 '            <td class="dataTableContent" align="right" valign="top"><strong>' .
                                $priceIncTax .
                                ($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']) : '') .
                              '</strong></td>' . "\n";
            echo '          </tr>' . "\n";
          }
      ?>
                <tr>
                  <td align="right" colspan="8"><table border="0" cellspacing="0" cellpadding="2">
      <?php
          for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
            echo '              <tr>' . "\n" .
                 '                <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Text">' . $order->totals[$i]['title'] . '</td>' . "\n" .
                 '                <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount">' . $currencies->format($order->totals[$i]['value'], false) . '</td>' . "\n" .
                 '              </tr>' . "\n";
          }
      ?>
                  </table></td>
                </tr>
              </table></td>
            </tr>
      
      <?php
        // show downloads
        require(DIR_WS_MODULES . 'orders_download.php');
      ?>
      
            <tr>
              <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
            </tr>
            <tr>
              <td class="main"><table border="1" cellspacing="0" cellpadding="5">
                <tr>
                  <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_DATE_ADDED; ?></strong></td>
                  <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_CUSTOMER_NOTIFIED; ?></strong></td>
                  <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_STATUS; ?></strong></td>
                  <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_COMMENTS; ?></strong></td>
      <?php //-bof-a-snap_affiliates-v2.5.0 ?>
                  <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_UPDATED_BY; ?></strong></td>
      <?php //-eof-a-snap_affiliates-v2.5.0 ?>
                </tr>
      <?php
          $orders_history = $db->Execute("select orders_status_id, date_added, customer_notified, comments" /*-bof-a-snap_affiliates-v2.5.0*/ . ', updated_by ' /*-eof-a-snap_affiliates-v2.5.0*/ . "
                                          from " . TABLE_ORDERS_STATUS_HISTORY . "
                                          where orders_id = '" . zen_db_input($oID) . "'
                                          order by date_added");
      
          if ($orders_history->RecordCount() > 0) {
            while (!$orders_history->EOF) {
              echo '          <tr>' . "\n" .
                   '            <td class="smallText" align="center">' . zen_datetime_short($orders_history->fields['date_added']) . '</td>' . "\n" .
                   '            <td class="smallText" align="center">';
              if ($orders_history->fields['customer_notified'] == '1') {
                echo zen_image(DIR_WS_ICONS . 'tick.gif', TEXT_YES) . "</td>\n";
              } else if ($orders_history->fields['customer_notified'] == '-1') {
                echo zen_image(DIR_WS_ICONS . 'locked.gif', TEXT_HIDDEN) . "</td>\n";
              } else {
                echo zen_image(DIR_WS_ICONS . 'unlocked.gif', TEXT_VISIBLE) . "</td>\n";
              }
              echo '            <td class="smallText">' . $orders_status_array[$orders_history->fields['orders_status_id']] . '</td>' . "\n";
              echo '            <td class="smallText">' . nl2br(zen_db_output($orders_history->fields['comments'])) . '&nbsp;</td>' . "\n" .
      //-bof-a-snap_affiliates-v2.5.0
                   '            <td class="smallText">' . (zen_not_null($orders_history->fields['updated_by']) ?  $orders_history->fields['updated_by'] : '&nbsp;') . '</td>' . "\n" .
      //-eof-a-snap_affiliates-v2.5.0
                   '          </tr>' . "\n";
              $orders_history->MoveNext();
            }
          } else {
              echo '          <tr>' . "\n" .
                   '            <td class="smallText" colspan="5">' . TEXT_NO_ORDER_HISTORY . '</td>' . "\n" .
                   '          </tr>' . "\n";
          }
      ?>
              </table></td>
            </tr>
            <tr>
              <td class="main noprint"><br /><strong><?php echo TABLE_HEADING_COMMENTS; ?></strong></td>
            </tr>
            <tr>
              <td class="noprint"><?php echo zen_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
            </tr>
            <tr><?php echo zen_draw_form('status', FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=update_order', 'post', '', true); ?>
              <td class="main noprint"><?php echo zen_draw_textarea_field('comments', 'soft', '60', '5'); ?></td>
            </tr>
            <tr>
              <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
            </tr>
            <tr>
              <td><table border="0" cellspacing="0" cellpadding="2" class="noprint">
                <tr>
                  <td><table border="0" cellspacing="0" cellpadding="2">
                    <tr>
                      <td class="main"><strong><?php echo ENTRY_STATUS; ?></strong> <?php echo zen_draw_pull_down_menu('status', $orders_statuses, $order->info['orders_status']); ?></td>
                    </tr>
                    <tr>
                      <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>
                      <td class="main"><strong><?php echo ENTRY_NOTIFY_COMMENTS; ?></strong> <?php echo zen_draw_checkbox_field('notify_comments', '', true); ?></td>
                    </tr>
                    <tr><td><br /></td></tr>
                  </table></td>
                  <td valign="top"><?php echo zen_image_submit('button_update.gif', IMAGE_UPDATE); ?></td>
                </tr>
              </table></td>
            </form></tr>
            <tr>
              <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>
            </tr>
      <?php
      // check if order has open gv
              $gv_check = $db->Execute("select order_id, unique_id
                                        from " . TABLE_COUPON_GV_QUEUE ."
                                        where order_id = '" . $_GET['oID'] . "' and release_flag='N' limit 1");
              if ($gv_check->RecordCount() > 0) {
                $goto_gv = '<a href="' . zen_href_link(FILENAME_GV_QUEUE, 'order=' . $_GET['oID']) . '">' . zen_image_button('button_gift_queue.gif',IMAGE_GIFT_QUEUE) . '</a>';
                echo '      <tr><td align="right"><table width="225"><tr>';
                echo '        <td align="center">';
                echo $goto_gv . '&nbsp;&nbsp;';
                echo '        </td>';
                echo '      </tr></table></td></tr>';
              }
      ?>
      <?php
        } else {
      ?>
            <tr>
              <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
                <tr>
                  <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
                  <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
                  <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0">
                    <tr><?php echo zen_draw_form('orders', FILENAME_ORDERS, '', 'get', '', true); ?>
                      <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>
                    </form></tr>
                    <tr><?php echo zen_draw_form('status', FILENAME_ORDERS, '', 'get', '', true); ?>
                      <td class="smallText" align="right">
                        <?php
                          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();"');
                          echo zen_hide_session_id();
                        ?>
                      </td>
                    </form></tr>
                  </table></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
                <tr>
                  <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 /*-bof-a-snap_affiliates*/ . snap_affiliates_image() /*-eof-a-snap_affiliates*/; ?>
                </td>
                <tr>
                  <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;
                    case "firstname":
                    $disp_order = "c.customers_firstname";
                    break;
                    case "firstname-desc":
                    $disp_order = "c.customers_firstname DESC";
                    break;
                    case "lastname":
                    $disp_order = "c.customers_lastname, c.customers_firstname";
                    break;
                    case "lastname-desc":
                    $disp_order = "c.customers_lastname DESC, c.customers_firstname";
                    break;
                    case "company":
                    $disp_order = "a.entry_company";
                    break;
                    case "company-desc":
                    $disp_order = "a.entry_company DESC";
                    break;
                    default:
                    $disp_order = "c.customers_id DESC";
                }
      ?>
                      <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_ORDERS_ID; ?></td>
                      <td class="dataTableHeadingContent" align="left" width="50"><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></td>
                      <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMERS; ?></td>
                      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ORDER_TOTAL; ?></td>
                      <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_DATE_PURCHASED; ?></td>
                      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td>
                      <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_CUSTOMER_COMMENTS; ?></td>
                      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</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);
            }
      
            if (isset($oInfo) && is_object($oInfo) && ($orders->fields['orders_id'] == $oInfo->orders_id)) {
              echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=edit', 'NONSSL') . '\'">' . "\n";
            } else {
              echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID')) . 'oID=' . $orders->fields['orders_id'], 'NONSSL') . '\'">' . "\n";
            }
      
            $show_difference = '';
            if (($orders->fields['delivery_name'] != $orders->fields['billing_name'] and $orders->fields['delivery_name'] != '')) {
              $show_difference = zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', TEXT_BILLING_SHIPPING_MISMATCH, 10, 10) . '&nbsp;';
            }
            if (($orders->fields['delivery_street_address'] != $orders->fields['billing_street_address'] and $orders->fields['delivery_street_address'] != '')) {
              $show_difference = zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', TEXT_BILLING_SHIPPING_MISMATCH, 10, 10) . '&nbsp;';
            }
            $show_payment_type = $orders->fields['payment_module_code'] . '<br />' . $orders->fields['shipping_module_code'];
      ?>
                      <td class="dataTableContent" align="right"><?php echo /*-bof-a-snap_affiliates*/ snap_affiliates_image($orders->fields['orders_id']) . /*-eof-a-snap_affiliates*/ $show_difference . $orders->fields['orders_id']; ?></td>
                      <td class="dataTableContent" align="left" width="50"><?php echo $show_payment_type; ?></td>
                      <td class="dataTableContent"><?php echo '<a href="' . zen_href_link(FILENAME_CUSTOMERS, 'cID=' . $orders->fields['customers_id'], 'NONSSL') . '">' . zen_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW . ' ' . TABLE_HEADING_CUSTOMERS) . '</a>&nbsp;' . $orders->fields['customers_name'] . ($orders->fields['customers_company'] != '' ? '<br />' . $orders->fields['customers_company'] : ''); ?></td>
                      <td class="dataTableContent" align="right"><?php echo strip_tags($orders->fields['order_total']); ?></td>
                      <td class="dataTableContent" align="center"><?php echo zen_datetime_short($orders->fields['date_purchased']); ?></td>
                      <td class="dataTableContent" align="right"><?php echo $orders->fields['orders_status_name']; ?></td>
                      <td class="dataTableContent" align="center"><?php echo (zen_get_orders_comments($orders->fields['orders_id']) == '' ? '' : zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', TEXT_COMMENTS_YES, 16, 16)); ?></td>
      
                      <td class="dataTableContent" align="right"><?php echo '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $orders->fields['orders_id'] . '&action=edit', 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_edit.gif', ICON_EDIT) . '</a>'; ?><?php if (isset($oInfo) && is_object($oInfo) && ($orders->fields['orders_id'] == $oInfo->orders_id)) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID')) . 'oID=' . $orders->fields['orders_id'], 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</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>
      <?php
        if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
      ?>
                        <tr>
                          <td class="smallText" align="right" colspan="2">
                            <?php
                              echo '<a href="' . zen_href_link(FILENAME_ORDERS, '', 'NONSSL') . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a>';
                              if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
                                $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
                                echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER . $keywords;
                              }
                            ?>
                          </td>
                        </tr>
      <?php
        }
      ?>
                      </table></td>
                    </tr>
                  </table></td>
      <?php
        $heading = array();
        $contents = array();
      
        switch ($action) {
          case 'delete':
            $heading[] = array('text' => '<strong>' . TEXT_INFO_HEADING_DELETE_ORDER . '</strong>');
      
            $contents = array('form' => zen_draw_form('orders', FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . '&action=deleteconfirm', 'post', '', true) . zen_draw_hidden_field('oID', $oInfo->orders_id));
      //      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO . '<br /><br /><strong>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</strong>');
            $contents[] = array('text' => TEXT_INFO_DELETE_INTRO . '<br /><br /><strong>' . ENTRY_ORDER_ID . $oInfo->orders_id . '<br />' . $oInfo->order_total . '<br />' . $oInfo->customers_name . ($oInfo->customers_company != '' ? '<br />' . $oInfo->customers_company : '') . '</strong>');
            $contents[] = array('text' => '<br />' . zen_draw_checkbox_field('restock') . ' ' . TEXT_INFO_RESTOCK_PRODUCT_QUANTITY);
            $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id, 'NONSSL') . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
            break;
          default:
            if (isset($oInfo) && is_object($oInfo)) {
              $heading[] = array('text' => '<strong>[' . $oInfo->orders_id . ']&nbsp;&nbsp;' . zen_datetime_short($oInfo->date_purchased) . '</strong>');
      
              $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=edit', 'NONSSL') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=delete', 'NONSSL') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
              $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $oInfo->orders_id) . '" TARGET="_blank">' . zen_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . zen_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $oInfo->orders_id) . '" TARGET="_blank">' . zen_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a>');
              $contents[] = array('text' => '<br />' . TEXT_DATE_ORDER_CREATED . ' ' . zen_date_short($oInfo->date_purchased));
              $contents[] = array('text' => '<br />' . $oInfo->customers_email_address);
              $contents[] = array('text' => TEXT_INFO_IP_ADDRESS . ' ' . $oInfo->ip_address);
              if (zen_not_null($oInfo->last_modified)) $contents[] = array('text' => TEXT_DATE_ORDER_LAST_MODIFIED . ' ' . zen_date_short($oInfo->last_modified));
              $contents[] = array('text' => '<br />' . TEXT_INFO_PAYMENT_METHOD . ' '  . $oInfo->payment_method);
              $contents[] = array('text' => '<br />' . ENTRY_SHIPPING . ' '  . $oInfo->shipping_method);
      
      // check if order has open gv
              $gv_check = $db->Execute("select order_id, unique_id
                                        from " . TABLE_COUPON_GV_QUEUE ."
                                        where order_id = '" . $oInfo->orders_id . "' and release_flag='N' limit 1");
              if ($gv_check->RecordCount() > 0) {
                $goto_gv = '<a href="' . zen_href_link(FILENAME_GV_QUEUE, 'order=' . $oInfo->orders_id) . '">' . zen_image_button('button_gift_queue.gif',IMAGE_GIFT_QUEUE) . '</a>';
                $contents[] = array('text' => '<br />' . zen_image(DIR_WS_IMAGES . 'pixel_black.gif','','100%','3'));
                $contents[] = array('align' => 'center', 'text' => $goto_gv);
              }
            }
      
      // indicate if comments exist
            $orders_history_query = $db->Execute("select orders_status_id, date_added, customer_notified, comments from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . $oInfo->orders_id . "' and comments !='" . "'" );
            if ($orders_history_query->RecordCount() > 0) {
              $contents[] = array('align' => 'left', 'text' => '<br />' . TABLE_HEADING_COMMENTS);
            }
      
            $contents[] = array('text' => '<br />' . zen_image(DIR_WS_IMAGES . 'pixel_black.gif','','100%','3'));
            $order = new order($oInfo->orders_id);
            $contents[] = array('text' => 'Products Ordered: ' . sizeof($order->products) );
            for ($i=0; $i<sizeof($order->products); $i++) {
              $contents[] = array('text' => $order->products[$i]['qty'] . '&nbsp;x&nbsp;' . $order->products[$i]['name']);
      
              if (sizeof($order->products[$i]['attributes']) > 0) {
                for ($j=0; $j<sizeof($order->products[$i]['attributes']); $j++) {
                  $contents[] = array('text' => '&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value'])) . '</i></nobr>' );
                }
              }
              if ($i > MAX_DISPLAY_RESULTS_ORDERS_DETAILS_LISTING and MAX_DISPLAY_RESULTS_ORDERS_DETAILS_LISTING != 0) {
                $contents[] = array('align' => 'left', 'text' => TEXT_MORE);
                break;
              }
            }
      
            if (sizeof($order->products) > 0) {
              $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=edit', 'NONSSL') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a>');
            }
            break;
        }
      
        if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
          echo '            <td width="25%" valign="top">' . "\n";
      
          $box = new box;
          echo $box->infoBox($heading, $contents);
      
          echo '            </td>' . "\n";
        }
      ?>
                </tr>
              </table></td>
            </tr>
      <?php
        }
      ?>
          </table></td>
      <!-- body_text_eof //-->
        </tr>
      </table>
      <!-- body_eof //-->
      
      <!-- footer //-->
      <div class="footer-area">
      <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
      </div>
      <!-- footer_eof //-->
      <br />
      </body>
      </html>
      <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

      Und hier meine orders.php:

      Code:
      <?php
      /**
       * @package admin
       * @copyright Copyright 2003-2011 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 $Id: orders.php for COWOA 3.0 ZC150 2011-11-28 11:12:51Z webchills $
       */
      
        require('includes/application_top.php');
      
        require(DIR_WS_CLASSES . 'currencies.php');
        $currencies = new currencies();
      
        if (isset($_GET['oID'])) $_GET['oID'] = (int)$_GET['oID'];
        if (isset($_GET['download_reset_on'])) $_GET['download_reset_on'] = (int)$_GET['download_reset_on'];
        if (isset($_GET['download_reset_off'])) $_GET['download_reset_off'] = (int)$_GET['download_reset_off'];
      
        include(DIR_WS_CLASSES . 'order.php');
      
        // prepare order-status pulldown list
        $orders_statuses = array();
        $orders_status_array = array();
        $orders_status = $db->Execute("select orders_status_id, orders_status_name
                                       from " . TABLE_ORDERS_STATUS . "
                                       where language_id = '" . (int)$_SESSION['languages_id'] . "' order by orders_status_id");
        while (!$orders_status->EOF) {
          $orders_statuses[] = array('id' => $orders_status->fields['orders_status_id'],
                                     'text' => $orders_status->fields['orders_status_name'] . ' [' . $orders_status->fields['orders_status_id'] . ']');
          $orders_status_array[$orders_status->fields['orders_status_id']] = $orders_status->fields['orders_status_name'];
          $orders_status->MoveNext();
        }
      
        $action = (isset($_GET['action']) ? $_GET['action'] : '');
        $order_exists = false;
        if (isset($_GET['oID']) && trim($_GET['oID']) == '') unset($_GET['oID']);
        if ($action == 'edit' && !isset($_GET['oID'])) $action = '';
      
        $oID = FALSE;
        if (isset($_POST['oID'])) {
          $oID = zen_db_prepare_input(trim($_POST['oID']));
        } elseif (isset($_GET['oID'])) {
          $oID = zen_db_prepare_input(trim($_GET['oID']));
        }
        if ($oID) {
          $orders = $db->Execute("select orders_id from " . TABLE_ORDERS . "
                                  where orders_id = '" . (int)$oID . "'");
          $order_exists = true;
          if ($orders->RecordCount() <= 0) {
            $order_exists = false;
            if ($action != '') $messageStack->add_session(ERROR_ORDER_DOES_NOT_EXIST . ' ' . $oID, 'error');
            zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')), 'NONSSL'));
          }
        }
      
        if (zen_not_null($action) && $order_exists == true) {
          switch ($action) {
            case 'edit':
            // reset single download to on
              if ($_GET['download_reset_on'] > 0) {
                // adjust download_maxdays based on current date
                $check_status = $db->Execute("select customers_name, customers_email_address, orders_status,
                                            date_purchased, COWOA_order from " . TABLE_ORDERS . "
                                            where orders_id = '" . $_GET['oID'] . "'");
      
                // check for existing product attribute download days and max
                $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'] . "'";
                $chk_products_download = $db->Execute($chk_products_download_query);
      
                $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
                from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                WHERE pa.products_attributes_id = pad.products_attributes_id
                and pad.products_attributes_filename = '" . $chk_products_download->fields['orders_products_filename'] . "'
                and pa.products_id = '" . (int)$chk_products_download->fields['products_prid'] . "'";
      
                $chk_products_download_time = $db->Execute($chk_products_download_time_query);
      
                if ($chk_products_download_time->EOF) {
                  $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);
                  $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'] . "'";
                } else {
                  $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']);
                  $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'] . "'";
                }
      
                $db->Execute($update_downloads_query);
                unset($_GET['download_reset_on']);
      
                $messageStack->add_session(SUCCESS_ORDER_UPDATED_DOWNLOAD_ON, 'success');
                zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              }
            // reset single download to off
              if ($_GET['download_reset_off'] > 0) {
                // adjust download_maxdays based on current date
                // *** fix: adjust count not maxdays to cancel download
      //          $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'] . "'";
                $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'] . "'";
                $db->Execute($update_downloads_query);
                unset($_GET['download_reset_off']);
      
                $messageStack->add_session(SUCCESS_ORDER_UPDATED_DOWNLOAD_OFF, 'success');
                zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              }
            break;
            case 'update_order':
              // demo active test
              if (zen_admin_demo()) {
                $_GET['action']= '';
                $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
                zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              }
              $oID = zen_db_prepare_input($_GET['oID']);
      // Begin Paket Tracking 2.1
              $track_id1 = str_replace(" ", "", zen_db_prepare_input($_POST['track_id1']));
              $track_id2 = str_replace(" ", "", zen_db_prepare_input($_POST['track_id2']));
              $track_id3 = str_replace(" ", "", zen_db_prepare_input($_POST['track_id3']));
              $track_id4 = str_replace(" ", "", zen_db_prepare_input($_POST['track_id4']));
              $track_id5 = str_replace(" ", "", zen_db_prepare_input($_POST['track_id5']));
      // End Paket Tracking 2.1
              $comments = zen_db_prepare_input($_POST['comments']);
              $status = (int)zen_db_prepare_input($_POST['status']);
              if ($status < 1) break;
      
              $order_updated = false;
              $check_status = $db->Execute("select customers_name, customers_email_address, orders_status,
                                            date_purchased, COWOA_order from " . TABLE_ORDERS . "
                                            where orders_id = '" . (int)$oID . "'");
      
              // BOF rl_incoice3                                       
              $rlStat = explode('|', RL_INVOICE3_SEND_ORDERSTATUS_CHANGE);
              $rl_invoice3_send = in_array($status, $rlStat);
              if ( ($check_status->fields['orders_status'] != $status  && $status==RL_INVOICE3_ORDERSTATUS)  || ($rl_invoice3_send == true)){
                  require_once (DIR_FS_CATALOG . DIR_WS_INCLUDES . 'classes/class.rl_invoice3.php');     
                  require_once ('../' . DIR_WS_LANGUAGES . $_SESSION['language'] . '/extra_definitions/rl_invoice3.php');
                  $paper = rl_invoice3::getDefault(RL_INVOICE3_PAPER, array('format' => 'A4', 'unit' => 'mm', 'orientation' => 'P'));
                  $pdfT = new rl_invoice3($oID, $paper['orientation'], $paper['unit'], $paper['format']);
                  $pdfT->createPdfFile(true);
                  $attach = $pdfT->getPDFAttachments('ALL');
              } else {
                  $attach = null;
              }
              // EOF rl_incoice3
              if ( ($check_status->fields['orders_status'] != $status) || zen_not_null($comments)) {
                $db->Execute("update " . TABLE_ORDERS . "
                              set orders_status = '" . zen_db_input($status) . "', last_modified = now()
                              where orders_id = '" . (int)$oID . "'");
      
                $customer_notified = '0';
                if (isset($_POST['notify']) && ($_POST['notify'] == '1')) {
                $notify_comments = '';
            
      // Begin Paket Tracking 2.1
              if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on')) {
              if (zen_not_null($comments)) {
              
                      $notify_comments = EMAIL_TEXT_COMMENTS_UPDATE . $comments . "\n\n";
                    }
                    if (zen_not_null($track_id1)) { $notify_comments .= "\n" .PT_EMAIL_YOURID ." " . CARRIER_NAME_1 . " Tracking ID " .PT_EMAIL_YOURIDIS ." " . $track_id1 . " \n\n<br />" .PT_EMAIL_LINKINFO ." \n<br />" . CARRIER_LINK_1 . $track_id1 . "\n\n<br />" .PT_EMAIL_24HOURS ."" . "\n\n<br />"; }
                    if (zen_not_null($track_id2)) { $notify_comments .= "\n" .PT_EMAIL_YOURID ." " . CARRIER_NAME_2 . " Tracking ID " .PT_EMAIL_YOURIDIS ." " . $track_id2 . " \n\n<br />" .PT_EMAIL_LINKINFO ." \n<br />" . CARRIER_LINK_2 . $track_id2 . "\n\n<br />" .PT_EMAIL_24HOURS ."" . "\n\n<br />"; }
                    if (zen_not_null($track_id3)) { $notify_comments .= "\n" .PT_EMAIL_YOURID ." " . CARRIER_NAME_3 . " Tracking ID " .PT_EMAIL_YOURIDIS ." " . $track_id3 . " \n\n<br />" .PT_EMAIL_LINKINFO ." \n<br />" . CARRIER_LINK_3 . $track_id3 . "\n\n<br />" .PT_EMAIL_24HOURS ."" . "\n\n<br />"; }
                    if (zen_not_null($track_id4)) { $notify_comments .= "\n" .PT_EMAIL_YOURID ." " . CARRIER_NAME_4 . " Tracking ID " .PT_EMAIL_YOURIDIS ." " . $track_id4 . " \n\n<br />" .PT_EMAIL_LINKINFO ." \n<br />" . CARRIER_LINK_4 . $track_id4 . "\n\n<br />" .PT_EMAIL_24HOURS ."" . "\n\n<br />"; }
                    if (zen_not_null($track_id5)) { $notify_comments .= "\n" .PT_EMAIL_YOURID ." " . CARRIER_NAME_5 . " Tracking ID " .PT_EMAIL_YOURIDIS ." " . $track_id5 . " \n\n<br />" .PT_EMAIL_LINKINFO ." \n<br />" . CARRIER_LINK_5 . $track_id5 . "\n\n<br />" .PT_EMAIL_24HOURS ."" . "\n\n<br />"; }
      // End Paket Tracking 2.1
                }
                //send emails
      // BOF COWOA SEND ORDER_STATUS EMAIL
      if (COWOA_ORDER_STATUS == 'true') {
          if ($check_status->fields['COWOA_order'] == 1)  {
        
                  $message =
                  EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n\n" .
                  EMAIL_TEXT_COWOA_URL . ' ' . zen_catalog_href_link(FILENAME_ORDER_STATUS, 'order_id=' . $oID, 'SSL') . "\n\n" .
                  EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($check_status->fields['date_purchased']) . "\n\n" .
            strip_tags($notify_comments) .
            EMAIL_TEXT_STATUS_UPDATED . sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ) .
            EMAIL_TEXT_STATUS_PLEASE_REPLY;
      
                $html_msg['EMAIL_CUSTOMERS_NAME']    = $check_status->fields['customers_name'];
                $html_msg['EMAIL_TEXT_ORDER_NUMBER'] = EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID;
                $html_msg['EMAIL_TEXT_INVOICE_URL']  = '<a href="' . zen_catalog_href_link(FILENAME_ORDER_STATUS, 'order_id=' . $oID, 'SSL') .'">'.str_replace(':','',EMAIL_TEXT_COWOA_URL).'</a>';
                $html_msg['EMAIL_TEXT_DATE_ORDERED'] = EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($check_status->fields['date_purchased']);
                $html_msg['EMAIL_TEXT_STATUS_COMMENTS'] = nl2br($notify_comments);
                $html_msg['EMAIL_TEXT_STATUS_UPDATED'] = str_replace('\n','', EMAIL_TEXT_STATUS_UPDATED);
                $html_msg['EMAIL_TEXT_STATUS_LABEL'] = str_replace('\n','', sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ));
                $html_msg['EMAIL_TEXT_NEW_STATUS'] = $orders_status_array[$status];
                $html_msg['EMAIL_TEXT_STATUS_PLEASE_REPLY'] = str_replace('\n','', EMAIL_TEXT_STATUS_PLEASE_REPLY);
      
                  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');
                  $customer_notified = '1';
                }
          } 
      if (COWOA_ORDER_STATUS == 'false') {
            if ($check_status->fields['COWOA_order'] == 1)  {
      
                $htmlInvoiceURL='';
                $htmlInvoiceValue='';
                $message =
                EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n\n" .
                EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($check_status->fields['date_purchased']) . "\n\n" .
                strip_tags($notify_comments) .
                EMAIL_TEXT_STATUS_UPDATED . sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ) .
                EMAIL_TEXT_STATUS_PLEASE_REPLY;
                $html_msg['EMAIL_CUSTOMERS_NAME']    = $check_status->fields['customers_name'];
                $html_msg['EMAIL_TEXT_ORDER_NUMBER'] = EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID;
                $html_msg['INTRO_URL_TEXT']        = '';
                $html_msg['INTRO_URL_VALUE']       = '';
                $html_msg['EMAIL_TEXT_DATE_ORDERED'] = EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($check_status->fields['date_purchased']);
                $html_msg['EMAIL_TEXT_STATUS_COMMENTS'] = nl2br($notify_comments);
                $html_msg['EMAIL_TEXT_STATUS_UPDATED'] = str_replace('\n','', EMAIL_TEXT_STATUS_UPDATED);
                $html_msg['EMAIL_TEXT_STATUS_LABEL'] = str_replace('\n','', sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ));
                $html_msg['EMAIL_TEXT_NEW_STATUS'] = $orders_status_array[$status];
                $html_msg['EMAIL_TEXT_STATUS_PLEASE_REPLY'] = str_replace('\n','', EMAIL_TEXT_STATUS_PLEASE_REPLY);
      
                  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');
                  $customer_notified = '1';
                }    
          }
      // EOF COWOA SEND ORDER_STATUS EMAIL    
          if ($check_status->fields['COWOA_order'] != 1)  {
                  $message =
                  EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n\n" .
                  EMAIL_TEXT_INVOICE_URL . ' ' . zen_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n\n" .
                  EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($check_status->fields['date_purchased']) . "\n\n" .
            strip_tags($notify_comments) .
            EMAIL_TEXT_STATUS_UPDATED . sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ) .
            EMAIL_TEXT_STATUS_PLEASE_REPLY;
      
                $html_msg['EMAIL_CUSTOMERS_NAME']    = $check_status->fields['customers_name'];
                $html_msg['EMAIL_TEXT_ORDER_NUMBER'] = EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID;
                $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>';
                $html_msg['EMAIL_TEXT_DATE_ORDERED'] = EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($check_status->fields['date_purchased']);
                $html_msg['EMAIL_TEXT_STATUS_COMMENTS'] = nl2br($notify_comments);
                $html_msg['EMAIL_TEXT_STATUS_UPDATED'] = str_replace('\n','', EMAIL_TEXT_STATUS_UPDATED);
                $html_msg['EMAIL_TEXT_STATUS_LABEL'] = str_replace('\n','', sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ));
                $html_msg['EMAIL_TEXT_NEW_STATUS'] = $orders_status_array[$status];
                $html_msg['EMAIL_TEXT_STATUS_PLEASE_REPLY'] = str_replace('\n','', EMAIL_TEXT_STATUS_PLEASE_REPLY);
                $html_msg['EMAIL_PAYPAL_TRANSID'] = '';
      
                  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');
                  $customer_notified = '1';
      
                  // PayPal Trans ID, if any
                  $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 ";
                  $sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
                  $result = $db->Execute($sql);
                  if ($result->RecordCount() > 0) {
                    $message .= "\n\n" . ' PayPal Trans ID: ' . $result->fields['txn_id'];
                    $html_msg['EMAIL_PAYPAL_TRANSID'] = $result->fields['txn_id'];
                  }
      
                  //send extra emails
                  if (SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_STATUS == '1' and SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO != '') {
                    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');
                  }
                } elseif (isset($_POST['notify']) && ($_POST['notify'] == '-1')) {
                  // hide comment
                  $customer_notified = '-1';
                }
      
      // Begin Paket Tracking 2.1
                $db->Execute("insert into " . TABLE_ORDERS_STATUS_HISTORY . "
                            (orders_id, orders_status_id, date_added, customer_notified, track_id1, track_id2, track_id3, track_id4, track_id5, comments)
                            values ('" . (int)$oID . "',
                            '" . zen_db_input($status) . "',
                            now(),
                            '" . zen_db_input($customer_notified) . "',
                            '" . zen_db_input($track_id1) . "',
                            '" . zen_db_input($track_id2) . "',
                            '" . zen_db_input($track_id3) . "',
                            '" . zen_db_input($track_id4) . "',
                            '" . zen_db_input($track_id5) . "',
                            '" . zen_db_input($comments)  . "')");
                $order_updated = true;
              }
      // End Paket Tracking 2.1
              // trigger any appropriate updates which should be sent back to the payment gateway:
              $order = new order((int)$oID);
              if ($order->info['payment_module_code']) {
                if (file_exists(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php')) {
                  require_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
                  require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
                  $module = new $order->info['payment_module_code'];
                  if (method_exists($module, '_doStatusUpdate')) {
                    $response = $module->_doStatusUpdate($oID, $status, $comments, $customer_notified, $check_status->fields['orders_status']);
                  }
                }
              }
      
              if ($order_updated == true) {
                if ($status == DOWNLOADS_ORDERS_STATUS_UPDATED_VALUE) {
      
                  // adjust download_maxdays based on current date
                  $chk_downloads_query = "SELECT opd.*, op.products_id from " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd, " . TABLE_ORDERS_PRODUCTS . " op
                                          WHERE op.orders_id='" . (int)$oID . "'
                                          and opd.orders_products_id = op.orders_products_id";
                  $chk_downloads = $db->Execute($chk_downloads_query);
      
                  while (!$chk_downloads->EOF) {
                    $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
                                                          from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                                                          WHERE pa.products_attributes_id = pad.products_attributes_id
                                                          and pad.products_attributes_filename = '" . $chk_downloads->fields['orders_products_filename'] . "'
                                                          and pa.products_id = '" . $chk_downloads->fields['products_id'] . "'";
      
                    $chk_products_download_time = $db->Execute($chk_products_download_time_query);
      
                    if ($chk_products_download_time->EOF) {
                      $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);
                      $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'] . "'";
                    } else {
                      $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']);
                      $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'] . "'";
                    }
      
                    $db->Execute($update_downloads_query);
      
                    $chk_downloads->MoveNext();
                  }
                }
                $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
              } else {
                $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');
             }
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
            }
              break;
            case 'deleteconfirm';
              // demo active test
              if (zen_admin_demo()) {
                $_GET['action']= '';
                $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
                zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')), 'NONSSL'));
              }
              $oID = zen_db_prepare_input($_POST['oID']);
      
              zen_remove_order($oID, $_POST['restock']);
      
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')), 'NONSSL'));
              break;
            case 'delete_cvv':
              $delete_cvv = $db->Execute("update " . TABLE_ORDERS . " set cc_cvv = '" . TEXT_DELETE_CVV_REPLACEMENT . "' where orders_id = '" . (int)$_GET['oID'] . "'");
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
            case 'mask_cc':
              $result  = $db->Execute("select cc_number from " . TABLE_ORDERS . " where orders_id = '" . (int)$_GET['oID'] . "'");
              $old_num = $result->fields['cc_number'];
              $new_num = substr($old_num, 0, 4) . str_repeat('*', (strlen($old_num) - 8)) . substr($old_num, -4);
              $mask_cc = $db->Execute("update " . TABLE_ORDERS . " set cc_number = '" . $new_num . "' where orders_id = '" . (int)$_GET['oID'] . "'");
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
      
            case 'doRefund':
              $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_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
                  require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
                  $module = new $order->info['payment_module_code'];
                  if (method_exists($module, '_doRefund')) {
                    $module->_doRefund($oID);
                  }
                }
              }
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
            case 'doAuth':
              $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_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
                  require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
                  $module = new $order->info['payment_module_code'];
                  if (method_exists($module, '_doAuth')) {
                    $module->_doAuth($oID, $order->info['total'], $order->info['currency']);
                  }
                }
              }
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
            case 'doCapture':
              $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_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
                  require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
                  $module = new $order->info['payment_module_code'];
                  if (method_exists($module, '_doCapt')) {
                    $module->_doCapt($oID, 'Complete', $order->info['total'], $order->info['currency']);
                  }
                }
              }
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
            case 'doVoid':
              $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_once(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php');
                  require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');
                  $module = new $order->info['payment_module_code'];
                  if (method_exists($module, '_doVoid')) {
                    $module->_doVoid($oID);
                  }
                }
              }
              zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
              break;
          }
        }
      ?>
      <!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/stylesheet.css">
      <link rel="stylesheet" type="text/css" media="print" href="includes/stylesheet_print.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 == '') { ?>
      <!-- search -->
        <tr>
          <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
            <tr>
              <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
               <tr><?php echo zen_draw_form('search', FILENAME_ORDERS, '', 'get', '', true); ?>
                  <td width="65%" class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
                  <td colspan="2" class="smallText" align="right">
      <?php
      // show reset search
        if ((isset($_GET['search']) && zen_not_null($_GET['search'])) or $_GET['cID'] !='') {
          echo '<a href="' . zen_href_link(FILENAME_ORDERS, '', 'NONSSL') . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a><br />';
        }
      ?>
      <?php
        echo HEADING_TITLE_SEARCH_DETAIL . ' ' . zen_draw_input_field('search') . zen_hide_session_id();
        if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
          $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
          echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER . $keywords;
        }
      ?>
                  </td>
                </form>
      
      
               <?php echo zen_draw_form('search_orders_products', FILENAME_ORDERS, '', 'get', '', true); ?>
                  <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
                  <td colspan="2" class="smallText" align="right">
      <?php
      // show reset search orders_products
        if ((isset($_GET['search_orders_products']) && zen_not_null($_GET['search_orders_products'])) or $_GET['cID'] !='') {
          echo '<a href="' . zen_href_link(FILENAME_ORDERS, '', 'NONSSL') . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a><br />';
        }
      ?>
      <?php
        echo HEADING_TITLE_SEARCH_DETAIL_ORDERS_PRODUCTS . ' ' . zen_draw_input_field('search_orders_products') . zen_hide_session_id();
        if (isset($_GET['search_orders_products']) && zen_not_null($_GET['search_orders_products'])) {
          $keywords_orders_products = zen_db_input(zen_db_prepare_input($_GET['search_orders_products']));
          echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER_ORDERS_PRODUCTS . zen_db_prepare_input($keywords_orders_products);
        }
      ?>
                  </td>
                </form>
      
              </table></td>
            </tr>
      <!-- search -->
      <?php } ?>
      
      
      <?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'];
      //        echo $module->admin_notification($oID);
            }
          }
      // Begin Paket Tracking 2.1
          $get_prev = $db->Execute("SELECT orders_id FROM " . TABLE_ORDERS . " WHERE orders_id < '" . $oID . "' ORDER BY orders_id DESC LIMIT 1");
      
          if (zen_not_null($get_prev->fields['orders_id'])) {
            $prev_button = '            <INPUT TYPE="BUTTON" VALUE="<<< ' . $get_prev->fields['orders_id'] . '" ONCLICK="window.location.href=\'' . zen_href_link(FILENAME_ORDERS, 'oID=' . $get_prev->fields['orders_id'] . '&action=edit') . '\'">';
          }
          else {
            $prev_button = '            <INPUT TYPE="BUTTON" VALUE="' . BUTTON_TO_LIST . '" ONCLICK="window.location.href=\'' . zen_href_link(FILENAME_ORDERS) . '\'">';
          }
      
      
          $get_next = $db->Execute("SELECT orders_id FROM " . TABLE_ORDERS . " WHERE orders_id > '" . $oID . "' ORDER BY orders_id ASC LIMIT 1");
      
          if (zen_not_null($get_next->fields['orders_id'])) {
            $next_button = '            <INPUT TYPE="BUTTON" VALUE="' . $get_next->fields['orders_id'] . ' >>>" ONCLICK="window.location.href=\'' . zen_href_link(FILENAME_ORDERS, 'oID=' . $get_next->fields['orders_id'] . '&action=edit') . '\'">';
          }
          else {
            $next_button = '            <INPUT TYPE="BUTTON" VALUE="' . BUTTON_TO_LIST . '" ONCLICK="window.location.href=\'' . zen_href_link(FILENAME_ORDERS) . '\'">';
        }
      // End Paket Tracking 2.1
      ?>
            <tr>
              <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
                <tr>
      <!-- Begin Paket Tracking 2.1 -->
                  <td class="pageHeading"><?php echo HEADING_TITLE_ORDER_DETAILS . $oID; ?></td>
                  <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
                  <?php if ($so->status) { ?>
                  <?php } ?>
                  <td align="center">
              <table border="0" cellspacing="3" cellpadding="0">
                    <tr>
                      <td class="main" align="center" valign="bottom"><?php echo $prev_button; ?></td>
                      <td class="smallText" align="center" valign="bottom"><?php
                        echo SELECT_ORDER_LIST . '<br>';
                        echo zen_draw_form('input_oid', FILENAME_ORDERS, '', 'get', '', true);
                        echo zen_draw_input_field('oID', '', 'size="6"');
                        echo zen_draw_hidden_field('action', 'edit');
                        echo '</form>';
                      ?></td>
                      <td class="main" align="center" valign="bottom"><?php echo $next_button; ?></td>
                    </tr>
                  </table>
            </td>
      <!-- End Paket Tracking 2.1 -->
                  <td class="pageHeading" align="right"><?php echo '<a href="javascript:history.back()">' . zen_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
                </tr>
              </table>
          </td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
                <tr>
                  <td colspan="3"><?php echo zen_draw_separator(); ?></td>
                </tr>
                <tr>
                  <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                    <tr>
                      <td class="main" valign="top"><strong><?php echo ENTRY_CUSTOMER; ?></strong></td>
                      <td class="main"><?php echo zen_address_format($order->customer['format_id'], $order->customer, 1, '', '<br />'); ?></td>
                    </tr>
                    <tr>
                      <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
                    </tr>
                    <tr>
                      <td class="main"><strong><?php echo ENTRY_TELEPHONE_NUMBER; ?></strong></td>
                      <td class="main"><?php echo $order->customer['telephone']; ?></td>
                    </tr>
                    <tr>
                      <td class="main"><strong><?php echo ENTRY_EMAIL_ADDRESS; ?></strong></td>
                      <td class="main"><?php echo '<a href="mailto:' . $order->customer['email_address'] . '">' . $order->customer['email_address'] . '</a>'; ?></td>
                    </tr>
                    <tr>
                      <td class="main"><strong><?php echo TEXT_INFO_IP_ADDRESS; ?></strong></td>
                      <td class="main"><?php echo $order->info['ip_address']; ?></td>
                    </tr>
                  </table></td>
                  <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                    <tr>
                      <td class="main" valign="top"><strong><?php echo ENTRY_SHIPPING_ADDRESS; ?></strong></td>
                      <td class="main"><?php echo zen_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br />'); ?></td>
                    </tr>
                  </table></td>
                  <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                    <tr>
                      <td class="main" valign="top"><strong><?php echo ENTRY_BILLING_ADDRESS; ?></strong></td>
                      <td class="main"><?php echo zen_address_format($order->billing['format_id'], $order->billing, 1, '', '<br />'); ?></td>
                    </tr>
                  </table></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
            </tr>
            <tr>
              <td class="main"><strong><?php echo ENTRY_ORDER_ID . $oID; ?></strong></td>
            </tr>
            <tr>
           <td><table border="0" cellspacing="0" cellpadding="2">
              <tr>
                 <td class="main"><strong><?php echo ENTRY_DATE_PURCHASED; ?></strong></td>
                 <td class="main"><?php echo zen_date_long($order->info['date_purchased']); ?></td>
              </tr>
              <tr>
                 <td class="main"><strong><?php echo ENTRY_PAYMENT_METHOD; ?></strong></td>
                 <td class="main"><?php echo $order->info['payment_method']; ?></td>
              </tr>
      <?php
          if (zen_not_null($order->info['cc_type']) || zen_not_null($order->info['cc_owner']) || zen_not_null($order->info['cc_number'])) {
      ?>
                <tr>
                  <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
                </tr>
                <tr>
                  <td class="main"><?php echo ENTRY_CREDIT_CARD_TYPE; ?></td>
                  <td class="main"><?php echo $order->info['cc_type']; ?></td>
                </tr>
                <tr>
                  <td class="main"><?php echo ENTRY_CREDIT_CARD_OWNER; ?></td>
                  <td class="main"><?php echo $order->info['cc_owner']; ?></td>
                </tr>
                <tr>
                  <td class="main"><?php echo ENTRY_CREDIT_CARD_NUMBER; ?></td>
                  <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>
                </tr>
      <?php if (zen_not_null($order->info['cc_cvv'])) { ?>
                <tr>
                  <td class="main"><?php echo ENTRY_CREDIT_CARD_CVV; ?></td>
                  <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>
                </tr>
      <?php } ?>
                <tr>
                  <td class="main"><?php echo ENTRY_CREDIT_CARD_EXPIRES; ?></td>
                  <td class="main"><?php echo $order->info['cc_expires']; ?></td>
                </tr>
      <?php
          }
      ?>
              </table></td>
            </tr>
      <?php
            if (method_exists($module, 'admin_notification')) {
      ?>
            <tr>
              <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
            </tr>
            <tr>
              <?php echo $module->admin_notification($oID); ?>
            </tr>
            <tr>
              <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
            </tr>
      <?php
      }
      ?>
            <tr>
              <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
                <tr class="dataTableHeadingRow">
                  <td class="dataTableHeadingContent" colspan="2"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TAX; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRICE_EXCLUDING_TAX; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRICE_INCLUDING_TAX; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_EXCLUDING_TAX; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_INCLUDING_TAX; ?></td>
                </tr>
      <?php
          for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
            if (DISPLAY_PRICE_WITH_TAX_ADMIN == 'true')
            {
              $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']);
            } else
            {
              $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']);
            }
            echo '          <tr class="dataTableRow">' . "\n" .
                 '            <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . '&nbsp;x</td>' . "\n" .
                 '            <td class="dataTableContent" valign="top">' . $order->products[$i]['name'];
      
            if (isset($order->products[$i]['attributes']) && (sizeof($order->products[$i]['attributes']) > 0)) {
              for ($j = 0, $k = sizeof($order->products[$i]['attributes']); $j < $k; $j++) {
                echo '<br /><nobr><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($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']) . ')';
                if ($order->products[$i]['attributes'][$j]['product_attribute_is_free'] == '1' and $order->products[$i]['product_is_free'] == '1') echo TEXT_INFO_ATTRIBUTE_FREE;
                echo '</i></small></nobr>';
              }
            }
      
            echo '            </td>' . "\n" .
                 '            <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n" .
                 '            <td class="dataTableContent" align="right" valign="top">' . zen_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n" .
                 '            <td class="dataTableContent" align="right" valign="top"><strong>' .
                                $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) .
                                ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format($order->products[$i]['onetime_charges'], true, $order->info['currency'], $order->info['currency_value']) : '') .
                              '</strong></td>' . "\n" .
                 '            <td class="dataTableContent" align="right" valign="top"><strong>' .
                                $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) .
                                ($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']) : '') .
                              '</strong></td>' . "\n" .
                 '            <td class="dataTableContent" align="right" valign="top"><strong>' .
                                $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']) .
                                ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format($order->products[$i]['onetime_charges'], true, $order->info['currency'], $order->info['currency_value']) : '') .
                              '</strong></td>' . "\n" .
                 '            <td class="dataTableContent" align="right" valign="top"><strong>' .
                                $priceIncTax .
                                ($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']) : '') .
                              '</strong></td>' . "\n";
            echo '          </tr>' . "\n";
          }
      ?>
                <tr>
                  <td align="right" colspan="8"><table border="0" cellspacing="0" cellpadding="2">
      <?php
          for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
            echo '              <tr>' . "\n" .
                 '                <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Text">' . $order->totals[$i]['title'] . '</td>' . "\n" .
                 '                <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount">' . $currencies->format($order->totals[$i]['value'], false) . '</td>' . "\n" .
                 '              </tr>' . "\n";
          }
      ?>
                  </table></td>
                </tr>
              </table></td>
            </tr>
      
      <?php
        // show downloads
        require(DIR_WS_MODULES . 'orders_download.php');
      ?>
      
            <tr>
              <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
            </tr>
            <tr>
              <td class="main"><table border="1" cellspacing="0" cellpadding="5">
                <tr>
                  <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_DATE_ADDED; ?></strong></td>
                  <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_CUSTOMER_NOTIFIED; ?></strong></td>
                  <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_STATUS; ?></strong></td>
      <!-- Begin Paket Tracking 2.0 ------------------------------->
              <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_TRACKING_ID; ?></strong></td>
      <!-- End Paket Tracking 2.0 ------------------------------------------------------------>
                  <td class="smallText" align="center"><strong><?php echo TABLE_HEADING_COMMENTS; ?></strong></td>
                </tr>
      <?php
      
      // Begin Paket Tracking 2.1
          $orders_history = $db->Execute("select orders_status_id, date_added, customer_notified, track_id1, track_id2, track_id3, track_id4, track_id5, comments
                                          from " . TABLE_ORDERS_STATUS_HISTORY . "
                                          where orders_id = '" . zen_db_input($oID) . "'
                                          order by date_added");
      // End Paket Tracking 2.1
          if ($orders_history->RecordCount() > 0) {
            while (!$orders_history->EOF) {
              echo '          <tr>' . "\n" .
                   '            <td class="smallText" align="center">' . zen_datetime_short($orders_history->fields['date_added']) . '</td>' . "\n" .
                   '            <td class="smallText" align="center">';
              if ($orders_history->fields['customer_notified'] == '1') {
                echo zen_image(DIR_WS_ICONS . 'tick.gif', TEXT_YES) . "</td>\n";
              } else if ($orders_history->fields['customer_notified'] == '-1') {
                echo zen_image(DIR_WS_ICONS . 'locked.gif', TEXT_HIDDEN) . "</td>\n";
              } else {
                echo zen_image(DIR_WS_ICONS . 'unlocked.gif', TEXT_VISIBLE) . "</td>\n";
              }
              echo '            <td class="smallText">' . $orders_status_array[$orders_history->fields['orders_status_id']] . '</td>' . "\n";
      // Begin Paket Tracking 2.1
              $display_track_id = '&nbsp;';
          $display_track_id .= (empty($orders_history->fields['track_id1']) ? '' : CARRIER_NAME_1 . ": <a href=" . CARRIER_LINK_1 . nl2br(zen_output_string_protected($orders_history->fields['track_id1'])) . ' target="_blank">' . nl2br(zen_output_string_protected($orders_history->fields['track_id1'])) . "</a>&nbsp;" );
          $display_track_id .= (empty($orders_history->fields['track_id2']) ? '' : CARRIER_NAME_2 . ": <a href=" . CARRIER_LINK_2 . nl2br(zen_output_string_protected($orders_history->fields['track_id2'])) . ' target="_blank">' . nl2br(zen_output_string_protected($orders_history->fields['track_id2'])) . "</a>&nbsp;" );
          $display_track_id .= (empty($orders_history->fields['track_id3']) ? '' : CARRIER_NAME_3 . ": <a href=" . CARRIER_LINK_3 . nl2br(zen_output_string_protected($orders_history->fields['track_id3'])) . ' target="_blank">' . nl2br(zen_output_string_protected($orders_history->fields['track_id3'])) . "</a>&nbsp;" );
          $display_track_id .= (empty($orders_history->fields['track_id4']) ? '' : CARRIER_NAME_4 . ": <a href=" . CARRIER_LINK_4 . nl2br(zen_output_string_protected($orders_history->fields['track_id4'])) . ' target="_blank">' . nl2br(zen_output_string_protected($orders_history->fields['track_id4'])) . "</a>&nbsp;" );
          $display_track_id .= (empty($orders_history->fields['track_id5']) ? '' : CARRIER_NAME_5 . ": <a href=" . CARRIER_LINK_5 . nl2br(zen_output_string_protected($orders_history->fields['track_id5'])) . ' target="_blank">' . nl2br(zen_output_string_protected($orders_history->fields['track_id5'])) . "</a>&nbsp;" );
              echo '            <td class="smallText" align="left" valign="top">' . $display_track_id . '</td>' . "\n";
      // End Paket Tracking 2.1
              echo '            <td class="smallText">' . nl2br(zen_db_output($orders_history->fields['comments'])) . '&nbsp;</td>' . "\n" .
                   '          </tr>' . "\n";
              $orders_history->MoveNext();
            }
          } else {
              echo '          <tr>' . "\n" .
                   '            <td class="smallText" colspan="5">' . TEXT_NO_ORDER_HISTORY . '</td>' . "\n" .
                   '          </tr>' . "\n";
          }
      ?>
              </table></td>
            </tr>
            <tr>
              <td class="main noprint"><br /><strong><?php echo TABLE_HEADING_COMMENTS; ?></strong></td>
            </tr>
            <tr>
              <td class="noprint"><?php echo zen_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
            </tr>
            <tr><?php echo zen_draw_form('status', FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=update_order', 'post', '', true); ?>
              <td class="main noprint"><?php echo zen_draw_textarea_field('comments', 'soft', '60', '5'); ?></td>
            </tr>
            <tr>
              <td>
      <?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?>
      <!-- Begin Paket Tracking 2.1 -->
          <table border="0" cellpadding="3" cellspacing="0">          
              <tr>
                  <td class="main"><strong><?php echo zen_image(DIR_WS_IMAGES . 'icon_track_add.png', ENTRY_ADD_TRACK) . '&nbsp;' . ENTRY_ADD_TRACK; ?></strong></td>
              </tr>
              <tr valign="top">
                  <td width="400">
                      <table border="1" cellpadding="3" cellspacing="0" width="100%">
                          <tr class="dataTableHeadingRow">
                              <td class="dataTableHeadingContent smallText"><strong><?php echo TABLE_HEADING_CARRIER_NAME; ?></strong></td>
                              <td class="dataTableHeadingContent smallText"><strong><?php echo TABLE_HEADING_TRACKING_ID; ?></strong></td>
                          </tr>
                          <?php if (CARRIER_STATUS_1 == 'True') { ?>
                          <tr>
                              <td><?php echo CARRIER_NAME_1; ?></td><td valign="top"><?php echo zen_draw_input_field('track_id1', '', 'size="50"'); ?></td>
                          </tr>
                          <?php } ?>
                          <?php if (CARRIER_STATUS_2 == 'True') { ?>
                          <tr>
                              <td><?php echo CARRIER_NAME_2; ?></td><td valign="top"><?php echo zen_draw_input_field('track_id2', '', 'size="50"'); ?></td>
                          </tr>
                          <?php } ?>
                          <?php if (CARRIER_STATUS_3 == 'True') { ?>
                          <tr>
                              <td><?php echo CARRIER_NAME_3; ?></td><td valign="top"><?php echo zen_draw_input_field('track_id3', '', 'size="50"'); ?></td>
                          </tr>
                          <?php } ?>
                          <?php if (CARRIER_STATUS_4 == 'True') { ?>
                          <tr>
                              <td><?php echo CARRIER_NAME_4; ?></td><td valign="top"><?php echo zen_draw_input_field('track_id4', '', 'size="50"'); ?></td>
                          </tr>
                          <?php } ?>
                          <?php if (CARRIER_STATUS_5 == 'True') { ?>
                          <tr>
                              <td><?php echo CARRIER_NAME_5; ?></td><td valign="top"><?php echo zen_draw_input_field('track_id5', '', 'size="50"'); ?></td>
                          </tr>
                          <?php } ?>
                      </table>
                  </td>
              </tr>
          </table>      
      <!-- Begin Paket Tracking 2.1 -->
          </td>
            </tr>
            <tr>
              <td><table border="0" cellspacing="0" cellpadding="2" class="noprint">
                <tr>
                  <td><table border="0" cellspacing="0" cellpadding="2">
                    <tr>
                      <td class="main"><strong><?php echo ENTRY_STATUS; ?></strong> <?php echo zen_draw_pull_down_menu('status', $orders_statuses, $order->info['orders_status']); ?></td>
                    </tr>
                    <tr>
                      <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>
                      <td class="main"><strong><?php echo ENTRY_NOTIFY_COMMENTS; ?></strong> <?php echo zen_draw_checkbox_field('notify_comments', '', true); ?></td>
                    </tr>
                    <tr><td><br /></td></tr>
                  </table></td>
                  <td valign="top"><?php echo zen_image_submit('button_update.gif', IMAGE_UPDATE); ?></td>
                </tr>
              </table></td>
            </form></tr>
            <tr>
              <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>
            </tr>
      <?php
      // check if order has open gv
              $gv_check = $db->Execute("select order_id, unique_id
                                        from " . TABLE_COUPON_GV_QUEUE ."
                                        where order_id = '" . $_GET['oID'] . "' and release_flag='N' limit 1");
              if ($gv_check->RecordCount() > 0) {
                $goto_gv = '<a href="' . zen_href_link(FILENAME_GV_QUEUE, 'order=' . $_GET['oID']) . '">' . zen_image_button('button_gift_queue.gif',IMAGE_GIFT_QUEUE) . '</a>';
                echo '      <tr><td align="right"><table width="225"><tr>';
                echo '        <td align="center">';
                echo $goto_gv . '&nbsp;&nbsp;';
                echo '        </td>';
                echo '      </tr></table></td></tr>';
              }
      ?>
      <?php
        } else {
      ?>
            <tr>
              <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
                <tr>
                  <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
                  <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
                  <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0">
                    <tr><?php echo zen_draw_form('orders', FILENAME_ORDERS, '', 'get', '', true); ?>
                      <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>
                    </form></tr>
                    <tr><?php echo zen_draw_form('status', FILENAME_ORDERS, '', 'get', '', true); ?>
                      <td class="smallText" align="right">
                        <?php
                          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();"');
                          echo zen_hide_session_id();
                        ?>
                      </td>
                    </form></tr>
                  </table></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
                <tr>
                  <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; ?>
                </td>
                <tr>
                  <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;
                    case "firstname":
                    $disp_order = "c.customers_firstname";
                    break;
                    case "firstname-desc":
                    $disp_order = "c.customers_firstname DESC";
                    break;
                    case "lastname":
                    $disp_order = "c.customers_lastname, c.customers_firstname";
                    break;
                    case "lastname-desc":
                    $disp_order = "c.customers_lastname DESC, c.customers_firstname";
                    break;
                    case "company":
                    $disp_order = "a.entry_company";
                    break;
                    case "company-desc":
                    $disp_order = "a.entry_company DESC";
                    break;
                    default:
                    $disp_order = "c.customers_id DESC";
                }
      ?>
                      <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_ORDERS_ID; ?></td>
                      <td class="dataTableHeadingContent" align="left" width="50"><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></td>
                      <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMERS; ?></td>
                      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ORDER_TOTAL; ?></td>
                      <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_DATE_PURCHASED; ?></td>
                      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td>
                      <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_CUSTOMER_COMMENTS; ?></td>
                      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</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);
            }
      
            if (isset($oInfo) && is_object($oInfo) && ($orders->fields['orders_id'] == $oInfo->orders_id)) {
              echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=edit', 'NONSSL') . '\'">' . "\n";
            } else {
              echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID')) . 'oID=' . $orders->fields['orders_id'], 'NONSSL') . '\'">' . "\n";
            }
      
            $show_difference = '';
            if (($orders->fields['delivery_name'] != $orders->fields['billing_name'] and $orders->fields['delivery_name'] != '')) {
              $show_difference = zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', TEXT_BILLING_SHIPPING_MISMATCH, 10, 10) . '&nbsp;';
            }
            if (($orders->fields['delivery_street_address'] != $orders->fields['billing_street_address'] and $orders->fields['delivery_street_address'] != '')) {
              $show_difference = zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', TEXT_BILLING_SHIPPING_MISMATCH, 10, 10) . '&nbsp;';
            }
            $show_payment_type = $orders->fields['payment_module_code'] . '<br />' . $orders->fields['shipping_module_code'];
      ?>
                      <td class="dataTableContent" align="right"><?php echo $show_difference . $orders->fields['orders_id']; ?></td>
                      <td class="dataTableContent" align="left" width="50"><?php echo $show_payment_type; ?></td>
                      <td class="dataTableContent"><?php echo '<a href="' . zen_href_link(FILENAME_CUSTOMERS, 'cID=' . $orders->fields['customers_id'], 'NONSSL') . '">' . zen_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW . ' ' . TABLE_HEADING_CUSTOMERS) . '</a>&nbsp;' . $orders->fields['customers_name'] . ($orders->fields['customers_company'] != '' ? '<br />' . $orders->fields['customers_company'] : ''); ?></td>
                      <td class="dataTableContent" align="right"><?php echo strip_tags($orders->fields['order_total']); ?></td>
                      <td class="dataTableContent" align="center"><?php echo zen_datetime_short($orders->fields['date_purchased']); ?></td>
                      <td class="dataTableContent" align="right"><?php echo $orders->fields['orders_status_name']; ?></td>
                      <td class="dataTableContent" align="center"><?php echo (zen_get_orders_comments($orders->fields['orders_id']) == '' ? '' : zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', TEXT_COMMENTS_YES, 16, 16)); ?></td>
      
                      <td class="dataTableContent" align="right"><?php echo '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $orders->fields['orders_id'] . '&action=edit', 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_edit.gif', ICON_EDIT) . '</a>'; ?><?php if (isset($oInfo) && is_object($oInfo) && ($orders->fields['orders_id'] == $oInfo->orders_id)) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID')) . 'oID=' . $orders->fields['orders_id'], 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</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>
      <?php
        if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
      ?>
                        <tr>
                          <td class="smallText" align="right" colspan="2">
                            <?php
                              echo '<a href="' . zen_href_link(FILENAME_ORDERS, '', 'NONSSL') . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a>';
                              if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
                                $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
                                echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER . $keywords;
                              }
                            ?>
                          </td>
                        </tr>
      <?php
        }
      ?>
                      </table></td>
                    </tr>
                  </table></td>
      <?php
        $heading = array();
        $contents = array();
      
        switch ($action) {
          case 'delete':
            $heading[] = array('text' => '<strong>' . TEXT_INFO_HEADING_DELETE_ORDER . '</strong>');
      
            $contents = array('form' => zen_draw_form('orders', FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . '&action=deleteconfirm', 'post', '', true) . zen_draw_hidden_field('oID', $oInfo->orders_id));
      //      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO . '<br /><br /><strong>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</strong>');
            $contents[] = array('text' => TEXT_INFO_DELETE_INTRO . '<br /><br /><strong>' . ENTRY_ORDER_ID . $oInfo->orders_id . '<br />' . $oInfo->order_total . '<br />' . $oInfo->customers_name . ($oInfo->customers_company != '' ? '<br />' . $oInfo->customers_company : '') . '</strong>');
            $contents[] = array('text' => '<br />' . zen_draw_checkbox_field('restock') . ' ' . TEXT_INFO_RESTOCK_PRODUCT_QUANTITY);
            $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id, 'NONSSL') . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
            break;
          default:
            if (isset($oInfo) && is_object($oInfo)) {
              $heading[] = array('text' => '<strong>[' . $oInfo->orders_id . ']&nbsp;&nbsp;' . zen_datetime_short($oInfo->date_purchased) . '</strong>');
      
              $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=edit', 'NONSSL') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=delete', 'NONSSL') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
              $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $oInfo->orders_id) . '" TARGET="_blank">' . zen_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . zen_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $oInfo->orders_id) . '" TARGET="_blank">' . zen_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a>');
              $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_RL_INVOICE3, 'oID=' . $oInfo -> orders_id) . '" TARGET="_blank">' . zen_image_button('button_rl_invoice3.gif', IMAGE_RL_INVOICE) );
              $contents[] = array('text' => '<br />' . TEXT_DATE_ORDER_CREATED . ' ' . zen_date_short($oInfo->date_purchased));
              $contents[] = array('text' => '<br />' . $oInfo->customers_email_address);
              $contents[] = array('text' => TEXT_INFO_IP_ADDRESS . ' ' . $oInfo->ip_address);
              if (zen_not_null($oInfo->last_modified)) $contents[] = array('text' => TEXT_DATE_ORDER_LAST_MODIFIED . ' ' . zen_date_short($oInfo->last_modified));
              $contents[] = array('text' => '<br />' . TEXT_INFO_PAYMENT_METHOD . ' '  . $oInfo->payment_method);
              $contents[] = array('text' => '<br />' . ENTRY_SHIPPING . ' '  . $oInfo->shipping_method);
      
      // check if order has open gv
              $gv_check = $db->Execute("select order_id, unique_id
                                        from " . TABLE_COUPON_GV_QUEUE ."
                                        where order_id = '" . $oInfo->orders_id . "' and release_flag='N' limit 1");
              if ($gv_check->RecordCount() > 0) {
                $goto_gv = '<a href="' . zen_href_link(FILENAME_GV_QUEUE, 'order=' . $oInfo->orders_id) . '">' . zen_image_button('button_gift_queue.gif',IMAGE_GIFT_QUEUE) . '</a>';
                $contents[] = array('text' => '<br />' . zen_image(DIR_WS_IMAGES . 'pixel_black.gif','','100%','3'));
                $contents[] = array('align' => 'center', 'text' => $goto_gv);
              }
            }
      
      // indicate if comments exist
            $orders_history_query = $db->Execute("select orders_status_id, date_added, customer_notified, comments from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . $oInfo->orders_id . "' and comments !='" . "'" );
            if ($orders_history_query->RecordCount() > 0) {
              $contents[] = array('align' => 'left', 'text' => '<br />' . TABLE_HEADING_COMMENTS);
            }
      
            $contents[] = array('text' => '<br />' . zen_image(DIR_WS_IMAGES . 'pixel_black.gif','','100%','3'));
            $order = new order($oInfo->orders_id);
            $contents[] = array('text' => 'Products Ordered: ' . sizeof($order->products) );
            for ($i=0; $i<sizeof($order->products); $i++) {
              $contents[] = array('text' => $order->products[$i]['qty'] . '&nbsp;x&nbsp;' . $order->products[$i]['name']);
      
              if (sizeof($order->products[$i]['attributes']) > 0) {
                for ($j=0; $j<sizeof($order->products[$i]['attributes']); $j++) {
                  $contents[] = array('text' => '&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value'])) . '</i></nobr>' );
                }
              }
              if ($i > MAX_DISPLAY_RESULTS_ORDERS_DETAILS_LISTING and MAX_DISPLAY_RESULTS_ORDERS_DETAILS_LISTING != 0) {
                $contents[] = array('align' => 'left', 'text' => TEXT_MORE);
                break;
              }
            }
      
            if (sizeof($order->products) > 0) {
              $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=edit', 'NONSSL') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a>');
            }
            break;
        }
      
        if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
          echo '            <td width="25%" valign="top">' . "\n";
      
          $box = new box;
          echo $box->infoBox($heading, $contents);
      
          echo '            </td>' . "\n";
        }
      ?>
                </tr>
              </table></td>
            </tr>
      <?php
        }
      ?>
          </table></td>
      <!-- body_text_eof //-->
        </tr>
      </table>
      <!-- body_eof //-->
      
      <!-- footer //-->
      <div class="footer-area">
      <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
      </div>
      <!-- footer_eof //-->
      <br />
      </body>
      </html>
      <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

      Ich wäre für jede Hilfe dankbar.

      Grüße
      Manfred

      Kommentar


        #5
        So, ich habe jetzt einfach die "ausgeklammerten Zeile" wieder "entklammert".

        Ich habe zwar keine Ahnung warum die Zeilen ausgeklammert sind, aber es scheint zu funktionieren, wenn sie NICHT ausgeklammert sind.

        Mal schauen.


        Grüße
        Manfred

        Kommentar


          #6
          Bin ich der einzige der das Modul eingebaut hat?

          Gibt es ein anderes Modul welches einfacher in den Shop zu integrieren ist?

          Grüße
          Manfred

          PS
          Würde mich über jede Hilfe freuen.

          Kommentar


            #7
            Eigentlich läuft soweit alles, bis auf diese Fehlermeldung die im Adminbereich erscheint, wenn ich dort eine Bestellung aktualisiere. Wenn ich z.B. die Paketnummer eingeben.

            Fehlermeldung oben am Rand des Adminbereiches:

            "WARNUNG: Keine Änderung festgestellt. Die Rechnung wurde nicht aktualisiert."

            Kennt jemand event. die Ursache bzw. hat eine Idee?

            Grüße
            Manfred

            Kommentar


              #8
              So,
              ich habe den Verfasser des Moduls gefragt.

              Dies ist seine Antwort:

              "@Manfred and xxxxx, I've reviewed the SNAP changes and now can't remember why I incorporated the orders-status-history function update for this plugin (adds the updated_by field to the orders_status_history table and displays which admin issued a status change). There is nothing on the admin-side of the plugin that needs the status-change notification that the OSH functionality brings with it.

              The "easiest" path to integration of SNAP and your modified orders.php file is to disregard the change block in the SNAP version of the file (lines 120-197)."

              Seine Einträge in den Zeilen 120 und 121 kann also entfernt werden.

              Es sind diese Einträge:
              " //-bof-c-snap_affiliates-v2.5.0
              /* ----- Processing now handled by separate function -----
              "

              Bitte nicht vergessen. In Zeile 191 stehen dann noch diese beiden Zeichen " */ ".

              Die müssen natürlich auch gelöscht werden.

              Grüße
              Manfred


              PS:
              Quelleangabe

              I'll be submitting this plugin to the Plugins area shortly, based on the similar-named plugin for the v1.3.x series (http://www.zen-cart.com/showthread.php?124461-snap-affiliates). This version (v2.0.0) will run only on Zen Cart v1.5.0 and later and includes the following additional changes: No core-file overwrites! Moved all language-specific text to the language file, both catalog and admin. Moved $_SESSION initialization to /includes/init_includes/init_snap.php and

              Kommentar


                #9
                funktionierts mit UltimateSeoUrls?!?

                Hi Manfred!
                Ich habe das alles eingespielt, kein Fehlermeldungen gar nix...bei mir ist nur nun das Problem, dass ich ULTIMATE SEO URLS verwende und dass die Referrer nicht übernommen werden sobald man weiterklickt...

                Die Links zu erzeugen ist kein Problem (../shop/&referrer=CNWR_236921467207766) und die funktionieren auch - nur wenn ich dann im Shop als Kunde weiterklicke dann übernimmt ers mir nicht, denke da muß man in der .htaccess was anpassen...

                Hast du zufällig auch ne SEO-contrib am laufen und kannst mir helfen?!?

                Greets

                Kommentar

                Info zu diesem Forenarchiv:
                Mit Release von 1.5.7 wurde die deutsche Zen Cart Version auf eine reine DIY-Lösung umgestellt.
                Für einen Support via Forum stehen keine personellen und zeitlichen Ressourcen mehr zur Verfügung.
                Dieses Supportforum bleibt im Nur-Lesen-Modus als Wissensarchiv noch online verfügbar.
                PM Funktionalität, Registrierung und Posten neuer Beiträge sind deaktiviert.
                Zugriff auf Anhänge in den Postings ist auch ohne Registrierung/Einloggen möglich.
                FAQ und Downloadbereich des Forums wurden in die neue umfangreiche Knowledgebase auf der zen-cart-pro.at Website übernommen.

                Das Development der deutschen Zen Cart Version geht wie bisher auf Github weiter.
                Wir werden auch weiterhin neue Versionen bereitstellen und die Onlinedokumentation/Knowledgebase aktualisieren.
                Fehler in der Software können auf Github als Issues gemeldet werden.
                Follow us
                aktuelle version
                Zen Cart 1.5.7g deutsch
                vom 12.12.2023
                [Download]
                Lädt...
                X