[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/ -> edit_orders.php (source)

   1  <?php
   2  /*
   3  $Id: edit_orders.php 14 2006-07-28 17:42:07Z user $
   4  
   5    osCMax Power E-Commerce
   6    http://oscdox.com
   7  
   8    Copyright 2006 osCMax
   9  
  10    Released under the GNU General Public License
  11  
  12    Original file written by Jonathan Hilgeman of SiteCreative.com
  13  
  14  */
  15  
  16    require ('includes/application_top.php');
  17  
  18    // include the appropriate functions & classes
  19    include ('order_editor/functions.php');
  20    include ('order_editor/cart.php');
  21    include ('order_editor/order.php');
  22    include ('order_editor/shipping.php');
  23    include ('order_editor/http_client.php');
  24  
  25   
  26    // Include currencies class
  27    require (DIR_WS_CLASSES . 'currencies.php');
  28    $currencies = new currencies();
  29  
  30   
  31   //orders status
  32    $orders_statuses = array();
  33    $orders_status_array = array();
  34    $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'");
  35    while ($orders_status = tep_db_fetch_array($orders_status_query)) {
  36      $orders_statuses[] = array('id' => $orders_status['orders_status_id'],
  37                                 'text' => $orders_status['orders_status_name']);
  38  
  39    $orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name'];
  40    }
  41  
  42    $action = (isset($_GET['action']) ? $_GET['action'] : 'edit');
  43  
  44    if (isset($action)) {
  45      switch ($action) {
  46  
  47      ////
  48      // Update Order
  49        case 'update_order':
  50          $oID = tep_db_prepare_input($_GET['oID']);
  51          $status = tep_db_prepare_input($_POST['status']);
  52  
  53          // Set this Session's variables
  54          if (isset($_POST['billing_same_as_customer'])) $_SESSION['billing_same_as_customer'] = $_POST['billing_same_as_customer'];
  55          if (isset($_POST['shipping_same_as_billing'])) $_SESSION['shipping_same_as_billing'] = $_POST['shipping_same_as_billing'];
  56  
  57          // Update Order Info
  58          //figure out the new currency value
  59          $currency_value_query = tep_db_query("SELECT value 
  60                                                FROM " . TABLE_CURRENCIES . " 
  61                                                WHERE code = '" . $_POST['update_info_payment_currency'] . "'");
  62          $currency_value = tep_db_fetch_array($currency_value_query);
  63  
  64          //figure out the country, state
  65          $update_customer_state = tep_get_zone_name($_POST['update_customer_country_id'], $_POST['update_customer_zone_id'], $_POST['update_customer_state']);
  66          $update_customer_country = tep_get_country_name($_POST['update_customer_country_id']);
  67          $update_billing_state = tep_get_zone_name($_POST['update_billing_country_id'], $_POST['update_billing_zone_id'], $_POST['update_billing_state']);
  68          $update_billing_country = tep_get_country_name($_POST['update_billing_country_id']);
  69          $update_delivery_state = tep_get_zone_name($_POST['update_delivery_country_id'], $_POST['update_delivery_zone_id'], $_POST['update_delivery_state']);
  70          $update_delivery_country = tep_get_country_name($_POST['update_delivery_country_id']);
  71  
  72          $sql_data_array = array(
  73              'customers_name' => tep_db_input(tep_db_prepare_input($_POST['update_customer_name'])),
  74              'customers_company' => tep_db_input(tep_db_prepare_input($_POST['update_customer_company'])),
  75              'customers_street_address' => tep_db_input(tep_db_prepare_input($_POST['update_customer_street_address'])),
  76              'customers_suburb' => tep_db_input(tep_db_prepare_input($_POST['update_customer_suburb'])),
  77              'customers_city' => tep_db_input(tep_db_prepare_input($_POST['update_customer_city'])),
  78              'customers_state' => tep_db_input(tep_db_prepare_input($update_customer_state)),
  79              'customers_postcode' => tep_db_input(tep_db_prepare_input($_POST['update_customer_postcode'])),
  80              'customers_country' => tep_db_input(tep_db_prepare_input($update_customer_country)),
  81              'customers_telephone' => tep_db_input(tep_db_prepare_input($_POST['update_customer_telephone'])),
  82              'customers_email_address' => tep_db_input(tep_db_prepare_input($_POST['update_customer_email_address'])),
  83  
  84              'billing_name' => tep_db_input(tep_db_prepare_input(((isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_name'] : $_POST['update_billing_name']))),
  85              'billing_company' => tep_db_input(tep_db_prepare_input(((isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_company'] : $_POST['update_billing_company']))),
  86              'billing_street_address' => tep_db_input(tep_db_prepare_input(((isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_street_address'] : $_POST['update_billing_street_address']))),
  87              'billing_suburb' => tep_db_input(tep_db_prepare_input(((isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_suburb'] : $_POST['update_billing_suburb']))),
  88              'billing_city' => tep_db_input(tep_db_prepare_input(((isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_city'] : $_POST['update_billing_city']))),
  89              'billing_state' => tep_db_input(tep_db_prepare_input(((isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on') ? $update_customer_state : $update_billing_state))),
  90              'billing_postcode' => tep_db_input(tep_db_prepare_input(((isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_postcode'] : $_POST['update_billing_postcode']))),
  91              'billing_country' => tep_db_input(tep_db_prepare_input(((isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on') ? $update_customer_country : $update_billing_country))),
  92  
  93  
  94              'delivery_name' => tep_db_input(tep_db_prepare_input(((isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_name'] : $_POST['update_billing_name']) : $_POST['update_delivery_name']))),
  95              'delivery_company' => tep_db_input(tep_db_prepare_input(((isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_company'] : $_POST['update_billing_company']) : $_POST['update_delivery_company']))),
  96              'delivery_street_address' => tep_db_input(tep_db_prepare_input(((isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_street_address'] : $_POST['update_billing_street_address']) : $_POST['update_delivery_street_address']))),
  97              'delivery_suburb' => tep_db_input(tep_db_prepare_input(((isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_suburb'] : $_POST['update_billing_suburb']) : $_POST['update_delivery_suburb']))),
  98              'delivery_city' => tep_db_input(tep_db_prepare_input(((isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_city'] : $_POST['update_billing_city']) : $_POST['update_delivery_city']))),
  99              'delivery_state' => tep_db_input(tep_db_prepare_input(((isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $update_customer_state : $update_billing_state) : $update_delivery_state))),
 100              'delivery_postcode' => tep_db_input(tep_db_prepare_input(((isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_postcode'] : $_POST['update_billing_postcode']) : $_POST['update_delivery_postcode']))),
 101              'delivery_country' => tep_db_input(tep_db_prepare_input(((isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $update_customer_country : $update_billing_country) : $update_delivery_country))),
 102  
 103              'payment_method' => tep_db_input(tep_db_prepare_input($_POST['update_info_payment_method'])),
 104              'currency' => tep_db_input(tep_db_prepare_input($_POST['update_info_payment_currency'])),
 105              'currency_value' => tep_db_input(tep_db_prepare_input($currency_value['value'])),
 106              'cc_type' => tep_db_prepare_input($_POST['update_info_cc_type']),
 107              'cc_owner' => tep_db_prepare_input($_POST['update_info_cc_owner']),
 108              'cc_number' => tep_db_input(tep_db_prepare_input($_POST['update_info_cc_number'])),
 109              'cc_expires' => tep_db_prepare_input($_POST['update_info_cc_expires']),
 110              'last_modified' => 'now()');
 111  
 112          tep_db_perform(TABLE_ORDERS, $sql_data_array, 'update', 'orders_id = \'' . tep_db_input($oID) . '\'');
 113          $order_updated = true;
 114  
 115  
 116    // UPDATE STATUS HISTORY & SEND EMAIL TO CUSTOMER IF NECESSARY #####
 117  
 118          $check_status_query = tep_db_query(" SELECT customers_name, customers_email_address, orders_status, date_purchased FROM " . TABLE_ORDERS . " WHERE orders_id = '" . (int)$oID . "'");
 119  
 120          $check_status = tep_db_fetch_array($check_status_query); 
 121  
 122          if (($check_status['orders_status'] != $_POST['status']) || (tep_not_null($_POST['comments']))) {
 123  
 124            tep_db_query("UPDATE " . TABLE_ORDERS . " SET 
 125                orders_status = '" . tep_db_input($_POST['status']) . "', 
 126                last_modified = now() 
 127                WHERE orders_id = '" . (int)$oID . "'");
 128  
 129            // Notify Customer ?
 130            $customer_notified = '0';
 131            if (isset($_POST['notify']) && ($_POST['notify'] == 'on')) {
 132              $notify_comments = '';
 133              if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on')) {
 134                $notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $_POST['comments']) . "\n\n";
 135              }
 136              $email = STORE_NAME . "\n" .
 137                  EMAIL_SEPARATOR . "\n" . 
 138                  EMAIL_TEXT_ORDER_NUMBER . ' ' . (int)$oID . "\n" . 
 139                  EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . (int)$oID, 'SSL') . "\n" . 
 140                  EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]) . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE2);
 141  
 142              tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
 143  
 144              $customer_notified = '1';
 145            }
 146  
 147            tep_db_query("INSERT into " . TABLE_ORDERS_STATUS_HISTORY . " 
 148            (orders_id, orders_status_id, date_added, customer_notified, comments) 
 149            values ('" . tep_db_input($_GET['oID']) . "', 
 150                '" . tep_db_input($_POST['status']) . "', 
 151                now(), 
 152                " . tep_db_input($customer_notified) . ", 
 153                '" . tep_db_input(tep_db_prepare_input($_POST['comments']))  . "')");
 154          }
 155  
 156          // Update Products
 157          if (is_array($_POST['update_products'])) {
 158            foreach($_POST['update_products'] as $orders_products_id => $products_details) {
 159  
 160            //  Update Inventory Quantity
 161            $order_query = tep_db_query("
 162            SELECT products_id, products_quantity 
 163                FROM " . TABLE_ORDERS_PRODUCTS . " 
 164                WHERE orders_id = '" . (int)$oID . "'
 165                AND orders_products_id = '" . (int)$orders_products_id . "'");
 166            $order_products = tep_db_fetch_array($order_query);
 167  
 168            // First we do a stock check 
 169  
 170            if ($products_details['qty'] != $order_products['products_quantity']){
 171  //Bugfix when update products quantity negative - changed $order to $order_products
 172            $quantity_difference = ($products_details['qty'] - $order_products['products_quantity']);
 173              if (STOCK_LIMITED == 'true'){
 174                tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET 
 175                    products_quantity = products_quantity - " . $quantity_difference . ",
 176                    products_ordered = products_ordered + " . $quantity_difference . " 
 177                    WHERE products_id = '" . (int)$order_products['products_id'] . "'");
 178              } else {
 179                tep_db_query ("UPDATE " . TABLE_PRODUCTS . " SET
 180                    products_ordered = products_ordered + " . $quantity_difference . "
 181                    WHERE products_id = '" . (int)$order_products['products_id'] . "'");
 182              }
 183            }
 184  
 185   
 186            if ( (isset($products_details['delete'])) && ($products_details['delete'] == 'on') ) {
 187            //check first to see if product should be deleted
 188   
 189            //update quantities first
 190            if (STOCK_LIMITED == 'true'){
 191              tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET 
 192                  products_quantity = products_quantity + " . $products_details["qty"] . ",
 193                  products_ordered = products_ordered - " . $products_details["qty"] . " 
 194                  WHERE products_id = '" . (int)$order_products['products_id'] . "'");
 195            } else {
 196            tep_db_query ("UPDATE " . TABLE_PRODUCTS . " SET
 197                products_ordered = products_ordered - " . $products_details["qty"] . "
 198                WHERE products_id = '" . (int)$order_products['products_id'] . "'");
 199            }
 200   
 201            tep_db_query("DELETE FROM " . TABLE_ORDERS_PRODUCTS . "
 202                WHERE orders_id = '" . (int)$oID . "'
 203                AND orders_products_id = '" . (int)$orders_products_id . "'");
 204  
 205            tep_db_query("DELETE FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . "
 206                WHERE orders_id = '" . (int)$oID . "'
 207                AND orders_products_id = '" . (int)$orders_products_id . "'");
 208  
 209            tep_db_query("DELETE FROM " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . "
 210                WHERE orders_id = '" . (int)$oID . "'
 211                AND orders_products_id = '" . (int)$orders_products_id . "'");
 212   
 213          } else {
 214            //not deleted=> updated
 215   
 216            // Update orders_products Table
 217            $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS . " SET
 218                products_model = '" . $products_details["model"] . "',
 219                products_name = '" . oe_html_quotes($products_details["name"]) . "',
 220                products_price = '" . $products_details["price"] . "',
 221                final_price = '" . $products_details["final_price"] . "',
 222                products_tax = '" . $products_details["tax"] . "',
 223                products_quantity = '" . $products_details["qty"] . "'
 224                WHERE orders_id = '" . (int)$oID . "'
 225                AND orders_products_id = '$orders_products_id';";
 226            tep_db_query($Query);
 227  
 228            // Update Any Attributes
 229            if(isset($products_details['attributes'])) { 
 230              foreach($products_details['attributes'] as $orders_products_attributes_id => $attributes_details) {
 231              $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set
 232                  products_options = '" . $attributes_details["option"] . "',
 233                  products_options_values = '" . $attributes_details["value"] . "',
 234                  options_values_price ='" . $attributes_details["price"] . "',
 235                  price_prefix ='" . $attributes_details["prefix"] . "'
 236                  where orders_products_attributes_id = '$orders_products_attributes_id';";
 237                  tep_db_query($Query);
 238              }//end of foreach($products_details["attributes"]
 239            }// end of if(isset($products_details[attributes]))
 240  
 241          } //end if/else product details delete= on
 242        } //end foreach post update products
 243      }//end if is-array update products
 244  
 245  
 246      //update any downloads that may exist
 247      if (is_array($_POST['update_downloads'])) {
 248        foreach($_POST['update_downloads'] as $orders_products_download_id => $download_details) {
 249          $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " SET
 250              orders_products_filename = '" . $download_details["filename"] . "',
 251              download_maxdays = '" . $download_details["maxdays"] . "',
 252              download_count = '" . $download_details["maxcount"] . "'
 253              WHERE orders_id = '" . (int)$oID . "'
 254              AND orders_products_download_id = '$orders_products_download_id';";
 255          tep_db_query($Query);
 256        }
 257      }  //end downloads
 258  
 259  
 260          //delete or update comments
 261      if (is_array($_POST['update_comments'])) {
 262        foreach($_POST['update_comments'] as $orders_status_history_id => $comments_details) {
 263  
 264          if (isset($comments_details['delete'])){
 265  
 266            $Query = "DELETE FROM " . TABLE_ORDERS_STATUS_HISTORY . " 
 267                WHERE orders_id = '" . (int)$oID . "' 
 268                AND orders_status_history_id = '$orders_status_history_id';";
 269            tep_db_query($Query);
 270  
 271          } else {
 272  
 273            $Query = "UPDATE " . TABLE_ORDERS_STATUS_HISTORY . " SET
 274                comments = '" . $comments_details["comments"] . "'
 275                WHERE orders_id = '" . (int)$oID . "'
 276                AND orders_status_history_id = '$orders_status_history_id';";
 277            tep_db_query($Query);
 278          }
 279        }
 280      }//end comments update section
 281  
 282      $shipping = array();
 283  
 284      if (is_array($_POST['update_totals'])) {
 285        foreach($_POST['update_totals'] as $total_index => $total_details) {
 286          extract($total_details, EXTR_PREFIX_ALL, "ot");
 287          if ($ot_class == "ot_shipping") {
 288            $shipping['cost'] = $ot_value;
 289            $shipping['title'] = $ot_title;
 290            $shipping['id'] = $ot_id;
 291          } // end if ($ot_class == "ot_shipping")
 292        } //end foreach
 293      } //end if is_array
 294  
 295        if (tep_not_null($shipping['id'])) {
 296          tep_db_query("UPDATE " . TABLE_ORDERS . " SET shipping_module = '" . $shipping['id'] . "' WHERE orders_id = '" . (int)$oID . "'");
 297        }
 298  
 299        $order = new manualOrder($oID);
 300        $order->adjust_zones();
 301  
 302        $cart = new manualCart();
 303        $cart->restore_contents($oID);
 304        $total_count = $cart->count_contents();
 305        $total_weight = $cart->show_weight();
 306  
 307        // Get the shipping quotes- if we don't have shipping quotes shipping tax calculation can't happen
 308        $shipping_modules = new shipping;
 309        $shipping_quotes = $shipping_modules->quote();
 310  
 311        if (DISPLAY_PRICE_WITH_TAX == 'true') {//extract the base shipping cost or the ot_shipping module will add tax to it again
 312          $module = substr($GLOBALS['shipping']['id'], 0, strpos($GLOBALS['shipping']['id'], '_'));
 313          $tax = tep_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
 314          $order->info['total'] -= ( $order->info['shipping_cost'] - ($order->info['shipping_cost'] / (1 + ($tax /100))) );
 315          $order->info['shipping_cost'] = ($order->info['shipping_cost'] / (1 + ($tax /100)));
 316        }
 317  
 318      //this is where we call the order total modules
 319        require ( 'order_editor/order_total.php');
 320        $order_total_modules = new order_total();
 321        $order_totals = $order_total_modules->process();
 322  
 323        $current_ot_totals_array = array();
 324        $current_ot_titles_array = array();
 325        $current_ot_totals_query = tep_db_query("select class, title from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$oID . "' order by sort_order");
 326        while ($current_ot_totals = tep_db_fetch_array($current_ot_totals_query)) {
 327          $current_ot_totals_array[] = $current_ot_totals['class'];
 328          $current_ot_titles_array[] = $current_ot_totals['title'];
 329        }
 330  
 331        tep_db_query("DELETE FROM " . TABLE_ORDERS_TOTAL . " WHERE orders_id = '" . (int)$oID . "'");
 332  
 333        $j=1; //giving something a sort order of 0 ain't my bag baby
 334        $new_order_totals = array();
 335  
 336        if (is_array($_POST['update_totals'])) { //1
 337          foreach($_POST['update_totals'] as $total_index => $total_details) { //2
 338            extract($total_details, EXTR_PREFIX_ALL, "ot");
 339            if (!strstr($ot_class, 'ot_custom')) { //3
 340              for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) { //4
 341  
 342                if ($order_totals[$i]['code'] == 'ot_tax') { //5
 343                  $new_ot_total = ((in_array($order_totals[$i]['title'], $current_ot_titles_array)) ? false : true);
 344                } else { //within 5
 345                  $new_ot_total = ((in_array($order_totals[$i]['code'], $current_ot_totals_array)) ? false : true);
 346                }  //end 5 if ($order_totals[$i]['code'] == 'ot_tax')
 347   
 348                if ( ( ($order_totals[$i]['code'] == 'ot_tax') && ($order_totals[$i]['code'] == $ot_class) && ($order_totals[$i]['title'] == $ot_title) ) || ( ($order_totals[$i]['code'] != 'ot_tax') && ($order_totals[$i]['code'] == $ot_class) ) ) { //6
 349                  //only good for components that show up in the $order_totals array
 350  
 351                  if ($ot_title != '') { //7
 352                    $new_order_totals[] = array('title' => $ot_title,
 353                                                'text' => (($ot_class != 'ot_total') ? $order_totals[$i]['text'] : '<b>' . $currencies->format($order->info['total'], true, $order->info['currency'], $order->info['currency_value']) . '</b>'),
 354                                                'value' => (($order_totals[$i]['code'] != 'ot_total') ? $order_totals[$i]['value'] : $order->info['total']),
 355                                                'code' => $order_totals[$i]['code'],
 356                                                'sort_order' => $j);
 357                    $written_ot_totals_array[] = $ot_class;
 358                    $written_ot_titles_array[] = $ot_title;
 359                    $j++;
 360                  } else { //within 7
 361  
 362                $order->info['total'] += ($ot_value*(-1)); 
 363                $written_ot_totals_array[] = $ot_class;
 364                $written_ot_titles_array[] = $ot_title; 
 365  
 366              } //end 7
 367  
 368            } elseif ( ($new_ot_total) && (!in_array($order_totals[$i]['title'], $current_ot_titles_array)) ) { //within 6
 369  
 370              $new_order_totals[] = array('title' => $order_totals[$i]['title'],
 371                                          'text' => $order_totals[$i]['text'],
 372                                          'value' => $order_totals[$i]['value'],
 373                                          'code' => $order_totals[$i]['code'],
 374                                          'sort_order' => $j);
 375              $current_ot_totals_array[] = $order_totals[$i]['code'];
 376              $current_ot_titles_array[] = $order_totals[$i]['title'];
 377              $written_ot_totals_array[] = $ot_class;
 378              $written_ot_titles_array[] = $ot_title;
 379              $j++;
 380              //echo $order_totals[$i]['code'] . "<br>"; for debugging- use of this results in errors
 381  
 382            } elseif ($new_ot_total) { //also within 6
 383              $order->info['total'] += ($order_totals[$i]['value']*(-1));
 384              $current_ot_totals_array[] = $order_totals[$i]['code'];
 385              $written_ot_totals_array[] = $ot_class;
 386              $written_ot_titles_array[] = $ot_title;
 387            }//end 6
 388         }//end 4
 389       } elseif ( (tep_not_null($ot_value)) && (tep_not_null($ot_title)) ) { // this modifies if (!strstr($ot_class, 'ot_custom')) { //3
 390          $new_order_totals[] = array('title' => $ot_title,
 391                                      'text' => $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']),
 392                                      'value' => $ot_value,
 393                                      'code' => 'ot_custom_' . $j,
 394                                      'sort_order' => $j);
 395          $order->info['total'] += $ot_value;
 396          $written_ot_totals_array[] = $ot_class;
 397          $written_ot_titles_array[] = $ot_title;
 398          $j++;
 399        } //end 3
 400  
 401        //save ot_skippy from certain annihilation
 402        if ( (!in_array($ot_class, $written_ot_totals_array)) && (!in_array($ot_title, $written_ot_titles_array)) && (tep_not_null($ot_value)) && (tep_not_null($ot_title)) && ($ot_class != 'ot_tax') && ($ot_class != 'ot_loworderfee') ) { //7
 403        //this is supposed to catch the oddball components that don't show up in $order_totals
 404   
 405          $new_order_totals[] = array('title' => $ot_title,
 406                                      'text' => $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']),
 407                                      'value' => $ot_value,
 408                                      'code' => $ot_class,
 409                                      'sort_order' => $j);
 410          //$current_ot_totals_array[] = $order_totals[$i]['code'];
 411          //$current_ot_titles_array[] = $order_totals[$i]['title'];
 412          $written_ot_totals_array[] = $ot_class;
 413          $written_ot_titles_array[] = $ot_title;
 414          $j++;
 415   
 416        } //end 7
 417      } //end 2
 418    } else {//within 1
 419    // $_POST['update_totals'] is not an array => write in all order total components that have been generated by the sundry modules
 420      for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) { //8
 421        $new_order_totals[] = array('title' => $order_totals[$i]['title'],
 422                                    'text' => $order_totals[$i]['text'],
 423                                    'value' => $order_totals[$i]['value'],
 424                                    'code' => $order_totals[$i]['code'],
 425                                    'sort_order' => $j);
 426          $j++;
 427  
 428        } //end 8
 429  
 430      } //end if (is_array($_POST['update_totals'])) { //1
 431  
 432      for ($i=0, $n=sizeof($new_order_totals); $i<$n; $i++) {
 433        $sql_data_array = array('orders_id' => $oID,
 434                                'title' => $new_order_totals[$i]['title'],
 435                                'text' => $new_order_totals[$i]['text'],
 436                                'value' => $new_order_totals[$i]['value'], 
 437                                'class' => $new_order_totals[$i]['code'], 
 438                                'sort_order' => $new_order_totals[$i]['sort_order']);
 439        tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
 440      }
 441  
 442  
 443      if (isset($_POST['subaction'])) {
 444        switch($_POST['subaction']) {
 445          case 'add_product':
 446            tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=edit#products'));
 447            break;
 448        }
 449      }
 450  
 451      // 1.5 SUCCESS MESSAGE #####
 452  
 453  
 454    // CHECK FOR NEW EMAIL CONFIRMATION
 455  
 456      if ( (isset($_POST['nC1'])) || (isset($_POST['nC2'])) || (isset($_POST['nC3'])) ) {
 457    //then the user selected the option of sending a new email
 458  
 459      tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=email')); 
 460    //redirect to the email case
 461   
 462    } else  { 
 463       //email? email?  We don't need no stinkin email!
 464   
 465      if ($order_updated)  {
 466        $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
 467      }
 468  
 469      tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=edit'));
 470  
 471    }
 472  
 473    break;
 474  
 475    // 3. NEW ORDER EMAIL ###############################################################################################
 476    case 'email':
 477  
 478      $oID = tep_db_prepare_input($_GET['oID']);
 479      $order = new manualOrder($oID);
 480  
 481      for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
 482      //loop all the products in the order
 483      $products_ordered_attributes = '';
 484      if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
 485        for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
 486          $products_ordered_attributes .= "\n\t" . $order->products[$i]['attributes'][$j]['option'] . ' ' . $order->products[$i]['attributes'][$j]['value'];
 487        }
 488      }
 489  
 490      $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . $products_model . ' = ' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . $products_ordered_attributes . "\n";
 491    }
 492   
 493    //Build the email
 494    $email_order = STORE_NAME . "\n" . 
 495        EMAIL_SEPARATOR . "\n" . 
 496        EMAIL_TEXT_ORDER_NUMBER . ' ' . (int)$oID . "\n" .
 497        EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . (int)$oID, 'SSL') . "\n" .
 498        EMAIL_TEXT_DATE_MODIFIED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
 499  
 500    $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . 
 501                    EMAIL_SEPARATOR . "\n" . 
 502                    $products_ordered . 
 503                    EMAIL_SEPARATOR . "\n";
 504  
 505    for ($i=0, $n=sizeof($order->totals); $i<$n; $i++) {
 506      $email_order .= strip_tags($order->totals[$i]['title']) . ' ' . strip_tags($order->totals[$i]['text']) . "\n";
 507    }
 508  
 509    if ($order->content_type != 'virtual') {
 510      $email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . 
 511                      EMAIL_SEPARATOR . "\n" .
 512                      $order->delivery['name'] . "\n";
 513      if ($order->delivery['company']) {
 514      $email_order .= $order->delivery['company'] . "\n";
 515      }
 516      $email_order .= $order->delivery['street_address'] . "\n";
 517      if ($order->delivery['suburb']) {
 518        $email_order .= $order->delivery['suburb'] . "\n";
 519      }
 520      $email_order .= $order->customer['city'] . "\n";
 521      if ($order->delivery['state']) {
 522        $email_order .= $order->delivery['state'] . "\n";
 523      }
 524      $email_order .= $order->customer['postcode'] . "\n" .
 525                      $order->delivery['country'] . "\n";
 526      }
 527  
 528      $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" .
 529                      EMAIL_SEPARATOR . "\n" .
 530                      $order->billing['name'] . "\n";
 531      if ($order->billing['company']) {
 532        $email_order .= $order->billing['company'] . "\n";
 533      }
 534      $email_order .= $order->billing['street_address'] . "\n";
 535      if ($order->billing['suburb']) {
 536        $email_order .= $order->billing['suburb'] . "\n";
 537                        }
 538      $email_order .= $order->customer['city'] . "\n";
 539      if ($order->billing['state']) {
 540        $email_order .= $order->billing['state'] . "\n";
 541      }
 542      $email_order .= $order->customer['postcode'] . "\n" .
 543                      $order->billing['country'] . "\n\n";
 544  
 545      $email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . 
 546                      EMAIL_SEPARATOR . "\n";
 547      $email_order .= $order->info['payment_method'] . "\n\n";
 548  
 549  
 550        //  if ( ($order->info['payment_method'] == ORDER_EDITOR_SEND_INFO_PAYMENT_METHOD) && (EMAIL_TEXT_PAYMENT_INFO) ) { 
 551        //     $email_order .= EMAIL_TEXT_PAYMENT_INFO . "\n\n";
 552        //   }
 553        //I'm not entirely sure what the purpose of this is so it is being shelved for now
 554  
 555      if (EMAIL_TEXT_FOOTER) {
 556        $email_order .= EMAIL_TEXT_FOOTER . "\n\n";
 557      }
 558  
 559      //code for plain text emails which changes the  sign to EUR, otherwise the email will show ? instead of 
 560      $email_order = str_replace("","EUR",$email_order);
 561      $email_order = str_replace("&nbsp;"," ",$email_order);
 562  
 563      //code which replaces the <br> tags within EMAIL_TEXT_PAYMENT_INFO and EMAIL_TEXT_FOOTER with the proper \n
 564      $email_order = str_replace("<br>","\n",$email_order);
 565  
 566      //send the email to the customer
 567      tep_mail($order->customer['name'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
 568  
 569     // send emails to other people as necessary
 570      if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
 571        tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
 572      }
 573  
 574           //do the dirty
 575   
 576      $messageStack->add_session(SUCCESS_EMAIL_SENT, 'success');
 577  
 578      tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=edit'));
 579  
 580      break;
 581  
 582  
 583    ////
 584    // Edit Order
 585    case 'edit':
 586      if (!isset($_GET['oID'])) {
 587        $messageStack->add(ERROR_NO_ORDER_SELECTED, 'error');
 588        break;
 589      }
 590      $oID = tep_db_prepare_input($_GET['oID']);
 591      $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
 592      $order_exists = true;
 593      if (!tep_db_num_rows($orders_query)) {
 594        $order_exists = false;
 595        $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error');
 596        break;
 597      }
 598  
 599        $order = new manualOrder($oID);
 600        $shippingKey = $order->adjust_totals($oID);
 601        $order->adjust_zones();
 602  
 603        $cart = new manualCart();
 604        $cart->restore_contents($oID);
 605        $total_count = $cart->count_contents();
 606        $total_weight = $cart->show_weight();
 607  
 608        // Get the shipping quotes
 609        $shipping_modules = new shipping;
 610        $shipping_quotes = $shipping_modules->quote();
 611   
 612   
 613        break;
 614      }
 615    }
 616  
 617    // currecies drop-down array
 618    $currency_query = tep_db_query("select distinct title, code from " . TABLE_CURRENCIES . " order by code ASC");
 619    $currency_array = array();
 620    while($currency = tep_db_fetch_array($currency_query)) {
 621      $currency_array[] = array('id' => $currency['code'],
 622                                'text' => $currency['code'] . ' - ' . $currency['title']);
 623    }
 624  
 625  ?>
 626  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 627  "http://www.w3.org/TR/html4/loose.dtd">
 628  <html <?php echo HTML_PARAMS; ?>>
 629  <head>
 630  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 631  <title><?php echo TITLE; ?></title>
 632  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 633  
 634    <?php include ('order_editor/css.php');
 635        //because if you haven't got your css, what have you got?
 636        ?>
 637  
 638  <script language="javascript" src="includes/general.js"></script>
 639  
 640    <?php include ('order_editor/javascript.php');
 641        //because if you haven't got your javascript, what have you got?
 642        ?>
 643   
 644  </head>
 645  <body>
 646  <div id="dhtmltooltip"></div>
 647  
 648  <script type="text/javascript">
 649  
 650  /***********************************************
 651  * Cool DHTML tooltip script-  Dynamic Drive DHTML code library (www.dynamicdrive.com)
 652  * This notice MUST stay intact for legal use
 653  * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
 654  ***********************************************/
 655  
 656  /***********************************************
 657  * For Order Editor
 658  * This has to stay here for the tooltips to work correctly
 659  * I tried sticking it with the rest of the javascript, but it has to be inside the <body> tag
 660  *
 661  ***********************************************/
 662  
 663  var offsetxpoint=-60 //Customize x offset of tooltip
 664  var offsetypoint=20 //Customize y offset of tooltip
 665  var ie=document.all
 666  var ns6=document.getElementById && !document.all
 667  var enabletip=false
 668  if (ie||ns6)
 669  var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
 670  
 671  function ietruebody(){
 672  return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
 673  }
 674  
 675  function ddrivetip(thetext, thecolor, thewidth){
 676  if (ns6||ie){
 677  if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
 678  if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
 679  tipobj.innerHTML=thetext
 680  enabletip=true
 681  return false
 682  }
 683  }
 684  
 685  function positiontip(e){
 686  if (enabletip){
 687  var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
 688  var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
 689  //Find out how close the mouse is to the corner of the window
 690  var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
 691  var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
 692  
 693  var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
 694  
 695  //if the horizontal distance isn't enough to accomodate the width of the context menu
 696  if (rightedge<tipobj.offsetWidth)
 697  //move the horizontal position of the menu to the left by it's width
 698  tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
 699  else if (curX<leftedge)
 700  tipobj.style.left="5px"
 701  else
 702  //position the horizontal position of the menu where the mouse is positioned
 703  tipobj.style.left=curX+offsetxpoint+"px"
 704  
 705  //same concept with the vertical position
 706  if (bottomedge<tipobj.offsetHeight)
 707  tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
 708  else
 709  tipobj.style.top=curY+offsetypoint+"px"
 710  tipobj.style.visibility="visible"
 711  }
 712  }
 713  
 714  function hideddrivetip(){
 715  if (ns6||ie){
 716  enabletip=false
 717  tipobj.style.visibility="hidden"
 718  tipobj.style.left="-1000px"
 719  tipobj.style.backgroundColor='white'
 720  tipobj.style.width='200'
 721  }
 722  }
 723  
 724  document.onmousemove=positiontip
 725  
 726  </script>
 727  
 728  <!-- header //-->
 729  <?php require (DIR_WS_INCLUDES . 'header.php'); ?>
 730  <!-- header_eof //-->
 731  
 732  <!-- body //-->
 733  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 734    <tr>
 735      <td width="<?php echo BOX_WIDTH; ?>" valign="top">
 736      <table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
 737  <!-- left_navigation //-->
 738  <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?>
 739  <!-- left_navigation_eof //-->
 740      </table>
 741      </td>
 742  <!-- body_text //-->
 743      <td width="100%" valign="top">
 744  
 745   <?php
 746   
 747     if (($action == 'edit') && ($order_exists == true)) {
 748   
 749     echo tep_draw_form('edit_order', FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=update_order');
 750  
 751   ?>
 752  
 753        <div id="header">
 754  
 755        <p id="headerTitle" class="pageHeading"><?php echo sprintf(HEADING_TITLE, $oID, tep_datetime_short($order->info['date_purchased'])); ?></p>
 756  
 757            <ul>
 758  
 759         <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>
 760          <script language="JavaScript" type="text/javascript"><!--
 761          //this button only works with javascript and is therefore only displayed on browsers with javascript enabled
 762                document.write("<li><a href=\"javascript:newOrderEmail()\"><img src=\"includes/languages/<?php echo $language; ?>/images/buttons/button_new_order_email.gif\" border=\"0\" alt=\"<?php echo IMAGE_NEW_ORDER_EMAIL; ?>\" title=\"<?php echo IMAGE_NEW_ORDER_EMAIL; ?>\" ></a></li>");
 763               //--></script>
 764           <?php } ?>
 765  
 766          <li><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $_GET['oID'] . '&action=edit') . '">' . tep_image_button('button_details.gif', IMAGE_EDIT) . '</a>'; ?></li>
 767          <li><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $_GET['oID']) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a>'; ?></li>
 768          <li><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $_GET['oID']) . '" TARGET="_blank">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a>'; ?></li>
 769          <li><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a> '; ?></li>
 770        </ul>
 771  
 772      </div>
 773   
 774        <div id="ordersMessageStack">
 775           <?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?>
 776        </div>
 777  
 778    <?php if (ORDER_EDITOR_USE_AJAX != 'true') { ?>
 779    <!-- Begin Update Block, only for non-ajax use -->
 780  
 781             <div class="updateBlock">
 782                <div class="update1"><?php echo HINT_PRESS_UPDATE; ?></div>
 783                <div class="update2">&nbsp;</div>
 784                <div class="update3">&nbsp;</div>
 785                <div class="update4" align="center"><?php echo ENTRY_SEND_NEW_ORDER_CONFIRMATION; ?>&nbsp;<?php echo tep_draw_checkbox_field('nC1', '', false); ?></div>
 786                <div class="update5" align="center"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?></div>
 787            </div>
 788  
 789      <br>
 790      <br>
 791      <!-- End of Update Block -->
 792      <?php } ?>
 793  
 794  
 795      <!-- customer_info bof //-->
 796  
 797          <table border="0" cellspacing="0" cellpadding="2">
 798            <tr>
 799              <td valign="top">
 800              <!-- customer_info bof //-->
 801              <table width="100%" border="0" cellspacing="0" cellpadding="2" style="border: 1px solid #C9C9C9;">
 802                <tr class="dataTableHeadingRow"> 
 803                  <td colspan="4" class="dataTableHeadingContent" valign="top"><?php echo ENTRY_CUSTOMER; ?></td>
 804                </tr>
 805                <tr class="dataTableRow"> 
 806                  <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_NAME; ?></td>
 807                  <td colspan="3" valign="top" class="dataTableContent"><input name="update_customer_name" size="37" value="<?php echo stripslashes($order->customer['name']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_name', encodeURIComponent(this.value))"<?php } ?>></td>
 808                </tr>
 809                <tr class="dataTableRow"> 
 810                  <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_COMPANY; ?></td>
 811                  <td colspan="3" valign="top" class="dataTableContent"><input name="update_customer_company" size="37" value="<?php echo stripslashes($order->customer['company']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_company', encodeURIComponent(this.value))"<?php } ?>></td>
 812                </tr>
 813                <tr class="dataTableRow"> 
 814                  <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_STREET_ADDRESS; ?></td>
 815                  <td colspan="3" valign="top" class="dataTableContent" nowrap><input name="update_customer_street_address" size="37" value="<?php echo stripslashes($order->customer['street_address']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_street_address', encodeURIComponent(this.value))"<?php } ?>></td>
 816                </tr>
 817                <tr class="dataTableRow"> 
 818                  <td class="dataTableContent" valign="middle" align="right"><?php echo ENTRY_SUBURB; ?></td>
 819                  <td colspan="3" valign="top" class="dataTableContent" nowrap><input name="update_customer_suburb" size="37" value="<?php echo stripslashes($order->customer['suburb']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_suburb', encodeURIComponent(this.value))"<?php } ?>></td>
 820                </tr>
 821                <tr class="dataTableRow"> 
 822                  <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_CITY_STATE; ?></td>
 823                  <td colspan="2" valign="top" class="dataTableContent" nowrap><input name="update_customer_city" size="15" value="<?php echo stripslashes($order->customer['city']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_city', encodeURIComponent(this.value))"<?php } ?>>,</td>
 824                  <td valign="top" class="dataTableContent"><span id="customerStateMenu">
 825          <?php if (ORDER_EDITOR_USE_AJAX == 'true') {
 826          echo tep_draw_pull_down_menu('update_customer_zone_id', tep_get_country_zones($order->customer['country_id']), $order->customer['zone_id'], 'style="width: 200px;" onChange="updateOrdersField(\'customers_state\', this.options[this.selectedIndex].text);"'); 
 827          } else {
 828          echo tep_draw_pull_down_menu('update_customer_zone_id', tep_get_country_zones($order->customer['country_id']), $order->customer['zone_id'], 'style="width: 200px;"');
 829          }?></span><span id="customerStateInput"><input name="update_customer_state" size="15" value="<?php echo stripslashes($order->customer['state']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_state', encodeURIComponent(this.value))"<?php } ?>></span></td>
 830                </tr>
 831                <tr class="dataTableRow"> 
 832                  <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_POST_CODE; ?></td>
 833                  <td class="dataTableContent" valign="top"><input name="update_customer_postcode" size="5" value="<?php echo $order->customer['postcode']; ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_postcode', encodeURIComponent(this.value))"<?php } ?>></td>
 834                  <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_COUNTRY; ?></td>
 835                  <td class="dataTableContent" valign="top">
 836          <?php if (ORDER_EDITOR_USE_AJAX == 'true') {
 837          echo tep_draw_pull_down_menu('update_customer_country_id', tep_get_countries(), $order->customer['country_id'], 'style="width: 200px;" onChange="update_zone(\'update_customer_country_id\', \'update_customer_zone_id\', \'customerStateInput\', \'customerStateMenu\'); updateOrdersField(\'customers_country\', this.options[this.selectedIndex].text);"'); 
 838          } else {
 839          echo tep_draw_pull_down_menu('update_customer_country_id', tep_get_countries(), $order->customer['country_id'], 'style="width: 200px;" onChange="update_zone(\'update_customer_country_id\', \'update_customer_zone_id\', \'customerStateInput\', \'customerStateMenu\');"'); 
 840          } ?></td>
 841                </tr>
 842                <tr class="dataTableRow"> 
 843                  <td colspan="4" style="border-top: 1px solid #C9C9C9;"><?php echo tep_draw_separator('pixel_trans.gif', '1', '1'); ?></td>
 844                </tr>
 845                <tr class="dataTableRow"> 
 846                  <td class="dataTableContent" valign="middle" align="right"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td>
 847                  <td colspan="3" valign="top" class="dataTableContent"><input name="update_customer_telephone" size="15" value="<?php echo $order->customer['telephone']; ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_telephone', encodeURIComponent(this.value))"<?php } ?>></td>
 848                </tr>
 849                <tr class="dataTableRow"> 
 850                  <td class="dataTableContent" valign="middle" align="right"><?php echo ENTRY_EMAIL_ADDRESS; ?></td>
 851                  <td colspan="3" valign="top" class="dataTableContent"><input name="update_customer_email_address" size="35" value="<?php echo $order->customer['email_address']; ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_email_address', encodeURIComponent(this.value))"<?php } ?>></td>
 852                </tr>
 853              </table>
 854  
 855        <!-- customer_info_eof //-->
 856              <!-- shipping_address bof -->
 857              <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border: 1px solid #C9C9C9;">
 858                <tr>
 859                  <td class="dataTableContent">
 860                  <table width="100%" cellspacing="0" cellpadding="2">
 861                    <tr class="dataTableHeadingRow"> 
 862             <td class="dataTableHeadingContent" valign="top" onMouseover="ddrivetip('<?php echo oe_html_no_quote(HINT_SHIPPING_ADDRESS); ?>')"; onMouseout="hideddrivetip()"><?php echo ENTRY_SHIPPING_ADDRESS; ?> 
 863               <script language="JavaScript" type="text/javascript">
 864                     <!--
 865                      document.write("<img src=\"images/icon_info.gif\" border= \"0\" width=\"13\" height=\"13\">");
 866                   //-->
 867                    </script>
 868  
 869          </td>
 870                    </tr>
 871  
 872                    <?php if (ORDER_EDITOR_USE_AJAX != 'true') { ?>
 873            <tr class="dataTableRow"> 
 874                      <td valign="middle" class="dataTableContent"><input type="checkbox" name="shipping_same_as_billing"> <?php echo TEXT_SHIPPING_SAME_AS_BILLING; ?></td>
 875                    </tr>
 876            <?php } ?>
 877  
 878                  </table>
 879                  </td>
 880                </tr>
 881                <tr id="shippingAddressEntry">
 882                  <td class="dataTableContent">
 883                  <table width="100%" cellspacing="0" cellpadding="2">
 884                    <tr class="dataTableRow"> 
 885                      <td colspan="4" style="border-top: 1px solid #C9C9C9;"><?php echo tep_draw_separator('pixel_trans.gif', '1', '1'); ?></td>
 886                    </tr>
 887                    <tr class="dataTableRow"> 
 888                      <td class="dataTableContent" valign="middle" align="right"><?php echo ENTRY_NAME; ?></td>
 889                      <td colspan="3" valign="top" class="dataTableContent"><input name="update_delivery_name" size="37" value="<?php echo stripslashes($order->delivery['name']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('delivery_name', encodeURIComponent(this.value))"<?php } ?>></td>
 890                    </tr>
 891                    <tr class="dataTableRow"> 
 892                      <td class="dataTableContent" valign="middle" align="right"><?php echo ENTRY_COMPANY; ?></td>
 893                      <td colspan="3" valign="top" class="dataTableContent"><input name="update_delivery_company" size="37" value="<?php echo stripslashes($order->delivery['company']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('delivery_company', encodeURIComponent(this.value))"<?php } ?>></td>
 894                    </tr>
 895                    <tr class="dataTableRow"> 
 896                      <td class="dataTableContent" valign="middle" align="right"><?php echo ENTRY_STREET_ADDRESS; ?></td>
 897                      <td colspan="3" valign="top" class="dataTableContent"><input name="update_delivery_street_address" size="37" value="<?php echo stripslashes($order->delivery['street_address']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('delivery_street_address', encodeURIComponent(this.value))"<?php } ?>></td>
 898                    </tr>
 899                    <tr class="dataTableRow"> 
 900                      <td class="dataTableContent" valign="middle" align="right"><?php echo ENTRY_SUBURB; ?></td>
 901                      <td colspan="3" valign="top" class="dataTableContent"><input name="update_delivery_suburb" size="37" value="<?php echo stripslashes($order->delivery['suburb']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('delivery_suburb', encodeURIComponent(this.value))"<?php } ?>></td>
 902                    </tr>
 903                    <tr class="dataTableRow">
 904                      <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_CITY_STATE; ?></td>
 905                      <td colspan="2" valign="top" class="dataTableContent" nowrap><input name="update_delivery_city" size="15" value="<?php echo stripslashes($order->delivery['city']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('delivery_city', encodeURIComponent(this.value))"<?php } ?>>,</td>
 906                      <td valign="top" class="dataTableContent"><span id="deliveryStateMenu">
 907            <?php if (ORDER_EDITOR_USE_AJAX == 'true') { 
 908          echo tep_draw_pull_down_menu('update_delivery_zone_id', tep_get_country_zones($order->delivery['country_id']), $order->delivery['zone_id'], 'style="width: 200px;" onChange="updateShippingZone(\'delivery_state\', this.options[this.selectedIndex].text);"'); 
 909            } else {
 910            echo tep_draw_pull_down_menu('update_delivery_zone_id', tep_get_country_zones($order->delivery['country_id']), $order->delivery['zone_id'], 'style="width: 200px;"'); 
 911            } ?>
 912            </span><span id="deliveryStateInput"><input name="update_delivery_state" size="15" value="<?php echo stripslashes($order->delivery['state']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateShippingZone('delivery_state', encodeURIComponent(this.value))"<?php } ?>></span></td>
 913                    </tr>
 914                    <tr class="dataTableRow"> 
 915                      <td class="dataTableContent" valign="middle" align="right"><?php echo ENTRY_POST_CODE; ?></td>
 916                      <td class="dataTableContent" valign="top"><input name="update_delivery_postcode" size="5" value="<?php echo $order->delivery['postcode']; ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateShippingZone('delivery_postcode', encodeURIComponent(this.value))"<?php } ?>></td>
 917                      <td class="dataTableContent" valign="middle" align="right"><?php echo ENTRY_COUNTRY; ?></td>
 918                      <td class="dataTableContent" valign="top">
 919            <?php if (ORDER_EDITOR_USE_AJAX == 'true') {
 920            echo tep_draw_pull_down_menu('update_delivery_country_id', tep_get_countries(), $order->delivery['country_id'], 'style="width: 200px;" onchange="update_zone(\'update_delivery_country_id\', \'update_delivery_zone_id\', \'deliveryStateInput\', \'deliveryStateMenu\'); updateShippingZone(\'delivery_country\', this.options[this.selectedIndex].text);"'); 
 921            } else {
 922            echo tep_draw_pull_down_menu('update_delivery_country_id', tep_get_countries(), $order->delivery['country_id'], 'style="width: 200px;" onchange="update_zone(\'update_delivery_country_id\', \'update_delivery_zone_id\', \'deliveryStateInput\', \'deliveryStateMenu\');"'); 
 923            }
 924            ?></td>
 925                    </tr> 
 926                  </table>
 927                  </td>
 928                </tr>
 929              </table>
 930              <!-- shipping_address_eof //-->
 931              </td>
 932              <td valign="top" width="10">&nbsp;</td>
 933              <td valign="top">
 934              <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border: 1px solid #C9C9C9;">
 935                <!-- billing_address bof //-->
 936                <tr>
 937                  <td class="dataTableContent">
 938                  <table width="100%" cellspacing="0" cellpadding="2">
 939                    <tr class="dataTableHeadingRow"> 
 940                      <td colspan="4" class="dataTableHeadingContent" valign="top"><?php echo ENTRY_BILLING_ADDRESS; ?></td>
 941                    </tr>
 942  
 943            <?php if (ORDER_EDITOR_USE_AJAX != 'true') { ?>
 944                    <tr class="dataTableRow"> 
 945                      <td colspan="4" valign="middle" class="dataTableContent"><input type="checkbox" name="billing_same_as_customer"> <?php echo TEXT_BILLING_SAME_AS_CUSTOMER; ?></td>
 946                    </tr>
 947            <?php } ?>
 948  
 949                  </table>
 950                  </td>
 951                </tr>
 952                <tr id="billingAddressEntry">
 953                  <td class="dataTableContent">
 954                  <table width="100%" cellspacing="0" cellpadding="2"> 
 955                    <tr class="dataTableRow">
 956                      <td colspan="4" style="border-top: 1px solid #C9C9C9;"><?php echo tep_draw_separator('pixel_trans.gif', '1', '1'); ?></td>
 957                    </tr>
 958                    <tr class="dataTableRow"> 
 959                      <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_NAME; ?></td>
 960                      <td colspan="3" valign="top" class="dataTableContent"><input name="update_billing_name" size="37" value="<?php echo stripslashes($order->billing['name']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('billing_name', encodeURIComponent(this.value))"<?php } ?>></td>
 961                    </tr>
 962                    <tr class="dataTableRow"> 
 963                      <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_COMPANY; ?></td>
 964                      <td colspan="3" valign="top" class="dataTableContent"><input name="update_billing_company" size="37" value="<?php echo stripslashes($order->billing['company']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('billing_company', encodeURIComponent(this.value))"<?php } ?>></td>
 965                    </tr>
 966                    <tr class="dataTableRow"> 
 967                      <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_STREET_ADDRESS; ?></td>
 968                      <td colspan="3" valign="top" class="dataTableContent"><input name="update_billing_street_address" size="37" value="<?php echo stripslashes($order->billing['street_address']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('billing_street_address', encodeURIComponent(this.value))"<?php } ?>></td>
 969                    </tr>
 970                    <tr class="dataTableRow"> 
 971                      <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_SUBURB; ?></td>
 972                      <td colspan="3" valign="top" class="dataTableContent"><input name="update_billing_suburb" size="37" value="<?php echo stripslashes($order->billing['suburb']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('billing_suburb', encodeURIComponent(this.value))"<?php } ?>></td>
 973                    </tr>
 974                    <tr class="dataTableRow"> 
 975                      <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_CITY_STATE; ?></td>
 976                      <td colspan="2" valign="top" class="dataTableContent" nowrap><input name="update_billing_city" size="15" value="<?php echo stripslashes($order->billing['city']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('billing_city', encodeURIComponent(this.value))"<?php } ?>>,</td>
 977                      <td valign="top" class="dataTableContent"><span id="billingStateMenu">
 978            <?php if (ORDER_EDITOR_USE_AJAX == 'true') {
 979            echo tep_draw_pull_down_menu('update_billing_zone_id', tep_get_country_zones($order->billing['country_id']), $order->billing['zone_id'], 'style="width: 200px;" onChange="updateOrdersField(\'billing_state\', this.options[this.selectedIndex].text);"'); 
 980            } else {
 981            echo tep_draw_pull_down_menu('update_billing_zone_id', tep_get_country_zones($order->billing['country_id']), $order->billing['zone_id'], 'style="width: 200px;"');
 982            } ?>
 983            </span><span id="billingStateInput"><input name="update_billing_state" size="15" value="<?php echo stripslashes($order->billing['state']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('billing_state', encodeURIComponent(this.value))"<?php } ?>></span></td>
 984                    </tr>
 985                    <tr class="dataTableRow"> 
 986                      <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_POST_CODE; ?></td>
 987                      <td class="dataTableContent" valign="top"><input name="update_billing_postcode" size="5" value="<?php echo $order->billing['postcode']; ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('billing_postcode', encodeURIComponent(this.value))"<?php } ?>></td>
 988                      <td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_COUNTRY; ?></td>
 989                      <td class="dataTableContent" valign="top">
 990            <?php if (ORDER_EDITOR_USE_AJAX == 'true') {
 991            echo tep_draw_pull_down_menu('update_billing_country_id', tep_get_countries(), $order->billing['country_id'], 'style="width: 200px;" onchange="update_zone(\'update_billing_country_id\', \'update_billing_zone_id\', \'billingStateInput\', \'billingStateMenu\'); updateOrdersField(\'billing_country\', this.options[this.selectedIndex].text);"'); 
 992            } else {
 993            echo tep_draw_pull_down_menu('update_billing_country_id', tep_get_countries(), $order->billing['country_id'], 'style="width: 200px;" onchange="update_zone(\'update_billing_country_id\', \'update_billing_zone_id\', \'billingStateInput\', \'billingStateMenu\'); updateOrdersField(\'billing_country\', this.options[this.selectedIndex].text);"'); 
 994            } ?></td>
 995                    </tr>
 996                  </table>
 997                  </td>
 998                </tr>
 999                <!-- billing_address_eof //-->
1000                <!-- payment_method bof //-->
1001                <tr>
1002                  <td class="dataTableContent">
1003   
1004        <table cellspacing="0" cellpadding="2" width="100%">
1005          <tr class="dataTableHeadingRow"> 
1006            <td colspan="2" class="dataTableHeadingContent" valign="bottom" onMouseover="ddrivetip('<?php echo oe_html_no_quote(HINT_UPDATE_TO_CC); ?>')" onMouseout="hideddrivetip()"><?php echo ENTRY_PAYMENT_METHOD; ?>
1007  
1008            <script language="JavaScript" type="text/javascript">
1009                     <!--
1010                      document.write("<img src=\"images/icon_info.gif\" border= \"0\" width=\"13\" height=\"13\">");
1011                   //-->
1012                    </script>
1013  
1014        </td>
1015  
1016           <td></td>
1017             <td class="dataTableHeadingContent" valign="bottom" onMouseover="ddrivetip('<?php echo oe_html_no_quote(HINT_UPDATE_CURRENCY); ?>')" onMouseout="hideddrivetip()"><?php echo ENTRY_CURRENCY_TYPE; ?> 
1018  
1019              <script language="JavaScript" type="text/javascript">
1020                     <!--
1021                      document.write("<img src=\"images/icon_info.gif\" border= \"0\" width=\"13\" height=\"13\">");
1022                   //-->
1023                    </script>
1024  
1025               </td>
1026             <td></td>
1027             <td class="dataTableHeadingContent"><?php echo ENTRY_CURRENCY_VALUE; ?></td>
1028           </tr>
1029  
1030         <tr class="dataTableRow"> 
1031           <td colspan="2" class="main">
1032           <?php 
1033            //START for payment dropdown menu use this by quick_fixer
1034              if (ORDER_EDITOR_PAYMENT_DROPDOWN == 'true') { 
1035  
1036          // Get list of all payment modules available
1037              $enabled_payment = array();
1038              $module_directory = DIR_FS_CATALOG_MODULES . 'payment/';
1039              $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
1040  
1041               if ($dir = @dir($module_directory)) {
1042                while ($file = $dir->read()) {
1043                 if (!is_dir( $module_directory . $file)) {
1044                  if (substr($file, strrpos($file, '.')) == $file_extension) {
1045                     $directory_array[] = $file;
1046                   }
1047                 }
1048               }
1049              sort($directory_array);
1050              $dir->close();
1051             }
1052  
1053            // For each available payment module, check if enabled
1054            for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {
1055            $file = $directory_array[$i];
1056  
1057            include(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/payment/' . $file);
1058            include($module_directory . $file);
1059  
1060            $class = substr($file, 0, strrpos($file, '.'));
1061            if (tep_class_exists($class)) {
1062               $module = new $class;
1063               if ($module->check() > 0) {
1064                // If module enabled create array of titles
1065                 $enabled_payment[] = array('id' => $module->title, 'text' => $module->title);
1066  
1067            //if the payment method is the same as the payment module title then don't add it to dropdown menu
1068            if ($module->title == $order->info['payment_method']) {
1069              $paymentMatchExists='true';
1070               }
1071                }
1072              }
1073            }
1074       //just in case the payment method found in db is not the same as the payment module title then make it part of the dropdown array or else it cannot be the selected default value
1075        if ($paymentMatchExists !='true') {
1076        $enabled_payment[] = array('id' => $order->info['payment_method'], 'text' => $order->info['payment_method']);
1077             }
1078              $enabled_payment[] = array('id' => 'Other', 'text' => 'Other');
1079          //draw the dropdown menu for payment methods and default to the order value
1080            if (ORDER_EDITOR_USE_AJAX == 'true') {
1081          echo tep_draw_pull_down_menu('update_info_payment_method', $enabled_payment, $order->info['payment_method'], 'id="update_info_payment_method" style="width: 150px;" onChange="init(); updateOrdersField(\'payment_method\', this.options[this.selectedIndex].text)"'); 
1082          } else {
1083          echo tep_draw_pull_down_menu('update_info_payment_method', $enabled_payment, $order->info['payment_method'], 'id="update_info_payment_method" style="width: 150px;" onChange="init();"'); 
1084          }
1085          }  else { //draw the input field for payment methods and default to the order value  ?>
1086  
1087         <input name="update_info_payment_method" size="35" value="<?php echo $order->info['payment_method']; ?>" id="update_info_payment_method" onChange="init();<?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?> updateOrdersField('payment_method', encodeURIComponent(this.value));<?php } ?>">
1088   
1089         <?php } //END for payment dropdown menu use this by quick_fixer ?>
1090   
1091         </td>
1092  
1093           <td width="20">
1094           </td>
1095  
1096            <td>
1097         <?php
1098             ///get the currency info
1099                reset($currencies->currencies);
1100                $currencies_array = array();
1101                  while (list($key, $value) = each($currencies->currencies)) {
1102                        $currencies_array[] = array('id' => $key, 'text' => $value['title']);
1103                   }
1104  
1105                 echo tep_draw_pull_down_menu('update_info_payment_currency', $currencies_array, $order->info['currency'], 'id="update_info_payment_currency" onChange="currency(this.value)"'); 
1106  
1107  ?>
1108            </td>
1109  
1110           <td width="10">
1111           </td>
1112  
1113         <td>
1114        <input name="update_info_payment_currency_value" size="15" readonly="readonly" id="update_info_payment_currency_value" value="<?php echo $order->info['currency_value']; ?>">
1115       </td>
1116        </tr>
1117  
1118                    <!-- credit_card bof //-->
1119      <tr class="dataTableRow"> 
1120        <td colspan="6">
1121  
1122      <table id="optional"><!--  -->
1123     <tr>
1124        <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
1125      </tr>
1126      <tr>
1127        <td class="main"><?php echo ENTRY_CREDIT_CARD_TYPE; ?></td>
1128    <td class="main"><input name="update_info_cc_type" size="32" value="<?php echo $order->info['cc_type']; ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('cc_type', encodeURIComponent(this.value))"<?php } ?>></td>
1129      </tr>
1130      <tr>
1131        <td class="main"><?php echo ENTRY_CREDIT_CARD_OWNER; ?></td>
1132        <td class="main"><input name="update_info_cc_owner" size="32" value="<?php echo $order->info['cc_owner']; ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('cc_owner', encodeURIComponent(this.value))<?php } ?>"></td>
1133      </tr>
1134      <tr>
1135        <td class="main"><?php echo ENTRY_CREDIT_CARD_NUMBER; ?></td>
1136        <td class="main"><input name="update_info_cc_number" size="32" value="<?php echo $order->info['cc_number']; ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('cc_number', encodeURIComponent(this.value))"<?php } ?>></td>
1137      </tr>
1138      <tr>
1139        <td class="main"><?php echo ENTRY_CREDIT_CARD_EXPIRES; ?></td>
1140        <td class="main"><input name="update_info_cc_expires" size="4" value="<?php echo $order->info['cc_expires']; ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('cc_expires', encodeURIComponent(this.value))"<?php } ?>></td>
1141      </tr>
1142    </table>
1143  
1144     </td>
1145    </tr>
1146   </table>
1147  
1148          </td>
1149                </tr>
1150              </table></td>
1151            </tr>
1152          </table>
1153  
1154    <div id="productsMessageStack">
1155      <?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?>
1156      </div>
1157  
1158  
1159    <div width="100%" style="border: 1px solid #C9C9C9;"> 
1160      <a name="products"></a>
1161      <!-- product_listing bof //-->
1162   
1163      <table border="0" width="100%" cellspacing="0" cellpadding="2" id="productsTable">
1164        <tr class="dataTableHeadingRow">
1165        <td class="dataTableHeadingContent"><div align="center"><?php echo TABLE_HEADING_DELETE; ?></div></td>
1166        <td class="dataTableHeadingContent"><div align="center"><?php echo TABLE_HEADING_QUANTITY; ?></div></td>
1167        <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
1168        <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
1169        <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_TAX; ?></td>
1170        <td class="dataTableHeadingContent" onMouseover="ddrivetip('<?php echo oe_html_no_quote(HINT_BASE_PRICE); ?>')"; onMouseout="hideddrivetip()"><?php  echo TABLE_HEADING_BASE_PRICE; ?> <script language="JavaScript" type="text/javascript">
1171        <!--
1172        document.write("<img src=\"images/icon_info.gif\" border= \"0\" width=\"13\" height=\"13\">");
1173        //-->
1174        </script></td>
1175        <td class="dataTableHeadingContent" onMouseover="ddrivetip('<?php echo oe_html_no_quote(HINT_PRICE_EXCL); ?>')"; onMouseout="hideddrivetip()"><?php  echo TABLE_HEADING_UNIT_PRICE; ?> <script language="JavaScript" type="text/javascript">
1176        <!--
1177        document.write("<img src=\"images/icon_info.gif\" border= \"0\" width=\"13\" height=\"13\">");
1178        //-->
1179        </script></td>
1180        <td class="dataTableHeadingContent" onMouseover="ddrivetip('<?php echo oe_html_no_quote(HINT_PRICE_INCL); ?>')"; onMouseout="hideddrivetip()"><?php  echo TABLE_HEADING_UNIT_PRICE_TAXED; ?> <script language="JavaScript" type="text/javascript">
1181        <!--
1182        document.write("<img src=\"images/icon_info.gif\" border= \"0\" width=\"13\" height=\"13\">");
1183        //-->
1184        </script></td>
1185        <td class="dataTableHeadingContent" onMouseover="ddrivetip('<?php echo oe_html_no_quote(HINT_TOTAL_EXCL); ?>')"; onMouseout="hideddrivetip()"><?php  echo TABLE_HEADING_TOTAL_PRICE; ?> <script language="JavaScript" type="text/javascript">
1186        <!--
1187        document.write("<img src=\"images/icon_info.gif\" border= \"0\" width=\"13\" height=\"13\">");
1188        //-->
1189        </script></td>
1190        <td class="dataTableHeadingContent" onMouseover="ddrivetip('<?php echo oe_html_no_quote(HINT_TOTAL_INCL); ?>')"; onMouseout="hideddrivetip()"><?php  echo TABLE_HEADING_TOTAL_PRICE_TAXED; ?> <script language="JavaScript" type="text/javascript">
1191        <!--
1192        document.write("<img src=\"images/icon_info.gif\" border= \"0\" width=\"13\" height=\"13\">");
1193        //-->
1194        </script></td>
1195      </tr>
1196  <?php
1197    if (sizeof($order->products)) {
1198      for ($i=0; $i<sizeof($order->products); $i++) {
1199        $orders_products_id = $order->products[$i]['orders_products_id'];  ?>
1200   
1201      <tr class="dataTableRow">
1202  
1203        <td class="dataTableContent" valign="top"><div align="center"><input type="checkbox" name="<?php echo "update_products[" . $orders_products_id . "][delete]"; ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onClick="updateProductsField('delete', '<?php echo $orders_products_id; ?>', 'delete', this.checked, this)"<?php } ?>></div></td>
1204        <td class="dataTableContent" valign="top"><div align="center"><input name="<?php echo "update_products[" . $orders_products_id . "][qty]"; ?>" size="2" onKeyUp="updatePrices('qty', '<?php echo $orders_products_id; ?>')" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateProductsField('reload1', '<?php echo $orders_products_id; ?>', 'products_quantity', encodeURIComponent(this.value))"<?php } ?> value="<?php echo $order->products[$i]['qty']; ?>" id="<?php echo "update_products[" . $orders_products_id . "][qty]"; ?>"></div></td>
1205        <td class="dataTableContent" valign="top"><input name="<?php echo "update_products[" . $orders_products_id . "][name]"; ?>" size="50" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateProductsField('update', '<?php echo $orders_products_id; ?>', 'products_name', encodeURIComponent(this.value))"<?php } ?> value='<?php echo oe_html_quotes($order->products[$i]['name']); ?>'>
1206  
1207    <?php
1208        // Has Attributes?
1209        if (isset($order->products[$i]['attributes']) && (sizeof($order->products[$i]['attributes']) > 0)) {
1210          for ($j=0; $j<sizeof($order->products[$i]['attributes']); $j++) {
1211            $orders_products_attributes_id = $order->products[$i]['attributes'][$j]['orders_products_attributes_id'];
1212          if (ORDER_EDITOR_USE_AJAX == 'true') {
1213            echo '<br><nobr><small>&nbsp;<i> - ' . "<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][option]' size='6' value='" . oe_html_quotes($order->products[$i]['attributes'][$j]['option']) . "' onChange=\"updateAttributesField('simple', 'products_options', '" . $orders_products_attributes_id . "', '" . $orders_products_id . "', encodeURIComponent(this.value))\">" . ': ' . "<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][value]' size='10' value='" . oe_html_quotes($order->products[$i]['attributes'][$j]['value']) . "' onChange=\"updateAttributesField('simple', 'products_options_values', '" . $orders_products_attributes_id . "', '" . $orders_products_id . "', encodeURIComponent(this.value))\">" . ': ' . "</i><input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][prefix]' size='1' id='p" . $orders_products_id . "_" . $orders_products_attributes_id . "_prefix' value='" . $order->products[$i]['attributes'][$j]['prefix'] . "' onKeyUp=\"updatePrices('att_price', '" . $orders_products_id . "')\" onChange=\"updateAttributesField('hard', 'price_prefix', '" . $orders_products_attributes_id . "', '" . $orders_products_id . "', encodeURIComponent(this.value))\">" . ': ' . "<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][price]' size='7' value='" . $order->products[$i]['attributes'][$j]['price'] . "' onKeyUp=\"updatePrices('att_price', '" . $orders_products_id . "')\" onChange=\"updateAttributesField('hard', 'options_values_price', '" . $orders_products_attributes_id . "', '" . $orders_products_id . "', encodeURIComponent(this.value))\" id='p". $orders_products_id . "a" . $orders_products_attributes_id . "'>";
1214          } else {
1215            echo '<br><nobr><small>&nbsp;<i> - ' . "<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][option]' size='6' value='" . oe_html_quotes($order->products[$i]['attributes'][$j]['option']) . "'>" . ': ' . "<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][value]' size='10' value='" . oe_html_quotes($order->products[$i]['attributes'][$j]['value']) . "'>" . ': ' . "</i><input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][prefix]' size='1' id='p" . $orders_products_id . "_" . $orders_products_attributes_id . "_prefix' value='" . $order->products[$i]['attributes'][$j]['prefix'] . "' onKeyUp=\"updatePrices('att_price', '" . $orders_products_id . "')\">" . ': ' . "<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][price]' size='7' value='" . $order->products[$i]['attributes'][$j]['price'] . "' onKeyUp=\"updatePrices('att_price', '" . $orders_products_id . "')\" id='p". $orders_products_id . "a" . $orders_products_attributes_id . "'>";
1216          }
1217          echo '</small></nobr>';
1218        }  //end for ($j=0; $j<sizeof($order->products[$i]['attributes']); $j++) {
1219  
1220        //Has downloads?
1221  
1222      if (DOWNLOAD_ENABLED == 'true') {
1223        $downloads_count = 1;
1224        $d_index = 0;
1225        $download_query_raw ="SELECT orders_products_download_id, orders_products_filename, download_maxdays, download_count
1226                             FROM " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " 
1227                             WHERE orders_products_id='" . $orders_products_id . "'
1228                             AND orders_id='" . (int)$oID . "'
1229                             ORDER BY orders_products_download_id";
1230  
1231        $download_query = tep_db_query($download_query_raw);
1232  
1233        //
1234        if (isset($downloads->products)) unset($downloads->products);
1235        //
1236  
1237        if (tep_db_num_rows($download_query) > 0) {
1238          while ($download = tep_db_fetch_array($download_query)) {
1239  
1240            $downloads->products[$d_index] = array(
1241                      'id' => $download['orders_products_download_id'],
1242                      'filename' => $download['orders_products_filename'],
1243                      'maxdays' => $download['download_maxdays'],
1244                      'maxcount' => $download['download_count']);
1245  
1246            $d_index++; 
1247          } 
1248        }
1249  
1250        if (isset($downloads->products) && (sizeof($downloads->products) > 0)) {
1251          for ($mm=0; $mm<sizeof($downloads->products); $mm++) {
1252            $id =  $downloads->products[$mm]['id'];
1253            echo '<br><small>';
1254            echo '<nobr>' . ENTRY_DOWNLOAD_COUNT . $downloads_count . "";
1255            echo ' </nobr><br>' . "\n";
1256  
1257            if (ORDER_EDITOR_USE_AJAX == 'true') {
1258              echo '<nobr>&nbsp;- ' . ENTRY_DOWNLOAD_FILENAME . ": <input name='update_downloads[" . $id . "][filename]' size='12' value='" . $downloads->products[$mm]['filename'] . "' onChange=\"updateDownloads('orders_products_filename', '" . $id . "', '" . $orders_products_id . "', this.value)\">";
1259              echo ' </nobr><br>' . "\n";
1260              echo '<nobr>&nbsp;- ' . ENTRY_DOWNLOAD_MAXDAYS . ": <input name='update_downloads[" . $id . "][maxdays]' size='6' value='" . $downloads->products[$mm]['maxdays'] . "' onChange=\"updateDownloads('download_maxdays', '" . $id . "', '" . $orders_products_id . "', this.value)\">";
1261              echo ' </nobr><br>' . "\n";
1262              echo '<nobr>&nbsp;- ' . ENTRY_DOWNLOAD_MAXCOUNT . ": <input name='update_downloads[" . $id . "][maxcount]' size='6' value='" . $downloads->products[$mm]['maxcount'] . "' onChange=\"updateDownloads('download_count', '" . $id . "', '" . $orders_products_id . "', this.value)\">";
1263            } else {
1264              echo '<nobr>&nbsp;- ' . ENTRY_DOWNLOAD_FILENAME . ": <input name='update_downloads[" . $id . "][filename]' size='12' value='" . $downloads->products[$mm]['filename'] . "'>";
1265              echo ' </nobr><br>' . "\n";
1266              echo '<nobr>&nbsp;- ' . ENTRY_DOWNLOAD_MAXDAYS . ": <input name='update_downloads[" . $id . "][maxdays]' size='6' value='" . $downloads->products[$mm]['maxdays'] . "'>";
1267              echo ' </nobr><br>' . "\n";
1268              echo '<nobr>&nbsp;- ' . ENTRY_DOWNLOAD_MAXCOUNT . ": <input name='update_downloads[" . $id . "][maxcount]' size='6' value='" . $downloads->products[$mm]['maxcount'] . "'>";
1269            }
1270  
1271            echo ' </nobr>' . "\n";
1272            echo '<br></small>';
1273            $downloads_count++;
1274          } //end  for ($mm=0; $mm<sizeof($download_query); $mm++) {
1275        }
1276      } //end download
1277    } //end if (sizeof($order->products[$i]['attributes']) > 0) {
1278  ?>
1279          </td>
1280          <td class="dataTableContent" valign="top"><input name="<?php echo "update_products[" . $orders_products_id . "][model]"; ?>" size="12" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateProductsField('update', '<?php echo $orders_products_id; ?>', 'products_model', encodeURIComponent(this.value))"<?php } ?> value="<?php echo $order->products[$i]['model']; ?>"></td>
1281          <td class="dataTableContent" valign="top"><input name="<?php echo "update_products[" . $orders_products_id . "][tax]"; ?>" size="5" onKeyUp="updatePrices('tax', '<?php echo $orders_products_id; ?>')" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateProductsField('reload1', '<?php echo $orders_products_id; ?>', 'products_tax', encodeURIComponent(this.value))"<?php } ?> value="<?php echo tep_display_tax_value($order->products[$i]['tax']); ?>" id="<?php echo "update_products[" . $orders_products_id . "][tax]"; ?>">%</td>
1282          <td class="dataTableContent" valign="top"><input name="<?php echo "update_products[" . $orders_products_id . "][price]"; ?>" size="5" onKeyUp="updatePrices('price', '<?php echo $orders_products_id; ?>')" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateProductsField('reload2', '<?php echo $orders_products_id; ?>')"<?php } ?> value="<?php echo number_format($order->products[$i]['price'], 4, '.', ''); ?>" id="<?php echo "update_products[" . $orders_products_id . "][price]"; ?>"></td>
1283          <td class="dataTableContent" valign="top"><input name="<?php echo "update_products[" . $orders_products_id . "][final_price]"; ?>" size="5" onKeyUp="updatePrices('final_price', '<?php echo $orders_products_id; ?>')" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateProductsField('reload2', '<?php echo $orders_products_id; ?>')"<?php } ?> value="<?php echo number_format($order->products[$i]['final_price'], 4, '.', ''); ?>" id="<?php echo "update_products[" . $orders_products_id . "][final_price]"; ?>"></td>
1284          <td class="dataTableContent" valign="top"><input name="<?php echo "update_products[" . $orders_products_id . "][price_incl]"; ?>" size="5" value="<?php echo number_format(($order->products[$i]['final_price'] * (($order->products[$i]['tax']/100) + 1)), 4, '.', ''); ?>" onKeyUp="updatePrices('price_incl', '<?php echo $orders_products_id; ?>')" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateProductsField('reload2', '<?php echo $orders_products_id; ?>')"<?php } ?> id="<?php echo "update_products[" . $orders_products_id . "][price_incl]"; ?>"></td>
1285          <td class="dataTableContent" valign="top"><input name="<?php echo "update_products[" . $orders_products_id . "][total_excl]"; ?>" size="5" value="<?php echo number_format($order->products[$i]['final_price'] * $order->products[$i]['qty'], 4, '.', ''); ?>" onKeyUp="updatePrices('total_excl', '<?php echo $orders_products_id; ?>')" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateProductsField('reload2', '<?php echo $orders_products_id; ?>')"<?php } ?> id="<?php echo "update_products[" . $orders_products_id . "][total_excl]"; ?>"></td>
1286          <td class="dataTableContent" valign="top"><input name="<?php echo "update_products[" . $orders_products_id . "][total_incl]"; ?>" size="5" value="<?php echo number_format((($order->products[$i]['final_price'] * (($order->products[$i]['tax']/100) + 1))) * $order->products[$i]['qty'], 4, '.', ''); ?>" onKeyUp="updatePrices('total_incl', '<?php echo $orders_products_id; ?>')" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateProductsField('reload2', '<?php echo $orders_products_id; ?>')"<?php } ?> id="<?php echo "update_products[" . $orders_products_id . "][total_incl]"; ?>"></td>
1287        </tr>
1288   
1289  <?php
1290      }
1291    } else {
1292      //the order has no products
1293  ?>
1294        <tr class="dataTableRow">
1295          <td colspan="10" class="dataTableContent" valign="middle" align="center" style="padding: 20px 0 20px 0;"><?php echo TEXT_NO_ORDER_PRODUCTS; ?></td>
1296        </tr>
1297        <tr class="dataTableRow"> 
1298          <td colspan="10" style="border-bottom: 1px solid #C9C9C9;"><?php echo tep_draw_separator('pixel_trans.gif', '1', '1'); ?></td>
1299        </tr>
1300  <?php
1301    }
1302  ?>
1303      </table><!-- product_listing_eof //-->
1304  
1305      <div id="totalsBlock">
1306      <table width="100%">
1307        <tr><td>
1308   
1309        <table border="0" width="100%" cellspacing="0" cellpadding="0">
1310          <tr>
1311            <td valign="top" width="100%">
1312              <br>
1313              <div>
1314                <a href="<?php echo tep_href_link(FILENAME_ORDERS_EDIT_ADD_PRODUCT, 'oID=' . $_GET['oID'] . '&step=1'); ?>" target="addProducts" onClick="openWindow('<?php echo tep_href_link(FILENAME_ORDERS_EDIT_ADD_PRODUCT, 'oID=' . $_GET['oID'] . '&step=1'); ?>','addProducts');return false"><?php echo tep_image_button('button_add_article.gif', TEXT_ADD_NEW_PRODUCT); ?></a><input type="hidden" name="subaction" value="">
1315              </div>
1316              <br>
1317            </td>
1318   
1319  <!-- order_totals bof //-->
1320            <td align="right" rowspan="2" valign="top" nowrap class="dataTableRow" style="border: 1px solid #C9C9C9;">
1321              <table border="0" cellspacing="0" cellpadding="2">
1322                <tr class="dataTableHeadingRow">
1323                  <td class="dataTableHeadingContent" width="15" nowrap onMouseover="ddrivetip('<?php echo oe_html_no_quote(HINT_TOTALS); ?>')"; onMouseout="hideddrivetip()"> <script language="JavaScript" type="text/javascript">
1324                  <!--
1325                  document.write("<img src=\"images/icon_info.gif\" border= \"0\" width=\"13\" height=\"13\">");
1326                  //-->
1327                  </script></td>
1328                  <td class="dataTableHeadingContent" nowrap><?php echo TABLE_HEADING_OT_TOTALS; ?></td>
1329                  <td class="dataTableHeadingContent" colspan="2" nowrap><?php echo TABLE_HEADING_OT_VALUES; ?></td>
1330                </tr>
1331  <?php
1332    for ($i=0; $i<sizeof($order->totals); $i++) {
1333  
1334      $id = $order->totals[$i]['class'];
1335  
1336      if ($order->totals[$i]['class'] == 'ot_shipping') {
1337        if (tep_not_null($order->info['shipping_id'])) {
1338          $shipping_module_id = $order->info['shipping_id'];
1339        } else {
1340          //here we could create logic to attempt to determine the shipping module used if it's not in the database
1341          $shipping_module_id = '';
1342        }
1343      } else {
1344        $shipping_module_id = '';
1345      } //end if ($order->totals[$i]['class'] == 'ot_shipping') {
1346   
1347      $rowStyle = (($i % 2) ? 'dataTableRowOver' : 'dataTableRow');
1348      if ( ($order->totals[$i]['class'] == 'ot_total') || ($order->totals[$i]['class'] == 'ot_subtotal') || ($order->totals[$i]['class'] == 'ot_tax') || ($order->totals[$i]['class'] == 'ot_loworderfee') ) {
1349        echo '                  <tr class="' . $rowStyle . '">' . "\n";
1350        if ($order->totals[$i]['class'] != 'ot_total') {
1351          echo '                    <td class="dataTableContent" valign="middle" height="15">
1352      <script language="JavaScript" type="text/javascript">
1353      <!--
1354      document.write("<span id=\"update_totals['.$i.']\"><a href=\"javascript:setCustomOTVisibility(\'update_totals['.($i+1).']\', \'visible\', \'update_totals['.$i.']\');\"><img src=\"order_editor/images/plus.gif\" border=\"0\" alt=\"' . IMAGE_ADD_NEW_OT . '\" title=\"' . IMAGE_ADD_NEW_OT . '\"></a></span>");
1355      //-->
1356          </script></td>' . "\n";
1357        } else {
1358          echo '                    <td class="dataTableContent" valign="middle">&nbsp;</td>' . "\n";
1359        }
1360  
1361        echo '                    <td align="right" class="dataTableContent"><input name="update_totals['.$i.'][title]" value="' . trim($order->totals[$i]['title']) . '" readonly="readonly"></td>' . "\n";
1362  
1363        if ($order->info['currency'] != DEFAULT_CURRENCY) echo '                    <td class="dataTableContent">&nbsp;</td>' . "\n";
1364        echo '                    <td align="right" class="dataTableContent" nowrap>' . $order->totals[$i]['text'] . '<input name="update_totals['.$i.'][value]" type="hidden" value="' . number_format($order->totals[$i]['value'], 2, '.', '') . '"><input name="update_totals['.$i.'][class]" type="hidden" value="' . $order->totals[$i]['class'] . '"></td>' . "\n" .
1365             '                  </tr>' . "\n";
1366      } else {
1367        if ($i % 2) {
1368          echo '                        <script language="JavaScript" type="text/javascript">
1369          <!--
1370          document.write("<tr class=\"' . $rowStyle . '\" id=\"update_totals['.$i.']\" style=\"visibility: hidden; display: none;\"><td class=\"dataTableContent\" valign=\"middle\" height=\"15\"><a href=\"javascript:setCustomOTVisibility(\'update_totals['.($i).']\', \'hidden\', \'update_totals['.($i-1).']\');\"><img src=\"order_editor/images/minus.gif\" border=\"0\" alt=\"' . IMAGE_REMOVE_NEW_OT . '\" title=\"' . IMAGE_REMOVE_NEW_OT . '\"></a></td>");
1371          //-->
1372          </script>
1373   
1374          <noscript><tr class="' . $rowStyle . '" id="update_totals['.$i.']" >' . "\n" .
1375               '                    <td class="dataTableContent" valign="middle" height="15"></td></noscript>' . "\n";
1376        } else {
1377          echo '                  <tr class="' . $rowStyle . '">' . "\n" .
1378               '                    <td class="dataTableContent" valign="middle" height="15">
1379        <script language="JavaScript" type="text/javascript">
1380        <!--
1381        document.write("<span id=\"update_totals['.$i.']\"><a href=\"javascript:setCustomOTVisibility(\'update_totals['.($i+1).']\', \'visible\', \'update_totals['.$i.']\');\"><img src=\"order_editor/images/plus.gif\" border=\"0\" alt=\"' . IMAGE_ADD_NEW_OT . '\" title=\"' . IMAGE_ADD_NEW_OT . '\"></a></span>");
1382        //-->
1383        </script></td>' . "\n";
1384        }
1385  
1386        if (ORDER_EDITOR_USE_AJAX == 'true') {
1387          echo '                    <td align="right" class="dataTableContent"><input name="update_totals['.$i.'][title]" id="'.$id.'[title]" value="' . trim($order->totals[$i]['title']) . '" onChange="obtainTotals()"></td>' . "\n" .
1388               '                    <td align="right" class="dataTableContent"><input name="update_totals['.$i.'][value]" id="'.$id.'[value]" value="' . number_format($order->totals[$i]['value'], 2, '.', '') . '" size="6" onChange="obtainTotals()"><input name="update_totals['.$i.'][class]" type="hidden" value="' . $order->totals[$i]['class'] . '"><input name="update_totals['.$i.'][id]" type="hidden" value="' . $shipping_module_id . '" id="' . $id . '[id]"></td>' . "\n";
1389        } else {
1390          echo '                    <td align="right" class="dataTableContent"><input name="update_totals['.$i.'][title]" id="'.$id.'[title]" value="' . trim($order->totals[$i]['title']) . '"></td>' . "\n" .
1391               '                    <td align="right" class="dataTableContent"><input name="update_totals['.$i.'][value]" id="'.$id.'[value]" value="' . number_format($order->totals[$i]['value'], 2, '.', '') . '" size="6"><input name="update_totals['.$i.'][class]" type="hidden" value="' . $order->totals[$i]['class'] . '"><input name="update_totals['.$i.'][id]" type="hidden" value="' . $shipping_module_id . '" id="' . $id . '[id]"></td>' . "\n";
1392        }
1393   
1394        if ($order->info['currency'] != DEFAULT_CURRENCY) echo '                    <td align="right" class="dataTableContent" nowrap>' . $order->totals[$i]['text'] . '</td>' . "\n";
1395        echo '                  </tr>' . "\n";
1396      }
1397    }
1398  ?>
1399                  </table>
1400          </td>
1401          <!-- order_totals_eof //-->
1402        </tr>
1403        <tr>
1404          <td valign="bottom">
1405  
1406  <?php 
1407    if (sizeof($shipping_quotes) > 0) {
1408  ?>
1409          <!-- shipping_quote bof //-->
1410          <table width="550" cellspacing="0" cellpadding="2" style="border: 1px solid #C9C9C9;">
1411            <tr class="dataTableHeadingRow">
1412              <td class="dataTableHeadingContent" colspan="3"><?php echo TABLE_HEADING_SHIPPING_QUOTES; ?></td>
1413            </tr>
1414  
1415  
1416  <?php
1417      $r = 0;
1418      for ($i=0, $n=sizeof($shipping_quotes); $i<$n; $i++) {
1419        for ($j=0, $n2=sizeof($shipping_quotes[$i]['methods']); $j<$n2; $j++) {
1420          $r++;
1421      if (!isset($shipping_quotes[$i]['tax'])) $shipping_quotes[$i]['tax'] = 0;
1422        $rowClass = ((($r/2) == (floor($r/2))) ? 'dataTableRowOver' : 'dataTableRow');
1423        echo '                  <tr class="' . $rowClass . '" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this, \'' . $rowClass . '\')" onClick="selectRowEffect(this, ' . $r . '); setShipping(' . $r . ');">' .
1424             '                    <td class="dataTableContent" valign="top" align="left">
1425         <script language="JavaScript" type="text/javascript">
1426          <!--
1427          document.write("<input type=\"radio\" name=\"shipping\" id=\"shipping_radio_' . $r . '\" value=\"' . $shipping_quotes[$i]['id'] . '_' . $shipping_quotes[$i]['methods'][$j]['id'].'\">");
1428          //-->
1429         </script>
1430         <input type="hidden" id="update_shipping[' . $r . '][title]" name="update_shipping[' . $r . '][title]" value="'.$shipping_quotes[$i]['module'] . ' (' . $shipping_quotes[$i]['methods'][$j]['title'].'):">' . "\n" .
1431         '      <input type="hidden" id="update_shipping[' . $r . '][value]" name="update_shipping[' . $r . '][value]" value="'.tep_add_tax($shipping_quotes[$i]['methods'][$j]['cost'], $shipping_quotes[$i]['tax']).'">' . "\n" .
1432         '      <input type="hidden" id="update_shipping[' . $r . '][id]" name="update_shipping[' . $r . '][id]" value="' . $shipping_quotes[$i]['id'] . '_' . $shipping_quotes[$i]['methods'][$j]['id'] . '">' . "\n" .
1433         '      <td class="dataTableContent" valign="top">' . $shipping_quotes[$i]['module'] . ' (' . $shipping_quotes[$i]['methods'][$j]['title'] . '):</td>' . "\n" . 
1434         '      <td class="dataTableContent" align="right">' . $currencies->format(tep_add_tax($shipping_quotes[$i]['methods'][$j]['cost'], $shipping_quotes[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n" . 
1435         '                  </tr>';
1436        }
1437      }
1438  ?>
1439                    <tr class="dataTableHeadingRow">
1440                      <td class="dataTableHeadingContent" colspan="3"><?php echo sprintf(TEXT_PACKAGE_WEIGHT_COUNT, $shipping_num_boxes . ' x ' . $shipping_weight, $total_count); ?></td>
1441                    </tr>
1442                  </table>
1443                  <!-- shipping_quote_eof //-->
1444  <?php
1445    } else {
1446      echo AJAX_NO_QUOTES;
1447    }
1448  ?>                </td>
1449                </tr> 
1450              </table>
1451  
1452        </td></tr>
1453       </table> 
1454      </div>
1455      </div> <!-- this is end of the master div for the whole totals/shipping area -->
1456  
1457    <?php if (ORDER_EDITOR_USE_AJAX != 'true') { ?> 
1458      <!-- Begin Update Block, only for non-javascript browsers -->
1459  
1460      <br>
1461      <div class="updateBlock">
1462        <div class="update1"><?php echo HINT_PRESS_UPDATE; ?></div>
1463        <div class="update2">&nbsp;</div>
1464        <div class="update3">&nbsp;</div>
1465        <div class="update4" align="center"><?php echo ENTRY_SEND_NEW_ORDER_CONFIRMATION; ?>&nbsp;<?php echo tep_draw_checkbox_field('nC1', '', false); ?></div>
1466        <div class="update5" align="center"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?></div>
1467      </div>
1468  
1469      <br>
1470      <div><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></div>
1471   
1472     <!-- End of Update Block -->
1473       <?php } ?>
1474  
1475      <div id="historyMessageStack">
1476        <?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?>
1477      </div>
1478  
1479      <div id="commentsBlock">
1480      <table style="border: 1px solid #C9C9C9;" cellspacing="0" cellpadding="2" class="dataTableRow" id="commentsTable">
1481         <tr class="dataTableHeadingRow">
1482          <td class="dataTableHeadingContent" align="left"><?php echo TABLE_HEADING_DELETE; ?></td>
1483          <td class="dataTableHeadingContent" align="left" width="10">&nbsp;</td>
1484          <td class="dataTableHeadingContent" align="left"><?php echo TABLE_HEADING_DATE_ADDED; ?></td>
1485          <td class="dataTableHeadingContent" align="left" width="10">&nbsp;</td>
1486          <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_CUSTOMER_NOTIFIED; ?></td>
1487          <td class="dataTableHeadingContent" align="left" width="10">&nbsp;</td>
1488          <td class="dataTableHeadingContent" align="left"><?php echo TABLE_HEADING_STATUS; ?></td>
1489          <td class="dataTableHeadingContent" align="left" width="10">&nbsp;</td>
1490          <td class="dataTableHeadingContent" align="left"><?php echo TABLE_HEADING_COMMENTS; ?></td>
1491        </tr>
1492  <?php
1493      $orders_history_query = tep_db_query("SELECT orders_status_history_id, orders_status_id, date_added, customer_notified, comments 
1494                                          FROM " . TABLE_ORDERS_STATUS_HISTORY . " 
1495                                          WHERE orders_id = '" . (int)$oID . "' 
1496                                          ORDER BY date_added");
1497      if (tep_db_num_rows($orders_history_query)) {
1498        while ($orders_history = tep_db_fetch_array($orders_history_query)) {
1499  
1500        $r++;
1501        $rowClass = ((($r/2) == (floor($r/2))) ? 'dataTableRowOver' : 'dataTableRow');
1502  
1503        if (ORDER_EDITOR_USE_AJAX == 'true') { 
1504          echo '  <tr class="' . $rowClass . '" id="commentRow' . $orders_history['orders_status_history_id'] . '" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this, \'' . $rowClass . '\')">' . "\n" .
1505               '    <td class="smallText" align="center"><div id="do_not_delete"><input name="update_comments[' . $orders_history['orders_status_history_id'] . '][delete]" type="checkbox" onClick="updateCommentsField(\'delete\', \'' . $orders_history['orders_status_history_id'] . '\', this.checked, \'\', this)"></div></td>' . "\n" . 
1506               '    <td class="dataTableHeadingContent" align="left" width="10"> </td>' . "\n" .
1507               '    <td class="smallText" align="center">' . tep_datetime_short($orders_history['date_added']) . '</td>' . "\n" .
1508               '    <td class="dataTableHeadingContent" align="left" width="10"> </td>' . "\n" .
1509               '    <td class="smallText" align="center">';
1510        } else {
1511          echo '  <tr class="' . $rowClass . '" id="commentRow' . $orders_history['orders_status_history_id'] . '" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this, \'' . $rowClass . '\')">' . "\n" .
1512               '    <td class="smallText" align="center"><div id="do_not_delete"><input name="update_comments[' . $orders_history['orders_status_history_id'] . '][delete]" type="checkbox"></div></td>' . "\n" . 
1513               '    <td class="dataTableHeadingContent" align="left" width="10"> </td>' . "\n" .
1514               '    <td class="smallText" align="center">' . tep_datetime_short($orders_history['date_added']) . '</td>' . "\n" .
1515               '    <td class="dataTableHeadingContent" align="left" width="10"> </td>' . "\n" .
1516               '    <td class="smallText" align="center">';
1517        }
1518  
1519        if ($orders_history['customer_notified'] == '1') {
1520          echo tep_image(DIR_WS_ICONS . 'tick.gif', ICON_TICK) . "</td>\n";
1521        } else {
1522          echo tep_image(DIR_WS_ICONS . 'cross.gif', ICON_CROSS) . "</td>\n";
1523        }
1524   
1525        echo '    <td class="dataTableHeadingContent" align="left" width="10">&nbsp;</td>' . "\n" .
1526             '    <td class="smallText" align="left">' . $orders_status_array[$orders_history['orders_status_id']] . '</td>' . "\n";
1527        echo '    <td class="dataTableHeadingContent" align="left" width="10">&nbsp;</td>' . "\n" .
1528             '    <td class="smallText" align="left">';
1529  
1530        if (ORDER_EDITOR_USE_AJAX == 'true') { 
1531          echo tep_draw_textarea_field("update_comments[" . $orders_history['orders_status_history_id'] . "][comments]", "soft", "40", "5", 
1532                "" .  tep_db_output($orders_history['comments']) . "", "onChange=\"updateCommentsField('update', '" . $orders_history['orders_status_history_id'] . "', 'false', encodeURIComponent(this.value))\"") . '' . "\n" .
1533              '    </td>' . "\n";
1534        } else {
1535          echo tep_draw_textarea_field("update_comments[" . $orders_history['orders_status_history_id'] . "][comments]", "soft", "40", "5", 
1536               "" .  tep_db_output($orders_history['comments']) . "") . '' . "\n" .
1537               '    </td>' . "\n";
1538        }
1539   
1540        echo '  </tr>' . "\n";
1541  
1542      }
1543    } else {
1544      echo '  <tr>' . "\n" .
1545           '    <td class="smallText" colspan="5">' . TEXT_NO_ORDER_HISTORY . '</td>' . "\n" .
1546           '  </tr>' . "\n";
1547    }
1548  
1549  ?>
1550    </table> 
1551    </div>
1552  
1553    <div>
1554      <?php echo tep_draw_separator('pixel_trans.gif', '1', '1'); ?>
1555    </div>
1556    <br>
1557  
1558  <table style="border: 1px solid #C9C9C9;" cellspacing="0" cellpadding="2" class="dataTableRow">
1559    <tr class="dataTableHeadingRow">
1560      <td class="dataTableHeadingContent" align="left"><?php echo TABLE_HEADING_NEW_STATUS; ?></td>
1561      <td class="main" width="10">&nbsp;</td>
1562      <td class="dataTableHeadingContent" align="left"><?php echo TABLE_HEADING_COMMENTS; ?></td>
1563    </tr>
1564    <tr>
1565      <td>
1566        <table border="0" cellspacing="0" cellpadding="2">
1567  
1568          <tr>
1569            <td class="main"><b><?php echo ENTRY_STATUS; ?></b></td>
1570            <td class="main" align="right"><?php echo tep_draw_pull_down_menu('status', $orders_statuses, $order->info['orders_status'], 'id="status"'); ?></td>
1571          </tr>
1572          <tr>
1573            <td class="main"><b><?php echo ENTRY_NOTIFY_CUSTOMER; ?></b></td>
1574            <td class="main" align="right"><?php echo oe_draw_checkbox_field('notify', '', false, '', 'id="notify"'); ?></td>
1575          </tr>
1576          <tr>
1577            <td class="main"><b><?php echo ENTRY_NOTIFY_COMMENTS; ?></b></td>
1578            <td class="main" align="right"><?php echo oe_draw_checkbox_field('notify_comments', '', false, '', 'id="notify_comments"'); ?></td>
1579          </tr>
1580       </table>
1581      </td>
1582      <td class="main" width="10">&nbsp;</td>
1583      <td class="main">
1584      <?php echo tep_draw_textarea_field('comments', 'soft', '40', '5', '', 'id="comments"'); ?>
1585      </td>
1586    </tr>
1587  
1588  <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?> 
1589    <script language="JavaScript" type="text/javascript">
1590    <!--
1591    document.write("<tr>");
1592    document.write("<td colspan=\"3\" align=\"right\">");
1593    document.write("<input type=\"button\" name=\"comments_button\" value=\"<?php echo oe_html_no_quote(AJAX_SUBMIT_COMMENT); ?>\" onClick=\"javascript:getNewComment();\">");
1594    document.write("</td>");
1595    document.write("</tr>");
1596    //-->
1597    </script>
1598  <?php } ?>
1599  
1600      </table>
1601  
1602      <div>
1603      <?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?>
1604      </div>
1605  
1606    <!-- End of Status Block -->
1607  
1608    <?php if (ORDER_EDITOR_USE_AJAX != 'true') { ?> 
1609  <!-- Begin Update Block, only for non-javascript browsers -->
1610      <div class="updateBlock">
1611          <div class="update1"><?php echo HINT_PRESS_UPDATE; ?></div>
1612          <div class="update2">&nbsp;</div>
1613          <div class="update3">&nbsp;</div>
1614          <div class="update4" align="center"><?php echo ENTRY_SEND_NEW_ORDER_CONFIRMATION; ?>&nbsp;<?php echo tep_draw_checkbox_field('nC1', '', false); ?></div>
1615          <div class="update5" align="center"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?></div>
1616      </div>
1617  
1618      <br>
1619      <div><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></div>
1620  
1621    <!-- End of Update Block -->
1622    <?php   }  //end if (ORDER_EDITOR_USE_AJAX != 'true') {
1623            echo '</form>';
1624          }
1625  ?>
1626  <!-- body_text_eof //-->
1627      </td>
1628    </tr>
1629    </table>
1630  <!-- body_eof //-->
1631  
1632  <!-- footer //-->
1633  <?php require (DIR_WS_INCLUDES . 'footer.php'); ?>
1634  <!-- footer_eof //-->
1635  <br>
1636  </body>
1637  </html>
1638  <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7