} else {
         $shipping_tax['shipping_tax'] = 0;
         $shipping_tax['shipping_country_tax'] = 0;
         $shipping_tax['shipping_region_tax'] = 0;
         $shipping_tax['shipping_total_tax_rate'] = 0;
         $shipping_tax['shipping_country_tax_rate'] = 0;
         $shipping_tax['shipping_region_tax_rate'] = 0;
     }
     $updateArray['shipping_method'] = $shipping_method['code'];
     $updateArray['shipping_method_label'] = $shipping_method['name'];
 }
 if ($this->post['payment_method']) {
     $payment_method = mslib_fe::getPaymentMethod($this->post['payment_method']);
     if (empty($order['orders_tax_data'])) {
         // temporary call, replacing the inner tax_ruleset inside the getPaymentMethod
         $tax_ruleset = mslib_fe::taxRuleSet($payment_method['tax_id'], 0, $country['cn_iso_nr'], $zone['zn_country_iso_nr']);
         $payment_method['tax_rate'] = $tax_ruleset['total_tax_rate'] / 100;
         $payment_method['country_tax_rate'] = $tax_ruleset['country_tax_rate'] / 100;
         $payment_method['region_tax_rate'] = $tax_ruleset['state_tax_rate'] / 100;
     }
     if ($this->post['tx_multishop_pi1']['payment_method_costs']) {
         $price = $this->post['tx_multishop_pi1']['payment_method_costs'];
     } else {
         $price = $payment_method['handling_costs'];
     }
     $updateArray['payment_method_costs'] = $price;
     if ($payment_method['tax_id'] && $updateArray['payment_method_costs']) {
         $payment_tax['payment_total_tax_rate'] = $payment_method['tax_rate'];
         if ($payment_method['country_tax_rate']) {
             $payment_tax['payment_country_tax_rate'] = $payment_method['country_tax_rate'];
             $payment_tax['payment_country_tax'] = mslib_fe::taxDecimalCrop($updateArray['payment_method_costs'] * $payment_method['country_tax_rate']);
 function countCartTotalTax($country_id = 0)
 {
     $total_product_tax = 0;
     $products_tax = array();
     //$cart=$GLOBALS['TSFE']->fe_user->getKey('ses', $this->cart_page_uid);
     require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'pi1/classes/class.tx_mslib_cart.php';
     $mslib_cart = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_mslib_cart');
     $mslib_cart->init($this);
     $cart = $mslib_cart->getCart();
     $address = $cart['user'];
     if (is_array($cart['products']) && count($cart['products'])) {
         foreach ($cart['products'] as $shopping_cart_item => $value) {
             if ($country_id > 0) {
                 $tax_rate = mslib_fe::taxRuleSet($value['tax_id'], 0, $country_id, 0);
                 $value['tax_rate'] = $tax_rate['total_tax_rate'] / 100;
             }
             if (is_numeric($value['products_id'])) {
                 $product_amount = $value['final_price'];
                 $subtotal_price = $value['qty'] * $product_amount;
                 if ($value['tax_rate']) {
                     $total_product_tax += $subtotal_price * $value['tax_rate'];
                 }
                 // attributes
                 if (is_array($value['attributes'])) {
                     foreach ($value['attributes'] as $attribute_key => $attribute_value) {
                         $total_product_tax += $attribute_value['options_values_price'] * $value['qty'] * $value['tax_rate'];
                     }
                 }
                 // attributes eof
                 $products_tax['products_tax']['products_tax_rate_' . $value['products_id']] = $value['tax_rate'];
             }
         }
     }
     $products_tax['total_tax'] = $total_product_tax;
     return $products_tax;
 }
Beispiel #3
0
 $global_start_time = microtime(true);
 $start_time = microtime(true);
 $total_datarows = count($rows);
 if ($this->msLogFile) {
     if ($total_datarows) {
         // sometimes the preload takes so long that the database connection is lost.
         $GLOBALS['TYPO3_DB']->connectDB();
         file_put_contents($this->msLogFile, $this->HTTP_HOST . ' - products loaded, now starting the import. (' . date("Y-m-d G:i:s") . ")\n", FILE_APPEND);
     } else {
         file_put_contents($this->msLogFile, $this->HTTP_HOST . ' - no products needed to be imported' . "\n", FILE_APPEND);
     }
 }
 // load default TAX rules
 if ($this->post['tx_multishop_pi1']['default_vat_rate']) {
     $default_iso_customer = mslib_fe::getCountryByName($this->tta_shop_info['country']);
     $default_tax_rate = mslib_fe::taxRuleSet($this->post['tx_multishop_pi1']['default_vat_rate'], 0, $default_iso_customer['cn_iso_nr'], 0);
 }
 // custom hook that can be controlled by third-party plugin
 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/admin_pages/admin_import.php']['iteratorPreProc'])) {
     $params = array('rows' => &$rows, 'prefix_source_name' => $this->post['prefix_source_name']);
     foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/admin_pages/admin_import.php']['iteratorPreProc'] as $funcRef) {
         \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
     }
 }
 // custom hook that can be controlled by third-party plugin eof
 foreach ($rows as $row) {
     $skipRow = 0;
     // custom hook that can be controlled by third-party plugin
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/admin_pages/admin_import.php']['itemIteratePreProc'])) {
         $params = array('row' => &$row, 'prefix_source_name' => $this->post['prefix_source_name'], 'skipRow' => &$skipRow);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/admin_pages/admin_import.php']['itemIteratePreProc'] as $funcRef) {
 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);
         }
     }
 }
        $payment_methods = $payment_methods_group;
    } else {
        $payment_methods = $payment_methods_product;
    }
}
if (!count($payment_methods)) {
    // nothing is loaded. this cant be valid so let's load the default methods.
    // load payment method based on store origin country
    $payment_methods = mslib_fe::loadPaymentMethods(0, $countries_id, true, true);
}
$data = array();
$k = 0;
foreach ($payment_methods as $payment_name => $payment_data) {
    $vars = unserialize($payment_data['vars']);
    if ($countries_id > 0) {
        $tax_ruleset = mslib_fe::taxRuleSet($payment_data['tax_id'], 0, $countries_id, 0);
    } else {
        $tax_ruleset = mslib_fe::getTaxRuleSet($payment_data['tax_id'], 0);
    }
    $payment_data['tax_rate'] = $tax_ruleset['total_tax_rate'] / 100;
    //print_r($payment_data);
    if (!$tr_type or $tr_type == 'even') {
        $tr_type = 'odd';
    } else {
        $tr_type = 'even';
    }
    if (!$payment_data['sort_order']) {
        $payment_data['sort_order'] = $k;
    }
    // refine the payment data, only sent what it's need to rebuild the <li> on the client side
    $data[$payment_data['sort_order']]['payment_id'] = $payment_data['id'];
            //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>
						<input name="tx_multishop_pi1[shipping_method_costs]" id="shipping_method_costs" type="text" class="form-control text-right priceInputDisplay" value="' . number_format($orders['shipping_method_costs'] + $orders_tax_data['shipping_tax'], 4, $this->ms['MODULES']['CUSTOMER_CURRENCY_ARRAY']['cu_decimal_point'], '') . '" class="align_right" />
						<input type="hidden" id="hidden_shipping_tax" value="' . $orders_tax_data['shipping_tax'] . '">
					</div>';
                    $payment_costs = '<div class="input-group pull-right" style="width:140px;">
						<span class="input-group-addon">' . mslib_fe::currency() . '</span>