$tmpcontent .= '<td>&nbsp;</td>';
            $tmpcontent .= '<td>&nbsp;</td>';
            $tmpcontent .= '<td>&nbsp;</td>';
            $tmpcontent .= '<td>&nbsp;</td>';
            $tmpcontent .= '</tr>';
            if (!isset($this->get['edit_product'])) {
                $tmpcontent .= '<tr><td colspan="' . $colspan . '" style="text-align:left;"><a href="#" id="button_manual_new_product" class="btn btn-success">' . $this->pi_getLL('add_manual_product', 'ADD ITEM') . '</a></td></tr>';
            }
        } else {
            $colspan = 7;
        }
        //		$tmpcontent.='<tr><td colspan="'.$colspan.'"><hr class="hr"></td></tr>';
        $orders_tax_data = unserialize($orders['orders_tax_data']);
        $tmpcontent .= '<tr><td align="right" colspan="' . $colspan . '" class="">';
        if ($this->ms['MODULES']['ORDER_EDIT'] and !$orders['is_locked']) {
            $payment_method = mslib_fe::getPaymentMethod($orders['payment_method'], 'p.code');
            $shipping_method = mslib_fe::getShippingMethod($orders['shipping_method'], 's.code');
            if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                $shipping_costs = mslib_fe::currency() . ' <input type="text" id="display_shipping_method_cost" value="' . round($orders['shipping_method_costs'] + $orders_tax_data['shipping_tax'], 4) . '" class="align_right" style="width:60px">
				<input name="tx_multishop_pi1[shipping_method_costs]" type="hidden" value="' . $orders['shipping_method_costs'] . '">
				<input type="hidden" id="shipping_method_tax_id" value="' . $shipping_method['tax_id'] . '" class="align_right" style="width:60px">';
                $payment_costs = mslib_fe::currency() . ' <input type="text" id="display_payment_method_cost" value="' . round($orders['payment_method_costs'] + $orders_tax_data['payment_tax'], 4) . '" class="align_right" style="width:60px">
				<input name="tx_multishop_pi1[payment_method_costs]" type="hidden" value="' . $orders['payment_method_costs'] . '">
				<input type="hidden" id="payment_method_tax_id" value="' . $payment_method['tax_id'] . '" class="align_right" style="width:60px">
				';
            } else {
                $shipping_costs = '<input name="tx_multishop_pi1[shipping_method_costs]" type="text" value="' . round($orders['shipping_method_costs'], 4) . '" class="align_right" style="width:60px">';
                $payment_costs = '<input name="tx_multishop_pi1[payment_method_costs]" type="text" value="' . round($orders['payment_method_costs'], 4) . '" class="align_right" style="width:60px">';
            }
        } else {
            if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
$mslib_cart->setPaymentMethod($this->post['tx_multishop_pi1']['pid']);
$cart = $mslib_cart->getCart();
// disable tax if the country is different and vat id is valid (NL & BE only)
if (isset($this->post['b_cc']) && !empty($this->post['b_cc']) && $this->post['tx_multishop_vat_id']) {
    $iso_customer = mslib_fe::getCountryByName($this->post['b_cc']);
    $iso_customer['country'] = $iso_customer['cn_short_en'];
    $vat_id = $this->post['tx_multishop_vat_id'];
}
$this->ms['MODULES']['DISABLE_VAT_RATE'] = 0;
if ($this->ms['MODULES']['DISABLE_VAT_FOR_FOREIGN_CUSTOMERS_WITH_COMPANY_VAT_ID'] and $vat_id) {
    if (strtolower($iso_customer['country']) != strtolower($this->tta_shop_info['country'])) {
        $this->ms['MODULES']['DISABLE_VAT_RATE'] = 1;
    }
}
$countries_id = $tmp_countries['cn_iso_nr'];
$payment_method = mslib_fe::getPaymentMethod($this->post['tx_multishop_pi1']['pid'], 'p.id', $countries_id, true);
if ($payment_method['handling_costs']) {
    if (!strstr($payment_method['handling_costs'], "%")) {
        $payment_method_costs = $payment_method['handling_costs'];
    } else {
        // calculate total payment costs based by %
        //$subtotal = $cart['summarize']['grand_total_excluding_vat'] - ($cart['user']['payment_method_costs']+$cart['user']['shipping_method_costs']);
        // calculate total payment costs based by %
        if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
            $subtotal = $cart['summarize']['sub_total_including_vat'] - $cart['discount_amount'];
        } else {
            $subtotal = $cart['summarize']['sub_total'] - $cart['discount_amount'];
        }
        if ($subtotal) {
            if (strstr($payment_method['handling_costs'], "%")) {
                $percentage = str_replace("%", '', $payment_method['handling_costs']);
 function setPaymentMethod($payment_method)
 {
     if (!$payment_method) {
         return 0;
     }
     $payment_method = mslib_fe::getPaymentMethod($payment_method);
     $iso_customer = mslib_fe::getCountryByName($this->cart['user']['country']);
     $countries_id = $iso_customer['cn_iso_nr'];
     if ($payment_method['handling_costs']) {
         if (!strstr($payment_method['handling_costs'], "%")) {
             $this->cart['user']['payment_method_costs'] = $payment_method['handling_costs'];
         } else {
             // calculate total payment costs based by %
             if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                 $subtotal = $this->cart['summarize']['sub_total_including_vat'] - $this->cart['discount_amount'];
             } else {
                 $subtotal = $this->cart['summarize']['sub_total'] - $this->cart['discount_amount'];
             }
             if ($subtotal) {
                 if (strstr($payment_method['handling_costs'], "%")) {
                     $percentage = str_replace("%", '', $payment_method['handling_costs']);
                     $total_include_vat = 0;
                     if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                         $total_include_vat = 1;
                     }
                     $subtotal = mslib_fe::countCartTotalPrice(1, $total_include_vat, $countries_id);
                     if ($subtotal) {
                         $handling_cost = $subtotal / 100 * $percentage;
                         if ($total_include_vat && $payment_method['tax_rate']) {
                             $handling_cost = $handling_cost / (1 + $payment_method['tax_rate']);
                         }
                         $this->cart['user']['payment_method_costs'] = $handling_cost;
                     }
                 } else {
                     $this->cart['user']['payment_method_costs'] = $payment_method['handling_costs'];
                 }
             }
         }
     } else {
         $this->cart['user']['payment_method_costs'] = 0;
     }
     if ($payment_method['tax_id'] && $this->cart['user']['payment_method_costs']) {
         $this->cart['user']['payment_total_tax_rate'] = $payment_method['tax_rate'];
         //if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
         //$this->cart['user']['payment_method_costs']=$this->cart['user']['payment_method_costs']-($this->cart['user']['payment_method_costs']*$this->cart['user']['payment_total_tax_rate']);
         //}
         if ($payment_method['country_tax_rate']) {
             $this->cart['user']['payment_country_tax_rate'] = $payment_method['country_tax_rate'];
             $this->cart['user']['payment_country_tax'] = mslib_fe::taxDecimalCrop($this->cart['user']['payment_method_costs'] * $payment_method['country_tax_rate']);
         } else {
             $this->cart['user']['payment_country_tax_rate'] = 0;
             $this->cart['user']['payment_country_tax'] = 0;
         }
         if ($payment_method['region_tax_rate']) {
             $this->cart['user']['payment_region_tax_rate'] = $payment_method['region_tax_rate'];
             $this->cart['user']['payment_region_tax'] = mslib_fe::taxDecimalCrop($this->cart['user']['payment_method_costs'] * $payment_method['region_tax_rate']);
         } else {
             $this->cart['user']['payment_region_tax_rate'] = 0;
             $this->cart['user']['payment_region_tax'] = 0;
         }
         if ($this->cart['user']['payment_region_tax'] && $this->cart['user']['payment_country_tax']) {
             $this->cart['user']['payment_tax'] = $this->cart['user']['payment_country_tax'] + $this->cart['user']['payment_region_tax'];
         } else {
             $this->cart['user']['payment_tax'] = $this->cart['user']['payment_method_costs'] * $payment_method['tax_rate'];
         }
     } else {
         $this->cart['user']['payment_tax'] = 0;
         $this->cart['user']['payment_country_tax'] = 0;
         $this->cart['user']['payment_region_tax'] = 0;
         $this->cart['user']['payment_total_tax_rate'] = 0;
         $this->cart['user']['payment_country_tax_rate'] = 0;
         $this->cart['user']['payment_region_tax_rate'] = 0;
     }
     $this->cart['user']['payment_method'] = $payment_method['code'];
     $this->cart['user']['payment_method_label'] = $payment_method['name'];
     // payment eof
     // hook to rewrite the whole methods
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_cart.php']['setPaymentMethodPreSaveHook'])) {
         $params = array('cart_user' => &$this->cart['user']);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_cart.php']['setPaymentMethodPreSaveHook'] as $funcRef) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
         }
     }
     tx_mslib_cart::storeCart($this->cart);
 }
        $content .= '</ul>';
        $content .= '</div>';
    }
    $content .= '
	<form action="' . mslib_fe::typolink($this->conf['checkout_page_pid'], 'tx_multishop_pi1[page_section]=' . $this->ms['page'] . '&tx_multishop_pi1[previous_checkout_section]=' . current($stepCodes)) . '" method="post" name="checkout" id="checkout">
	';
    if (count($payment_methods)) {
        $content .= '
		<div id="multishopPaymentMethodWrapper">
		<div class="main-heading"><h2>' . $this->pi_getLL('choose_payment_method') . '</h2></div>
		<ul id="multishopPaymentMethod" class="row">';
        $count = 0;
        $tr_type = 'even';
        $countries_id = $mslib_cart->getCountry();
        foreach ($payment_methods as $code => $item) {
            $payment_method = mslib_fe::getPaymentMethod($code, 'p.code', $countries_id);
            $vars = unserialize($payment_method['vars']);
            if (!$tr_type or $tr_type == 'even') {
                $tr_type = 'odd';
            } else {
                $tr_type = 'even';
            }
            // custom hook that can be controlled by third-party plugin
            $payment_method_description = '';
            if (!empty($item['description'])) {
                $payment_method_description = '<div class="description">' . $item['description'] . '</div>';
            }
            if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/front_pages/includes/checkout/multistep/checkout_shipping_payment_method']['checkoutMultistepPaymentgMethodSelectionHook'])) {
                $params = array('shipping_method' => &$shipping_method, 'item' => &$item, 'payment_method_description' => &$payment_method_description);
                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/front_pages/includes/checkout/multistep/checkout_shipping_payment_method']['checkoutMultistepPaymentgMethodSelectionHook'] as $funcRef) {
                    \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
</script>
';
$default_payment_methods = mslib_fe::loadAllPaymentMethods();
$mslib_payment = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('mslib_payment');
$mslib_payment->init($this);
$payment_methods = array();
$payment_methods = $mslib_payment->getInstalledPaymentMethods($this);
if (count($payment_methods) > 0) {
    // merge default and installed payment
    $payment_methods = array_merge($default_payment_methods, $payment_methods);
} else {
    $payment_methods = $default_payment_methods;
}
//$content.=mslib_befe::print_r($payment_methods);
if ($this->get['edit']) {
    $row = mslib_fe::getPaymentMethod($this->get['payment_method_id'], 'p.id');
    $str = "SELECT * from tx_multishop_payment_methods_description where id='" . $row['id'] . "'";
    $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
    $lngproduct = array();
    while (($tmprow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) {
        $lngproduct[$tmprow['language_id']] = $tmprow;
    }
    $psp = $payment_methods[$row['provider']];
    // default_order status
    if (!isset($psp['vars']['default_order_status'])) {
        $psp['vars']['default_order_status']['type'] = 'order_status';
    }
    // order status
    if (!isset($psp['vars']['success_status'])) {
        $psp['vars']['success_status']['type'] = 'order_status';
    }
 function repairOrder($orders_id)
 {
     if (is_numeric($orders_id)) {
         $this->conf['order_id'] = (int) $orders_id;
         $tax_separation = array();
         $sql = "select orders_id, orders_tax_data, payment_method_costs, shipping_method_costs, discount, shipping_method, payment_method, billing_region, billing_country, billing_vat_id from tx_multishop_orders where orders_id='" . $orders_id . "' order by orders_id asc";
         $qry = $GLOBALS['TYPO3_DB']->sql_query($sql);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
             $sub_total_tax = 0;
             $sub_total = 0;
             $sub_total_excluding_vat = 0;
             $shipping_tax = 0;
             $payment_tax = 0;
             $grand_total = 0;
             $order_tax_data['shipping_tax'] = '0';
             $order_tax_data['shipping_country_tax'] = '0';
             $order_tax_data['shipping_region_tax'] = '0';
             $order_tax_data['shipping_total_tax_rate'] = '0';
             $order_tax_data['shipping_country_tax_rate'] = '0';
             $order_tax_data['shipping_region_tax_rate'] = '0';
             $order_tax_data['payment_tax'] = '0';
             $order_tax_data['payment_country_tax'] = '0';
             $order_tax_data['payment_region_tax'] = '0';
             $order_tax_data['payment_total_tax_rate'] = '0';
             $order_tax_data['payment_country_tax_rate'] = '0';
             $order_tax_data['payment_region_tax_rate'] = '0';
             $order_tax_data['grand_total'] = '0';
             $order_tax_data['total_orders_tax'] = '0';
             // get shipping method by code
             $this->tta_user_info['default']['country'] = $row['billing_country'];
             $iso_customer = mslib_fe::getCountryByName($this->tta_user_info['default']['country']);
             $iso_customer['country'] = $iso_customer['cn_short_en'];
             // if store country is different from customer country and user provided valid VAT id, change VAT rate to zero
             //$this->ms['MODULES']['DISABLE_VAT_RATE']=0;
             if (!$this->ms['MODULES']['DISABLE_VAT_RATE'] && $this->ms['MODULES']['DISABLE_VAT_FOR_FOREIGN_CUSTOMERS_WITH_COMPANY_VAT_ID'] and $row['billing_vat_id']) {
                 if (strtolower($row['billing_country']) != strtolower($this->tta_shop_info['country'])) {
                     $this->ms['MODULES']['DISABLE_VAT_RATE'] = 1;
                 }
             }
             // get shipping tax rate
             $shipping_method = mslib_fe::getShippingMethod($row['shipping_method'], 's.code', $iso_customer['cn_iso_nr']);
             $tax_rate = mslib_fe::taxRuleSet($shipping_method['tax_id'], 0, $iso_customer['cn_iso_nr'], 0);
             if (!$tax_rate['total_tax_rate']) {
                 $tax_rate['total_tax_rate'] = $this->ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS'];
             }
             if ($this->ms['MODULES']['DISABLE_VAT_RATE']) {
                 $tax_rate['total_tax_rate'] = 0;
             }
             $shipping_tax_rate = $tax_rate['total_tax_rate'] / 100;
             // get payment tax rate
             $payment_method = mslib_fe::getPaymentMethod($row['payment_method'], 'p.code', $iso_customer['cn_iso_nr']);
             $tax_rate = mslib_fe::taxRuleSet($payment_method['tax_id'], 0, $iso_customer['cn_iso_nr'], 0);
             if (!$tax_rate['total_tax_rate']) {
                 $tax_rate['total_tax_rate'] = $this->ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS'];
             }
             if ($this->ms['MODULES']['DISABLE_VAT_RATE']) {
                 $tax_rate['total_tax_rate'] = 0;
             }
             $payment_tax_rate = $tax_rate['total_tax_rate'] / 100;
             if ($shipping_tax_rate > 0 or $payment_tax_rate > 0) {
                 // disable rounding to prevent cents short issue
                 $shipping_tax = $row['shipping_method_costs'] * $shipping_tax_rate;
                 $payment_tax = $row['payment_method_costs'] * $payment_tax_rate;
                 /*if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) {
                 			$shipping_tax=round($row['shipping_method_costs']*$shipping_tax_rate, 2);
                 			$payment_tax=round($row['payment_method_costs']*$payment_tax_rate, 2);
                 		} else {
                 			$shipping_tax=$row['shipping_method_costs']*$shipping_tax_rate;
                 			$payment_tax=$row['payment_method_costs']*$payment_tax_rate;
                 		}*/
                 $order_tax_data['shipping_total_tax_rate'] = (string) number_format($shipping_tax_rate, 2, '.', ',');
                 $order_tax_data['payment_total_tax_rate'] = (string) number_format($payment_tax_rate, 2, '.', ',');
                 $order_tax_data['shipping_tax'] = (string) $shipping_tax;
                 $order_tax_data['payment_tax'] = (string) $payment_tax;
                 //$total_tax+=$shipping_tax+$payment_tax;
                 //$grand_total+=(($row['shipping_method_costs']+$row['payment_method_costs'])+($shipping_tax+$payment_tax));
             } else {
                 //$grand_total+=($row['shipping_method_costs']+$row['payment_method_costs']);
             }
             $tax_separation[$shipping_tax_rate * 100]['shipping_tax'] += $shipping_tax;
             $tax_separation[$payment_tax_rate * 100]['payment_tax'] += $payment_tax;
             $tax_separation[$shipping_tax_rate * 100]['shipping_costs'] = $row['shipping_method_costs'];
             $tax_separation[$payment_tax_rate * 100]['payment_costs'] = $row['payment_method_costs'];
             //
             $product_tax_data['country_tax_rate'] = '0';
             $product_tax_data['region_tax_rate'] = '0';
             $product_tax_data['total_tax_rate'] = '0';
             $product_tax_data['country_tax'] = '0';
             $product_tax_data['region_tax'] = '0';
             $product_tax_data['total_tax'] = '0';
             $product_tax_data['total_attributes_tax'] = '0';
             $sql_prod = "select * from tx_multishop_orders_products where orders_id = " . $row['orders_id'];
             $qry_prod = $GLOBALS['TYPO3_DB']->sql_query($sql_prod);
             while ($row_prod = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry_prod)) {
                 $tax_rate = $row_prod['products_tax'] / 100;
                 $product_tax = unserialize($row_prod['products_tax_data']);
                 // attributes tax
                 $sql_attr = "select * from tx_multishop_orders_products_attributes where orders_products_id = " . $row_prod['orders_products_id'] . " and orders_id = " . $row_prod['orders_id'];
                 $qry_attr = $GLOBALS['TYPO3_DB']->sql_query($sql_attr);
                 $attributes_tax = 0;
                 $tmp_attributes_price = 0;
                 $tmp_attributes_tax = 0;
                 while ($row_attr = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry_attr)) {
                     if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) {
                         // remove the rounding to prevent cents short
                         //$tmp_attributes_tax=round(($row_attr['price_prefix'].$row_attr['options_values_price'])*($tax_rate), 2);
                         $tmp_attributes_tax = ($row_attr['price_prefix'] . $row_attr['options_values_price']) * $tax_rate;
                     } else {
                         $tmp_attributes_tax = mslib_fe::taxDecimalCrop(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $tax_rate);
                     }
                     $attributes_tax += $tmp_attributes_tax;
                     $tmp_attributes_price += $row_attr['price_prefix'] . $row_attr['options_values_price'] * $row_prod['qty'];
                     $sub_total += ($row_attr['price_prefix'] . $row_attr['options_values_price']) * $row_prod['qty'];
                     $sub_total_excluding_vat += $row_attr['price_prefix'] . $row_attr['options_values_price'] * $row_prod['qty'];
                     $grand_total += $row_attr['price_prefix'] . $row_attr['options_values_price'] * $row_prod['qty'];
                     // set the attributes tax data
                     $attributes_tax_data = array();
                     if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) {
                         $attributes_tax_data['country_tax'] = round(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $product_tax['country_tax_rate'], 2);
                         $attributes_tax_data['region_tax'] = round(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $product_tax['region_tax_rate'], 2);
                         if ($attributes_tax_data['country_tax'] && $attributes_tax_data['region_tax']) {
                             $attributes_tax_data['tax'] = $attributes_tax_data['country_tax'] + $attributes_tax_data['region_tax'];
                         } else {
                             $attributes_tax_data['tax'] = round(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $tax_rate, 2);
                         }
                     } else {
                         $attributes_tax_data['country_tax'] = mslib_fe::taxDecimalCrop(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $product_tax['country_tax_rate']);
                         $attributes_tax_data['region_tax'] = mslib_fe::taxDecimalCrop(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $product_tax['region_tax_rate']);
                         if ($attributes_tax_data['country_tax'] && $attributes_tax_data['region_tax']) {
                             $attributes_tax_data['tax'] = $attributes_tax_data['country_tax'] + $attributes_tax_data['region_tax'];
                         } else {
                             $attributes_tax_data['tax'] = mslib_fe::taxDecimalCrop(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $tax_rate);
                         }
                     }
                     $serial_product_attributes_tax = serialize($attributes_tax_data);
                     $sql_update = "update tx_multishop_orders_products_attributes set attributes_tax_data = '" . $serial_product_attributes_tax . "' where orders_products_attributes_id='" . $row_attr['orders_products_attributes_id'] . "' and orders_products_id = " . $row_attr['orders_products_id'] . " and orders_id = " . $row_attr['orders_id'];
                     $GLOBALS['TYPO3_DB']->sql_query($sql_update);
                 }
                 $sub_total_tax += $attributes_tax * $row_prod['qty'];
                 $sub_total += $attributes_tax * $row_prod['qty'];
                 // subtotal including vat
                 $grand_total += $attributes_tax * $row_prod['qty'];
                 $product_tax_data['total_attributes_tax'] = (string) $attributes_tax;
                 $product_tax_data['total_tax_rate'] = (string) number_format($tax_rate, 2, '.', ',');
                 $final_price = $row_prod['final_price'];
                 /*if ($this->ms['MODULES']['ENABLE_DISCOUNT_ON_EDIT_ORDER_PRODUCT']) {
                 			if (!empty($row_prod['discount_amount'])) {
                 				$final_price-=$row_prod['discount_amount'];
                 			}
                 		}*/
                 //print_r($row_prod);
                 // b2b mode 1 cent bugfix: 2013-05-09 cbc in grand total. this came from the products final price that must be round first
                 // I have fixed the b2b issue by updating all the products prices in the database to have max 2 decimals
                 // therefore I disabled below bugfix, cause thats a ducktape solution that can break b2c sites
                 //$final_price=round($final_price,2);
                 /*
                  * the rounding for excluding vat price is causing cents short
                  */
                 /*if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) {
                 			$tax=round($final_price*$tax_rate, 2);
                 		} else {
                 			$tax=$final_price*$tax_rate;
                 		}
                 		*/
                 $tax = $final_price * $tax_rate;
                 $product_tax_data['total_tax'] = (string) $tax;
                 $sub_total_tax += $tax * $row_prod['qty'];
                 $sub_total += ($final_price + $tax) * $row_prod['qty'];
                 $sub_total_excluding_vat += $final_price * $row_prod['qty'];
                 $grand_total += ($final_price + $tax) * $row_prod['qty'];
                 $serial_prod = serialize($product_tax_data);
                 $sql_update = "update tx_multishop_orders_products set products_tax_data = '" . $serial_prod . "' where orders_products_id = " . $row_prod['orders_products_id'] . " and orders_id = " . $row['orders_id'];
                 $GLOBALS['TYPO3_DB']->sql_query($sql_update);
                 // separation of tax
                 $tax_separation[$row_prod['products_tax'] / 100 * 100]['products_total_tax'] += ($tax + $attributes_tax) * $row_prod['qty'];
                 $tax_separation[$row_prod['products_tax'] / 100 * 100]['products_sub_total_excluding_vat'] += ($final_price + $tmp_attributes_price) * $row_prod['qty'];
                 $tax_separation[$row_prod['products_tax'] / 100 * 100]['products_sub_total'] += $final_price + $tmp_attributes_price + ($tax + $attributes_tax) * $row_prod['qty'];
             }
             $order_tax_data['total_orders_tax_including_discount'] = $order_tax_data['total_orders_tax'];
             $order_tax_data['sub_total'] = (string) $sub_total;
             $order_tax_data['sub_total_excluding_vat'] = (string) $sub_total_excluding_vat;
             // discount
             //echo "<pre>";
             //echo $sub_total."<br/>";
             //echo $sub_total_excluding_vat."<br/>";
             if ($row['discount'] < 0 || $row['discount'] > 0) {
                 if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) {
                     $discount_price = round($row['discount'], 2);
                     //$sub_total_excluding_vat-=$discount_price;
                     $discount_percentage = $discount_price / $sub_total_excluding_vat * 100;
                     //$tmp_sub_total=(($sub_total_excluding_vat)/100*(100-$discount_percentage));
                     if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                         $sub_total_tax = round((1 - $discount_price / $sub_total) * $sub_total_tax, 2);
                     } else {
                         $sub_total_tax = ($sub_total - $sub_total_excluding_vat) / 100 * (100 - $discount_percentage);
                     }
                 } else {
                     $discount_price = $row['discount'];
                     //$sub_total-=$discount_price;
                     $discount_percentage = $discount_price / $sub_total * 100;
                     //$tmp_sub_total=(($sub_total)/100*(100-$discount_percentage));
                     //
                     if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                         $sub_total_tax = round((1 - $discount_price / $sub_total) * $sub_total_tax, 2);
                     } else {
                         $sub_total_tax = ($sub_total - $sub_total_excluding_vat) / 100 * (100 - $discount_percentage);
                     }
                 }
                 if (count($tax_separation) > 1) {
                     $tax_separation = array();
                 }
             }
             //echo $discount_percentage."<br/>";
             //echo $discount_price."<br/>";
             //echo $sub_total_tax."<br/>";
             //die();
             $order_tax_data['total_orders_tax'] = (string) $sub_total_tax + $shipping_tax + $payment_tax;
             if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) {
                 $order_tax_data['grand_total'] = (string) ($sub_total_excluding_vat - $discount_price + $sub_total_tax) + ($row['shipping_method_costs'] + $shipping_tax) + ($row['payment_method_costs'] + $payment_tax);
             } else {
                 $order_tax_data['grand_total'] = (string) ($sub_total - $discount_price) + ($row['shipping_method_costs'] + $shipping_tax) + ($row['payment_method_costs'] + $payment_tax);
             }
             $order_tax_data['grand_total_excluding_vat'] = (string) ($sub_total_excluding_vat - $discount_price) + $row['shipping_method_costs'] + $row['payment_method_costs'];
             //
             $order_tax_data['tax_separation'] = $tax_separation;
             //print_r($order_tax_data);
             $serial_orders = serialize($order_tax_data);
             // update orders
             $updateArray = array();
             $updateArray['grand_total'] = round($order_tax_data['grand_total'], 2);
             $updateArray['grand_total_excluding_vat'] = round($order_tax_data['grand_total_excluding_vat'], 2);
             $updateArray['orders_tax_data'] = $serial_orders;
             if ($row['discount'] > 0) {
                 $updateArray['discount'] = $discount_price;
             }
             $updateArray['orders_last_modified'] = time();
             $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_orders', 'orders_id=\'' . $row['orders_id'] . '\'', $updateArray);
             $res = $GLOBALS['TYPO3_DB']->sql_query($query);
             //$sql_update="update tx_multishop_orders set grand_total='".round($order_tax_data['grand_total'], 2)."', orders_tax_data = '".$serial_orders."' where orders_id = ".$row['orders_id'];
             //$GLOBALS['TYPO3_DB']->sql_query($sql_update);
         }
     }
 }
 $return_data = array();
 $order_id = $this->post['tx_multishop_pi1']['order_id'];
 $invoice_id = $this->post['tx_multishop_pi1']['invoice_id'];
 $invoice_nr = $this->post['tx_multishop_pi1']['invoice_nr'];
 $return_data['status'] = 'NOTOK';
 $return_data['status'] = 'NOTOK';
 if (is_numeric($invoice_id)) {
     $invoice = mslib_fe::getInvoice($invoice_id, 'id');
     if ($invoice['id']) {
         $order = mslib_fe::getOrder($invoice['orders_id']);
         if ($order['orders_id']) {
             $date_paid = strtotime($this->post['tx_multishop_pi1']['date_paid']);
             $payment_id = $this->post['tx_multishop_pi1']['payment_id'];
             //
             if (is_numeric($payment_id) && $payment_id > 0) {
                 $payment_method = mslib_fe::getPaymentMethod($payment_id);
                 $updateArray = array();
                 $updateArray['payment_method_costs'] = $payment_method['handling_costs'];
                 $updateArray['payment_method'] = $payment_method['code'];
                 $updateArray['payment_method_label'] = $payment_method['name'];
                 $updateArray['orders_last_modified'] = time();
                 $updateArray['orders_paid_timestamp'] = $date_paid;
                 $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_orders', 'orders_id=\'' . $order_id . '\'', $updateArray);
                 $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                 //
                 require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'pi1/classes/class.tx_mslib_order.php';
                 $mslib_order = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_mslib_order');
                 $mslib_order->init($this);
                 $mslib_order->repairOrder($order_id);
             }
             //
Beispiel #8
0
         $insertArray['status'] = 1;
         $insertArray['provider'] = 'cod';
         $insertArray = mslib_befe::rmNullValuedKeys($insertArray);
         $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_payment_methods', $insertArray);
         $res = $GLOBALS['TYPO3_DB']->sql_query($query);
         $id = $GLOBALS['TYPO3_DB']->sql_insert_id();
         if ($id) {
             $updateArray = array();
             $updateArray['name'] = $record['payment_method'];
             $updateArray['description'] = '';
             $updateArray['id'] = $id;
             $updateArray['language_id'] = 0;
             $updateArray = mslib_befe::rmNullValuedKeys($updateArray);
             $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_payment_methods_description', $updateArray);
             $res = $GLOBALS['TYPO3_DB']->sql_query($query);
             $payment_method = mslib_fe::getPaymentMethod($record['payment_method'], 'd.name');
         }
     }
     $row['payment_method'] = $payment_method['code'];
     $row['payment_method_label'] = $payment_method['name'];
 }
 if ($record['shipping_method']) {
     $shipping_method = mslib_fe::getShippingMethod($record['shipping_method'], 'd.name');
     if (!$shipping_method['code']) {
         // insert
         $insertArray = array();
         $insertArray['code'] = mslib_fe::rewritenamein($record['shipping_method']);
         $insertArray['handling_costs'] = 0;
         $insertArray['sort_order'] = 0;
         $insertArray['date'] = time();
         $insertArray['status'] = 1;
                    if ($use_tbody) {
                        $tmpcontent .= '</tbody>';
                    }
                }
            }
            //echo '<pre>';
            //print_r($order_products_table);
            //die();
            //		$tmpcontent.='<tr><td colspan="'.$colspan.'"><hr class="hr"></td></tr>';
            $orders_tax_data = unserialize($orders['orders_tax_data']);
            $tmpcontent .= '<tfoot><tr><td colspan="' . $colspan . '" class="order_total_data text-right">';
            if ($this->ms['MODULES']['ORDER_EDIT'] and $settings['enable_edit_orders_details']) {
                $iso_customer = mslib_fe::getCountryByName($orders['billing_country']);
                $iso_customer['country'] = $iso_customer['cn_short_en'];
                //
                $payment_method = mslib_fe::getPaymentMethod($orders['payment_method'], 'p.code', $iso_customer['cn_iso_nr']);
                $shipping_method = mslib_fe::getShippingMethod($orders['shipping_method'], 's.code', $iso_customer['cn_iso_nr']);
                //
                if ($iso_customer['cn_iso_nr'] > 0) {
                    $payment_tax_ruleset = mslib_fe::taxRuleSet($payment_method['tax_id'], 0, $iso_customer['cn_iso_nr'], 0);
                    $shipping_tax_ruleset = mslib_fe::taxRuleSet($shipping_method['tax_id'], 0, $iso_customer['cn_iso_nr'], 0);
                    if (!$payment_tax_ruleset) {
                        $payment_method['tax_id'] = 0;
                    }
                    if (!$shipping_tax_ruleset) {
                        $shipping_method['tax_id'] = 0;
                    }
                }
                if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                    $shipping_costs = '<div class="input-group pull-right" style="width:140px;">
						<span class="input-group-addon">' . mslib_fe::currency() . '</span>