$orders_status['orders_status_id'], 'text' => $orders_status['orders_status_name']); $orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name']; } $action = (isset($_GET['action']) ? $_GET['action'] : 'edit'); // Update Inventory Quantity if (tep_not_null($action)) { switch ($action) { // 1. UPDATE ORDER ############################################################################################### case 'update_order': $oID = tep_db_prepare_input($_GET['oID']); $order = new oe_order($oID); $status = tep_db_prepare_input($_POST['status']); // Set this Session's variables $_SESSION['billing_same_as_customer'] = $_POST['billing_same_as_customer']; $_SESSION['shipping_same_as_billing'] = $_POST['shipping_same_as_billing']; //tax business $default_tax_name = tep_get_tax_description($default_tax_class, $_POST['update_delivery_country_id'], $_POST['update_delivery_zone_id']); //figure out the new currency value $currency_value_query = tep_db_query("SELECT value FROM " . TABLE_CURRENCIES . " WHERE code = '" . $_POST['update_info_payment_currency'] . "'"); $currency_value = tep_db_fetch_array($currency_value_query); //figure out the country, state $update_customer_state = tep_get_zone_name($_POST['update_customer_country_id'], $_POST['update_customer_zone_id'], $_POST['update_customer_state']); $update_customer_country = tep_get_country_name($_POST['update_customer_country_id']); $update_billing_state = tep_get_zone_name($_POST['update_billing_country_id'], $_POST['update_billing_zone_id'], $_POST['update_billing_state']); $update_billing_country = tep_get_country_name($_POST['update_billing_country_id']); $update_delivery_state = tep_get_zone_name($_POST['update_delivery_country_id'], $_POST['update_delivery_zone_id'], $_POST['update_delivery_state']); $update_delivery_country = tep_get_country_name($_POST['update_delivery_country_id']); // 1.1 UPDATE ORDER INFO ##### $UpdateOrders = "UPDATE " . TABLE_ORDERS . " SET customers_name = '" . tep_db_input(tep_db_prepare_input($_POST['update_customer_name'])) . "', customers_company = '" . tep_db_input(tep_db_prepare_input($_POST['update_customer_company'])) . "', customers_street_address = '" . tep_db_input(tep_db_prepare_input($_POST['update_customer_street_address'])) . "', customers_suburb = '" . tep_db_input(tep_db_prepare_input($_POST['update_customer_suburb'])) . "', customers_city = '" . tep_db_input(tep_db_prepare_input($_POST['update_customer_city'])) . "', customers_state = '" . tep_db_input(tep_db_prepare_input($update_customer_state)) . "', customers_postcode = '" . tep_db_input(tep_db_prepare_input($_POST['update_customer_postcode'])) . "', customers_country = '" . tep_db_input(tep_db_prepare_input($update_customer_country)) . "', customers_telephone = '" . tep_db_input(tep_db_prepare_input($_POST['update_customer_telephone'])) . "', customers_email_address = '" . tep_db_input(tep_db_prepare_input($_POST['update_customer_email_address'])) . "',"; $UpdateOrders .= " billing_name = '" . tep_db_input(tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_name'] : $_POST['update_billing_name']))) . "', billing_company = '" . tep_db_input(tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_company'] : $_POST['update_billing_company']))) . "', billing_street_address = '" . tep_db_input(tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_street_address'] : $_POST['update_billing_street_address']))) . "', billing_suburb = '" . tep_db_input(tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_suburb'] : $_POST['update_billing_suburb']))) . "', billing_city = '" . tep_db_input(tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_city'] : $_POST['update_billing_city']))) . "', billing_state = '" . tep_db_input(tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $update_customer_state : $update_billing_state))) . "', billing_postcode = '" . tep_db_input(tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_postcode'] : $_POST['update_billing_postcode']))) . "', billing_country = '" . tep_db_input(tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $update_customer_country : $update_billing_country))) . "',"; $UpdateOrders .= " delivery_name = '". tep_db_input(tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_name'] : $_POST['update_billing_name']) : $_POST['update_delivery_name']))) . "', delivery_company = '". tep_db_input(tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_company'] : $_POST['update_billing_company']) : $_POST['update_delivery_company']))) . "', delivery_street_address = '". tep_db_input(tep_db_prepare_input((($_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']))) . "', delivery_suburb = '". tep_db_input(tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_suburb'] : $_POST['update_billing_suburb']) : $_POST['update_delivery_suburb']))) . "', delivery_city = '". tep_db_input(tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_city'] : $_POST['update_billing_city']) : $_POST['update_delivery_city']))) . "', delivery_state = '". tep_db_input(tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $update_customer_state : $update_billing_state) : $update_delivery_state))) . "', delivery_postcode = '". tep_db_input(tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_postcode'] : $_POST['update_billing_postcode']) : $_POST['update_delivery_postcode']))) . "', delivery_country = '". tep_db_input(tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $update_customer_country : $update_billing_country) : $update_delivery_country))) . "',"; $UpdateOrders .= " payment_method = '" . tep_db_input(tep_db_prepare_input($_POST['update_info_payment_method'])) . "', currency = '" . tep_db_input(tep_db_prepare_input($_POST['update_info_payment_currency'])) . "', currency_value = '" . tep_db_input(tep_db_prepare_input($currency_value['value'])) . "', cc_type = '" . tep_db_input(tep_db_prepare_input($_POST['update_info_cc_type'])) . "', cc_owner = '" . tep_db_input(tep_db_prepare_input($_POST['update_info_cc_owner'])) . "', cc_number = '" . tep_db_input(tep_db_prepare_input($_POST['update_info_cc_number'])) . "', cc_expires = '" . tep_db_input(tep_db_prepare_input($_POST['update_info_cc_expires'])) . "', shipping_tax = '" . tep_db_input(tep_db_prepare_input($_POST['update_shipping_tax'])) . "'"; $UpdateOrders .= " where orders_id = '" . tep_db_prepare_input($_GET['oID']) . "';"; tep_db_query($UpdateOrders); $order_updated = true; // 1.2 UPDATE STATUS HISTORY & SEND EMAIL TO CUSTOMER IF NECESSARY ##### $check_status_query = tep_db_query(" SELECT customers_name, customers_email_address, orders_status, date_purchased FROM " . TABLE_ORDERS . " WHERE orders_id = '" . (int)$oID . "'"); $check_status = tep_db_fetch_array($check_status_query); if (($check_status['orders_status'] != $_POST['status']) || (tep_not_null($_POST['comments']))) { tep_db_query("UPDATE " . TABLE_ORDERS . " SET orders_status = '" . tep_db_input($_POST['status']) . "', last_modified = now() WHERE orders_id = '" . (int)$oID . "'"); // Notify Customer ? $customer_notified = '0'; if (isset($_POST['notify']) && ($_POST['notify'] == 'on')) { $notify_comments = ''; if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on')) { $notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $_POST['comments']) . "\n\n"; } $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . (int)$oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . (int)$oID, 'SSL') . "\n" . 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); tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); $customer_notified = '1'; } tep_db_query("INSERT into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . tep_db_input($_GET['oID']) . "', '" . tep_db_input($_POST['status']) . "', now(), " . tep_db_input($customer_notified) . ", '" . tep_db_input($_POST['comments']) . "')"); } // 1.3 UPDATE PRODUCTS ##### $RunningSubTotal = 0; // -> VDSTHT $RunningNetto = 0; // <- VDSTHT $RunningTax = array($default_tax_name => 0); // Do pre-check for subtotal field existence $ot_subtotal_found = false; $ot_total_found = false; if (is_array ($_POST['update_totals'])) { foreach($_POST['update_totals'] as $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot"); if($ot_class == "ot_subtotal") { $ot_subtotal_found = true; break; } if($ot_class == "ot_total"){ $ot_total_found = true; break; } }//end foreach() }//end if (is_array()) // 1.3.1 Update orders_products Table if (is_array ($_POST['update_products'])){ foreach($_POST['update_products'] as $orders_products_id => $products_details) { if (!tep_not_null($products_details["qty"])) $products_details["qty"] = 0; // 1.3.1.1 Update Inventory Quantity $order_query = tep_db_query(" SELECT products_id, products_quantity FROM " . TABLE_ORDERS_PRODUCTS . " WHERE orders_id = '" . (int)$oID . "' AND orders_products_id = '$orders_products_id'"); $order = tep_db_fetch_array($order_query); // First we do a stock check if ($products_details["qty"] != $order['products_quantity']){ $quantity_difference = ($products_details["qty"] - $order['products_quantity']); if (STOCK_LIMITED == 'true'){ tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET products_quantity = products_quantity - " . $quantity_difference . ", products_ordered = products_ordered + " . $quantity_difference . " WHERE products_id = '" . (int)$order['products_id'] . "'"); } else { tep_db_query ("UPDATE " . TABLE_PRODUCTS . " SET products_ordered = products_ordered + " . $quantity_difference . " WHERE products_id = '" . (int)$order['products_id'] . "'"); } } //Then we check if the product should be deleted if (isset($products_details['delete'])){ //update quantities first if (STOCK_LIMITED == 'true'){ tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET products_quantity = products_quantity + " . $products_details["qty"] . ", products_ordered = products_ordered - " . $products_details["qty"] . " WHERE products_id = '" . (int)$order['products_id'] . "'"); } else { tep_db_query ("UPDATE " . TABLE_PRODUCTS . " SET products_ordered = products_ordered - " . $products_details["qty"] . " WHERE products_id = '" . (int)$order['products_id'] . "'"); } //then delete the little bugger $Query = "DELETE FROM " . TABLE_ORDERS_PRODUCTS . " WHERE orders_id = '" . (int)$oID . "' AND orders_products_id = '$orders_products_id';"; tep_db_query($Query); // and all its attributes if(isset($products_details[attributes])) { $Query = "DELETE FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " WHERE orders_id = '" . (int)$oID . "' AND orders_products_id = '$orders_products_id';"; tep_db_query($Query); $Query2 = "DELETE FROM " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " WHERE orders_id = '" . (int)$oID . "' AND orders_products_id = '$orders_products_id';"; tep_db_query($Query2); } }// end of if (isset($products_details['delete'])) else { // if we don't delete, we update $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS . " SET products_model = '" . $products_details["model"] . "', products_name = '" . tep_html_quotes($products_details["name"]) . "', products_price = '" . $products_details["price"] . "', final_price = '" . $products_details["final_price"] . "', products_tax = '" . $products_details["tax"] . "', products_quantity = '" . $products_details["qty"] . "' WHERE orders_id = '" . (int)$oID . "' AND orders_products_id = '$orders_products_id';"; tep_db_query($Query); //update subtotal and total during update function // -> VDSTHT $RunningSubTotal += (($products_details['tax']/100 + 1) * ($products_details['qty'] * $products_details['final_price'])); $RunningNetto += $products_details["qty"] * $products_details["final_price"]; /* if (DISPLAY_PRICE_WITH_TAX == 'true') { $RunningSubTotal += (($products_details['tax']/100 + 1) * ($products_details['qty'] * $products_details['final_price'])); } else { $RunningSubTotal += $products_details["qty"] * $products_details["final_price"]; } */ // <- VDSTHT $RunningTax[$products_details['tax_description']] += (($products_details['tax']/100) * ($products_details['qty'] * $products_details['final_price'])); // Update Any Attributes if(isset($products_details[attributes])) { foreach($products_details["attributes"] as $orders_products_attributes_id => $attributes_details) { $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set products_options = '" . $attributes_details["option"] . "', products_options_values = '" . $attributes_details["value"] . "', options_values_price ='" . $attributes_details["price"] . "', price_prefix ='" . $attributes_details["prefix"] . "' where orders_products_attributes_id = '$orders_products_attributes_id';"; tep_db_query($Query); }//end of foreach($products_details["attributes"] }// end of if(isset($products_details[attributes])) }// end of if/else (isset($products_details['delete'])) }//end of foreach }//end of if (is_array()) //1.3.5 //update any downloads that may exist if (is_array($_POST['update_downloads'])) { foreach($_POST['update_downloads'] as $orders_products_download_id => $download_details) { $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " SET orders_products_filename = '" . $download_details["filename"] . "', download_maxdays = '" . $download_details["maxdays"] . "', download_count = '" . $download_details["maxcount"] . "' WHERE orders_id = '" . (int)$oID . "' AND orders_products_download_id = '$orders_products_download_id';"; tep_db_query($Query); } } ///1.3.6 //delete or update comments if (is_array($_POST['update_comments'])) { foreach($_POST['update_comments'] as $orders_status_history_id => $comments_details) { if (isset($comments_details['delete'])){ $Query = "DELETE FROM " . TABLE_ORDERS_STATUS_HISTORY . " WHERE orders_id = '" . (int)$oID . "' AND orders_status_history_id = '$orders_status_history_id';"; tep_db_query($Query); } else { $Query = "UPDATE " . TABLE_ORDERS_STATUS_HISTORY . " SET comments = '" . $comments_details["comments"] . "' WHERE orders_id = '" . (int)$oID . "' AND orders_status_history_id = '$orders_status_history_id';"; tep_db_query($Query); } } } //end comments update section // 1.4 UPDATE SHIPPING, CUSTOM FEES, DISOUNTS, TAXES, AND TOTALS ##### // 1.4.0.1 Shipping Tax if (is_array ($_POST['update_totals'])){ foreach($_POST['update_totals'] as $total_index => $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot"); if($ot_class == "ot_shipping")//a good place to add in custom total components { if (DISPLAY_PRICE_WITH_TAX == 'true') {//the shipping charge includes tax $RunningTax[$default_tax_name] += ($ot_value * $_POST['update_shipping_tax']) / ($_POST['update_shipping_tax'] + 100); } else { //shipping tax is in addition to the shipping charge $RunningTax[$default_tax_name] += (($_POST['update_shipping_tax'] / 100) * $ot_value); } } } } //1.4.1.0 $RunningTotal = 0; $sort_order = 0; // 1.4.1.1 If ot_tax doesn't exist, but $RunningTax has been calculated, create an appropriate entry in the db and add tax to the subtotal or total as appropriate if (array_sum($RunningTax) != 0) { foreach ($RunningTax as $key => $val) { if (is_array ($_POST['update_totals'])){//1 foreach($_POST['update_totals'] as $total_details) {//2 extract($total_details,EXTR_PREFIX_ALL,"ot"); $ot_tax_found = 0; if (($ot_class == "ot_tax") && (preg_replace("/:$/","",$ot_title) == $key)) {//3 $ot_tax_found = 1; break; }//end 3 }//end 2 //bizzarro code needed to input text value into db properly //I still don't understand why //text = '" . $currencies->format($val, true, $order->info['currency'], $order->info['currency_value']) . "', //isn't adequate. Maybe I never will if ($ot_class == "ot_total" || $ot_class == "ot_tax" || $ot_class == "ot_subtotal" || // -> VDSTHT $ot_class == "ot_subtotal_wotax" || // <- VDSTHT $ot_class == "ot_shipping" || $ot_class == "ot_custom" || $ot_class == "ot_loworderfee") { $order = new oe_order($oID); // $RunningTax[$default_tax_name] += 0 * $products_details['tax'] / $order->info['currency_value'] / 100 ; }//end bizarro code }// end 1 if (($val > 0) && ($ot_tax_found != 1)) { $sort_order++; $Query = "INSERT INTO " . TABLE_ORDERS_TOTAL . " SET orders_id = '" . (int)$oID . "', title ='" . $key . ":', text = '" . $currencies->format($val, true, $order->info['currency'], $order->info['currency_value']) . "', value = '" . $val . "', class = 'ot_tax', sort_order = '2'"; tep_db_query($Query); $ot_tax_found = 1; if (DISPLAY_PRICE_WITH_TAX != 'true') { $RunningTotal += $val; } //end if (DISPLAY_PRICE_WITH_TAX != 'true') } //end if (($val > 0) && ($ot_tax_found != 1)) { } //end foreach ($RunningTax as $key => $val) } //end if (array_sum($RunningTax) != 0) //OPTIONAL- create entries for subtotal and/or total if none exists //1.4.1.2 //Add in subtotal to db if it doesn't already exist if (($RunningSubTotal >0) && ($ot_subtotal_found != true)) { $Query = 'INSERT INTO ' . TABLE_ORDERS_TOTAL . ' SET orders_id = "' . (int)$oID . '", title ="' . ENTRY_SUB_TOTAL . '", text = "' . $currencies->format($RunningSubTotal, true, $order->info['currency'], $order->info['currency_value']) . '", value = "' . $RunningSubTotal . '", class = "ot_subtotal", sort_order = "3"'; tep_db_query($Query); $ot_subtotal_found = true; $RunningTotal += $RunningSubTotal; } //1.4.1.3 //Add in total to db if it doesn't already exist if (($RunningTotal >0) && ($ot_total_found != true)) { $Query = 'INSERT INTO ' . TABLE_ORDERS_TOTAL . ' SET orders_id = "' . (int)$oID . '", title ="' . ENTRY_TOTAL . '", text = "' . $currencies->format($RunningTotal, true, $order->info['currency'], $order->info['currency_value']) . '", value = "' . $RunningTotal . '", class = "ot_total", sort_order = "6"'; tep_db_query($Query); $ot_total_found = true; } // 1.4.2. Summing up total if (is_array ($_POST['update_totals'])) { foreach($_POST['update_totals'] as $total_index => $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot"); if (trim($ot_title)) { $sort_order++; if ($ot_class == "ot_subtotal") { $ot_value = $RunningSubTotal; } // -> VDSTHT if ($ot_class == "ot_subtotal_wotax") { $ot_value = $RunningNetto; } // <- VDSTHT if ($ot_class == "ot_tax") { $ot_value = $RunningTax[preg_replace("/:$/","",$ot_title)]; } if ($ot_class == "ot_total") { $ot_value = $RunningTotal; if ( !$ot_subtotal_found ) { // There was no subtotal on this order, lets add the running subtotal in. $ot_value += $RunningSubTotal; } } // Set $ot_text (display-formatted value) $order = new oe_order($oID); $ot_text = $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']); if ($ot_class == "ot_total") { $ot_text = "" . $ot_text . ""; } if($ot_total_id > 0) { // Already in database --> Update $Query = "UPDATE " . TABLE_ORDERS_TOTAL . " SET title = '" . $ot_title . "', text = '" . $ot_text . "', value = '" . $ot_value . "', sort_order = '" . $sort_order . "' WHERE orders_total_id = '". $ot_total_id . "' AND orders_id = '" . (int)$oID . "'"; tep_db_query($Query); } else { // New Insert (ie ot_custom) $Query = "INSERT INTO " . TABLE_ORDERS_TOTAL . " SET orders_id = '" . (int)$oID . "', title = '" . $ot_title . "', text = '" . $ot_text . "', value = '" . $ot_value . "', class = '" . $ot_class . "', sort_order = '" . $sort_order . "'"; tep_db_query($Query); } if ($ot_class == "ot_tax") { if (DISPLAY_PRICE_WITH_TAX != 'true') { //we don't add tax to the total here because it's already added to the subtotal // -> VDSTHT // $RunningTotal += $ot_value; // <- VDSTHT } } // -> VDSTHT // else { elseif ($ot_class != "ot_subtotal_wotax") { // <- VDSTHT $RunningTotal += $ot_value; } } // -> VDSTHT // if (!trim($ot_value) && ($ot_class != "ot_shipping") && ($ot_class != "ot_subtotal") && ($ot_class != "ot_total")) { // value = 0 => Delete Total Piece if (!trim($ot_value) && ($ot_class != "ot_shipping") && ($ot_class != "ot_subtotal") && ($ot_class != "ot_total") && ($ot_class != "ot_subtotal_wotax")) { // value = 0 => Delete Total Piece // <- VDSTHT $Query = "DELETE from " . TABLE_ORDERS_TOTAL . " WHERE orders_id = '" . (int)$oID . "' AND orders_total_id = '$ot_total_id'"; tep_db_query($Query); } } }//end if (is_array()) // 1.5 SUCCESS MESSAGE ##### // CHECK FOR NEW EMAIL CONFIRMATION if ( (isset($_POST['nC1'])) || (isset($_POST['nC2'])) || (isset($_POST['nC3'])) ) { //then the user selected the option of sending a new email tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=email')); //redirect to the email case } else { //email? email? We don't need no stinkin email! if ($order_updated) { $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success'); } tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=edit')); } break; // 2. ADD A PRODUCT ############################################################################################### case 'add_product': if($_POST['step'] == 4) { // 2.1 GET ORDER INFO ##### $oID = tep_db_prepare_input($_GET['oID']); $order = new oe_order($oID); $AddedOptionsPrice = 0; //tax business $default_tax_name = tep_get_tax_description($default_tax_class, $order->delivery['country_id'], $order->delivery['zone_id']); // 2.1.1 Get Product Attribute Info if(is_array ($_POST['add_product_options'])) { foreach($_POST['add_product_options'] as $option_id => $option_value_id) { $result = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa INNER JOIN " . TABLE_PRODUCTS_OPTIONS . " po ON po.products_options_id=pa.options_id INNER JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov ON pov.products_options_values_id=pa.options_values_id WHERE products_id=" . $_POST['add_product_products_id'] . " and options_id=" . $option_id . " and options_values_id=" . $option_value_id . " and po.language_id = '" . (int)$languages_id . "' and pov.language_id = '" . (int)$languages_id . "'"); $row = tep_db_fetch_array($result); if (is_array($row)) extract($row, EXTR_PREFIX_ALL, "opt"); if ($opt_price_prefix == '-') {$AddedOptionsPrice -= $opt_options_values_price;} else //default to positive {$AddedOptionsPrice += $opt_options_values_price;} $option_value_details[$option_id][$option_value_id] = array ( "options_values_price" => $opt_options_values_price, "price_prefix" => $opt_price_prefix); $option_names[$option_id] = $opt_products_options_name; $option_values_names[$option_value_id] = $opt_products_options_values_name; //add on for downloads if (DOWNLOAD_ENABLED == 'true') { $download_query_raw =" SELECT products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " WHERE products_attributes_id='" . $opt_products_attributes_id . "'"; $download_query = tep_db_query($download_query_raw); if (tep_db_num_rows($download_query) > 0) { $download = tep_db_fetch_array($download_query); $filename[$option_id] = $download['products_attributes_filename']; $maxdays[$option_id] = $download['products_attributes_maxdays']; $maxcount[$option_id] = $download['products_attributes_maxcount']; } //end if (tep_db_num_rows($download_query) > 0) { } //end if (DOWNLOAD_ENABLED == 'true') { //end downloads } //end foreach($_POST['add_product_options'] as $option_id => $option_value_id) } //end if(is_array ($_POST['add_product_options'])) // 2.1.2 Get Product Info $InfoQuery = " SELECT p.products_model, p.products_price, pd.products_name, p.products_tax_class_id FROM " . TABLE_PRODUCTS . " p INNER JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON pd.products_id=p.products_id WHERE p.products_id=" . $_POST['add_product_products_id'] . " AND pd.language_id = '" . (int)$languages_id . "'"; $result = tep_db_query($InfoQuery); $row = tep_db_fetch_array($result); if (is_array($row)) extract($row, EXTR_PREFIX_ALL, "p"); // 2.1.3 Pull specials price from db if there is an active offer $special_price = tep_db_query(" SELECT specials_new_products_price FROM " . TABLE_SPECIALS . " WHERE products_id =". $_POST['add_product_products_id'] . " AND status"); $new_price = tep_db_fetch_array($special_price); if ($new_price) { $p_products_price = $new_price['specials_new_products_price']; } //sppc patch //Set to false by default, configurable in the My Store section of the admin panel //thanks to whistlerxj for the original version of this patch if (ORDER_EDITOR_USE_SPPC == 'true') { // first find out the customer associated with this order ID.. $c_id_result = tep_db_query('SELECT customers_id FROM orders WHERE orders_id="' . (int)$oID . '"'); $cid = tep_db_fetch_array($c_id_result); if ($cid){ $cust_id = $cid['customers_id']; // now find the customer's group. $c_g_id_result = tep_db_query('SELECT customers_group_id FROM customers WHERE customers_id="' . $cust_id . '"'); $c_g_id = tep_db_fetch_array($c_g_id_result); if ($c_g_id){ $cust_group_id = $c_g_id['customers_group_id']; // get the price of the product from the products_groups table. $price_result = tep_db_query('SELECT customers_group_price FROM products_groups WHERE products_id="' . $_POST['add_product_products_id'] . '" AND customers_group_id="' . $cust_group_id . '"'); $price_array = tep_db_fetch_array($price_result); if ($price_array){ // set the price of the new product to the group specific price. $p_products_price = $price_array['customers_group_price']; } } } } //end sppc patch // 2.2 UPDATE ORDER #### $Query = "INSERT INTO " . TABLE_ORDERS_PRODUCTS . " SET orders_id = '" . (int)$oID . "', products_id = '" . $_POST['add_product_products_id'] . "', products_model = '" . $p_products_model . "', products_name = '" . tep_html_quotes($p_products_name) . "', products_price = '" . $p_products_price . "', final_price = '" . ($p_products_price + $AddedOptionsPrice) . "', products_tax = '" . tep_get_tax_rate($p_products_tax_class_id, $order->delivery['country_id'], $order->delivery['zone_id']) . "', products_quantity = '" . $_POST['add_product_quantity'] . "'"; tep_db_query($Query); $new_product_id = tep_db_insert_id(); // 2.2.1 Update inventory Quantity //This is only done if store is set up to use stock if (STOCK_LIMITED == 'true'){ tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET products_quantity = products_quantity - " . $_POST['add_product_quantity'] . " WHERE products_id = '" . $_POST['add_product_products_id'] . "'"); } //2.2.1.1 Update products_ordered info tep_db_query ("UPDATE " . TABLE_PRODUCTS . " SET products_ordered = products_ordered + " . $_POST['add_product_quantity'] . " WHERE products_id = '" . $_POST['add_product_products_id'] . "'"); //2.2.1.2 keep a record of the products attributes if (is_array ($_POST['add_product_options'])) { foreach($_POST['add_product_options'] as $option_id => $option_value_id) { $Query = "INSERT INTO " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " SET orders_id = '" . (int)$oID . "', orders_products_id = '" . $new_product_id . "', products_options = '" . $option_names[$option_id] . "', products_options_values = '" . tep_db_input($option_values_names[$option_value_id]) . "', options_values_price = '" . $option_value_details[$option_id][$option_value_id]['options_values_price'] . "', price_prefix = '" . $option_value_details[$option_id][$option_value_id]['price_prefix'] . "'"; tep_db_query($Query); //add on for downloads if (DOWNLOAD_ENABLED == 'true' && isset($filename[$option_id])) { $Query2 = "INSERT INTO " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " SET orders_id = '" . (int)$oID . "', orders_products_id = '" . $new_product_id . "', orders_products_filename = '" . $filename[$option_id] . "', download_maxdays = '" . $maxdays[$option_id] . "', download_count = '" . $maxcount[$option_id] . "'"; tep_db_query($Query2); } //end if (DOWNLOAD_ENABLED == 'true') { //end downloads } } // 2.2.2 Calculate Tax and Sub-Totals $order = new oe_order($oID); $RunningSubTotal = 0; // -> VDSTHT $RunningNetto = 0; // <- VDSTHT $RunningTax = array($default_tax_name => 0); //just adding in shipping tax, don't mind me $ot_shipping_query = tep_db_query(" SELECT value FROM " . TABLE_ORDERS_TOTAL . " WHERE orders_id = '" . (int)$oID . "' AND class = 'ot_shipping'"); while ($ot_shipping_info = tep_db_fetch_array($ot_shipping_query)) { $ot_shipping_value = $ot_shipping_info['value']; if (DISPLAY_PRICE_WITH_TAX == 'true') { $RunningTax[$default_tax_name] += ($ot_shipping_value * $order->info['shipping_tax'] / ($order->info['shipping_tax'] + 100)); } else { $RunningTax[$default_tax_name] += (($order->info['shipping_tax'] / 100) * $ot_shipping_value); }// end if (DISPLAY_PRICE_WITH_TAX == 'true') { }// end while // end shipping tax calcs for ($i=0; $iproducts); $i++) { // This calculatiion of Subtotal and Tax is part of the 'add a product' process // -> VDSTHT $RunningSubTotal += (($order->products[$i]['tax'] / 100 + 1) * ($order->products[$i]['qty'] * $order->products[$i]['final_price'])); $RunningNetto += ($order->products[$i]['qty'] * $order->products[$i]['final_price']); /* if (DISPLAY_PRICE_WITH_TAX == 'true') { $RunningSubTotal += (($order->products[$i]['tax'] / 100 + 1) * ($order->products[$i]['qty'] * $order->products[$i]['final_price'])); } else { $RunningSubTotal += ($order->products[$i]['qty'] * $order->products[$i]['final_price']); } */ // <- VDSTHT $RunningTax[$order->products[$i]['tax_description']] += (($order->products[$i]['tax'] / 100) * ($order->products[$i]['qty'] * $order->products[$i]['final_price'])); }// end of for ($i=0; $iproducts); $i++) { // 2.2.2.1 Tax foreach ($RunningTax as $key => $val) { $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' set text = "' . $currencies->format($val, true, $order->info['currency'], $order->info['currency_value']) . '", value = "' . $val . '" WHERE class= "ot_tax" AND (title = "' . $key . ':" OR title = "' . $key . '") AND orders_id= "' . (int)$oID . '"'; tep_db_query($Query); } // 2.2.2.2 Sub-Total $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' SET text = "' . $currencies->format($RunningSubTotal, true, $order->info['currency'], $order->info['currency_value']) . '", value = "' . $RunningSubTotal . '" WHERE class="ot_subtotal" AND orders_id= "' . (int)$oID . '"'; tep_db_query($Query); // -> VDSTHT // 2.2.2.2.1 ot_subtotal_wotax $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' SET text = "' . $currencies->format($RunningNetto, true, $order->info['currency'], $order->info['currency_value']) . '", value = "' . $RunningNetto . '" WHERE class="ot_subtotal_wotax" AND orders_id= "' . (int)$oID . '"'; tep_db_query($Query); // <- VDSTHT // 2.2.2.3 Total if (DISPLAY_PRICE_WITH_TAX == 'true') { $Query = 'SELECT sum(value) AS total_value from ' . TABLE_ORDERS_TOTAL . ' WHERE class != "ot_total" // -> VDSTHT AND class != "ot_subtotal_wotax" // <- VDSTHT AND class != "ot_tax" AND orders_id= "' . (int)$oID . '"'; $result = tep_db_query($Query); $row = tep_db_fetch_array($result); $Total = $row['total_value']; } else { $Query = 'SELECT sum(value) AS total_value from ' . TABLE_ORDERS_TOTAL . ' WHERE class != "ot_total" // -> VDSTHT AND class != "ot_subtotal_wotax" // <- VDSTHT AND orders_id= "' . (int)$oID . '"'; $result = tep_db_query($Query); $row = tep_db_fetch_array($result); $Total = $row['total_value']; } $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' set text = "' . $currencies->format($Total, true, $order->info['currency'], $order->info['currency_value']) . '", value = "' . $Total . '" WHERE class="ot_total" and orders_id= "' . (int)$oID . '"'; tep_db_query($Query); // 2.3 REDIRECTION ##### tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=edit')); } break; // 3. NEW ORDER EMAIL ############################################################################################### case 'email': $oID = tep_db_prepare_input($_GET['oID']); $order = new oe_order($oID); for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { //loop all the products in the order $products_ordered_attributes = ''; if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) { for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) { $products_ordered_attributes .= "\n\t" . $order->products[$i]['attributes'][$j]['option'] . ' ' . $order->products[$i]['attributes'][$j]['value']; } } $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"; } //Build the email $email_order = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . (int)$oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . HTTP_CATALOG_SERVER . '/account_history_info.php?order_id=' . (int)$oID . "\n" . EMAIL_TEXT_DATE_MODIFIED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n"; if ($_POST['comments']) { $email_order .= $_POST['comments'] . "\n\n"; } $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n" . $products_ordered . EMAIL_SEPARATOR . "\n"; for ($i=0, $n=sizeof($order->totals); $i<$n; $i++) { $email_order .= strip_tags($order->totals[$i]['title']) . ' ' . strip_tags($order->totals[$i]['text']) . "\n"; } if ($order->content_type != 'virtual') { $email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . $order->delivery['name'] . "\n"; if ($order->delivery['company']) { $email_order .= $order->delivery['company'] . "\n"; } $email_order .= $order->delivery['street_address'] . "\n"; if ($order->delivery['suburb']) { $email_order .= $order->delivery['suburb'] . "\n"; } $email_order .= $order->customer['city'] . "\n"; if ($order->delivery['state']) { $email_order .= $order->delivery['state'] . "\n"; } $email_order .= $order->customer['postcode'] . "\n" . $order->delivery['country'] . "\n"; } $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . $order->billing['name'] . "\n"; if ($order->billing['company']) { $email_order .= $order->billing['company'] . "\n"; } $email_order .= $order->billing['street_address'] . "\n"; if ($order->billing['suburb']) { $email_order .= $order->billing['suburb'] . "\n"; } $email_order .= $order->customer['city'] . "\n"; if ($order->billing['state']) { $email_order .= $order->billing['state'] . "\n"; } $email_order .= $order->customer['postcode'] . "\n" . $order->billing['country'] . "\n\n"; $email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . EMAIL_SEPARATOR . "\n"; $email_order .= $order->info['payment_method'] . "\n\n"; if ($order->info['payment_method'] == 'NAMEOFPAYMENTMETHOD') { $email_order .= EMAIL_TEXT_PAYMENT_INFO . "\n\n"; } if (EMAIL_TEXT_FOOTER) { $email_order .= EMAIL_TEXT_FOOTER . "\n\n"; } //code for plain text emails which changes the € sign to EUR, otherwise the email will show ? instead of € $email_order = str_replace("€","EUR",$email_order); $email_order = str_replace(" "," ",$email_order); //code which replaces the
tags within EMAIL_TEXT_PAYMENT_INFO and EMAIL_TEXT_FOOTER with the proper \n $email_order = str_replace("
","\n",$email_order); //send the email to the customer tep_mail($order->customer['name'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); // send emails to other people as necessary if (SEND_EXTRA_ORDER_EMAILS_TO != '') { tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } //do the dirty $messageStack->add_session(SUCCESS_EMAIL_SENT, 'success'); tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=edit')); break; ////end case 3 (email) of switch statement //4. edit case 'edit': if (isset($_GET['oID'])) { $oID = tep_db_prepare_input($_GET['oID']); $order = new oe_order($oID); $orders_query = tep_db_query(" SELECT orders_id FROM " . TABLE_ORDERS . " WHERE orders_id = '" . (int)$oID . "'"); $order_exists = true; if (!tep_db_num_rows($orders_query)) { $order_exists = false; $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error'); } } break; //end case 4 (edit) } //end switch ($action) { } //end if (tep_not_null($action)) { //and, we're off.... ?> > <?php echo TITLE; ?>
'; } /// end if action == edit if ($action == "add_product"){ ?> ' . "\n"; } ?>
info['date_purchased']) . ')'; ?> ' . tep_image_button('button_details.gif', IMAGE_EDIT) . ' ' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . ' ' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . ' ' . tep_image_button('button_back.gif', IMAGE_BACK) . ' '; ?>
        
, customer['country_id']), $order->customer['zone_id']); ?>
customer['country']), 'onchange="update_zone(this.form, \'update_customer_country_id\', \'update_customer_zone_id\', \'customerStateInput\', \'customerStateMenu\');"'); ?>
'>
, delivery['country_id']), $order->delivery['zone_id']); ?>
delivery['country']), 'onchange="update_zone(this.form, \'update_delivery_country_id\', \'update_delivery_zone_id\', \'deliveryStateInput\', \'deliveryStateMenu\');"'); ?>
 
, billing['country_id']), $order->billing['zone_id']); ?>
billing['country']), 'onchange="update_zone(this.form, \'update_billing_country_id\', \'update_billing_zone_id\', \'billingStateInput\', \'billingStateMenu\');"'); ?>
read()) { if (!is_dir( $module_directory . $file)) { if (substr($file, strrpos($file, '.')) == $file_extension) { $directory_array[] = $file; } } } sort($directory_array); $dir->close(); } // For each available payment module, check if enabled for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) { $file = $directory_array[$i]; include(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/payment/' . $file); include($module_directory . $file); $class = substr($file, 0, strrpos($file, '.')); if (tep_class_exists($class)) { $module = new $class; if ($module->check() > 0) { // If module enabled create array of titles $enabled_payment[] = array('id' => $module->title, 'text' => $module->title); //if the payment method is the same as the payment module title then don't add it to dropdown menu if ($module->title == $order->info['payment_method']) { $paymentMatchExists='true'; } } } } //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 if ($paymentMatchExists !='true') { $enabled_payment[] = array('id' => $order->info['payment_method'], 'text' => $order->info['payment_method']); } $enabled_payment[] = array('id' => 'Other', 'text' => 'Other'); //draw the dropdown menu for payment methods and default to the order value echo tep_draw_pull_down_menu('update_info_payment_method', $enabled_payment, $order->info['payment_method'], 'id="update_info_payment_method" onChange="init()"'); } else { //draw the input field for payment methods and default to the order value ?> currencies); $currencies_array = array(); while (list($key, $value) = each($currencies->currencies)) { $currencies_array[] = array('id' => $key, 'text' => $value['title']); } echo tep_draw_pull_down_menu('update_info_payment_currency', $currencies_array, $order->info['currency'], 'id="update_info_payment_currency" onChange="currency()"'); ?>
products); $i++) { //calculate total weight $products_weight = array($order->products[$i]['weight'] * $order->products[$i]['qty']); foreach ($products_weight as $key => $value); $total_weight += $value; //end total weight $orders_products_id = $order->products[$i]['orders_products_id']; $RowStyle = "dataTableContent"; echo ' ' . "\n" . ' \n" . ' \n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n"; } ?>
' . "
' . "products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-qty'>
' . ""; // Has Attributes? if (sizeof($order->products[$i]['attributes']) > 0) { for ($j=0; $jproducts[$i]['attributes']); $j++) { $orders_products_attributes_id = $order->products[$i]['attributes'][$j]['orders_products_attributes_id']; echo '
  - ' . "" . ': ' . "" . ': ' . "products[$i]['tax_description'] . "', '" . $orders_products_attributes_id . "')\">" . ': ' . "products[$i]['tax_description'] . "', '" . $orders_products_attributes_id . "')\" id='p". $orders_products_id . "a" . $orders_products_attributes_id . "'>"; echo ''; } //end for ($j=0; $jproducts[$i]['attributes']); $j++) { //Has downloads? if (DOWNLOAD_ENABLED == 'true') { $downloads_count = 1; $d_index = 0; $download_query_raw ="SELECT orders_products_download_id, orders_products_filename, download_maxdays, download_count FROM " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " WHERE orders_products_id='" . $orders_products_id . "' AND orders_id='" . (int)$oID . "' ORDER BY orders_products_download_id"; $download_query = tep_db_query($download_query_raw); // if (isset($downloads->products)) unset($downloads->products); // if (tep_db_num_rows($download_query) > 0) { while ($download = tep_db_fetch_array($download_query)) { $downloads->products[$d_index] = array( 'id' => $download['orders_products_download_id'], 'filename' => $download['orders_products_filename'], 'maxdays' => $download['download_maxdays'], 'maxcount' => $download['download_count']); $d_index++; } } for ($mm=0; $mmproducts); $mm++) { $id = $downloads->products[$mm]['id']; echo '
'; echo '' . ENTRY_DOWNLOAD_COUNT . $downloads_count . ""; echo '
' . "\n"; echo ' - ' . ENTRY_DOWNLOAD_FILENAME . ": "; echo '
' . "\n"; echo ' - ' . ENTRY_DOWNLOAD_MAXDAYS . ": "; echo '
' . "\n"; echo ' - ' . ENTRY_DOWNLOAD_MAXCOUNT . ": "; echo ' ' . "\n"; echo '
'; $downloads_count++; } //end for ($mm=0; $mmproducts[$i]['attributes']) > 0) { echo '
' . "" . '' . "products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-tax'>" . "" . "products[$i]['final_price'] / 100 * $order->products[$i]['qty']), 4, '.', '') . "'>" . '' . "products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-price'>" . '' . "products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-final_price'>" . '' . "products[$i]['tax']/100) + 1)), 4, '.', '') . "' onKeyUp=\"updatePrices('price_incl', 'p" . $orders_products_id . "', '" . $order->products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-price_incl'>" . '' . "products[$i]['qty'], 4, '.', '') . "' onKeyUp=\"updatePrices('total_excl', 'p" . $orders_products_id . "', '" . $order->products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-total_excl'>" . '' . "products[$i]['tax']/100) + 1))) * $order->products[$i]['qty'], 4, '.', '') . "' onKeyUp=\"updatePrices('total_incl', 'p" . $orders_products_id . "', '" . $order->products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-total_incl'>" . '' . "products[$i]['qty']), 2, '.', '') . "' id='p" . $orders_products_id . "-total_weight' readonly='readonly'>" . "" . '' . "" . "" . '
' . tep_draw_separator('pixel_trans.gif', '1', '1') . '
' . tep_image_button('button_add_article.gif', ADDING_TITLE) . ''; ?>
        
totals); $i++) { $TotalsLengthArray[] = array("Name" => $order->totals[$i]['title']); } reset($TotalsLengthArray); foreach($TotalsLengthArray as $TotalIndex => $TotalDetails) { if (strlen($TotalDetails["Name"]) > $max_length) { $max_length = strlen($TotalDetails["Name"]); } } // END OF MAKING ALL INPUT FIELDS THE SAME LENGTH $TotalsArray = array(); for ($i=0; $itotals); $i++) { $TotalsArray[] = array( "Name" => $order->totals[$i]['title'], "Price" => number_format($order->totals[$i]['value'], 2, '.', ''), "Class" => $order->totals[$i]['class'], "TotalID" => $order->totals[$i]['orders_total_id']); $TotalsArray[] = array( "Name" => "", "Price" => "", "Class" => "ot_custom", "TotalID" => "0"); } array_pop($TotalsArray); foreach($TotalsArray as $TotalIndex => $TotalDetails) { $TotalStyle = "smallText"; // -> VDSTHT // if ($TotalDetails["Class"] == "ot_total" || $TotalDetails["Class"] == "ot_subtotal") { if ($TotalDetails["Class"] == "ot_total" || $TotalDetails["Class"] == "ot_subtotal" || $TotalDetails["Class"] == "ot_subtotal_wotax") { // <- VDSTHT $id = $TotalDetails["Class"];//subtotal and total should each only exist once } elseif ($TotalDetails["Class"] == "ot_tax") { $id = preg_replace("/:$/", "", $TotalDetails["Name"]) . '-total'; } elseif ($TotalDetails["Class"] == "ot_shipping") { $id = $TotalDetails["Class"] . $TotalIndex; } else { $id = $TotalDetails["Class"] . $TotalIndex; } if(//tax, subtotal, and total are not editable, but have all the same format $TotalDetails["Class"] == "ot_total" || // -> VDSTHT $TotalDetails["Class"] == "ot_subtotal_wotax" || // <- VDSTHT $TotalDetails["Class"] == "ot_subtotal" || $TotalDetails["Class"] == "ot_tax") { echo ' ' . "\n" . ' ' . ' ' . ' ' . "\n"; } elseif (($TotalDetails["Class"] == "ot_shipping") && (ORDER_EDITOR_SHIPPING_DROPDOWN == 'true')) { //shipping method dropdown? // Get list of all payment modules available $enabled_shipping = array(); $shipping_directory = DIR_FS_CATALOG_MODULES . 'shipping/'; $shipping_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.')); if ($dir = @dir($shipping_directory)) { while ($file = $dir->read()) { if (!is_dir( $shipping_directory . $file)) { if (substr($file, strrpos($file, '.')) == $shipping_extension) { $shipping_array[] = $file; } } } sort($shipping_array); $dir->close(); } // For each available shipping module, check if enabled for ($i=0, $n=sizeof($shipping_array); $i<$n; $i++) { $file = $shipping_array[$i]; include(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/shipping/' . $file); include($shipping_directory . $file); $class = substr($file, 0, strrpos($file, '.')); if (tep_class_exists($class)) { $module = new $class; if ($module->check() > 0) { // If module enabled create array of titles $enabled_shipping[] = array('id' => $module->title, 'text' => $module->title . ':'); //if the shipping method is the same as the payment module title then don't add it to dropdown menu if (($module->title == $TotalDetails["Name"]) ||($module->title . ':' == $TotalDetails["Name"])) { $shippingMatchExists='true'; } } } } //in case the shipping method found in db is not the same as the shipping module title then make it part of the dropdown array or else it cannot be the selected default value if ($shippingMatchExists !='true') { $enabled_shipping[] = array('id' => $TotalDetails["Name"], 'text' => $TotalDetails["Name"]); } $enabled_shipping[] = array('id' => 'Other', 'text' => 'Other:'); //draw the dropdown menu for shipment methods and default to the order value echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; } else { //no shipping dropdown, the other total components are editable echo ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n"; } } ?>
'; ?>
' . $TotalDetails["Name"] . '' . "" . "" . "" . "\n" . "" . '' . tep_draw_separator('pixel_trans.gif', '1', '17') . '' . '
' . "\n"; echo tep_draw_pull_down_menu('update_totals[' . $TotalIndex . '][title]', $enabled_shipping, $TotalDetails["Name"], 'style="width:' . $max_length . '"'); echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . tep_draw_separator('pixel_trans.gif', '1', '17') . '' . "\n"; echo '
' . "" . '' . "" . "" . "" . ' ' . tep_draw_separator('pixel_trans.gif', '1', '17') . '' . '
' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' \n"; } else { echo tep_image(DIR_WS_ICONS . 'cross.gif', ICON_CROSS) . "\n"; } echo ' ' . "\n" . ' ' . "\n"; echo ' ' . "\n" . ' ' . "\n"; echo ' ' . "\n"; } } else { echo ' ' . "\n" . ' ' . "\n" . ' ' . "\n"; } ?>
       
 ' . tep_datetime_short($orders_history['date_added']) . ' '; if ($orders_history['customer_notified'] == '1') { echo tep_image(DIR_WS_ICONS . 'tick.gif', ICON_TICK) . " ' . $orders_status_array[$orders_history['orders_status_id']] . ' ' . tep_draw_textarea_field("update_comments[" . $orders_history['orders_status_history_id'] . "][comments]", "soft", "40", "5", "" . tep_db_output($orders_history['comments']) . "") . '' . "\n" . '
' . TEXT_NO_ORDER_HISTORY . '
 
info['orders_status']); ?>
 
        
) ' . tep_image_button('button_back.gif', IMAGE_BACK) . ''; ?>
' . "\n"; echo '' . tep_draw_form('quick_find', FILENAME_ORDERS_EDIT,'oID=' . $_GET['oID'] . '&action=' . $_GET['action']) . "\n"; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; // Step 2: Choose Options if( (($_GET['step'] > 1) && ($_GET['add_product_products_id'] > 0)) || (($_POST['step'] > 1) && ($_POST['add_product_products_id'] > 0)) ) { // Get Options for Products $products_attributes_query = tep_db_query(" SELECT count(*) AS total FROM " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib WHERE patrib.products_id='" . $_GET['add_product_products_id'] . "' AND patrib.options_id = popt.products_options_id AND popt.language_id = '" . (int)$languages_id . "'"); $products_attributes = tep_db_fetch_array($products_attributes_query); if ($products_attributes['total'] == 0) { echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; $_POST['step'] = 3; } else //product options exist { echo '' . tep_draw_form('addProduct', FILENAME_ORDERS_EDIT,'oID=' . $_GET['oID'] . '&action=' . $_GET['action'] . '&add_product_products_id=' . $_GET['add_product_products_id']) . "\n"; echo ''; echo '' . "\n"; echo '' . "\n"; } echo '' . "\n"; } // Step 3: Confirm if($_POST['step'] > 2) { echo '' . tep_draw_form('addProduct', FILENAME_ORDERS_EDIT,'oID=' . $_GET['oID'] . '&action=' . $_GET['action']) . "\n"; echo ''; echo ''; echo ''; echo '' . "\n"; echo '' . "\n"; } echo '
' . ADDPRODUCT_TEXT_STEP . ' 1:'; if (isset($_GET['add_product_products_id'])) { $form_product_name_query = tep_db_query(" SELECT products_name FROM " . TABLE_PRODUCTS_DESCRIPTION . " WHERE products_id = '" . $_GET['add_product_products_id'] . "' AND language_id = '" . (int)$languages_id . "'"); $form_product_name = tep_db_fetch_array($form_product_name_query); echo ' ' . ''; }else{ echo ' ' . ''; } echo '' . "\n"; echo '
 
' . ADDPRODUCT_TEXT_STEP . ' 2: ' . ADDPRODUCT_TEXT_OPTIONS_NOTEXIST . '
' . ADDPRODUCT_TEXT_STEP . ' 2: '; $products_options_name_query = tep_db_query(" SELECT distinct popt.products_options_id, popt.products_options_name FROM " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib WHERE patrib.products_id='" . $_GET['add_product_products_id'] . "' AND patrib.options_id = popt.products_options_id AND popt.language_id = '" . (int)$languages_id . "' ORDER BY popt.products_options_name"); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $products_options_array = array(); $products_options_query = tep_db_query(" SELECT pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov WHERE pa.products_id = '" . $_GET['add_product_products_id'] . "' AND pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' AND pa.options_values_id = pov.products_options_values_id AND pov.language_id = '" . (int)$languages_id . "'"); while ($products_options = tep_db_fetch_array($products_options_query)) { $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); if ($products_options['options_values_price'] != '0') { $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } } if(isset($_POST['add_product_options'])) { $selected_attribute = $_POST['add_product_options'][$products_options_name['products_options_id']]; } else { $selected_attribute = false; } echo $products_options_name['products_options_name'] . ':' . "\n"; echo tep_draw_pull_down_menu('add_product_options[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . '
' . "\n"; } echo '
'; echo ''; echo ''; echo '
 
' . ADDPRODUCT_TEXT_STEP . ' 3: ' . ADDPRODUCT_TEXT_CONFIRM_QUANTITY . ''; if(is_array ($_POST['add_product_options'])) { foreach($_POST['add_product_options'] as $option_id => $option_value_id) { echo ''; } } echo ''; echo ''; echo '