Jump to content
Sign in to follow this  
Buttmunch

[Contribution] Order Update

Recommended Posts

I have been trying to use this contribution, but I need it to add tax to the shipping.

 

The problem is when you update the order, the tax is actually taken OFF the order! And it changes the total, when it shouldn't.

 

Has anybody managed to make this Mod leave the tax in shipping, or if shipping is changed add the tax back in again??

 

Here is the full code for the Order Update contribution:

<?php

/*

 Order Update Contribution  

 update_order.php German v 1.1 2003/02/18 

 German Version and some new Features by Martin Kruse  m.kruse@kruma2000.de 

 Several Enhancements by Alonso Acu?a alonso@admintek.net

 Heavily Modified by Shawn W. Roy shawn@the-wizards.com

 Original Code by Jonathan Hilgeman jhilgeman@red-tea-rooibos.com

 

*/

// This is a "Bolt-On Contribution". You should be able to drop this file 

// into your Admin Directory and edit the configuration data below. 

// Once complete you can link to this file from the Administration Site or

// simply navigate to http://yourwebsite.com/youradmindir/update_order.php



//TODO:

// *osCommerce coding standard generally not observed

// *clean up code, there are references to GET vars as global vars

// *replace print("HTML CODE") with HTML code blocks

// *tables are sometimes accessed with constant names sometimes directly

// *no language support

// *uses own db functions

// *filter orders by status

// *force manual entry of order id instead of combobox if too many orders

// *Add the abiltiy to change the Delivery address separate from the Billing address

// *Add USPS and Fedex Shipping options if selected via the rest of the admin module

// *Add UPS worldwide shipping

// *Change the shipping options (RDP, CP, RES) to utilize the set variables from the Admin module



require("includes/application_top.php");

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();



// ---Begin Edit---

// Your Store Variables

$btf = "1";                                           // 1 wenn Lastschriftmodul installiert - 0 wenn nicht

$cod = "1";                                              // 1 wenn Nachnamemodul installiert - 0 wenn nicht

$showcc = "0";                                         // Kreditkartendaten anzeigen -> 1 an - 0 aus

$Handle = "0";         	 // Extra Kosten f?r Handling und Versand - 0 f?r keine

$OriginZip = "22111";       	 // Shop PLZ f?r die Berechnung der UPS Kosten

$UpsPath = "../catalog/includes/classes/_ups.php";  // Path should point to your catalog/includes/classes/_ups.php file 

$Country = "US";          // UPS Country Origin - Use ISO country codes! 

$UPSPickup = "RDP";          // See the rate() function for codes

$Container = "CP";          // See the container() function for codes

$Deliver = "RES";          // See the rescom() function for codes         	 



// ---End Edit--- 

// ----------------------------------------



$db_Database = DB_DATABASE;      

$db_Table_Orders = TABLE_ORDERS;   	 

$db_Table_Orders_Products = TABLE_ORDERS_PRODUCTS;	

$db_Table_Orders_Totals = TABLE_ORDERS_TOTAL;  

$db_Table_Products = TABLE_PRODUCTS;    

$db_Table_Products_Description = TABLE_PRODUCTS_DESCRIPTION;





// #### Define Messages

$Msg_CouldNotGetOrders = "I was unable to fetch the orders listings from $db_Database.$db_Table_Orders. Make sure $db_Database is a valid osCommerce 2.2 database.";

$Msg_CouldNotGetOrderInfo = "I was unable to fetch the orders information from $db_Database.$db_Table_Orders. Make sure you have a valid order ID.";

$Msg_CouldNotGetOrdersProducts = "I was unable to fetch the order's products information from $db_Database.$db_Table_Orders_Products. Make sure you have a valid order ID.";

$Msg_CouldNotGetOrdersTotals = "I was unable to fetch the order's totals information from $db_Database.$db_Table_Orders_Totals. Make sure you have a valid order ID.";

$Msg_CouldNotGetProducts = "I was unable to fetch the products from $db_Database.$db_Table_Products.";



// #### Get Available Orders

$db_Query = "SELECT orders_id, customers_name, date_purchased FROM $db_Table_Orders ORDER BY date_purchased DESC,customers_name";

$db_Result = db_query($db_Query) or FailPage($Msg_CouldNotGetOrders);

if(db_num_rows($db_Result) > 0)

{

 // Query Successful

 $SelectOrderBox = "<select name='OrderID'>n";

 while($db_Row = db_fetch_assoc($db_Result))

 { $SelectOrderBox .= "<option value='" . $db_Row["orders_id"] . "'";

   if(IsSet($HTTP_GET_VARS['OrderID']) and $db_Row["orders_id"]==$HTTP_GET_VARS['OrderID'])

	 $SelectOrderBox .= " SELECTED ";

   $SelectOrderBox .= ">" . $db_Row["orders_id"] . " : " . $db_Row["date_purchased"] . " : " . $db_Row["customers_name"] . "</option>n"; 

 

 }

 

 $SelectOrderBox .= "</select>n";

}

else

{

 // Query Failed

  FailPage($Msg_CouldNotGetOrders);

}



// #### Load Order

if(IsSet($HTTP_GET_VARS['OrderID']))

{

 if($step == 2)

 {

	 // Print Stats

	 // print "<pre>n";

	 // print_r($HTTP_GET_VARS);

	 // print "</pre>n";

	 

	 // Update CC Info

	 foreach($Orders as $dbVar => $dbVal)

	 { $tmp_Query[] = "$dbVar='$dbVal'"; }

	 $Query = "UPDATE orders SET " . join(", ",$tmp_Query) . " WHERE orders_id=$OrderID";

	 unset($tmp_Query);

	 $Result = db_query($Query);



	 // Update Banktransfer Info

	 if ($btf == 1) {

	 foreach($Bank as $dbVar => $dbVal)

	 { $tmp_Query[] = "$dbVar='$dbVal'"; }

	 $Query = "UPDATE banktransfer SET " . join(", ",$tmp_Query) . " WHERE orders_id=$OrderID";

	 unset($tmp_Query);

	 $Result = db_query($Query);

	 }

	 

	 // Update Order's Products

	 $TotalWeight = 0.00;

	 $SubTotal = 0.00;

	 foreach($OrdersProducts as $OrderProductID => $OrdersProductArray)

	 {

   if($OrdersProductArray["products_quantity"] < 1)

   {

  	 $Query = "DELETE FROM orders_products WHERE orders_products_id=$OrderProductID";

  	 $Result = db_query($Query);

   }

   else

   {

  	 // Extract Important Variables & Calculate

  	 $Tax = $OrdersProductArray["products_tax"];

  	 $OrdersProductArray["final_price"] =  $OrdersProductArray["products_price"];// + tep_calculate_tax($OrdersProductArray["products_price"], $Tax);



  	 // Update Orders_Products Record

  	 foreach($OrdersProductArray as $dbVar => $dbVal)

  	 { $tmp_Query[] = "$dbVar='$dbVal'"; }

  	 $Query = "UPDATE orders_products SET " . join(", ",$tmp_Query) . " WHERE orders_products_id=$OrderProductID";

  	 

  	 unset($tmp_Query);

  	 $Result = db_query($Query);

  	 

  	 // Look up Weight

  	 $Query = "SELECT products_weight FROM products WHERE products_id=" . $OrdersProductArray["products_id"];

  	 $Result = db_query($Query);

  	 $Row = db_fetch_assoc($Result);

  	 $TotalWeight = $TotalWeight + ($Row["products_weight"] * $OrdersProductArray["products_quantity"]);

  	 

  	 // Add to Subtotal

  	 $SubTotal = $SubTotal + ($OrdersProductArray["products_price"] * $OrdersProductArray["products_quantity"]);

   }

	 }

	 

	 // Optional - Add Another Product

	 if(($NewOrdersProductID > 0) && ($NewOrdersProductQuantity > 0))

	 {

   // Look Up Product

   $Query = "SELECT * FROM products p LEFT JOIN products_description pd ON pd.products_id=p.products_id WHERE p.products_id=" . $NewOrdersProductID;

   $Result = db_query($Query);

   $Row = db_fetch_assoc($Result);

   

   // Insert New Orders_Products Record

   $Query = "INSERT INTO orders_products SET orders_products_id=NULL, orders_id=$OrderID, products_id=$NewOrdersProductID, products_model='" . $Row["products_model"] . "', products_name='" . $Row["products_name"] . "', products_price='" . $Row["products_price"] . "', final_price='" . ($Row["products_price"] + ($Row["products_price"]*($Tax/100))). "', products_tax='$Tax', products_quantity=" . $NewOrdersProductQuantity;

   $Result = db_query($Query);

   

   // Add to Weight & SubTotal

   $TotalWeight = $TotalWeight + ($Row["products_weight"] * $NewOrdersProductQuantity);

   $SubTotal = $SubTotal + ($Row["products_price"] * $NewOrdersProductQuantity);

	 }

	 

	 // Create Taxed Sub-Total

	 $TaxedSubTotal = $SubTotal + ($SubTotal * ($Tax/100));

	 $TaxedAmount = $TaxedSubTotal - $SubTotal;

	 

	 // Format Weight

	 $TotalWeight = number_format($TotalWeight,3);



	 //All totals up to here are in default currency, find out order's currency for use later

	 $db_Query = "SELECT currency,currency_value FROM $db_Table_Orders WHERE orders_id=" . $HTTP_GET_VARS["OrderID"];

	 $db_Result = db_query($db_Query) or FailPage($Msg_CouldNotGetOrderInfo);

	 $OrdersInfo = db_fetch_assoc($db_Result);

	 $order_currency = $OrdersInfo['currency'];

	 $order_currency_value = $OrdersInfo['currency_value'];  

	 

	 // Calculate UPS Ground Shipping & Grand Total

	 $GrandTotal = $TaxedSubTotal;

	 if($shipping == "upsgnd")

	 {

   include($UpsPath);

   $rate = new _Ups; 

   $rate->upsProduct("GND");    // See upsProduct() function for codes 

   $rate->origin($OriginZip, $Country);  

   $rate->dest($Orders["customers_postcode"], "US");      // Use ISO country codes! 

   $rate->rate($UPSPickup);       

   $rate->container($Container);     

   $rate->weight($TotalWeight); 

   $rate->rescom($Deliver);     

   $quote = $rate->getQuote(); 

   $quote += $Handle;

   $quote = number_format($quote,2);

   $GrandTotal += $quote;

   // Anfang Nachname Patch

   if ($cod == 1) {

   $db_Query2 = "SELECT * FROM $db_Table_Orders_Totals WHERE class='ot_cod_fee' AND orders_id=" . $HTTP_GET_VARS["OrderID"];

   $db_Result2 = db_query($db_Query2) or FailPage($Msg_CouldNotGetOrderInfo);

   $OrdersInfo2 = db_fetch_assoc($db_Result2);

   $quote2 = empty($OrdersInfo2['value'])?0:$OrdersInfo2['value'];

   $GrandTotal += $quote2;

   }

   // Ende Nachname Patch

	 } 

   if($shipping == "ups3ds") {

	 

   include($UpsPath);

   $rate = new _Ups; 

   $rate->upsProduct("3DS");    // See upsProduct() function for codes 

   $rate->origin($OriginZip, $Country); 

   $rate->dest($Orders["customers_postcode"], "US");      // Use ISO country codes! 

   $rate->rate($UPSPickup);         

   $rate->container($Container);     

   $rate->weight($TotalWeight); 

   $rate->rescom($Deliver);     

   $quote = $rate->getQuote(); 

   $quote += $Handle;

   $quote = number_format($quote,2);

   $GrandTotal += $quote;

   // Anfang Nachname Patch

   if ($cod == 1) {

   $db_Query2 = "SELECT * FROM $db_Table_Orders_Totals WHERE class='ot_cod_fee' AND orders_id=" . $HTTP_GET_VARS["OrderID"];

   $db_Result2 = db_query($db_Query2) or FailPage($Msg_CouldNotGetOrderInfo);

   $OrdersInfo2 = db_fetch_assoc($db_Result2);

   $quote2 = empty($OrdersInfo2['value'])?0:$OrdersInfo2['value'];

   $GrandTotal += $quote2;

   }

   // Ende Nachname Patch

	 }

	 if($shipping == "ups1dm") {

	 

   include($UpsPath);

   $rate = new _Ups; 

   $rate->upsProduct("1DM");    // See upsProduct() function for codes 

   $rate->origin($OriginZip, $Country); 

   $rate->dest($Orders["customers_postcode"], "US");      // Use ISO country codes! 

   $rate->rate($UPSPickup);        

   $rate->container($Container);    

   $rate->weight($TotalWeight); 

   $rate->rescom($Deliver);     

   $quote = $rate->getQuote(); 

   $quote += $Handle;

   $quote = number_format($quote,2);

   $GrandTotal += $quote;

   // Anfang Nachname Patch

   if ($cod == 1) {

   $db_Query2 = "SELECT * FROM $db_Table_Orders_Totals WHERE class='ot_cod_fee' AND orders_id=" . $HTTP_GET_VARS["OrderID"];

   $db_Result2 = db_query($db_Query2) or FailPage($Msg_CouldNotGetOrderInfo);

   $OrdersInfo2 = db_fetch_assoc($db_Result2);

   $quote2 = empty($OrdersInfo2['value'])?0:$OrdersInfo2['value'];

   $GrandTotal += $quote2;

   }

   // Ende Nachname Patch

	 }

	 if($shipping == "ups1da") {

	 

   include($UpsPath);

   $rate = new _Ups; 

   $rate->upsProduct("1DA");    // See upsProduct() function for codes 

   $rate->origin($OriginZip, $Country); 

   $rate->dest($Orders["customers_postcode"], "US");      // Use ISO country codes! 

   $rate->rate($UPSPickup);        

   $rate->container($Container);    

   $rate->weight($TotalWeight); 

   $rate->rescom($Deliver);    

   $quote = $rate->getQuote(); 

   $quote += $Handle;

   $quote = number_format($quote,2);

   $GrandTotal += $quote;

   // Anfang Nachname Patch

   if ($cod == 1) {

   $db_Query2 = "SELECT * FROM $db_Table_Orders_Totals WHERE class='ot_cod_fee' AND orders_id=" . $HTTP_GET_VARS["OrderID"];

   $db_Result2 = db_query($db_Query2) or FailPage($Msg_CouldNotGetOrderInfo);

   $OrdersInfo2 = db_fetch_assoc($db_Result2);

   $quote2 = empty($OrdersInfo2['value'])?0:$OrdersInfo2['value'];

   $GrandTotal += $quote2;

   }

   // Ende Nachname Patch

	 }

	 if($shipping == "ups2da") {

	 

   include($UpsPath);

   $rate = new _Ups; 

   $rate->upsProduct("2DA");    // See upsProduct() function for codes 

   $rate->origin($OriginZip, $Country);  

   $rate->dest($Orders["customers_postcode"], "US");      // Use ISO country codes! 

   $rate->rate($UPSPickup);       

   $rate->container($Container);     

   $rate->weight($TotalWeight); 

   $rate->rescom($Deliver);     

   $quote = $rate->getQuote(); 

   $quote += $Handle;

   $quote = number_format($quote,2);

   $GrandTotal += $quote;

   // Anfang Nachname Patch

   if ($cod == 1) {

   $db_Query2 = "SELECT * FROM $db_Table_Orders_Totals WHERE class='ot_cod_fee' AND orders_id=" . $HTTP_GET_VARS["OrderID"];

   $db_Result2 = db_query($db_Query2) or FailPage($Msg_CouldNotGetOrderInfo);

   $OrdersInfo2 = db_fetch_assoc($db_Result2);

   $quote2 = empty($OrdersInfo2['value'])?0:$OrdersInfo2['value'];

   $GrandTotal += $quote2;

   }

   // Ende Nachname Patch

	 }

	 if($shipping == "ups1dp") { 	 

   include($UpsPath);

   $rate = new _Ups; 

   $rate->upsProduct("1DP");    // See upsProduct() function for codes 

   $rate->origin($OriginZip, $Country); 

   $rate->dest($Orders["customers_postcode"], "US");      // Use ISO country codes! 

   $rate->rate($UPSPickup);         

   $rate->container($Container);    

   $rate->weight($TotalWeight); 

   $rate->rescom($Deliver);

   $quote = $rate->getQuote();

   $quote += $Handle;

   $quote = number_format($quote,2);

   $GrandTotal += $quote;

   // Anfang Nachname Patch

   if ($cod == 1) {

   $db_Query2 = "SELECT * FROM $db_Table_Orders_Totals WHERE class='ot_cod_fee' AND orders_id=" . $HTTP_GET_VARS["OrderID"];

   $db_Result2 = db_query($db_Query2) or FailPage($Msg_CouldNotGetOrderInfo);

   $OrdersInfo2 = db_fetch_assoc($db_Result2);

   $quote2 = empty($OrdersInfo2['value'])?0:$OrdersInfo2['value'];

   $GrandTotal += $quote2;

   }

   // Ende Nachname Patch

	 }

	 if($shipping == "noupdate") { //find original amount

   $db_Query = "SELECT * FROM $db_Table_Orders_Totals WHERE class='ot_shipping' AND orders_id=" . $HTTP_GET_VARS["OrderID"];

   $db_Result = db_query($db_Query) or FailPage($Msg_CouldNotGetOrderInfo);

   $OrdersInfo = db_fetch_assoc($db_Result);

   $quote = empty($OrdersInfo['value'])?0:$OrdersInfo['value'];

   $GrandTotal += $quote;

   // Anfang Nachname Patch

   if ($cod == 1) {

   $db_Query2 = "SELECT * FROM $db_Table_Orders_Totals WHERE class='ot_cod_fee' AND orders_id=" . $HTTP_GET_VARS["OrderID"];

   $db_Result2 = db_query($db_Query2) or FailPage($Msg_CouldNotGetOrderInfo);

   $OrdersInfo2 = db_fetch_assoc($db_Result2);

   $quote2 = empty($OrdersInfo2['value'])?0:$OrdersInfo2['value'];

   $GrandTotal += $quote2;

   }

   // Ende Nachname Patch

	 }

      	 

	 // Update Totals

   // Get Order's Totals

   $db_Query = "SELECT * FROM $db_Table_Orders_Totals WHERE orders_id=" . $HTTP_GET_VARS["OrderID"];

   $db_Result = db_query($db_Query) or FailPage($Msg_CouldNotGetOrdersTotals);

   if(db_num_rows($db_Result) > 0)

   {

  	 while($db_Row = db_fetch_assoc($db_Result))

  	 {

  	 $OrdersTotals[] = $db_Row;

  	 }

   }

   else

   {

  	 // Query Failed

     FailPage($Msg_CouldNotGetOrdersTotals);

   }



   // Go Through Each Total

   foreach($OrdersTotals as $OrdersTotalArray)

   {

  	 // Taxed Subtotal

  	 if($OrdersTotalArray["class"] == "ot_subtotal")

  	 {

     $OrdersTotalArray["text"] = $currencies->format($TaxedSubTotal,true,$order_currency,$order_currency_value);

     $OrdersTotalArray["value"] = number_format($TaxedSubTotal,4);

  	 }

                  

  	 

  	 // Tax

  	 if($OrdersTotalArray["class"] == "ot_tax")

  	 {

     $OrdersTotalArray["text"] = $currencies->format($TaxedAmount,true,$order_currency,$order_currency_value);

     $OrdersTotalArray["value"] = number_format($TaxedAmount,4);

  	 }



  	 // Shipping

  	 if($OrdersTotalArray["class"] == "ot_shipping")

  	 {

     if($shipping == "noupdate")

     {

    	 continue; //don't mess with it

     }

     if($shipping == "upsgnd")

     {

    	 $shiptitle = 'UPS GND 1 X ' . $TotalWeight . ':';

     }

     elseif($shipping == "spu")

     {

    	 $shiptitle = 'Store Pickup:';

    	 $quote=0;

     }

     elseif($shipping == "ups3ds")

     {

    	 $shiptitle = 'UPS 3DS 1 X ' . $TotalWeight . ':';

     }

     elseif($shipping == "ups1dm")

     {

    	 $shiptitle = 'UPS 1DM 1 X ' . $TotalWeight . ':';

     }

     elseif($shipping == "ups1da")

     {

    	 $shiptitle = 'UPS 1DA 1 X ' . $TotalWeight . ':';

     }

     elseif($shipping == "ups2da")

     {

    	 $shiptitle = 'UPS 2DA 1 X ' . $TotalWeight . ':';

     }

     elseif($shipping == "ups1dp")

     {

    	 $shiptitle = 'UPS 1DP 1 X ' . $TotalWeight . ':';

     }

     $OrdersTotalArray["title"] = $shiptitle;

     $OrdersTotalArray["text"] = $currencies->format($quote,true,$order_currency,$order_currency_value);

     $OrdersTotalArray["value"] = number_format($quote,4);



  	 }



  	 // Grand Total

  	 if($OrdersTotalArray["class"] == "ot_total")

  	 {

     $OrdersTotalArray["text"] = '<b>' . $currencies->format($GrandTotal,true,$order_currency,$order_currency_value) . '</b>';

     $OrdersTotalArray["value"] = number_format($GrandTotal,4);

  	 }

  	 

  	 // Update Totals

  	 foreach($OrdersTotalArray as $dbVar => $dbVal)

  	 { $tmp_Query[] = "$dbVar='$dbVal'"; }

  	 $Query = "UPDATE orders_total SET " . join(", ",$tmp_Query) . " WHERE orders_total_id=" . $OrdersTotalArray["orders_total_id"];

  	 unset($tmp_Query);

  	 $Result = db_query($Query);

  	 

   }

	 

	 // Unset Variables

	 unset($Orders);

	 unset($OrdersProducts);

	 unset($NewOrdersProductID);

	 unset($NewOrdersProducts);

	 unset($shipping);

	 $step = 1;

 }  



 // Get Order Info to Update

 $db_Query = "SELECT * FROM $db_Table_Orders WHERE orders_id=" . $HTTP_GET_VARS["OrderID"];

 $db_Result = db_query($db_Query) or FailPage($Msg_CouldNotGetOrderInfo);

 $OrdersInfo = db_fetch_assoc($db_Result);



 // Get Banktransfer Info

 $db_Query = "SELECT * FROM banktransfer WHERE orders_id=" . $HTTP_GET_VARS["OrderID"];

 $db_Result = db_query($db_Query) or FailPage($Msg_CouldNotGetOrderInfo);

 $OrdersBank = db_fetch_assoc($db_Result);

          	 

 // Get Order's Products

 $db_Query = "SELECT * FROM $db_Table_Orders_Products WHERE orders_id=" . $HTTP_GET_VARS["OrderID"];

 $db_Result = db_query($db_Query) or FailPage($Msg_CouldNotGetOrdersProducts);

 if(db_num_rows($db_Result) > 0)

 {

	 while($db_Row = db_fetch_assoc($db_Result))

	 {

	 $OrdersProducts[] = $db_Row;

	 }

 }

 else

 {

	 // Query Failed

   FailPage($Msg_CouldNotGetOrdersProducts);

 }

          	 

 // Get Order's Totals

 $db_Query = "SELECT * FROM $db_Table_Orders_Totals WHERE orders_id=" . $HTTP_GET_VARS["OrderID"];

 $db_Result = db_query($db_Query) or FailPage($Msg_CouldNotGetOrdersTotals);

 if(db_num_rows($db_Result) > 0)

 {

	 while($db_Row = db_fetch_assoc($db_Result))

	 {

	 $OrdersTotals[] = $db_Row;

	 }

 }

 else

 {

	 // Query Failed

   FailPage($Msg_CouldNotGetOrdersTotals);

 }



 // Get All Products

 $db_Query = "SELECT * FROM $db_Table_Products p LEFT JOIN $db_Table_Products_Description pd ON pd.products_id=p.products_id ORDER BY products_name";

 $db_Result = db_query($db_Query) or FailPage($Msg_CouldNotGetProducts);

 if(db_num_rows($db_Result) > 0)

 {

	 while($db_Row = db_fetch_assoc($db_Result))

	 {

	 $AllProducts[] = $db_Row;

	 }

 }

 else

 {

	 // Query Failed

   FailPage($Msg_CouldNotGetProducts);

 } 	 

 

 /*

 // Success!

 $SuccessMessage = "<font class=main><i>Products in category have been updated successfully!</i></font><br>n";

 */

}



// ===========================================================

// ===========================================================

// ===========================================================



// #### Generate Page

?>  

 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

 <html <?php echo HTML_PARAMS; ?>>

 <head>

 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

 <title>osCommerce 2.2 Order Update Utility (Deutsch)</title>

 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

 </head>

 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

 <!-- header //-->

 <?php

  	 require(DIR_WS_INCLUDES . 'header.php');

 ?>

 <!-- header_eof //-->  

 <table border="0" width="100%" cellspacing="2" cellpadding="2">

   <tr>

     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

	 <!-- left_navigation //-->

	 <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

	 <!-- left_navigation_eof //-->

     </table></td>

 <!-- body_text //-->  

 <td valign="top">

 <table border='0' bgcolor='#7c6bce' width='100%'>

	 <tr><td class=main><font color='#ffffff'><b>osCommerce 2.2 Order Update Utility (Deutsch)</b></td></tr>

 </table>

 <table border='0' cellpadding='7'><tr><td class="main" valign="top">



<?php

// #### "Select" Form

print "<form action='$PHP_SELF' method='GET'>n";

print "<table border='0'>n";



if(IsSet($SuccessMessage))

{

print "<tr>n";

print "<td colspan='2' class=main>$SuccessMessage</td>n";

print "</tr>n";

}



print "<tr>n";

print "<td><font class=main><b>Bitte w?hlen Sie eine Bestellung:</b></font><br>$SelectOrderBox</td>n";

print "<td valign='bottom'><input type='submit' value="Bearbeiten"></td>n";

print "</tr>n";

print "</table>n";

print "</form>n";



// #### "Update" Form

if(IsSet($OrderID))

{

print "<br><form action='$PHP_SELF?OrderID=$OrderID' method='POST'><h3>Bestell Informationen</h1>n";

print "<b><font color="#990000">Klicke unten auf ?nderungen speichern um die ?nderungen zu ?bernehmen.</font></b><br><br>n";

print "<table border='0'>n";

print TRInput_Text("Kunden Name","Orders[customers_name]",$OrdersInfo["customers_name"],20);

print TRInput_Text("eMail","Orders[customers_email_address]",$OrdersInfo["customers_email_address"],30);

print TRInput_Text("Adresse","Orders[customers_street_address]",$OrdersInfo["customers_street_address"],30);

print TRInput_Text("Stadt","Orders[customers_city]",$OrdersInfo["customers_city"],25);

print TRInput_Text("Bundesland","Orders[customers_state]",$OrdersInfo["customers_state"],15);

print TRInput_Text("PLZ","Orders[customers_postcode]",$OrdersInfo["customers_postcode"],6);

print TRInput_Text("Zahlungsart","Orders[payment_method]",$OrdersInfo["payment_method"],20);

// Begin ShowCC

if ($showcc == 1) {

print TRInput_Text("CC Typ","Orders[cc_type]",$OrdersInfo["cc_type"],10);

print TRInput_Text("CC Inhaber","Orders[cc_owner]",$OrdersInfo["cc_owner"],30);

print TRInput_Text("CC Nummer","Orders[cc_number]",$OrdersInfo["cc_number"],20);

print TRInput_Text("CC Ablaufdatum","Orders[cc_expires]",$OrdersInfo["cc_expires"],5);

}

// End ShowCC

// Begin Banktransfer 

if ($btf == 1) {

   print TRInput_Text("Kto. Inhaber","Bank[banktransfer_owner]",$OrdersBank["banktransfer_owner"],20);	

print TRInput_Text("Bank","Bank[banktransfer_bankname]",$OrdersBank["banktransfer_bankname"],30);	

print TRInput_Text("Bankleitzahl","Bank[banktransfer_blz]",$OrdersBank["banktransfer_blz"],20);	

print TRInput_Text("Kto. Nummer","Bank[banktransfer_number]",$OrdersBank["banktransfer_number"],20);	

}

// end Banktransfer

print "<tr>n";

print "<td colspan='2'><br>n";

 print "<table border='0'>n";

 print "<tr>n";

 print "<td class=main><b>Produkt Name</b></td>n";

 print "<td class=main><b>Art.Nr.</b></td>n";

 print "<td class=main><b>Netto ".DEFAULT_CURRENCY."</b></td>n";

 print "<td class=main><b>Brutto ".DEFAULT_CURRENCY."</b></td>n";

 print "<td class=main><b>Steuersatz</b></td>n";

 print "<td class=main><b>Menge</b></td>n";

 print "<td class=main> </td>n";

 print "</tr>n";

 foreach($OrdersProducts as $OrderedProductInfo)

 {

     $steuer = ($OrderedProductInfo["products_price"] * $OrderedProductInfo["products_tax"]) / 100;

	 $bruttopreis = $OrderedProductInfo["products_price"] + $steuer;

	 print "<tr>n";

	 print "<td class=main><input name='OrdersProducts[" . $OrderedProductInfo["orders_products_id"] . "][products_name]' value='" . $OrderedProductInfo["products_name"] . "' size='" . strlen($OrderedProductInfo["products_name"]) . "'>";

	 print "<input type='hidden' name='OrdersProducts[" . $OrderedProductInfo["orders_products_id"] . "][products_id]' value='" . $OrderedProductInfo["products_id"] . "' size='" . strlen($OrderedProductInfo["products_name"]) . "'></td>n";

	 print "<td class=main><input name='OrdersProducts[" . $OrderedProductInfo["orders_products_id"] . "][products_model]' value='" . $OrderedProductInfo["products_model"] . "' size='" . strlen($OrderedProductInfo["products_model"]) . "'></td>n";

	 print "<td class=main><input name='OrdersProducts[" . $OrderedProductInfo["orders_products_id"] . "][products_price]' value='" . $OrderedProductInfo["products_price"] . "' size='" . strlen($OrderedProductInfo["products_price"]) . "'></td>n";

	 print "<td class=main>" . number_format($bruttopreis,2) . "</td>n";

	 print "<td class=main><input name='OrdersProducts[" . $OrderedProductInfo["orders_products_id"] . "][products_tax]' value='" . $OrderedProductInfo["products_tax"] . "' size='" . strlen($OrderedProductInfo["products_tax"]) . "'></td>n";

	 print "<td class=main><input name='OrdersProducts[" . $OrderedProductInfo["orders_products_id"] . "][products_quantity]' value='" . $OrderedProductInfo["products_quantity"] . "' size='" . strlen($OrderedProductInfo["products_quantity"]) . "'></td>n";

	 print "<td class=main><b><font color='white'>.</font></b></td>n";

	 print "</tr>n";

 }

 

 flush();

 print "<tr>n";

 print "<td class=main colspan='4'><select name='NewOrdersProductID'>n";

 print "<option value='0'>W?hle ein Produkt das hinzugef?gt werden solln";

 foreach($AllProducts as $ProductInfoArray)

 {

	 print "<option value='" . $ProductInfoArray["products_id"] . "'>" . $ProductInfoArray["products_name"] . "n";

 }

 print "</select></td>n";

 // print "<td class=main><input name='NewOrdersProducts[products_name]' value='' size='30'>";

 // print "<input type='hidden' name='NewOrdersProducts[products_id]' value='9999'></td>n";

 // print "<td class=main><input name='NewOrdersProducts[products_model]' value='' size='7'></td>n";

 // print "<td class=main><input name='NewOrdersProducts[products_price]' value='' size='" . strlen($OrderedProductInfo["products_price"]) . "'></td>n";

 // print "<td class=main><input name='NewOrdersProducts[products_tax]' value='" . $OrderedProductInfo["products_tax"] . "' size='" . strlen($OrderedProductInfo["products_tax"]) . "'></td>n";

 print "<td class=main><input name='NewOrdersProductQuantity' value='1' size='" . strlen($OrderedProductInfo["products_quantity"]) . "'></td>n";

 print "<td class=main><b><-- NEU</b></td>n";

 print "</tr>n";

 print "</table>n";

print "</td>n";

print "</tr>n";



print "<tr>n";

print "<table border='0'>n";

print "<td class=main><b>Versandart:</b> <br>

<select name='shipping'>

<option value='noupdate'> Keine ?nderungen (Empfohlen)</option>

<option value='spu'> Store Pickup (FREE)</option>

   <option value='upsgnd'> UPS Ground (GND)</option>

<option value='ups3ds'> UPS 3 Day Select (3DS)</option>

<option value='ups2da'> UPS Second Day Air (2DA)</option>

<option value='ups1dp'> UPS Next Day Saver (1DP)</option>

<option value='ups1da'> UPS Next Day Air (1DA)</option>

<option value='ups1dm'> UPS Next Day Air Early AM (1DM)</option></select></td>n";

print "</tr>n";



print "<tr>n";

print "<td><input type='hidden' name='step' value='2'><input type='hidden' name='OrderID' value='$OrderID'><input type='submit' value="?nderungen speichern"></td>n";

print "</tr>n";

print "</table>n";



print "<tr>n";

print "<td colspan='2'>n";

 print "<table border='0'>n";

 foreach($OrdersTotals as $OrderTotalInfo)

 {

	 $TotalOrder = $OrderTotalInfo["sort_order"];

	 $TotalPieces[$TotalOrder] = "<tr><td class=main align='right'><b>" . $OrderTotalInfo["title"] . "</b></td><td class=main>" . $OrderTotalInfo["text"] . "</td></tr>n";

 }

 

 ksort($TotalPieces);

 

 foreach($TotalPieces as $TotalPiece)

 {

	 print $TotalPiece;

 }

 print "</table>n";

print "</td>n";

print "</tr>n";



print "</table>n";

print "</form>n";

}



?>

 </td></tr></table></td></tr></table>

 <!-- footer //-->

 <?php

     require(DIR_WS_INCLUDES . 'footer.php');

 ?>

 <!-- footer_eof //-->

 <br>

 </body>

 </html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>



<?php





// ===========================================================

// ===========================================================

// ===========================================================



// #### Formatting Functions

function TRInput_Text($Label,$Name,$Value,$Size)

{	

 $String  = "<tr>n";

 $String .= "<td><font class=main><b>$Label:</b></font></td><td><input name='$Name' value='$Value' size='$Size'></td>n";

 $String .= "</tr>n";

 

 return $String;

}



function FailPage($Message)

{

?>  

 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

 <html <?php echo HTML_PARAMS; ?>>

 <head>

 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

 <title>osCommerce 2.2 Order Update Utility</title>

 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

 </head>

 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

 <!-- header //-->

 <?php

  	 require(DIR_WS_INCLUDES . 'header.php');

 ?>

 <!-- header_eof //-->  

 <table border='0' bgcolor='#7c6bce' width='100%'>

	 <tr><td class=main><font color='#ffffff'><b>osCommerce 2.2 Order Update Utility</b></td></tr>

 </table>

 <table border='0' cellpadding='7'><tr><td class="main">

<?php

 

print "<font class=main>n";

print "<b>Failure</b><br>n";

print "$Message<br><br>n";



print "<b>Last MySQL Message was:</b><br>n";

print db_error() . "<br>n";



print "<b>Last MySQL Query was:</b><br>n";

global $db_Query;

print $db_Query;



print "</font></td></tr></table>";

die();

}





// #### Database Functions

function db_query($db_Query)

{ print "<!-- " . $db_Query . " -->n";;

 return mysql_query($db_Query); }



function db_num_rows($db_Result)

{ return mysql_num_rows($db_Result); }



function db_fetch_assoc($db_Result)

{ return mysql_fetch_assoc($db_Result); }



function db_error()

{ return mysql_error(); }



?>

 

Any help at all on this, I would REALLY appreciate.

 

I'll even pay for help if someone can please.

Share this post


Link to post
Share on other sites

Hi,

 

did you already find a solution to this problem?

 

Regards,

 

Tom

Share this post


Link to post
Share on other sites

same problem here!

 

I think it would be the easiest way to have an extra field next to each field where you can enter manually the tax rate.

 

like: Product XYZ Price Tax%

Shipping Price Tax%

Discount Price Tax%

-------------------------------

Total (Net) Sum

Tax Sum (calculated from the Price * Tax% above)

Total Sum

 

 

But please, do not forget that a discount also reduces the tax! (so you have a -Tax :) )

 

sry for my bad english.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×