Index: /controller/wpsg_AdminController.class.php
===================================================================
--- /controller/wpsg_AdminController.class.php	(revision 6349)
+++ /controller/wpsg_AdminController.class.php	(revision 6350)
@@ -1236,5 +1236,4 @@
 		public function voucherDataAction()
 		{
-			//die('voucher');
 			$t1 = 0;
 			$oid = 0;
@@ -1253,7 +1252,15 @@
 							'cdate' => $dt1, 'start_date' => $dt1, 'end_date' => $dt2);
 				$gs_id = $this->db->ImportQuery(WPSG_TBL_GUTSCHEIN, $gs);
-
-				$ogs = array('gs_id' => $gs_id, 'price_gs' => 10.0);
-				$this->db->UpdateQuery(WPSG_TBL_ORDER, $ogs, "`id` = '".$oid."'");
+				$sval = 10.0;
+				if ($option == WPSG_NETTO)
+				{
+					$data = array('price_gs' => $sval, 'price_gs_netto' => $sval);
+				}
+				else
+				{
+					$data = array('price_gs' => $sval, 'price_gs_brutto' => $sval);
+				}
+
+				$this->db->UpdateQuery(WPSG_TBL_ORDER, $data, "`id` = '".$oid."'");
 				$_REQUEST['gs_id'] = $gs_id;
 
@@ -1281,5 +1288,5 @@
 				//submitdata: { field: 'code', gs_id: 92 }
 				$sval = abs(wpsg_tf($_REQUEST['value']));
-
+				/*
 				$arTaxKey = explode('_', wpsg_q($_REQUEST['mwst']));
 				$country_id = $arTaxKey[1];
@@ -1290,4 +1297,5 @@
 				if ($noMwSt === true) $tax_value = 0; else $tax_value = $country->getTax($tax_key);
 				//if (wpsg_q($_REQUEST['price_frontend']) == WPSG_NETTO)
+				*/
 				if ($option == WPSG_NETTO)
 				{
@@ -1298,4 +1306,5 @@
 					$data = array('price_gs' => $sval, 'price_gs_brutto' => $sval);
 				}
+
 				$this->db->UpdateQuery(WPSG_TBL_ORDER, $data, "`id` = '".wpsg_q($_REQUEST['edit_id'])."'");
 
@@ -1307,5 +1316,5 @@
 			$this->shop->view['basket'] = $basket->toArray(true);
 
-			if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'editvalue')
+			//if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'editvalue')
 			{
 				if ($option == WPSG_NETTO)
@@ -1334,5 +1343,4 @@
 		public function discountDataAction()
 		{
-			//die('voucher');
 			$t1 = 0;
 			$oid = 0;
@@ -1369,5 +1377,5 @@
 				$country_id = $arTaxKey[1];
 				$country = wpsg_country::getInstance($country_id);
-				$tax_key = 'c';
+				$tax_key = $arTaxKey[0];
 				$noMwSt = false;
 				if (wpsg_q($_REQUEST['noMwSt']) == 1) $noMwSt = true;
@@ -1382,6 +1390,6 @@
 					$data = array('price_rabatt' => $sval, 'price_rabatt_brutto' => $sval);
 				}
+
 				$this->db->UpdateQuery(WPSG_TBL_ORDER, $data, "`id` = '".wpsg_q($_REQUEST['edit_id'])."'");
-
 			}
 
@@ -1391,5 +1399,5 @@
 			$this->shop->view['basket'] = $basket->toArray(true);
 
-			if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'editvalue')
+			//if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'editvalue')
 			{
 				if ($option == WPSG_NETTO)
@@ -1508,4 +1516,7 @@
 				$diff = $brutto - $netto;
 
+				$count = $this->db->fetchOne("SELECT COUNT(*) FROM `".WPSG_TBL_ORDERPRODUCT."` WHERE `o_id` = '".wpsg_q($oid)."' ");
+
+				$data['product_index'] = $count;
 				$data['price'] = $price;
 				$data['price_netto'] = $netto;
Index: /lib/wpsg_basket.class.php
===================================================================
--- /lib/wpsg_basket.class.php	(revision 6349)
+++ /lib/wpsg_basket.class.php	(revision 6350)
@@ -2,16 +2,16 @@
 
 	/**
-	 * Diese Klasse kapselt die Produkte 
+	 * Diese Klasse kapselt die Produkte
 	 * @author Daschmi
 	 */
 	class wpsg_basket
 	{
-		
+
 		/** @var wpsg_db */
 		var $db;
-		
+
 		/** @var wpsg_ShopController */
 		var $shop;
-		
+
 		/** Array mit den Produkten */
 		public $arProdukte;
@@ -19,25 +19,25 @@
 		/** Gutscheinwert */
 		public $gs_value = false;
-		
+
 		/** Gutscheinberechnungstyp */
 		public $gs_calc = false;
-		
+
 		/** Gutscheincode */
 		public $gs_code = false;
-			
+
 		/** Gutschein ID */
 		public $gs_id = false;
-		
+
 		/** True wenn aus Session geladen */
 		public $loadFromSession = false;
-		
+
 		/** Wenn der Warenkorb aus der DB kommt ist hier die BestellID drin */
 		public $o_id = false;
-		
+
 		/** EnthÃ€lt die ID der Bestellung wenn aus DB geladen */
 		public $db_id = false;
-		
+
 		public $arCheckout;
-		
+
 		/**
 		 * Konstruktor
@@ -45,15 +45,15 @@
 		public function __construct()
 		{
-			
+
 			$this->db = &$GLOBALS['wpsg_db'];
 			$this->shop = &$GLOBALS['wpsg_sc'];
-			
+
 			$this->reset();
-			
+
 		} // public function __construct()
-		
+
 		public function reset()
 		{
-			
+
 			$this->arProdukte = array();
 			$this->arCheckout = array();
@@ -64,7 +64,7 @@
 			$this->gs_code = false;
 			$this->gs_calc = false;
-			
+
 		}
-		
+
 		/**
 		 * FÃŒgt ein Produkt in die Session ein
@@ -72,15 +72,15 @@
 		public function addProduktToSession($produkt_key, $menge)
 		{
-			
+
 			if (!wpsg_isSizedArray($_SESSION['wpsg']['basket'])) $_SESSION['wpsg']['basket'] = array();
-			
+
 			$product_data = $this->shop->cache->loadProduct($this->shop->getProduktId($produkt_key));
-						
+
 			if ($product_data['basket_multiple'] == 1)
 			{
-				
+
 				// Nur einmal mit beliebiger Menge
 				// Hier nichts machen, es wird weiter unten hinzugefÃŒgt
-				
+
 			}
 			else if ($product_data['basket_multiple'] == 2)
@@ -90,43 +90,43 @@
 				if ($menge > 1)
 				{
-					
+
 					$bOK = true;
-					
+
 					// Hier die Funktion mehrfach aufrufen (mit Menge 1) und dann abbrechen
 					for ($i = 1; $i <= $menge; $i ++)
 					{
-						
+
 						$bOK = $bOK && $this->addProduktToSession($produkt_key, 1);
-						
-					}
-					
+
+					}
+
 					return $bOK;
-					
-				}
-				
+
+				}
+
 			}
 			else if ($product_data['basket_multiple'] == 4)
 			{
-				
+
 				// Einmal mit Menge 1
 				// Basket durchgehen und schauen ob es schon drin ist und dann abbrechen sonst mit 1 hinzufÃŒgen
 				foreach ((array)$_SESSION['wpsg']['basket'] as $p_key => $p)
 				{
-						
+
 					if ($p['id'] == $produkt_key)
 					{
-						
+
 						// Produkt ist schon drin, ich breche hier mit -1 ab, damit zum Warenkorb geleitet wird und eine Meldung wird angezeigt
-						$this->shop->addFrontendMessage(__('Das Produkt befindet sich bereits im Warenkorb, es kann nur einmal erworben werden.', 'wpsg'));						
+						$this->shop->addFrontendMessage(__('Das Produkt befindet sich bereits im Warenkorb, es kann nur einmal erworben werden.', 'wpsg'));
 						return -1;
-						
-					}
-					
-				} 
-				
+
+					}
+
+				}
+
 				$menge = 1;
-				
-			}
-			else 
+
+			}
+			else
 			{
 
@@ -135,45 +135,45 @@
 				foreach ((array)$_SESSION['wpsg']['basket'] as $p_key => $p)
 				{
-					
+
 					if ($p['id'] == $produkt_key)
 					{
-						 
+
 						$bOK = $this->shop->callMods('basket_produkttosession', array($produkt_key, &$menge, &$_SESSION['wpsg']['basket'][$p_key]));
-						if ($bOK === false) 
+						if ($bOK === false)
 						{
-							
+
 							return false;
-							
+
 						}
-						 	
+
 						$GLOBALS['wpsg_lastInsertIndex'] = $p_key;
 						$_SESSION['wpsg']['basket'][$p_key]['menge'] += intval($menge);
-						
+
 						// Sollte die Menge auf 0 korrigiert werden dann Produkt entfernen
 						if ($_SESSION['wpsg']['basket'][$p_key]['menge'] <= 0)
 						{
-								
+
 							unset($_SESSION['wpsg']['basket'][$p_key]);
-								
-						}							
-								
+
+						}
+
 						return true;
-											
-					}
-					
-				}
-				
-			}
-			
+
+					}
+
+				}
+
+			}
+
 			$ses_data = array();
-			
+
 			$bOK = $this->shop->callMods('basket_produkttosession', array($produkt_key, &$menge, &$ses_data));
-			if ($bOK === false) 
-			{
-				
+			if ($bOK === false)
+			{
+
 				return false;
-				
-			}
-			
+
+			}
+
 			// War noch nicht drin => neu hinzufÃŒgen
 			$ses_data = wpsg_array_merge($ses_data, array(
@@ -182,14 +182,14 @@
 				'referer' => ''
 			));
-			
+
 			if (isset($_REQUEST['myReferer'])) $ses_data['referer'] = $_REQUEST['myReferer'];
-			
+
 			//$_SESSION['wpsg']['basket'][] = wpsg_xss($ses_data);
 			array_push($_SESSION['wpsg']['basket'], wpsg_xss($ses_data));
 			end($_SESSION['wpsg']['basket']);
 			$GLOBALS['wpsg_lastInsertIndex'] = key($_SESSION['wpsg']['basket']);
-			
+
 			return true;
-					
+
 		} // public function addProduktToBasket($produkt_id, $menge)
 
@@ -201,19 +201,19 @@
 		public function addGutscheinToSession($value, $calc, $code, $gs_id)
 		{
-			 
+
 			$this->gs_value = $value;
 			$this->gs_calc = $calc;
 			$this->gs_code = $code;
 			$this->gs_id = $gs_id;
-			
-			$_SESSION['wpsg']['gs'] = wpsg_xss(array(	
+
+			$_SESSION['wpsg']['gs'] = wpsg_xss(array(
 				'value' => $this->gs_value,
 				'calc' => $this->gs_calc,
 				'code' => $this->gs_code,
-				'id' => $this->gs_id			
+				'id' => $this->gs_id
 			));
-			
+
 		} // public function addGutscheinToSession($value, $calc, $code)
-		
+
 		/**
 		 * Entfernt ein Produkt aus dem Warenkorb
@@ -221,12 +221,12 @@
 		public function removeProduktFromSession($produkt_index)
 		{
- 
+
 			unset($_SESSION['wpsg']['basket'][$produkt_index]);
 			$this->shop->cache->clearShopBasketArray();
-			
+
 			return true;
-			
+
 		} // public function removeProduktFromSession($produkt_key)
-		
+
 		/**
 		 * Aktualisiert den Warenkorb in der Session
@@ -234,33 +234,33 @@
 		public function updateProduktFromSession($product_index, $produkt_menge)
 		{
-					
+
 			if (intval($produkt_menge) <= 0)
 			{
-				
+
 				$this->removeProduktFromSession($product_index);
 				return true;
-				
-			} 
-			
-				 	 
+
+			}
+
+
 			foreach ($_SESSION['wpsg']['basket'] as $k => $p)
 			{
-				
+
 				if ($k == $product_index)
-				{ 
-					 
+				{
+
 					$this->shop->callMods('basket_updateProduktFromSession', array(&$product_index, &$produkt_menge));
 					$_SESSION['wpsg']['basket'][$k]['menge'] = intval($produkt_menge);
-					
+
 					if (!wpsg_isSizedInt($_SESSION['wpsg']['basket'][$k]['menge'])) unset($_SESSION['wpsg']['basket'][$k]);
-					
-				}
-				
-			}
-			
+
+				}
+
+			}
+
 			return true;
-			
+
 		} // public function updateProduktFromSession($produkt_key, $produkt_menge)
-		
+
 		/**
 		 * Initiiert den Warenkorb aus der Session heraus
@@ -268,27 +268,27 @@
 		public function initFromSession($rebuild = false)
 		{
-												
+
 			if (!isset($_SESSION['wpsg']['basket'])) return;
 			if ($this->loadFromSession === true && $rebuild === false) return;
-			
+
 			$this->arProdukte = array();
-			
+
 			foreach ((array)$_SESSION['wpsg']['basket'] as $produkt_key => $b)
 			{
-				
+
 				$this->arProdukte[$produkt_key] = $b;
-				
-			}
-			
+
+			}
+
 			if (isset($_SESSION['wpsg']['gs']))
 			{
-				
+
 				$this->gs_value = $_SESSION['wpsg']['gs']['value'];
 				$this->gs_calc = $_SESSION['wpsg']['gs']['calc'];
 				$this->gs_code = $_SESSION['wpsg']['gs']['code'];
 				$this->gs_id = $_SESSION['wpsg']['gs']['id'];
-				
-			}
-						
+
+			}
+
 			$this->arCheckout = wpsg_array_merge(array(
 				'firma' => '',
@@ -306,9 +306,9 @@
 				'comment' => ''
 			), $_SESSION['wpsg']['checkout']);
-									
+
 			$this->loadFromSession = true;
 
 		} // public function initFromSession()
-		
+
 		/**
 		 * Gibt die ID eines Produktes in der Datenbank zurÃŒck
@@ -316,19 +316,19 @@
 		public function getProduktDBID($produkt_key)
 		{
-			
+
 			if (is_numeric($produkt_key)) return $produkt_key;
 			else if (preg_match('/pv_\d(.*)/', $produkt_key))
 			{
-				
-				// Varianten ProduktschlÃŒssel				
+
+				// Varianten ProduktschlÃŒssel
 				$produkt_id = preg_replace('/(pv_)|(\|(.*))/', '', $produkt_key);
 
 				return $produkt_id;
-				
+
 			}
 			else return false;
-			
+
 		}
-		
+
 		/**
 		 * Initiiert den Basket aus der Datenbank
@@ -336,24 +336,24 @@
 		public function initFromDB($o_id, $backend = false)
 		{
-			
+
 			$order = $this->db->fetchRow("
-				SELECT 
-					* 
-			  	FROM 
-					`".WPSG_TBL_ORDER."` 
-			  	WHERE 
+				SELECT
+					*
+			  	FROM
+					`".WPSG_TBL_ORDER."`
+			  	WHERE
 			  		`id` = '".wpsg_q($o_id)."'
 			");
-			
+
 			$kunde = $this->db->fetchRow("
-				SELECT 
-					K.*, A.*, K.`id` AS `id` 
-				FROM 
+				SELECT
+					K.*, A.*, K.`id` AS `id`
+				FROM
 					`".WPSG_TBL_KU."` AS K
 					 	LEFT JOIN `".WPSG_TBL_ADRESS."` AS A ON (A.`id` = K.`adress_id`)
-				WHERE 
+				WHERE
 					K.`id` = '".wpsg_q($order['k_id'])."'
 			");
-			
+
 			$this->arCheckout = array(
 				'firma' => $kunde['firma'],
@@ -378,8 +378,8 @@
 				'datum' => strftime($order['cdate'])
 			);
-			
+
 			if ($this->shop->hasMod('wpsg_mod_autodebit'))
 			{
-				
+
 				$this->arCheckout['mod_autodebit_name'] = wpsg_getStr($order['mod_autodebit_name']);
 		   		$this->arCheckout['mod_autodebit_blz'] = wpsg_getStr($order['mod_autodebit_blz']);
@@ -388,18 +388,18 @@
 		   		$this->arCheckout['mod_autodebit_knr'] = wpsg_getStr($order['mod_autodebit_knr']);
 				$this->arCheckout['mod_autodebit_iban'] = wpsg_getStr($order['mod_autodebit_iban']);
-				
-			}
-			
+
+			}
+
 			$this->arOrder = $order;
-			
+
 			// Produkte
 			$arProdukte = $this->db->fetchAssoc("
 				SELECT
-					OP.`menge`, OP.`price` AS preis_brutto, 
+					OP.`menge`, OP.`price` AS preis_brutto,
 					OP.`price`, OP.`price_netto`, OP.`price_brutto`, OP.`mwst_key` AS op_mwst_key,
 					OP.`mwst_value` AS `mwst_value`,
-					IF (OP.`productkey` != '', OP.`productkey`, P.`id`) AS `productkey`, 
+					IF (OP.`productkey` != '', OP.`productkey`, P.`id`) AS `productkey`,
 					OP.`mod_vp_varkey`,
-					OP.`id` AS `order_product_id`,					
+					OP.`id` AS `order_product_id`,
 					P.`id`, P.`anr`, P.`name`, OP.`product_index`
 				FROM
@@ -407,19 +407,19 @@
 						LEFT JOIN `".WPSG_TBL_PRODUCTS."` AS P ON (OP.`p_id` = P.`id`)
 				WHERE
-					OP.`o_id` = '".wpsg_q($o_id)."'					
-			", "product_index"); 
-			 
+					OP.`o_id` = '".wpsg_q($o_id)."'
+			", "product_index");
+
 			foreach ($arProdukte as $k => $v)
 			{
-				 				
+
 				$arProdukte[$k]['varPriceAdded'] = 1;
 				if ($v['mod_vp_varkey'] != '') $arProdukte[$k]['id'] = $v['mod_vp_varkey'];
-				
+
 				// Preis ist immer in Brutto in der WPSG_TBL_ORDERPRODUCTS
 				$arProdukte[$k]['preis_netto'] = wpsg_calculatePreis($v['preis_brutto'], WPSG_NETTO, $v['mwst_value']);
-				
+
 				if ($backend)
 				{
-					
+
 					if ($this->shop->get_option('wpsg_preisangaben') == WPSG_BRUTTO)
 					{
@@ -428,11 +428,11 @@
 					else
 					{
-						$arProdukte[$k]['preis'] = $arProdukte[$k]['preis_netto'];						
-					}
-					
+						$arProdukte[$k]['preis'] = $arProdukte[$k]['preis_netto'];
+					}
+
 				}
 				else
 				{
-				
+
 					if ($this->shop->getFrontendTaxview() == WPSG_BRUTTO)
 					{
@@ -443,9 +443,9 @@
 						$arProdukte[$k]['preis'] = $arProdukte[$k]['preis_netto'];
 					}
-					
-				}
-				
-			}
-			
+
+				}
+
+			}
+
 			// Gutschein
 			if ($order['gs_id'] > 0)
@@ -453,12 +453,12 @@
 
 				$gs = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_GUTSCHEIN."` WHERE `id` = '".wpsg_q($order['gs_id'])."'");
-				
+
 				$this->gs_value = $gs['value'];
 				$this->gs_calc = $gs['calc_typ'];
 				$this->gs_code = $gs['code'];
 				$this->gs_id = $gs['id'];
-				
-			}
-			
+
+			}
+
 			// Gutschein-Wert aus der Order-Tabelle wegen Bearbeitung
 			if ($backend)
@@ -466,14 +466,14 @@
 				$val = abs($order['price_gs']);
 				$this->gs_value = $val;
-				
-			}
-			
+
+			}
+
 			$this->arProdukte = $arProdukte;
-			
+
 			$this->loadFromSession = false;
 			$this->o_id = $o_id;
-			 
+
 		} // public function initFromDB($o_id)
-		
+
 		/**
 		 * LÃ¶scht die Session
@@ -481,32 +481,32 @@
 		public function clearSession($customer_id)
 		{
-			
+
 			$this->shop->callMods('clearSession');
-			
+
 			if ($this->shop->get_option('wpsg_afterorder') == '1')
 			{
-				
+
 				// LÃ¶schen
 				unset($_SESSION['wpsg']);
-				
+
 			}
 			else
 			{
-			
+
 				// In Session belassen
 				unset($_SESSION['wpsg']['basket']);
 				unset($_SESSION['wpsg']['gs']);
-			 				
+
 				if ($this->shop->hasMod('wpsg_mod_kundenverwaltung'))
 				{
-					
+
 					$this->shop->callMod('wpsg_mod_kundenverwaltung', 'login', array($customer_id));
-					
-				}
-			
-			}
-			
+
+				}
+
+			}
+
 		} // public function clearSession()
-		
+
 		/**
 		 * Sendet die Mails beim Kauf an Admin und Kunden
@@ -516,42 +516,42 @@
 		public function sendOrderSaveMails($order_id, $arBasket, $bCustomerMail = true, $bAdminMail = true, $bDebug = false)
 		{
-			
+
 			$oOrder = wpsg_order::getInstance($order_id);
-			
+
 			$this->shop->view['oOrder'] = $oOrder;
 			$this->shop->view['basket'] = $arBasket;
-			
+
 			$this->shop->view['o_id'] = $order_id;
 			$this->shop->view['order'] = $this->shop->cache->loadOrder($order_id);
 			$this->shop->view['customer'] = $this->shop->cache->loadKunden($this->shop->view['oOrder']->k_id);
-			
+
 			if ($bDebug === true)
 			{
-			
+
 				$this->shop->view['basket']['checkout']['datum'] = time();
 				$this->shop->view['basket']['checkout']['onr'] = $this->shop->view['oOrder']->onr;
 				$this->shop->view['basket']['checkout']['knr'] = $this->shop->view['customer']['knr'];
 				$this->shop->view['basket']['checkout']['comment'] = $oOrder->comment;
-			
-			}
-			
+
+			}
+
 			// Adminmail
 			if ($bAdminMail === true)
 			{
-			
+
 				$arAttach = array();
 				// Anhang aufbereiten
 				$this->shop->callMod('wpsg_mod_orderupload', 'getAdminAttachment', array(&$arAttach));
-				
+
 				$mail_text = $this->shop->render(WPSG_PATH_VIEW.'/mailtemplates/adminmail.phtml', false);
-				
+
 				if ($this->shop->get_option('wpsg_htmlmail') === '1') $mail_html = $this->shop->render(WPSG_PATH_VIEW.'/mailtemplates/html/adminmail.phtml', false);
 				else $mail_html = false;
-				
+
 				$this->shop->sendMail($mail_text, $this->shop->get_option('wpsg_adminmail_empfaenger'), 'adminmail', $arAttach, $order_id, $oOrder->k_id, $mail_html);
-				
+
 				if ($bDebug === false)
 				{
-					
+
 					$this->db->ImportQuery(WPSG_TBL_OL, array(
 						"o_id" => wpsg_q($order_id),
@@ -560,51 +560,51 @@
 						"mailtext" => wpsg_q($mail_text)
 					));
-					
-				}
-					
+
+				}
+
 				sleep(1);
-				
-			}
-				
+
+			}
+
 			// Kundenmail
 			if ($bCustomerMail === true)
 			{
-			
+
 				$mail_text = $this->shop->render(WPSG_PATH_VIEW.'/mailtemplates/kundenmail.phtml', false);
-				
+
 				if ($this->shop->get_option('wpsg_htmlmail') === '1') $mail_html = $this->shop->render(WPSG_PATH_VIEW.'/mailtemplates/html/kundenmail.phtml', false);
 				else $mail_html = false;
-					
+
 				$arAttachments = array();
-					
+
 				if (wpsg_isSizedString($this->shop->get_option('wpsg_kundenmail_attachfile')) && file_exists(wpsg_getUploadDir('wpsg_mailconf').$this->shop->get_option('wpsg_kundenmail_attachfile')))
 				{
-				
+
 					$arAttachments[] = wpsg_getUploadDir('wpsg_mailconf').$this->shop->get_option('wpsg_kundenmail_attachfile');
-				
-				}
-				
+
+				}
+
 				if ($this->shop->get_option('wpsg_widerrufsformular_kundenmail') === '1' && wpsg_isSizedString($this->shop->get_option('wpsg_revocationform')))
 				{
-				
+
 					$revocationFile = WPSG_PATH_UPLOADS.'wpsg_revocation/'.$this->shop->get_option('wpsg_revocationform');
-				
+
 					if (file_exists($revocationFile) && is_file($revocationFile))
 					{
-							
+
 						$arAttachments[] = $revocationFile;
-							
-					}
-				
+
+					}
+
 				}
 
 				if ($bDebug === true) $empfaenger = $this->shop->get_option('wpsg_adminmail_empfaenger');
 				else $empfaenger = $this->arCheckout['email'];
-												
+
 				$this->shop->sendMail($mail_text, $empfaenger, 'kundenmail', $arAttachments, $order_id, $oOrder->k_id, $mail_html);
 
 				if ($bDebug === false)
 				{
-				
+
 					$this->db->ImportQuery(WPSG_TBL_OL, array(
 						"o_id" => wpsg_q($order_id),
@@ -613,11 +613,11 @@
 						"mailtext" => wpsg_q($mail_text)
 					));
-					
-				}
-				
-			}
-			
+
+				}
+
+			}
+
 		} // public function sendOrderSaveMails($order_id)
-		 
+
 		/**
 		 * Speichert die Bestellung in die Datenbank
@@ -626,118 +626,118 @@
 		public function save($finish_order = true)
 		{
-			
+
 			try
 			{
-				
+
 				// Berechnen
 				$arBasket = $this->toArray();
 
-				// Keine Produkte nix speichern 
-				// Sonst wurden schon beim Betreten des leeren Warenkorb (Bots) leere Bestellungen erzeugt 
+				// Keine Produkte nix speichern
+				// Sonst wurden schon beim Betreten des leeren Warenkorb (Bots) leere Bestellungen erzeugt
 				if (!wpsg_isSizedArray($arBasket['produkte'])) return;
-				
+
 				// Eintrag in Kundentabelle
-				$data = array(					
-					'email' 	=> wpsg_q(wpsg_getStr($this->arCheckout['email'])),					
+				$data = array(
+					'email' 	=> wpsg_q(wpsg_getStr($this->arCheckout['email'])),
 					'invisible' => 1, 	// 1=unvollstÃ€ndige Bestellung
 					'geb' 		=> wpsg_q(wpsg_toDate(wpsg_getStr($this->arCheckout['geb']))),
 					'ustidnr' 	=> wpsg_q(wpsg_getStr($this->arCheckout['ustidnr']))
-				);	
-				
+				);
+
 				$this->shop->callMods('basket_save_kunde', array(&$data, &$this->arCheckout));
-				
+
 				$saved_order_db = array();
 				$k_id = wpsg_getStr($this->arCheckout['id']);
-				
+
 				if (wpsg_isSizedInt($_SESSION['wpsg']['order_id']))
 				{
-					
+
 					$saved_order_db = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_ORDER."` WHERE `id` = '".wpsg_q($_SESSION['wpsg']['order_id'])."' ");
-					
+
 					if ($saved_order_db['id'] != $_SESSION['wpsg']['order_id'])
 					{
-						
+
 						// Wenn die Bestellung aus der Session nicht in der Datenbank existiert lege ich sie neu an
-						unset($_SESSION['wpsg']['order_id']); 
-						
+						unset($_SESSION['wpsg']['order_id']);
+
 					}
 					else
 					{
-					
+
 						$k_id = $saved_order_db['k_id'];
-						
-					}
-					
-				}
-				
+
+					}
+
+				}
+
 				// Sollte die ID des eingeloggten Kunden nicht mit der ID in der Bestellung passen
 				if (wpsg_isSizedInt($_SESSION['wpsg']['checkout']['id']))
 				{
-				
+
 					if (wpsg_isSizedInt($k_id) && $k_id != $_SESSION['wpsg']['checkout']['id'])
 					{
-						
+
 						$k_id = $_SESSION['wpsg']['checkout']['id'];
-				
-					}
-				
-				}			
-				
+
+					}
+
+				}
+
 				$data['custom'] = array();
-				
+
 				if (isset($this->arCheckout['custom']) && wpsg_isSizedArray($this->arCheckout)) $data['custom'] = $this->arCheckout['custom'];
-				
+
 				if (wpsg_isSizedInt($k_id))
 				{
-					
+
 					// Kunde existiert bereits, hier muss aufgepasst werden dass nur abgefragte Kundenvariablen ersetzt werden
-					$kunde_data = $this->shop->cache->loadKunden($k_id);					
+					$kunde_data = $this->shop->cache->loadKunden($k_id);
 					$custom_old = @unserialize($kunde_data['custom']);
-					
+
 					if (wpsg_isSizedArray($custom_old))
 					{
-						
+
 						$data['custom'] = wpsg_array_merge($custom_old, (array)$this->arCheckout['custom']);
-						
-					}
-					
-				}
-				
+
+					}
+
+				}
+
 				$data['custom'] = serialize($data['custom']);
-				
+
 				$update_customer_data = array();
-				
+
 				if ($k_id > 0)
 				{
-					
+
 					$this->db->UpdateQuery(WPSG_TBL_KU, $data, "`id` = '".wpsg_q($k_id)."'");
 					$knr = $this->db->fetchOne("SELECT `knr` FROM `".WPSG_TBL_KU."` WHERE `id` = '".wpsg_q($k_id)."'");
-					
+
 					$this->shop->callMods('customer_updatePwd', array(&$k_id, &$this->arCheckout['password']));
 					$this->shop->callMods('customer_updated', array(&$k_id));
-					
+
 				}
 				else
 				{
-					
+
 					if ($this->shop->hasMod('wpsg_mod_customergroup'))
 					{
-					
+
 						if (wpsg_isSizedInt($this->shop->get_option('wpsg_page_mod_kundenverwaltung_group_checkout'))) $data['group_id'] = $this->shop->get_option('wpsg_page_mod_kundenverwaltung_group_checkout');
-						
-					}
-
-					$k_id = $this->db->ImportQuery(WPSG_TBL_KU, $data);					
+
+					}
+
+					$k_id = $this->db->ImportQuery(WPSG_TBL_KU, $data);
 					$knr = $this->shop->buildKNR($k_id);
-					
+
 					$update_customer_data['knr'] = wpsg_q($knr);
-					
-					$this->shop->callMods('customer_created', array(&$k_id, &$this->arCheckout['password']));				
-					
-				}
-				
-				// Adresse speichern wenn der Kunde noch keine Adresse hat				
+
+					$this->shop->callMods('customer_created', array(&$k_id, &$this->arCheckout['password']));
+
+				}
+
+				// Adresse speichern wenn der Kunde noch keine Adresse hat
 				$customer_data = $this->shop->cache->loadKunden($k_id, true);
-				
+
 				$adress_data = array(
 					'firma' => wpsg_q(wpsg_getStr($this->arCheckout['firma'])),
@@ -754,58 +754,58 @@
 				);
 				//$adress_data['cdate'] = 'NOW()';
-				
+
 				$re_adress_id = 0;
-				if (false && $finish_order === true) 
-				{
-					
+				if (false && $finish_order === true)
+				{
+
 					// Adresse als Rechnungsadresse anlegen
 					$re_adress_id = wpsg_q($this->db->ImportQuery(WPSG_TBL_ADRESS, $adress_data));
-					
+
 					if (!wpsg_isSizedInt($customer_data['adress_id']))
 						$update_customer_data['adress_id'] = $re_adress_id;
-					
-				}
-				
+
+				}
+
 				if (!wpsg_isSizedInt($customer_data['adress_id']))
 				{
-				
+
 					$adress_data['cdate'] = 'NOW()';
-					
+
 					$customer_data['adress_id'] = wpsg_q($this->db->ImportQuery(WPSG_TBL_ADRESS, $adress_data));
 					$update_customer_data['adress_id'] = $customer_data['adress_id'];
-					
+
 				}
 				else
 				{
-			 
+
 					$this->db->UpdateQuery(WPSG_TBL_ADRESS, $adress_data, " `id` = '".wpsg_q($customer_data['adress_id'])."' ");
-					
+
 				}
 				$re_adress_id = $customer_data['adress_id'];
-				
+
 				// Kundendaten ggf. aktualisieren
 				if (wpsg_isSizedArray($update_customer_data)) $this->db->UpdateQuery(WPSG_TBL_KU, $update_customer_data, "`id` = '".wpsg_q($k_id)."'");
-				
+
 				$arBasket['checkout']['k_id'] = $k_id;
 				$arBasket['checkout']['knr'] = $knr;
-				
-				// Produkte letztmalig ÃŒberprÃŒfen			
+
+				// Produkte letztmalig ÃŒberprÃŒfen
 				foreach ($arBasket['produkte'] as $p_id => $p)
 				{
-				
+
 					if ($this->shop->hasMod('wpsg_mod_stock'))
 					{
-				
+
 						if (!$this->shop->callMod('wpsg_mod_stock', 'checkBestand', array($p['id'], $p['menge'])) && $this->shop->get_option('wpsg_mod_stock_allow') == '1')
 						{
-						
+
 							$p['menge'] = $this->shop->callMod('wpsg_mod_stock', 'getBestand', array($p['id']));
 
 						}
-						
-					}
-					
-				}
-				
+
+					}
+
+				}
+
 				$data = array(
 					'cdate' 			=> 'NOW()',
@@ -823,5 +823,5 @@
 					'price_payment_netto' 	=> wpsg_getFloat($arBasket['sum']['preis_payment_netto']),
 					'price_payment_brutto' 	=> wpsg_getFloat($arBasket['sum']['preis_payment_brutto']),
-					'price_rabatt' 		=> wpsg_tf($arBasket['sum']['preis_rabatt']),	
+					'price_rabatt' 		=> wpsg_tf($arBasket['sum']['preis_rabatt']),
 					'price_frontend'	=> $this->shop->getFrontendTaxview(),
 					'mwst_payment' 		=> wpsg_tf(wpsg_getFloat($arBasket['payment']['preis_payment_brutto']) - wpsg_getFloat($arBasket['payment']['preis_payment_netto'])),
@@ -837,33 +837,33 @@
 					)
 				);
-				
+
 				if ($finish_order === true) $data['status'] = wpsg_ShopController::STATUS_EINGEGANGEN;
 				else $data['status'] = wpsg_ShopController::STATUS_UNVOLLSTAENDIG;
-				
+
 				// Sprache des Nutzers speichern
 				if ($this->shop->isOtherLang())
 				{
-					
+
 					$data['language'] = wpsg_q($this->shop->getCurrentLanguageCode());
-					
-				}
-				
+
+				}
+
 				/** Gutschein speichern */
 				if ($this->gs_id !== false && $this->gs_id > 0)
 				{
-					
+
 					$gs_db = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_GUTSCHEIN."` WHERE `id` = '".wpsg_q($this->gs_id)."'");
-					
+
 					if ($gs_db['id'] != $this->gs_id) die(__('Unerwarteter Fehler bei Gutscheinzuordnung.', 'wpsg'));
-					
+
 					$data['gs_id'] = wpsg_q($this->gs_id);
 					$data['price_gs'] = wpsg_q($arBasket['sum']['gs']);
-					
-				}
-				
+
+				}
+
 				// Rabatt und Gutschein netto und brutto speichern
 				$data['price_rabatt_netto'] = wpsg_getFloat($arBasket['sum']['preis_rabatt_netto']);
 				$data['price_rabatt_brutto'] = wpsg_getFloat($arBasket['sum']['preis_rabatt_brutto']);
-				
+
 				if (isset($arBasket['sum']['gs']))
 				{
@@ -871,5 +871,5 @@
 					$data['price_gs_brutto'] = $arBasket['sum']['gs_brutto'];
 				}
-				
+
 				/*
 				if ($this->shop->getFrontendTaxview() == WPSG_BRUTTO)
@@ -884,5 +884,5 @@
 						$data['price_gs_brutto'] = $arBasket['sum']['gs'];
 					}
-					
+
 				}
 				else
@@ -897,13 +897,13 @@
 						$data['price_gs_brutto'] = $arBasket['sum']['gs'] + $tax;
 					}
-					
+
 				} $_REQUEST
 				*/
-				
+
 				$this->shop->callMods('basket_save_order', array(&$data, &$this->arCheckout, &$arBasket, $finish_order));
-				
+
 				if (($finish_order === true) && (wpsg_getStr($this->arCheckout['diff_shippingadress']) == '1'))
 				{	// Gesonderte Lieferadresse speichern
-					
+
 					$adata['cdate'] = 'NOW()';
 
@@ -916,7 +916,7 @@
 					$adata['firma'] 	= $data['shipping_firma'];
 					$adata['land'] 		= $data['shipping_land'];
-					
+
 					$data['shipping_adress_id'] = wpsg_q($this->db->ImportQuery(WPSG_TBL_ADRESS, $adata));
-					
+
 					// Daten fÃŒr BestellbestÃ€tigungsmail bereitstellen
 					$arBasket['checkout']['shipping_title'] = $data['shipping_title'];
@@ -928,5 +928,5 @@
 					$arBasket['checkout']['shipping_firma'] = $data['shipping_firma'];
 					$arBasket['checkout']['shipping_land'] = $data['shipping_land'];
-						
+
 				}
 				$data['adress_id'] = $re_adress_id;
@@ -939,60 +939,60 @@
 				unset($data['shipping_firma']);
 				unset($data['shipping_land']);
-				
+
 				$data['custom_data']['basket']['oOrder'] = Array();
 				//unset($data['custom_data']['basket']['oOrder']['shop']);
-				
+
 				$data['custom_data'] = wpsg_q(serialize($data['custom_data']));
-				
+
 				if (wpsg_isSizedInt($_SESSION['wpsg']['order_id']))
 				{
-					
+
 					$this->db->UpdateQuery(WPSG_TBL_ORDER, $data, " `id` = '".wpsg_q($_SESSION['wpsg']['order_id'])."' ");
-					
+
 					$o_id = $_SESSION['wpsg']['order_id'];
 					$o_nr = $saved_order_db['onr'];
-					
-				}
-				else 
-				{
-					
+
+				}
+				else
+				{
+
 					$o_id = $this->db->ImportQuery(WPSG_TBL_ORDER, $data);
 					$o_nr = $this->shop->buildONR($o_id, $k_id, $knr);
-				
+
 					// Bestellnummer speichern
 					$this->db->UpdateQuery(WPSG_TBL_ORDER, array(
 						'onr' => wpsg_q($o_nr)
 					), "`id` = '".wpsg_q($o_id)."'");
-					
-				}
-				
-				$arBasket['checkout']['onr'] = $o_nr;			
+
+				}
+
+				$arBasket['checkout']['onr'] = $o_nr;
 				$arBasket['checkout']['o_id'] = $o_id;
-				$arBasket['checkout']['datum'] = strtotime($this->db->fetchOne("SELECT `cdate` FROM `".WPSG_TBL_ORDER."` WHERE `id` = '".wpsg_q($o_id)."'")); 
-				
+				$arBasket['checkout']['datum'] = strtotime($this->db->fetchOne("SELECT `cdate` FROM `".WPSG_TBL_ORDER."` WHERE `id` = '".wpsg_q($o_id)."'"));
+
 				if ($finish_order === true)
 				{
-				
+
 					/** Gutschein der Bestellung zuordnen */
 					if ($this->gs_id !== false && $this->gs_id > 0)
 					{
-					
+
 						if ($gs_db['multi'] != '1')
 						{
-						
+
 							$this->db->UpdateQuery(WPSG_TBL_GUTSCHEIN, array('o_id' => $o_id), "`id` = '".wpsg_q($this->gs_id)."'");
-						
+
 						}
-					
-					}
-					
+
+					}
+
 					$this->shop->cache->clearOrderCache($o_id);
 					$this->shop->cache->clearKundenCache($k_id);
-					
-				}
-				
+
+				}
+
 				// DB bereinigen und alte zur Bestellung gespeicherte Produkte lÃ¶schen
 				$this->db->Query("DELETE FROM `".WPSG_TBL_ORDERPRODUCT."` WHERE `o_id` = '".wpsg_q($o_id)."' ");
-				
+
 				// Produkte eintragen
 				foreach ($arBasket['produkte'] as $p_id => $p)
@@ -1017,48 +1017,48 @@
 						'allowedshipping' => wpsg_q($p['allowedshipping'])
 					);
-					
+
 					// Hier wird der Lagerbestand final geschrieben, sollte ein Fehler ausgelÃ¶st werden soll zum Warenkorb geleitet werden
-					if ($finish_order === true && $this->shop->hasMod('wpsg_mod_stock'))					
-					{
-						
+					if ($finish_order === true && $this->shop->hasMod('wpsg_mod_stock'))
+					{
+
 						$p_stock = $p;
 						$bStockError = $this->shop->callMod('wpsg_mod_stock', 'checkReduceStock', array(&$data, &$p_stock));
-						
+
 						if ($bStockError === false)
 						{
-							
+
 							$this->shop->addFrontendError(__('Lagerbestand hat sich zwischenzeitlich geÃ€ndert. Bitte Bestellung ÃŒberprÃŒfen.', 'wpsg'));
 							$this->shop->redirect($this->shop->getUrl(wpsg_ShopController::URL_BASKET));
-							
+
 						}
-						
-					}
-					
+
+					}
+
 					$this->shop->callMods('basket_save_product', array(&$data, &$p, $finish_order));
-					
+
 					$this->db->ImportQuery(WPSG_TBL_ORDERPRODUCT, $data);
-					
+
 					// Eventuelle URL Benachrichtigung bei Kauf
 					if ($finish_order === true)
 					{
-					
+
 						$produkt_db = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".wpsg_q($produkt_id)."'");
-					
+
 						if ($produkt_db['posturl'] != '' && $produkt_db['posturl_verkauf'] == '1')
 						{
-							
+
 							$this->shop->notifyURL($produkt_db['posturl'], $p['id'], $p['menge'], $o_id, 0, false, array(
 								'product_index' => $p_id
 							));
-					
+
 						}
-						
-					}
-					
-				}
-				
+
+					}
+
+				}
+
 				if ($finish_order === true)
 				{
-				
+
 					$this->shop->callMods('basket_save_done', array(&$o_id, &$k_id, &$this));
 					$this->shop->callMods('basket_save_done_array', array(&$o_id, &$k_id, &$arBasket));
@@ -1066,13 +1066,13 @@
 					// Wenn CrefoPay aktiv, werden die Mails spÃ€ter versendet
 					if (!$this->shop->hasMod('wpsg_mod_crefopay')) $this->sendOrderSaveMails($o_id, $arBasket);
-					
+
 					// Bestellung direkt auf "Zahlung akzeptiert setzen" wenn option aktiv ist
 					if ($this->shop->get_option('wpsg_emptyorder_clear') == '1' && $arBasket['sum']['preis_gesamt_brutto'] == 0)
 					{
-						
+
 						$this->shop->setOrderStatus($o_id, 100, true);
-						
-					}
-					
+
+					}
+
 
 					// Eintrag in die Kundentabelle
@@ -1081,5 +1081,5 @@
 					);
 					$this->db->UpdateQuery(WPSG_TBL_KU, $kdata, "`id` = '".wpsg_q($k_id)."'");
-					
+
 					// Alte BestellID muss nach AbschluÃ entfernt werden
 					unset($_SESSION['wpsg']['order_id']);
@@ -1087,36 +1087,36 @@
 					unset($_SESSION['wpsg']['checkout']['paymentId']);
 					unset($_SESSION['wpsg']['checkout']['payer_id']);
-					
+
 					$this->clearSession($k_id);
-					
+
 				}
 				else
 				{
-					
+
 					$_SESSION['wpsg']['order_id'] = $o_id;
-					
-				}
-			
+
+				}
+
 			}
 			catch (Exception $e)
 			{
-			
+
 				$this->db->unlockTables();
-				
+
 				die($e->getMessage());
-				
-			}
-			
+
+			}
+
 			$this->db->unlockTables();
-			
+
 			return $o_id;
-			
+
 		} // public function save()
-		
+
 		/**
 		 * Wird als letzte ÃberprÃŒfung der Bestellung aufgerufen und leitet zu overview.phtml wenn $error true wird
 		 */
 		public function checkFinaly(&$error) { }
-		
+
 		/**
 		 * ÃberprÃŒft die Korrektheit der Kunden- und Bestelldaten
@@ -1124,71 +1124,71 @@
 		public function checkCheckout($state = true)
 		{
-			
+
 			$bError = false;
-			
+
 			// Darf hier nicht ÃŒberschrieben werden sonst keine Feldmarkierung fÃŒr ordercondition
 			if (!wpsg_isSizedArray($_SESSION['wpsg']['errorFields'])) $_SESSION['wpsg']['errorFields'] = array();
-			
+
 			$custom_config = $GLOBALS['wpsg_sc']->loadPflichtFeldDaten();
 
 			$this->shop->callMods('checkCheckout', array(&$state, &$bError, &$this->arCheckout));
-			
+
 			if ($state == 1 || $state)
 			{
-			
+
 				// Anrede ÃŒberprÃŒfen
 				if ($custom_config['anrede'] != '1' && $this->arCheckout['title'] == '-1')
 				{
-					
+
 					$this->shop->addFrontendError(__('Bitte im Feld "Anrede" eine Angabe machen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'title';
 					$bError = true;
-					
-				}
-	
-				// Firma 
+
+				}
+
+				// Firma
 				if ($custom_config['firma'] != '1' && trim($this->arCheckout['firma']) == '')
 				{
-					
+
 					$this->shop->addFrontendError(__('Bitte im Feld "Firma" eine Angabe machen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'firma';
 					$bError = true;
-					
-				}
-				
+
+				}
+
 				// Vorname
 				if ($custom_config['vname'] != '1' && trim(wpsg_getStr($this->arCheckout['vname'])) == '')
 				{
-					
+
 					$this->shop->addFrontendError(__('Bitte im Feld "Vorname" eine Angabe machen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'vname';
 					$bError = true;
-					
-				}
-				
+
+				}
+
 				// Name
 				if ($custom_config['name'] != '1' && trim(wpsg_getStr($this->arCheckout['name'])) == '')
 				{
-					
+
 					$this->shop->addFrontendError(__('Bitte im Feld "Name" eine Angabe machen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'name';
 					$bError = true;
-					
-				}
-				
-				// Geburtsdatum 
+
+				}
+
+				// Geburtsdatum
 				if (
 						($custom_config['geb'] != '1' && !wpsg_isValidGeb($this->arCheckout['geb'])) ||
 						(wpsg_isSizedString($this->arCheckout['geb']) && !wpsg_isValidGeb($this->arCheckout['geb']))
-					
+
 					)
 				{
-					
+
 					$this->shop->addFrontendError(__('Bitte die Eingabe im Feld "Geburtsdatum" ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'geb';
 					$bError = true;
-					
-				}
-				
+
+				}
+
 				// E-Mail Adresse
 				if (
@@ -1197,29 +1197,29 @@
 					)
 				{
-									
+
 					$this->shop->addFrontendError(__('Bitte die Eingabe der E-Mail Adresse ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'email';
 					$bError = true;
-					
-				}
-	
+
+				}
+
 				// E-Mail EingabeÃŒberprÃŒfung
 				if ($custom_config['emailconfirm'] == '1')
 				{
-					
+
 					$this->arCheckout['email'] = strtolower($this->arCheckout['email']);
 					$this->arCheckout['email2'] = strtolower($this->arCheckout['email2']);
-					
+
 					if ($this->arCheckout['email'] != wpsg_getStr($this->arCheckout['email2']))
 					{
-	
+
 						$this->shop->addFrontendError(__('Bitte ÃŒberprÃŒfen Sie die Eingaben in der E-Mail BestÃ€tigung!', 'wpsg'));
-						$_SESSION['wpsg']['errorFields'][] = 'email'; 
+						$_SESSION['wpsg']['errorFields'][] = 'email';
 						$bError = true;
-						 
-					}
-					
-				}
-				
+
+					}
+
+				}
+
 				// Telefonnummer validieren
 				if ($custom_config['tel'] != '1' && $this->arCheckout['tel'] == '')
@@ -1229,170 +1229,170 @@
 					$_SESSION['wpsg']['errorFields'][] = 'tel';
 					$bError = true;
-					
-				}
-				
+
+				}
+
 				// StraÃe prÃŒfen
 				if ($custom_config['strasse'] != '1' && wpsg_getStr($this->arCheckout['strasse']) == '')
 				{
-					
+
 					$this->shop->addFrontendError(__('Bitte die Eingaben im Feld "StraÃe" ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'strasse';
 					$bError = true;
-					
-				}
-				
+
+				}
+
 				// Fax prÃŒfen
 				if ($custom_config['fax'] != '1' && $this->arCheckout['fax'] == '')
 				{
-					
+
 					$this->shop->addFrontendError(__('Bitte die Eingaben im Feld "Fax" ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'fax';
 					$bError = true;
-					
-				}
-				
+
+				}
+
 				// PLZ ÃŒberprÃŒfen
 				if ($custom_config['plz'] != '1' && wpsg_getStr($this->arCheckout['plz']) == '')
 				{
-					
+
 					$this->shop->addFrontendError(__('Bitte die Eingaben im Feld "PLZ" ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'plz';
 					$bError = true;
-					
-				}
-				
+
+				}
+
 				// Ort ÃŒberprÃŒfen
 				if ($custom_config['ort'] != '1' && wpsg_getStr($this->arCheckout['ort']) == '')
 				{
-					
+
 					$this->shop->addFrontendError(__('Bitte die Eingaben im Feld "Ort" ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'ort';
 					$bError = true;
-					
-				}
-				
+
+				}
+
 				// Land ÃŒberprÃŒfen
 				if ($custom_config['land'] != '1' && $this->arCheckout['land'] <= 0)
 				{
-					
+
 					$this->shop->addFrontendError(__('Bitte ein Land auswÃ€hlen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'land';
 					$bError = true;
-					
-				}
-				
+
+				}
+
 				// UStIdNr prÃŒfen
 				if ($custom_config['ustidnr'] != '1' && !preg_match("/^[a-zA-Z]+\d+/", $this->arCheckout['ustidnr']))
 				{
-					
+
 					$this->shop->addFrontendError(__('Bitte die Eingaben im Feld "UStIdNr." prÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'ustidnr';
 					$bError = true;
-					
-				}
-				
+
+				}
+
 				// Benutzerdefinierte Felder prÃŒfen
 				foreach ((array)$custom_config['custom'] as $c_id => $c)
 				{
-					
+
 					// Wenn die Kundenvariable nicht im Request drin ist dann auch nichts machen
-					// Problem war der Fall, dass eine Kundenvariable nicht angezeigt wurde 
+					// Problem war der Fall, dass eine Kundenvariable nicht angezeigt wurde
 					if (!isset($this->arCheckout['custom'][$c_id])) continue;
-					
+
 					if ($c['show'] == '0')
 					{
-						
+
 						if ($c['typ'] == '2')
 						{
-							
+
 							// Checkbox
 							if ($this->arCheckout['custom'][$c_id] != '1')
 							{
-								
+
 								$this->shop->addFrontendError(wpsg_translate(__('Bitte "#1#" akzeptieren!', 'wpsg'), __($c['name'], 'wpsg')));
 								$_SESSION['wpsg']['errorFields'][] = 'custom_'.$c_id;
 								$bError = true;
-								
+
 							}
-							
+
 						}
 						else if ($c['typ'] == '1')
 						{
-							
+
 							// Auswahl
 							if ($this->arCheckout['custom'][$c_id] == '-1')
 							{
-								
+
 								$this->shop->addFrontendError(wpsg_translate(__('Bitte eine Auswahl im Feld "#1#" treffen!', 'wpsg'), __($c['name'], 'wpsg')));
 								$_SESSION['wpsg']['errorFields'][] = 'custom_'.$c_id;
 								$bError = true;
-								
+
 							}
-							
+
 						}
 						else if ($c['typ'] == '0')
 						{
-						 
+
 							// Texte
 							if (trim($this->arCheckout['custom'][$c_id]) == '')
 							{
-								
+
 								$this->shop->addFrontendError(wpsg_translate(__('Bitte machen Sie in Feld "#1#" eine Angabe!', 'wpsg'), __($c['name'], 'wpsg')));
 								$_SESSION['wpsg']['errorFields'][] = 'custom_'.$c_id;
 								$bError = true;
-								
+
 							}
-							
+
 						}
-						
-					}
-					
-				}
-
-			}
-			
+
+					}
+
+				}
+
+			}
+
 			/**
 			 * Versand- und Zahlungsarten nur Checken wenn State=2 oder alle State=true (Alles prÃŒfen)
 			 * Wenn Einseiten-Checkout aktiv, dann auch bei State=1 prÃŒfen aber nicht(!) Wenn Profil oder Registrierung abgeschickt wird
-			 */			
-			if ($state == 2 || $state === true || 
+			 */
+			if ($state == 2 || $state === true ||
 				($this->shop->hasMod('wpsg_mod_onepagecheckout') && $state == 1 && !isset($_REQUEST['wpsg_mod_kundenverwaltung_save']) && !isset($_REQUEST['wpsg_mod_kundenverwaltung_register'])))
 			{
-				 			
-				$this->shop->checkShippingAvailable(); 
- 
+
+				$this->shop->checkShippingAvailable();
+
 				// Versandart prÃŒfen
 				if (!isset($this->arCheckout['shipping']) || !array_key_exists($this->arCheckout['shipping'], $this->shop->arShipping) || $this->arCheckout['shipping'] == '')
 				{
-										
+
 					$this->shop->addFrontendError(__('Bitte eine gÃŒltige Versandart auswÃ€hlen.', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'shipping';
 					$bError = true;
-					
-				}
-  
+
+				}
+
 				// Zahlungsart prÃŒfen
 				if (!$this->shop->hasMod('wpsg_mod_crefopay'))
 				{
-				
+
 					if (!isset($this->arCheckout['payment']) || !array_key_exists($this->arCheckout['payment'], $this->shop->arPayment) || $this->arCheckout['payment'] == '')
 					{
-					
+
 						// Fake Zahlungsart PayPal Plus soll keinen Fehler schreiben
 						if ($this->arCheckout['payment'] != 'ppp')
 						{
-						
+
 							$this->shop->addFrontendError(__('Bitte eine gÃŒltige Zahlungsart auswÃ€hlen.', 'wpsg'));
 							$_SESSION['wpsg']['errorFields'][] = 'payment';
 							$bError = true;
-							
+
 						}
-						
-					}
-					
-				}
-			 
-			}
-			
+
+					}
+
+				}
+
+			}
+
 			// prÃŒft ob tatsÃ€chlich mind. ein Produkt im Warenkorb liegt
 			if (isset($_SESSION['wpsg']['basket']) && count($_SESSION['wpsg']['basket']) < 1 && !is_numeric($state))
@@ -1402,7 +1402,7 @@
 				$bError = true;
 			}
-				
-			return !$bError; 
-			
+
+			return !$bError;
+
 		} // public function checkCheckout()
 
@@ -1412,16 +1412,16 @@
 		public function hasEULeistungsortProduct(&$arBasket)
 		{
-			
+
 			foreach ($arBasket['produkte'] as $p)
 			{
-				
+
 				if (wpsg_isSizedInt($p['euleistungsortregel'])) return true;
-				
-			}
-			
+
+			}
+
 			return false;
-			
+
 		} // public function hasEULeistungsortProduct(&$arBasket)
-		
+
 		/**
 		 * Wandelt die in der Session gespeicherten Produkte in einen aufgewerteten Array
@@ -1429,89 +1429,89 @@
 		public function toArray($backend = false, $clearVK = false)
 		{
-			
+
 			if (($this->o_id > 0) && false)
 			{
-				
+
 				$order_data = $this->shop->cache->loadOrder($this->o_id);
-				$custom_data = @unserialize($order_data['custom_data']);	
-								
+				$custom_data = @unserialize($order_data['custom_data']);
+
 				if (is_array($custom_data['basket']))
 				{
-					
+
 					$arBasket = $custom_data['basket'];
-					
+
 					// Ich vereinige die Checkoutdaten mit den Kundendaten aus der Datenbank
 					// Damit sind hier die aktuellen Werte aus der Datenbank enthalten
 					$arBasket['checkout'] = wpsg_array_merge($arBasket['checkout'], $this->shop->cache->loadKunden($arBasket['checkout']['k_id']));
-										
+
 					// FÃŒr das Backend eventuell Preise drehen
 					if ($backend === true)
 					{
-						
+
 						if ($this->shop->get_option('wpsg_preisangaben') == WPSG_NETTO)
 						{
-						 
+
 							if (isset($arBasket['sum']['preis_payment_netto'])) $arBasket['sum']['preis_payment'] = $arBasket['sum']['preis_payment_netto'];
-							if (isset($arBasket['sum']['preis_shipping_netto'])) $arBasket['sum']['preis_shipping'] = $arBasket['sum']['preis_shipping_netto']; 
+							if (isset($arBasket['sum']['preis_shipping_netto'])) $arBasket['sum']['preis_shipping'] = $arBasket['sum']['preis_shipping_netto'];
 							if (isset($arBasket['sum']['gs_netto'])) $arBasket['sum']['gs'] = $arBasket['sum']['gs_netto'];
 							if (isset($arBasket['sum']['preis_rabatt_netto'])) $arBasket['sum']['preis_rabatt'] = $arBasket['sum']['preis_rabatt_netto'];
 							if (isset($arBasket['sum']['preis_netto'])) $arBasket['sum']['preis'] = $arBasket['sum']['preis_netto'];
 							if (isset($arBasket['sum']['preis_gesamt_netto'])) $arBasket['sum']['preis_gesamt'] = $arBasket['sum']['preis_gesamt_netto'];
-											
+
 						}
 						else
 						{
-							
+
 							if (isset($arBasket['sum']['preis_payment_brutto'])) $arBasket['sum']['preis_payment'] = $arBasket['sum']['preis_payment_brutto'];
-							if (isset($arBasket['sum']['preis_shipping_brutto'])) $arBasket['sum']['preis_shipping'] = $arBasket['sum']['preis_shipping_brutto']; 
+							if (isset($arBasket['sum']['preis_shipping_brutto'])) $arBasket['sum']['preis_shipping'] = $arBasket['sum']['preis_shipping_brutto'];
 							if (isset($arBasket['sum']['gs_brutto'])) $arBasket['sum']['gs'] = $arBasket['sum']['gs_brutto'];
 							if (isset($arBasket['sum']['preis_rabatt_brutto'])) $arBasket['sum']['preis_rabatt'] = $arBasket['sum']['preis_rabatt_brutto'];
 							if (isset($arBasket['sum']['preis_brutto'])) $arBasket['sum']['preis'] = $arBasket['sum']['preis_brutto'];
 							if (isset($arBasket['sum']['preis_gesamt_brutto'])) $arBasket['sum']['preis_gesamt'] = $arBasket['sum']['preis_gesamt_brutto'];
-							
+
 						}
-						 						
-					}
-					
+
+					}
+
 					$arBasket['oOrder'] = wpsg_order::getInstance($this->o_id);
-					
+
 					return $arBasket;
-					
-				}
-				
+
+				}
+
 			}	// if (($this->o_id > 0) && false)
-			
+
 			$arReturn = array();
 
 			if (wpsg_isSizedInt($_SESSION['wpsg']['order_id'])) $arReturn['oOrder'] = wpsg_order::getInstance($_SESSION['wpsg']['order_id']);
-			
+
 			if (wpsg_isSizedInt($this->arCheckout['land']))
 			{
-			
+
 				$db_country_invoice = $this->shop->db->fetchRow("SELECT * FROM `".WPSG_TBL_LAND."` WHERE `id` = '".wpsg_q($this->arCheckout['land'])."'");
 				$arReturn['land'] = $db_country_invoice;
-				
+
 				if (wpsg_isSizedInt($this->arCheckout['shipping_land']))
 				{
-					
+
 					$db_country_shipping = $this->shop->db->fetchRow("SELECT * FROM `".WPSG_TBL_LAND."` WHERE `id` = '".wpsg_q($this->arCheckout['shipping_land'])."'");
 					$arReturn['shipping_land'] = $db_country_shipping;
 					$land = $db_country_shipping;
-					
-				}
-				else 
-				{
-					
+
+				}
+				else
+				{
+
 					$db_country_shipping = $db_country_invoice;
 					$land = $db_country_shipping;
-									
-				}
-				
+
+				}
+
 			} else $land = 0;
-						
+
 			if ($land['mwst'] == '1' || $this->shop->get_option('wpsg_kleinunternehmer') == '1') $noMwSt = true;
 			else if ($land['mwst'] == '2' && wpsg_isSizedString($this->arCheckout['ustidnr'])) $noMwSt = true;
 			else $noMwSt = false;
-			
+
 			$arReturn['noMwSt'] = $noMwSt;
 			$arReturn['produkte'] = array();
@@ -1529,5 +1529,5 @@
 				'preis_rabatt' => 0
 			);
-					
+
 			// Hier sammel ich die Produktpreise
 			$arProductPrice = array(
@@ -1535,17 +1535,17 @@
 				WPSG_BRUTTO => array()
 			);
-			
+
 			foreach ($this->arProdukte as $product_index => &$b)
 			{
-								
+
 				$produkt_id = $this->shop->getProduktID($b['id']);
-				
+
 				wpsg_addSet($arReturn['menge'], $b['menge']);
-				
+
 				$country = $this->shop->getDefaultCountry();
-				
+
 				if (is_numeric($produkt_id))
 				{
-				
+
 					// Preis wird berechnet daher entfernen
 					unset($b['preis']);
@@ -1553,122 +1553,122 @@
 					unset($b['preis_brutto']);
 					unset($b['mwst_key']); // Key muss auch gelÃ¶scht werden, damit die loadProduktArray den Preis korrekt ermittelt (Sonst funktioniert es beim 2. Mal nicht)
-						
+
 					// in $b sind eventuell auch Moduldaten drin (Produktvariablen)
 					$b = $this->shop->loadProduktArray($produkt_id, $b);
-						
+
 					if (wpsg_isSizedInt($b['euleistungsortregel']))
 					{
-				
+
 						$this->shop->showEULayer = true;
 						$country = $this->shop->getFrontendCountry();
-				
-					}
-						
+
+					}
+
 					$b['productkey'] = $b['id'];
-									
-				}
-								
-				$this->shop->callMods('basket_toArray', array(&$b, $backend, $noMwSt));				
+
+				}
+
+				$this->shop->callMods('basket_toArray', array(&$b, $backend, $noMwSt));
 				$this->checkMwSt($b['mwst_key'], $country, $arReturn);
-				 	
+
 				if ($noMwSt)
 				{
-					
+
 					// Damit erreiche ich, dass 0% angezeigt wird, wenn keine MwSt. berechnet wird
 					$this->arProdukte[$product_index]['mwst_key'] = false;
-					
+
 					$price_product_netto = $b['preis_netto'];
 					$price_product_brutto = $b['preis_netto'];
-										
+
 				}
 				else
 				{
-					
+
 					$price_product_netto = $b['preis_netto'];
 					$price_product_brutto = $b['preis_brutto'];
-					
-				}
-				 			
+
+				}
+
 				// Hier wird entschieden ob der gerundete oder der genaue Wert zum Gesamtpreis hinzuaddiert wird
 				if ($this->shop->addRoundedValues === true)
 				{
-				 
+
 					$b['preis_netto'] = round($price_product_netto, 2);
 					$b['preis_brutto'] = round($price_product_brutto, 2);
-					  									
+
 				}
 				else
 				{
-				
+
 					$b['preis_netto'] = $price_product_netto;
 					$b['preis_brutto'] = $price_product_brutto;
-														
-				}
-				
+
+				}
+
 				$price_sum_netto = $b['preis_netto'] * $b['menge'];
 				$price_sum_brutto = $b['preis_brutto'] * $b['menge'];
-				
+
 				if ($this->shop->getFrontendTaxView() == WPSG_NETTO) $b['preis'] = round($b['preis_netto'], 2);
 				else $b['preis'] = round($b['preis_brutto'], 2);
-								
+
 				$arProductPrice[WPSG_NETTO][$b['mwst_key'].'_'.$country->id][] = $price_sum_netto;
 				$arProductPrice[WPSG_BRUTTO][$b['mwst_key'].'_'.$country->id][] = $price_sum_brutto;
-								
+
 				$b['product_index'] = $product_index;
 				$arReturn['produkte'][$product_index] = $b;
-								
+
 			} // foreach Produkte
-			
-			// Die Basis der Preisberechnung, wenn Brutto, dann wird Netto berechnet 
+
+			// Die Basis der Preisberechnung, wenn Brutto, dann wird Netto berechnet
 			if ($this->shop->getFrontendTaxview() == WPSG_NETTO)
 			{
-				
+
 				$base = WPSG_NETTO;
 				$calc = WPSG_BRUTTO;
-				
-			}
-			else 
-			{
-			
+
+			}
+			else
+			{
+
 				$base = WPSG_BRUTTO;
 				$calc = WPSG_NETTO;
-				
-			}
-			 
+
+			}
+
 			// Jetzt die jeweilige Steuer berechnen, damit die Anzeige stimmt
 			foreach ($arProductPrice[$base] as $tax_key_lang => $tax)
 			{
-				
+
 				$arTaxKey = explode('_', $tax_key_lang);
 				$country_id = $arTaxKey[1];
 				$country = wpsg_country::getInstance($country_id);
 				$tax_key = $arTaxKey[0];
-				
+
 				if ($noMwSt === true) $tax_value = 0; else $tax_value = $country->getTax($tax_key);
-				
+
 				$sum_tax_value = round(wpsg_calculateSteuer(array_sum($tax), $base, $tax_value), 2);
-								
+
 				wpsg_addSet($arReturn['sum']['mwst'], $sum_tax_value);
-				
+
 				if ($calc === WPSG_NETTO)
 				{
-				 
+
 					$sum_netto = round(wpsg_calculatePreis(array_sum($tax), WPSG_NETTO, $tax_value), 2);
-					$sum_brutto = array_sum($tax);					
-					 
+					$sum_brutto = array_sum($tax);
+
 				}
 				else
 				{
-					
+
 					$sum_netto = array_sum($tax);
 					$sum_brutto = round(wpsg_calculatePreis(array_sum($tax), WPSG_BRUTTO, $tax_value), 2);
-						
-				}	
-				
+
+				}
+
 				wpsg_addSet($arReturn['sum']['preis_netto'], $sum_netto);
 				wpsg_addSet($arReturn['sum']['preis_gesamt_netto'], $sum_netto);
 				wpsg_addSet($arReturn['sum']['preis_brutto'], $sum_brutto);
 				wpsg_addSet($arReturn['sum']['preis_gesamt_brutto'], $sum_brutto);
-						
+
 				if (!$noMwSt)
 				{
@@ -1678,5 +1678,5 @@
 						wpsg_addSet($arReturn['mwst'][$tax_key_lang]['sum'], $sum_tax_value);
 						wpsg_addSet($arReturn['mwst'][$tax_key_lang]['base_value'], $sum_brutto);
-						
+
 					}
 					else if ((isset($this->arOrder['price_frontend'])) && ($this->arOrder['price_frontend'] == WPSG_NETTO))
@@ -1684,5 +1684,5 @@
 						wpsg_addSet($arReturn['mwst'][$tax_key_lang]['sum'], $sum_tax_value);
 						wpsg_addSet($arReturn['mwst'][$tax_key_lang]['base_value'], $sum_netto);
-						
+
 					}
 					else */
@@ -1690,26 +1690,26 @@
 						wpsg_addSet($arReturn['mwst'][$tax_key_lang]['sum'], $sum_tax_value);
 						wpsg_addSet($arReturn['mwst'][$tax_key_lang]['base_value'], $sum_brutto);
-						
-					}
-						
-				}
-				
-			}
-			
+
+					}
+
+				}
+
+			}
+
 			if ($base === WPSG_NETTO)
 			{
-				
+
 				wpsg_addSet($arReturn['sum']['preis'], $arReturn['sum']['preis_netto']);
 				wpsg_addSet($arReturn['sum']['preis_gesamt'], $arReturn['sum']['preis_gesamt_netto']);
-				
+
 			}
 			else
 			{
-				 
+
 				wpsg_addSet($arReturn['sum']['preis'], $arReturn['sum']['preis_brutto']);
 				wpsg_addSet($arReturn['sum']['preis_gesamt'], $arReturn['sum']['preis_gesamt_brutto']);
-				
-			}
-						
+
+			}
+
 			if ($backend)
 			{
@@ -1718,7 +1718,7 @@
 				$arReturn['order_rabatt'] = $this->arOrder['price_rabatt'];
 				$arReturn['gs_value'] = $this->arOrder['price_gs'];
-				
-			}
-				
+
+			}
+
 			// Gutschein einberechnen
 			$this->shop->callMod('wpsg_mod_gutschein', 'basket_toArray_gs', array(&$this, &$arReturn));
@@ -1726,10 +1726,10 @@
 			// Staffelrabatt
 			$this->shop->callMod('wpsg_mod_discount', 'basket_toArray_discount', array(&$this, &$arReturn));
-			
-			// Kundendaten einfÃŒgen			
+
+			// Kundendaten einfÃŒgen
 			$arReturn['checkout'] = $this->arCheckout;
 
 			$this->shop->callMods('basket_toArray_preshippayment', array(&$this, &$arReturn));
-			  
+
 			// Die Versandkosten fÃŒr den Warenkorb berechnen
 			// Dies darf im checkout2 nicht passieren, oder wenn der Parameter auf true
@@ -1745,26 +1745,26 @@
 				$arReturn['sum']['preis_shipping_brutto'] = $order_data['price_shipping_brutto'];
 				$arReturn['sum']['preis_shipping_netto'] = $order_data['price_shipping_netto'];
-				
+
 				/*
 
 				if ($this->shop->getFrontendTaxview() == WPSG_BRUTTO)
 				{
-				
+
 					$arReturn['sum']['preis_payment_brutto'] = $price_payment;
 					$arReturn['sum']['preis_payment_netto'] = wpsg_calculatePreis($price_payment, WPSG_NETTO, $order_data['mwst_payment']);
-				
+
 					$arReturn['sum']['preis_shipping_brutto'] = $price_shipping;
 					$arReturn['sum']['preis_shipping_netto'] = wpsg_calculatePreis($price_shipping, WPSG_NETTO, $order_data['mwst_shipping']);
-					
+
 				}
 				else
 				{
-					
+
 					$arReturn['sum']['preis_payment_netto'] = $price_payment;
 					$arReturn['sum']['preis_payment_brutto'] = wpsg_calculatePreis($price_payment, WPSG_BRUTTO, $order_data['mwst_payment']);
-					
+
 					$arReturn['sum']['preis_shipping_netto'] = $price_shipping;
 					$arReturn['sum']['preis_shipping_brutto'] = wpsg_calculatePreis($price_shipping, WPSG_BRUTTO, $order_data['mwst_shipping']);
-					
+
 				}
 				*/
@@ -1772,40 +1772,40 @@
 			else
 			{
-				
+
 				// Bin mir nicht sicher warum die Versandkosten/Zahlungskosten im Checkout nicht berechnet wurde
-				// Aufgrund von PayPal (PayPal Plus) brauch ich sie aber 
+				// Aufgrund von PayPal (PayPal Plus) brauch ich sie aber
 				//if (!isset($_REQUEST['wpsg_checkout2']) && !$clearVK)
 				{
-				
+
 					if ($backend) $arReturn['backend'] = true;
 					else $arReturn['backend'] = false;
-					
+
 					if (!$backend)
 					{
-						
+
 						/*
 						 * PrÃŒfen ob die gesetzte Zahlungsart auch in den VerfÃŒgbaren ist
 						 * Ist fÃŒr die Auswahl der LÃ€nder, Zahlungsarten und Versandarten im Warenkorb nÃ¶tig geworden
 						 */
-						if (wpsg_isSizedInt($arReturn['checkout']['shipping']) && !@array_key_exists($arReturn['checkout']['shipping'], $this->shop->arShipping)) 
+						if (wpsg_isSizedInt($arReturn['checkout']['shipping']) && !@array_key_exists($arReturn['checkout']['shipping'], $this->shop->arShipping))
 						{
-							
+
 							unset($arReturn['checkout']['shipping']);
-							
+
 						}
-						
+
 						if (wpsg_isSizedInt($arReturn['checkout']['payment']) && !array_key_exists($arReturn['checkout']['payment'], $this->shop->arPayment))
 						{
-							
+
 							unset($arReturn['checkout']['payment']);
-							
+
 						}
-												
-					}
-					
+
+					}
+
 					// Versandarten kÃ¶nnen gruppiert sein, vorher trennen
 					if (wpsg_isSizedString($arReturn['checkout']['shipping']) && preg_match('/(.*)\-(.*)/', $arReturn['checkout']['shipping']))
 					{
-						
+
 						$arShipping = explode('-', $arReturn['checkout']['shipping']);
 
@@ -1813,88 +1813,88 @@
 						// Sonst ist die Grundlage fÃŒr die Berechnung nicht die Selbe
 						$arBasketPreShipping = $arReturn;
-						
+
 						foreach ($arShipping as $shipping)
 						{
-							
+
 							$basket_calc = $arBasketPreShipping;
-							
+
 							$this->shop->callMods('calcShipping', array(&$basket_calc, $shipping));
-							
+
 							wpsg_addSet($arReturn['sum']['preis_shipping'], $basket_calc['sum']['preis_shipping']);
 							wpsg_addSet($arReturn['sum']['preis_shipping_brutto'], $basket_calc['sum']['preis_shipping_brutto']);
 							wpsg_addSet($arReturn['sum']['preis_shipping_netto'], $basket_calc['sum']['preis_shipping_netto']);
-							
+
 							wpsg_addSet($arReturn['shipping']['mwst'], $basket_calc['shipping']['mwst']);
 							wpsg_addSet($arReturn['shipping']['preis_shipping_netto'], $basket_calc['shipping']['preis_shipping_netto']);
 							wpsg_addSet($arReturn['shipping']['preis_shipping_brutto'], $basket_calc['shipping']['preis_shipping_brutto']);
- 
+
 							foreach ($basket_calc['mwst'] as $tax_key => $mwst)
 							{
-								
+
 								$this->shop->basket->checkMwSt(substr($tax_key, 0, 1), $this->shop->getDefaultCountry(), $arReturn);
-								
+
 								if (!array_key_exists($tax_key, $arBasketPreShipping['mwst']))
 								{
-								
+
 									// Satz war vorher noch nicht drin
 									$arReturn['mwst'][$tax_key]['sum'] += $mwst['sum'];
 									$arReturn['mwst'][$tax_key]['base_value'] += $mwst['base_value'];
-									
+
 								}
 								else
 								{
-									
-									$arReturn['mwst'][$tax_key]['sum'] += ($mwst['sum'] - $arBasketPreShipping['mwst'][$tax_key]['sum']); 
+
+									$arReturn['mwst'][$tax_key]['sum'] += ($mwst['sum'] - $arBasketPreShipping['mwst'][$tax_key]['sum']);
 									$arReturn['mwst'][$tax_key]['base_value'] += ($mwst['base_value'] - $arBasketPreShipping['mwst'][$tax_key]['base_value']);
-									
+
 								}
-								
+
 							}
-							
+
 							if (wpsg_isSizedArray($arReturn['shipping']['methods'])) $arReturn['shipping']['methods'][] = $shipping;
 							else $arReturn['shipping']['methods'] = array($shipping);
-							
+
 						}
-						
+
 						//wpsg_debug($arReturn);die();
-						 
+
 						// In den Produktdaten sind die fÃŒr das Produkt zulÃ€ssigen Versandarten gespeichert, hier entferne ich noch die die in dieser Bestellung nicht gewÃ€hlt wurden
 						foreach ($arReturn['produkte'] as &$p)
 						{
-							
+
 							if (wpsg_isSizedString($p['allowedshipping']))
 							{
-								
+
 								$arAllowedShipping = explode(',', $p['allowedshipping']);
-								
+
 								foreach ($arAllowedShipping as $shipping)
 								{
-									
+
 									if (!in_array($shipping, $arReturn['shipping']['methods'])) unset($arReturn['shipping']['methods'][$shipping]);
-									
+
 								}
-								
+
 								$p['order_allowedshipping'] = $arAllowedShipping;
-								
+
 							}
-							
+
 						}
-						
+
 						// Anteilig und kein eindeutiger Satz, wenn zusammengesetzte Versandart
 						unset($arReturn['shipping']['mwst']);
 						$arReturn['shipping']['tax_rata'] = true;
-						
+
 					}
 					else
 					{
-						
+
 						$this->shop->callMods('calcShipping', array(&$arReturn, $arReturn['checkout']['shipping']));
-						
-					}
-					
+
+					}
+
 					$this->shop->callMods('calcPayment', array(&$arReturn));
-										
-				}
-				
+
+				}
+
 			}
 			/*
@@ -1902,5 +1902,5 @@
 			if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
 			if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
-	
+
 			// Versandkosten der Summe hinzurechnen
 			if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
@@ -1923,10 +1923,10 @@
 					}
 				}
-				
+
 /*
 				// Zahlungskosten der Summe hinzurechnen
 				if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
 				if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
-				
+
 				// Versandkosten der Summe hinzurechnen
 				if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
@@ -1941,5 +1941,5 @@
 					//$taxp = abs($taxp);
 					//$taxs = abs($taxs);
-					
+
 					$mb = new wpsg_mod_basic;
 					//$t = $this->shop->get_option('wpsg_mod_targo_mwst');	// 0=anteilig, sonst a,b,c,d,e
@@ -1950,42 +1950,42 @@
 					unset($arReturn['sum']['preis_shipping_netto']);
 					unset($arReturn['sum']['preis_shipping_brutto']);
-						
+
 					$id = $this->arOrder['type_payment'];
 					$tax_keyp = $this->shop->arPayment[$id]['mwst_key'];
 					$mb->setPaymentKosten($arReturn, $pricep, $tax_keyp);
 					$taxp = $arReturn['payment']['mwst'];
-						
+
 					$id = $this->arOrder['type_shipping'];
 					$tax_keys = $this->shop->arShipping[$id]['mwst_key'];
 					$mb->setShippingKosten($arReturn, 'x', $prices, $tax_keys);
 					$taxs = $arReturn['shipping']['mwst'];
-						
+
 					if ($this->shop->addRoundedValues === true)
 					{
-							
+
 						$arReturn['sum']['preis_payment_brutto'] = round($arReturn['sum']['preis_payment_brutto'], 2);
 						$arReturn['sum']['preis_payment_netto'] = round($arReturn['sum']['preis_payment_netto'], 2);
 						$arReturn['sum']['preis_shipping_brutto'] = round($arReturn['sum']['preis_shipping_brutto'], 2);
 						$arReturn['sum']['preis_shipping_netto'] = round($arReturn['sum']['preis_shipping_netto'], 2);
-						
+
 					}
 					else
 					{
-						
+
 						$arReturn['sum']['preis_payment_brutto'] = $arReturn['sum']['preis_payment_netto'] + $taxp;
 						$arReturn['sum']['preis_payment_netto'] = $arReturn['sum']['preis_payment_netto'];
 						$arReturn['sum']['preis_shipping_brutto'] = $arReturn['sum']['preis_shipping_netto'] + $taxs;
 						$arReturn['sum']['preis_shipping_netto'] = $arReturn['sum']['preis_shipping_netto'];
-						
-					}
-						
+
+					}
+
 					// Zahlungskosten der Summe hinzurechnen
 					if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
 					if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
-					
+
 					// Versandkosten der Summe hinzurechnen
 					if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
 					if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_shipping_brutto'];
-					
+
 					foreach ($arReturn['mwst'] as $key => $value) {
 						$arReturn['sum']['preis_gesamt_netto'] += $value['sum'];
@@ -2000,5 +2000,5 @@
 						$arReturn['sum']['gs'] = $arReturn['sum']['gs_netto'];
 					}
-						
+
 				}
 				else	// if ($price_option == WPSG_NETTO)
@@ -2013,52 +2013,52 @@
 					unset($arReturn['sum']['preis_shipping_netto']);
 					unset($arReturn['sum']['preis_shipping_brutto']);
-					
+
 					$id = $this->arOrder['type_payment'];
 					$tax_keyp = $this->shop->arPayment[$id]['mwst_key'];
 					$mb->setPaymentKosten($arReturn, $pricep, $tax_keyp);
 					$taxp = $arReturn['payment']['mwst'];
-					
+
 					$id = $this->arOrder['type_shipping'];
 					$tax_keys = wpsg_getStr($this->shop->arShipping[$id]['mwst_key']);
 					$mb->setShippingKosten($arReturn, 'x', $prices, $tax_keys);
 					$taxs = $arReturn['shipping']['mwst'];
-					
+
 					//$taxp = $this->addMwSt($arReturn, $arReturn['sum']['preis_payment_brutto']);
 					//$taxs = $this->addMwSt($arReturn, $arReturn['sum']['preis_shipping_brutto']);
 					//$taxp = abs($taxp);
 					//$taxs = abs($taxs);
-					
+
 					if ($this->shop->addRoundedValues === true)
 					{
-							
+
 						$arReturn['sum']['preis_payment_brutto'] = round($arReturn['sum']['preis_payment_brutto'], 2);
 						$arReturn['sum']['preis_payment_netto'] = round($arReturn['sum']['preis_payment_brutto'] - $taxp, 2);
 						$arReturn['sum']['preis_shipping_brutto'] = round($arReturn['sum']['preis_shipping_brutto'], 2);
 						$arReturn['sum']['preis_shipping_netto'] = round($arReturn['sum']['preis_shipping_brutto'] - $taxs, 2);
-						
+
 					}
 					else
 					{
-						
+
 						$arReturn['sum']['preis_payment_brutto'] = $arReturn['sum']['preis_payment_netto'];
 						$arReturn['sum']['preis_payment_netto'] = $arReturn['sum']['preis_payment_brutto'] - $taxp;
 						$arReturn['sum']['preis_shipping_brutto'] = $arReturn['sum']['preis_shipping_brutto'];
 						$arReturn['sum']['preis_shipping_netto'] = $arReturn['sum']['preis_shipping_brutto'] - $taxs;
-						
-					}
-					
+
+					}
+
 					// Zahlungskosten der Summe hinzurechnen
 					if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
 					if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
-					
+
 					// Versandkosten der Summe hinzurechnen
 					if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
 					if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_shipping_brutto'];
-					
+
 					$arReturn['sum']['preis'] = $arReturn['sum']['preis_brutto'];
 					$arReturn['sum']['preis_gesamt'] = $arReturn['sum']['preis_gesamt_brutto'];
 					$arReturn['sum']['preis_payment'] = $arReturn['sum']['preis_payment_brutto'];
 					$arReturn['sum']['preis_shipping'] = $arReturn['sum']['preis_shipping_brutto'];
-					$arReturn['sum']['preis_rabatt'] = $arReturn['sum']['preis_rabatt_brutto'];
+					$arReturn['sum']['preis_rabatt'] = wpsg_getFloat($arReturn['sum']['preis_rabatt_brutto']);
 					if (array_key_exists('gs', $arReturn['sum']))
 					{
@@ -2066,41 +2066,41 @@
 					}
 				}	// else if ($price_option == WPSG_NETTO)
-				
+
 			}
 			else 	// if ($backend)
 			{
-				
+
 				// Zahlungskosten der Summe hinzurechnen
 				if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
 				if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
-				
+
 				// Versandkosten der Summe hinzurechnen
 				if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
 				if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_shipping_brutto'];
-				
-				// Preisangaben fÃŒrs Frontend 
+
+				// Preisangaben fÃŒrs Frontend
 				if ($this->shop->getFrontendTaxview() == WPSG_NETTO)
 				{
-					
+
 					if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt'] += $arReturn['sum']['preis_shipping_netto'];
 					if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt'] += $arReturn['sum']['preis_payment_netto'];
-					
+
 					if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_shipping'] = $arReturn['sum']['preis_shipping_netto'];
 					if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_payment'] = $arReturn['sum']['preis_payment_netto'];
-					
+
 				}
 				else
 				{
-					
+
 					if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt'] += $arReturn['sum']['preis_shipping_brutto'];
 					if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt'] += $arReturn['sum']['preis_payment_brutto'];
-					
+
 					if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_shipping'] = $arReturn['sum']['preis_shipping_brutto'];
 					if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_payment'] = $arReturn['sum']['preis_payment_brutto'];
-					 
-				}
-				
+
+				}
+
 			}	// else if ($backend)
-			
+
 			// Leere MwSt. SÃ€tze entfernen
 			foreach ((array)$arReturn['mwst'] as $k => $v)
@@ -2108,6 +2108,6 @@
 				if ($v['sum'] <= 0) unset($arReturn['mwst'][$k]);
 			}
-			 			
-			// Negative Bestellungen Verhindern 
+
+			// Negative Bestellungen Verhindern
 			if (isset($arReturn['sum']['preis_netto']) && $arReturn['sum']['preis_netto'] < 0) $arReturn['sum']['preis_netto'] = 0;
 			if (isset($arReturn['sum']['preis_brutto']) && $arReturn['sum']['preis_brutto'] < 0) $arReturn['sum']['preis_brutto'] = 0;
@@ -2115,13 +2115,13 @@
 			if (isset($arReturn['sum']['preis_gesamt_netto']) && $arReturn['sum']['preis_gesamt_netto'] < 0) $arReturn['sum']['preis_gesamt_netto'] = 0;
 			if (isset($arReturn['sum']['preis_gesamt_brutto']) && $arReturn['sum']['preis_gesamt_brutto'] < 0) $arReturn['sum']['preis_gesamt_brutto'] = 0;
-			if (isset($arReturn['sum']['preis_gesamt']) && $arReturn['sum']['preis_gesamt'] < 0) $arReturn['sum']['preis_gesamt'] = 0; 
-			
+			if (isset($arReturn['sum']['preis_gesamt']) && $arReturn['sum']['preis_gesamt'] < 0) $arReturn['sum']['preis_gesamt'] = 0;
+
 			$this->shop->callMods('basket_toArray_final', array(&$this, &$arReturn));
-			
+
 			return $arReturn;
-			
+
 		} // public function toArray()
-		
-		
+
+
 		/**
 		 * Verteilt den Wert $value auf die MwSt SÃ€tze in $arBasket
@@ -2130,13 +2130,13 @@
 		public function addMwSt(&$arBasket, $value)
 		{
-				
+
 			if (wpsg_tf($value) <= 0) return 0;
-				
+
 			$price_option = $this->shop->get_option('wpsg_preisangaben');
-				
+
 			// Anteilig auf die SÃ€tze verteilen
 			foreach ((array)$arBasket['mwst'] as $mw_id => $mw)
 			{
-					
+
 				if ($mw['base_value'] > 0)
 				{
@@ -2147,39 +2147,39 @@
 						$arBasket['mwst'][$mw_id]['base_value'] += $proz * $value;
 						$arBasket['mwst'][$mw_id]['sum'] = wpsg_calculateSteuer($arBasket['mwst'][$mw_id]['base_value'], WPSG_BRUTTO, $mw['value']);
-		
+
 					}
 					else
 					{
 						$proz = $mw['base_value'] / $arBasket['sum']['preis_netto'];
-						
+
 						$arBasket['mwst'][$mw_id]['base_value'] -= wpsg_calculatePreis($proz * $value, WPSG_NETTO, $mw['value']);
 						//$arBasket['mwst'][$mw_id]['base_value'] += $proz * $value;
 						$arBasket['mwst'][$mw_id]['sum'] = wpsg_calculateSteuer($arBasket['mwst'][$mw_id]['base_value'], WPSG_NETTO, $mw['value']);
-		
-					}
-		
-				}
-		
-			}
-				
+
+					}
+
+				}
+
+			}
+
 			// Mehrwertsteuer Summe korrigieren
 			$sum_mwst = 0;
 			foreach ($arBasket['mwst'] as $mw_id => $mw)
 			{
-		
+
 				$sum_mwst += $arBasket['mwst'][$mw_id]['sum'];
-		
-			}
-				
+
+			}
+
 			$sub = $arBasket['sum']['mwst'];
-				
+
 			$arBasket['sum']['mwst'] = abs($sum_mwst);
-		
+
 			return $sub - $arBasket['sum']['mwst'];
-				
+
 		} // public function addMwSt(&$arBasket, $value)
-		
-		
-		
+
+
+
 		/**
 		 * Gibt die Anzahl zurÃŒck, die im Warenkorb zu einem ProduktKEY enthalten ist
@@ -2187,25 +2187,25 @@
 		public function getBasketAmount($product_key)
 		{
-			
+
 			$nAmount = 0;
-			
+
 			if (!wpsg_isSizedArray($_SESSION['wpsg']['basket'])) return 0;
-			
+
 			foreach ($_SESSION['wpsg']['basket'] as $product_index => $product_data)
 			{
-				
+
 				if ($product_data['id'] == $product_key)
 				{
-					
+
 					$nAmount += $product_data['menge'];
-					
-				}
-				
-			}
-			
+
+				}
+
+			}
+
 			return $nAmount;
-						
+
 		} // public function getBasketAmount($product_key)
-		
+
 		/**
 		 * Gibt die ProduktIDs der Produkte aus dem Warenkorb zurÃŒck
@@ -2213,19 +2213,19 @@
 		public function getProductIDs()
 		{
-			
+
 			$arReturn = array();
-			
+
 			foreach ($this->arProdukte as $p)
 			{
-				
+
 				$product_id = $this->shop->getProduktID($p['id']);
 				if (!in_array($product_id, $arReturn)) $arReturn[] = $product_id;
-				
-			}
-			
+
+			}
+
 			return $arReturn;
-			
+
 		} // public function getProductIDs()
-				
+
 		/**
 		 * Verteilt den Wert $value auf die Steuerarten in $arReturn
@@ -2233,17 +2233,17 @@
 		public function distributeMwSt($value, &$arReturn)
 		{
-			
-			if ($arReturn['noMwSt'] == true) 
-			{
-				
+
+			if ($arReturn['noMwSt'] == true)
+			{
+
 				$arReturn['sum']['preis_brutto'] -= $value;
-				$arReturn['sum']['preis_gesamt_brutto'] -= $value;				
+				$arReturn['sum']['preis_gesamt_brutto'] -= $value;
 				$arReturn['sum']['preis_netto'] -= $value;
 				$arReturn['sum']['preis_gesamt_netto'] -= $value;
 				$arReturn['sum']['preis'] -= $value;
 				$arReturn['sum']['preis_gesamt'] -= $value;
-				
-			}
-			
+
+			}
+
 			// Da ich hier nicht weiÃ ob der Basket fÃŒrs Frontend/Backend berechnet werden soll schaue ich hier ob der NETTO oder BRUTTO Preis im Preisarray ist
 			// Die unterschiedliche Speicherung in preis is ansich quatsch ... Bei Ausgabe sollte immer Brutto / Netto entsprechend verwendet werden
@@ -2256,47 +2256,47 @@
 				$brut_nett = WPSG_BRUTTO;
 			}
-			
+
 			// Gesamt Brutto. vor der Verteilung
 			$netto_gesamt = $arReturn['sum']['preis_netto'];
-			
+
 			foreach ($arReturn['mwst'] as $k => $v)
 			{
-				
-				$proz = ($v['base_value'] - $v['sum']) * 100 / $netto_gesamt; // Anteil 
+
+				$proz = ($v['base_value'] - $v['sum']) * 100 / $netto_gesamt; // Anteil
 				$value_anteilig = $value / 100 * $proz; // Der Teil, der mit der Steuer besteuert werden soll 70% mit 19%, 30% mit 7% usw.
-				
-				if ($brut_nett == WPSG_BRUTTO) 
-				{
-					 
+
+				if ($brut_nett == WPSG_BRUTTO)
+				{
+
 					$mwst_anteilig = wpsg_calculateSteuer($value_anteilig, WPSG_BRUTTO, $v['value']); // Der anteilige Steuerwert
-					
+
 					$arReturn['mwst'][$k]['sum'] -= $mwst_anteilig;
 					$arReturn['sum']['mwst'] -= $mwst_anteilig;
 					$arReturn['sum']['preis_brutto'] -= $mwst_anteilig;
-					$arReturn['sum']['preis_gesamt_brutto'] -= $mwst_anteilig;				
+					$arReturn['sum']['preis_gesamt_brutto'] -= $mwst_anteilig;
 					$arReturn['sum']['preis_netto'] -= $value_anteilig;
 					$arReturn['sum']['preis_gesamt_netto'] -= $value_anteilig;
 					$arReturn['sum']['preis'] -= $value_anteilig;
 					$arReturn['sum']['preis_gesamt'] -= $value_anteilig;
-					
+
 				}
 				else
 				{
-					
+
 					$mwst_anteilig = wpsg_calculateSteuer($value_anteilig, WPSG_NETTO, $v['value']); // Der anteilige Steuerwert
-					
+
 					$arReturn['mwst'][$k]['sum'] -= $mwst_anteilig;
 					$arReturn['sum']['mwst'] -= $mwst_anteilig;
 					$arReturn['sum']['preis_brutto'] -= $mwst_anteilig;
-					$arReturn['sum']['preis_gesamt_brutto'] -= $mwst_anteilig;				
+					$arReturn['sum']['preis_gesamt_brutto'] -= $mwst_anteilig;
 					$arReturn['sum']['preis_netto'] -= $value_anteilig;
 					$arReturn['sum']['preis_gesamt_netto'] -= $value_anteilig;
 					$arReturn['sum']['preis'] -= $value_anteilig;
 					$arReturn['sum']['preis_gesamt'] -= $value_anteilig;
-					
-				}
-				
-			} 
-			
+
+				}
+
+			}
+
 		} // public function distributeMwSt($value, &$arReturn)
 
@@ -2307,14 +2307,14 @@
 		public function checkMwSt($tax_key, $country, &$arReturn)
 		{
-		
+
 			if ($tax_key != null && !array_key_exists($tax_key.'_'.$country->id, (array)$arReturn['mwst']))
 			{
-		
+
 				if (is_object($country)) $tax_value = $country->getTax($tax_key);
 				else $tax_value = 0;
-				
+
 				$name = wpsg_ff($tax_value, '%');
 				if ($country->id != $this->shop->getDefaultCountry(true)) $name .= ' / '.$country->name;
-				
+
 				$arReturn['mwst'][$tax_key.'_'.$country->id] = array(
 					'country' => $country->id,
@@ -2322,11 +2322,11 @@
 					'sum' => '0',
 					'name' => $name,
-					'value' => $tax_value		
-				); 
-		
-			}
-				
+					'value' => $tax_value
+				);
+
+			}
+
 		} // private function checkMwSt($mwst_id, $country, &$arReturn)
-		
+
 	} // class wpsg_basket
 
Index: /mods/wpsg_mod_discount.class.php
===================================================================
--- /mods/wpsg_mod_discount.class.php	(revision 6349)
+++ /mods/wpsg_mod_discount.class.php	(revision 6350)
@@ -497,6 +497,4 @@
 			if ($value == 0) return;
 
-
-
 			foreach ((array)$data_rabatt as $k => $v)
 			{
@@ -514,7 +512,9 @@
 			{
 				// Im Backend Rabatt nicht neu berechnen aus Bestellung entnehmen
-				$discount_brutto = $basket->arOrder['price_rabatt_brutto'];
-				$discount_netto = $basket->arOrder['price_rabatt_netto'];
-				//$price_option = $arReturn['price_frontend'];
+				//$discount_brutto = $basket->arOrder['price_rabatt_brutto'];
+				//$discount_netto = $basket->arOrder['price_rabatt_netto'];
+				if ($basket->arOrder['price_rabatt'] <= 0) return;
+
+				$discount = $basket->arOrder['price_rabatt'];
 				$price_option = $this->shop->get_option('wpsg_preisangaben');
 				$discount_tax = 0.0;
@@ -527,5 +527,5 @@
 						// Rabatt auf die verschiedenen Produkte aufteilen.
 						//$discount_tax = $this->shop->addMwSt($arReturn, $discount);
-						$discount_tax = $this->shop->subMwSt($arReturn, $discount_brutto);
+						$discount_tax = $this->shop->subMwSt($arReturn, $discount);
 
 					}
@@ -534,6 +534,6 @@
 					{
 
-						$discount_brutto = round($discount_brutto, 2);
-						$discount_netto = round($discount_brutto - $discount_tax, 2);
+						$discount_brutto = round($discount, 2);
+						$discount_netto = round($discount - $discount_tax, 2);
 
 					}
@@ -541,6 +541,6 @@
 					{
 
-						$discount_brutto = $discount_brutto;
-						$discount_netto = $discount_brutto - $discount_tax;
+						$discount_brutto = $discount;
+						$discount_netto = $discounto - $discount_tax;
 
 					}
@@ -553,5 +553,5 @@
 					{
 
-						$discount_tax = $this->shop->addMwSt($arReturn, $discount_netto);
+						$discount_tax = $this->shop->addMwSt($arReturn, $discount);
 
 					}
@@ -560,6 +560,6 @@
 					{
 
-						$discount_brutto = round($discount_netto + $discount_tax, 2);
-						//$discount_netto = round($discount_value - $discount_tax, 2);
+						$discount_brutto = round($discount + $discount_tax, 2);
+						$discount_netto = round($discount, 2);
 
 					}
@@ -567,6 +567,6 @@
 					{
 
-						//$discount_brutto = $discount_value;
-						$discount_netto = $discount_brutto - $discount_tax;
+						$discount_brutto = $discount + $discount_tax;
+						$discount_netto = $discount;
 
 					}
@@ -582,5 +582,5 @@
 				$arReturn['sum']['preis_rabatt_brutto'] = $discount_brutto;
 
-				if ($this->shop->getFrontendTaxview() == WPSG_NETTO)
+				if ($price_option == WPSG_NETTO)
 				{
 
@@ -590,5 +590,5 @@
 
 				}
-				else if ($this->shop->getFrontendTaxview() == WPSG_BRUTTO)
+				else if ($price_option == WPSG_BRUTTO)
 				{
 
Index: /mods/wpsg_mod_gutschein.class.php
===================================================================
--- /mods/wpsg_mod_gutschein.class.php	(revision 6349)
+++ /mods/wpsg_mod_gutschein.class.php	(revision 6350)
@@ -6,9 +6,9 @@
 	class wpsg_mod_gutschein extends wpsg_mod_basic
 	{
-		
-		var $id = 160;		
+
+		var $id = 160;
 		var $lizenz = 1;
 		var $hilfeURL = 'http://wpshopgermany.de/?p=455';
-		
+
 		/**
 		 * Costructor
@@ -16,21 +16,21 @@
 		public function __construct()
 		{
-			
+
 			parent::__construct();
-			
+
 			$this->name = __('Gutscheine', 'wpsg');
 			$this->group = __('Sonstiges', 'wpsg');
 			$this->desc = __('Erlaubt das Erstellen von Gutscheinen.', 'wpsg');
-						
+
 		} // public function __construct()
-		 
-		public function install() 
-		{ 
- 	
+
+		public function install()
+		{
+
 			require_once(WPSG_PATH_WP.'/wp-admin/includes/upgrade.php');
 
 			/**
 			 * Tabelle fÃŒr die Gutscheine
-			 */			
+			 */
 			$sql = "CREATE TABLE ".WPSG_TBL_GUTSCHEIN." (
 		   		id mediumint(9) NOT NULL AUTO_INCREMENT,
@@ -41,5 +41,5 @@
 		   		cdate datetime NOT NULL,
 		   		start_date datetime NOT NULL,
-		   		end_date datetime NOT NULL, 
+		   		end_date datetime NOT NULL,
 		   		multi INT(11) NOT NULL,
 		   		comment TEXT NOT NULL,
@@ -55,12 +55,12 @@
 		   		KEY autocreate_product (autocreate_product)
 		   	) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
-			
+
 			dbDelta($sql);
-			
+
 			$this->shop->checkDefault('wpsg_mod_gutschein_size', '10');
 			$this->shop->checkDefault('wpsg_mod_gutschein_perPage', '25');
-						
-		} // public function install() 
-		
+
+		} // public function install()
+
 		public function init()
 		{
@@ -71,50 +71,50 @@
 			$role_object = get_role('administrator');
 			$role_object->add_cap('wpsg_voucher');
-			
+
 		} // public function init()
-		
-		public function dispatch() 
-		{
-			
+
+		public function dispatch()
+		{
+
 			if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add')
 			{
-				
+
 				$this->addAction();
-				
+
 			}
 			else if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'import')
 			{
-				
+
 				$this->importAction();
-				
+
 			}
 			else if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'save')
 			{
-				
+
 				$this->saveAction();
-				
-			}
-			else 
-			{
-				
+
+			}
+			else
+			{
+
 				$this->indexAction();
-				
-			}
-			
+
+			}
+
 		} // public function dispatch()
-		 
-		public function admin_setcapabilities() { 
-			
+
+		public function admin_setcapabilities() {
+
 			$this->render(WPSG_PATH_VIEW.'/mods/mod_gutschein/admin_setcapabilities.phtml');
-			
+
 		} // public function admin_setcapabilities()
-		
+
 		public function wpsg_add_pages()
 		{
-						
+
 			add_submenu_page('wpsg-Admin', __("Gutscheine", "wpsg"), __("Gutscheine", "wpsg"), 'wpsg_voucher', 'wpsg-Voucher', array($this, 'dispatch'));
-			
+
 		} // public function wpsg_add_pages()
-		
+
 		/**
 		 * Maske fÃŒr einen neuen Gutschein
@@ -122,7 +122,7 @@
 		public function addAction()
 		{
-			
+
 			$this->shop->view['mod_gutschein'] = array();
-			
+
 			if (isset($_SESSION['wpsg']['mod_gutschein_error']))
 			{
@@ -137,41 +137,41 @@
 				$this->shop->view['mod_gutschein']['comment'] = $_SESSION['wpsg']['mod_gutschein_error']['wpsg_mod_gutschein_comment'];
 				$this->shop->view['mod_gutschein']['multi'] = $_SESSION['wpsg']['mod_gutschein_error']['wpsg_mod_gutschein_multi'];
-				if (isset($_REQUEST['wpsg']['mod_gutschein_error']['wpsg_mod_gutschein_minvalue'])) $this->shop->view['mod_gutschein']['minvalue'] = $_SESSION['wpsg']['mod_gutschein_error']['wpsg_mod_gutschein_minvalue'];				
+				if (isset($_REQUEST['wpsg']['mod_gutschein_error']['wpsg_mod_gutschein_minvalue'])) $this->shop->view['mod_gutschein']['minvalue'] = $_SESSION['wpsg']['mod_gutschein_error']['wpsg_mod_gutschein_minvalue'];
 				if (isset($_SESSION['wpsg']['mod_gutschein_error']['wpsg_mod_gutschein_products'])) $this->shop->view['mod_gutschein']['products'] = $_SESSION['wpsg']['mod_gutschein_error']['wpsg_mod_gutschein_products'];
 				if (isset($_SESSION['wpsg']['mod_gutschein_error']['wpsg_mod_gutschein_productgroups'])) $this->shop->view['mod_gutschein']['productgroups'] = $_SESSION['wpsg']['mod_gutschein_error']['wpsg_mod_gutschein_productgroups'];
-				
+
 				unset($_SESSION['wpsg']['mod_gutschein_error']);
-				
+
 			}
 			else
 			{
-				
+
 				$this->shop->view['mod_gutschein']['value'] = 10;
-				$this->shop->view['mod_gutschein']['calc'] = 'w';				
+				$this->shop->view['mod_gutschein']['calc'] = 'w';
 				$this->shop->view['mod_gutschein']['count'] = '1';
-				$this->shop->view['mod_gutschein']['multi'] = '0';	
-				$this->shop->view['mod_gutschein']['productgroups'] = '-1';			
-				
-			}
-			
+				$this->shop->view['mod_gutschein']['multi'] = '0';
+				$this->shop->view['mod_gutschein']['productgroups'] = '-1';
+
+			}
+
 			if ($this->shop->hasMod('wpsg_mod_productgroups'))
 			{
-				
+
 				$this->shop->view['wpsg_mod_gutschein']['arProductGroups'] = $this->shop->callMod('wpsg_mod_productgroups', 'getAllProductGroups');
-				
-			}
-			
-			$this->shop->view['wpsg_mod_gutschein']['arProducts'] = $this->shop->getAllProductsForSelect();			
-			
+
+			}
+
+			$this->shop->view['wpsg_mod_gutschein']['arProducts'] = $this->shop->getAllProductsForSelect();
+
 			if (!isset($this->shop->view['mod_gutschein']['start']) || !is_int($this->view['mod_gutschein']['start']) || $this->view['mod_gutschein']['start'] <= 0)
 				$this->shop->view['mod_gutschein']['start'] = wpsg_date('d.m.Y H:i');
-				
+
 			if (!isset($this->shop->view['mod_gutschein']['end']) || !is_int($this->view['mod_gutschein']['end']) || $this->view['mod_gutschein']['end'] <= 0)
 				$this->shop->view['mod_gutschein']['end'] = wpsg_date('d.m.').(wpsg_date('Y') + 1).' '.wpsg_date('H:i');
-			
+
 			$this->render(WPSG_PATH_VIEW.'/mods/mod_gutschein/add.phtml');
-			
+
 		} // public function addAction()
-		
+
 		/**
 		 * CSV Import von Gutscheinen
@@ -179,82 +179,82 @@
 		public function importAction()
 		{
-			
+
 			if (isset($_REQUEST['submit']))
 			{
-					
+
 				// Datei angegeben?
 				if (!file_exists($_FILES['wpsg_file']['tmp_name']) || !preg_match('/(.*)\.csv$/i', $_FILES['wpsg_file']['name']))
 				{
-						
+
 					$this->shop->addBackendError(__('Bitte eine CSV Datei angeben!', 'wpsg'));
 					$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Voucher&action=import');
-						
-				}
-			
+
+				}
+
 				$arData = array();
-			
+
 				if (($handle = fopen($_FILES['wpsg_file']['tmp_name'], "r")) !== false)
 				{
-						
+
 					while (($data = fgetcsv($handle, 1000, ";")) !== false)
 					{
-						 
+
 						$arData[] = $data;
-			
-					}
-			
+
+					}
+
 					fclose($handle);
-			
-				}
-			
+
+				}
+
 				if (!wpsg_isSizedArray($arData))
 				{
-						
+
 					$this->shop->addBackendError(__('CSV Datei konnte nicht geladen werden!', 'wpsg'));
 					$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Voucher&action=import');
-						
-				}
-								
+
+				}
+
 				// Spalten identifizieren
 				$arCol = array_flip($arData[0]);
 				$arColPflicht = array('code', 'value', 'start_date', 'end_date');
 				$bColError = false;
-				
+
 				foreach ($arColPflicht as $v)
 				{
-				
+
 					if (!isset($arCol[$v]))
 					{
-					
+
 						$this->shop->addBackendError(wpsg_translate(
 							__('CSV Datei ungÃŒltig. (Spalte "#1#" muss vorhanden sein)', 'wpsg'),
 							$v)
 						);
-						
+
 						$bColError = true;
-					
-					}
-					
-				}
-				
+
+					}
+
+				}
+
 				if ($bColError === true)
 				{
-					
+
 					$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Voucher&action=import');
-					
-				}
-				
+
+				}
+
 				$nImport = 0;
-				 				
+
 				// Daten importieren / Erste Zeile sind die SchlÃŒssel
 				for ($i = 1; $i < sizeof($arData); $i ++)
 				{
-					
+
 					// Leere Zeilen ÃŒberspringen
 					if (!wpsg_isSizedArray($arData[$i])) continue;
-					
+
 					if (!preg_match('/\d{4}\-\d{2}\-\d{2}\040\d{2}\:\d{2}\:\d{2}/', $arData[$i][$arCol['start_date']]))
 					{
-												
+
 						$this->shop->addBackendError(wpsg_translate(
 							__('Spalte "#1#" in Zeile #2# enthÃ€lt kein gÃŒltiges Datum -> Zeile wurde ÃŒbersprungen', 'wpsg'),
@@ -262,12 +262,12 @@
 							$i + 1)
 						);
-						
+
 						continue;
-						
-					} 
-					
+
+					}
+
 					if (!preg_match('/\d{4}\-\d{2}\-\d{2}\040\d{2}\:\d{2}\:\d{2}/', $arData[$i][$arCol['end_date']]))
 					{
-					
+
 						$this->shop->addBackendError(wpsg_translate(
 							__('Spalte "#1#" in Zeile #2# enthÃ€lt kein gÃŒltiges Datum -> Zeile wurde ÃŒbersprungen', 'wpsg'),
@@ -275,56 +275,56 @@
 							$i + 1)
 						);
-						
+
 						continue;
-					
-					}
-					
+
+					}
+
 					if (strlen($arData[$i][$arCol['code']]) < $this->shop->get_option('wpsg_mod_gutschein_size'))
 					{
-						
+
 						$this->shop->addBackendError(wpsg_translate(
-							__('UngÃŒltiger Gutscheincode in Zeile #1# (zu Kurz) -> Zeile wurde ÃŒbersprungen', 'wpsg'),		
+							__('UngÃŒltiger Gutscheincode in Zeile #1# (zu Kurz) -> Zeile wurde ÃŒbersprungen', 'wpsg'),
 							$i + 1)
 						);
-						
+
 						continue;
-						
-					}
-					
+
+					}
+
 					if (doubleval($arData[$i][$arCol['value']]) <= 0)
 					{
-						
+
 						$this->shop->addBackendError(wpsg_translate(
 							__('UngÃŒltiger Gutscheinwert in Zeile #1# (kleiner gleich 0) -> Zeile wurde ÃŒbersprungen', 'wpsg'),
 							$i + 1)
 						);
-						
+
 						continue;
-						
-					}
-					
+
+					}
+
 					// Existiert schon ein Gutschein mit dem Code
 					$bExists = $this->db->fetchOne("SELECT G.`id` FROM `".WPSG_TBL_GUTSCHEIN."` AS G WHERE G.`code` = '".wpsg_q($arData[$i][$arCol['code']])."'");
-					
+
 					$doImport = false;
-					
+
 					if ($bExists > 0)
 					{
-						
+
 						// Existiert schon
 						if ($_REQUEST['gs_exists'] == '0')
 						{
-							
+
 							$this->shop->addBackendMessage(wpsg_translate(
-								__('Code aus Zeile #1# existierte schon und wurde ÃŒberschrieben.', 'wpsg'),	
+								__('Code aus Zeile #1# existierte schon und wurde ÃŒberschrieben.', 'wpsg'),
 								$i + 1)
 							);
-							
+
 							$doImport = true;
-							
+
 						}
 						else
 						{
-							
+
 							$this->shop->addBackendMessage(wpsg_translate(
 								__('Code (#1#) aus Zeile #2# existiert schon -> Zeile wurde ÃŒbersprungen.', 'wpsg'),
@@ -332,28 +332,28 @@
 								$i + 1)
 							);
-														
+
 						}
-						
+
 					}
 					else
 					{
-						
+
 						$nImport ++;
 						$doImport = true;
-						
-					}
-					
+
+					}
+
 					if ($doImport === true)
 					{
-						
+
 						if ($bExists > 0) $this->db->Query("DELETE FROM `".WPSG_TBL_GUTSCHEIN."` WHERE `id` = '".wpsg_q($bExists)."'");
-						
+
 						$data = array(
 							'code' => wpsg_q($arData[$i][$arCol['code']]),
 							'value' => wpsg_q(wpsg_tf($arData[$i][$arCol['value']])),
 							'start_date' => wpsg_q($arData[$i][$arCol['start_date']]),
-							'end_date' => wpsg_q($arData[$i][$arCol['end_date']])								
+							'end_date' => wpsg_q($arData[$i][$arCol['end_date']])
 						);
-						
+
 						if ($arData[$i][$arCol['calc_typ']] == 'p') $data['calc_typ'] = 'p'; else $data['calc_typ'] = 'w';
 						if ($arData[$i][$arCol['multi']] == '1') $data['multi'] = '1'; else $data['multi'] = '0';
@@ -361,23 +361,23 @@
 						if (isset($arCol['productgroups']) && wpsg_isSizedString($arData[$i][$arCol['productgroups']])) $data['productgroups'] = $arData[$i][$arCol['productgroups']]; else $data['productgroups'] = '';
 						if (isset($arCol['comment']) && wpsg_isSizedString($arData[$i][$arCol['comment']])) $data['comment'] = $arData[$i][$arCol['comment']]; else $data['comment'] = '';
-	
+
 						$this->db->ImportQuery(WPSG_TBL_GUTSCHEIN, $data);
-						
-					}
-					
+
+					}
+
 				} // for data
- 
+
 				if ($nImport == 1) $this->shop->addBackendMessage(__('Ein Gutschein erfolgreich importiert.', 'wpsg'));
 				else if ($nImport > 1) $this->shop->addBackendMessage(wpsg_translate(__('#1# Gutscheine erfolgreich importiert.', 'wpsg'), $nImport));
 				else $this->shop->addBackendMessage(__('Keine Gutscheine importiert.', 'wpsg'));
-					
+
 				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Voucher');
-				
-			}
-			
+
+			}
+
 			$this->render(WPSG_PATH_VIEW.'/mods/mod_gutschein/import.phtml');
-			
+
 		} // public function importAction()
-		
+
 		/**
 		 * Speichert einen Gutschein
@@ -385,5 +385,5 @@
 		public function saveAction()
 		{
-			
+
 			$bError = false;
 			//$tStart = wpsg_fieldarray_todate($_REQUEST['wpsg_mod_gutschein_start']);
@@ -391,75 +391,75 @@
 			$tStart = strtotime($_REQUEST['wpsg_mod_gutschein_start']);
 			$tEnd = strtotime($_REQUEST['wpsg_mod_gutschein_end']);
-			
-			// Validierung 
+
+			// Validierung
 			if ($_REQUEST['wpsg_mod_gutschein_count'] <= 0)
 			{
-				
+
 				$this->shop->addBackendError(__('Eingabe im Feld "Menge" ist ungÃŒltig.', 'wpsg'));
 				$bError = true;
-				
-			}
-						
+
+			}
+
 			if ($tStart <= 0)
 			{
-				
+
 				$this->shop->addBackendError(__('Eingabe im Feld "GÃŒltig ab" ÃŒberprÃŒfen.', 'wpsg'));
 				$bError = true;
-				
-			}
-			
+
+			}
+
 			if ($tEnd <= 0)
 			{
-				
+
 				$this->shop->addBackendError(__('Eingabe im Feld "GÃŒltig bis" ÃŒberprÃŒfen.', 'wpsg'));
 				$bError = true;
-				
-			}
-			
+
+			}
+
 			if ($_REQUEST['wpsg_mod_gutschein_value'] <= 0)
 			{
-				
+
 				$this->shop->addBackendError(__('Eingabe im Feld "Wert" ÃŒberprÃŒfen.', 'wpsg'));
 				$bError = true;
-				
-			}
-			
+
+			}
+
 			if ($bError)
 			{
-				
+
 				$_SESSION['wpsg']['mod_gutschein_error'] = wpsg_xss($_REQUEST);
-				
+
 				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Voucher&action=add');
-				
+
 			}
 			else
 			{
-				 	
+
 				for ($i = 0; $i < $_REQUEST['wpsg_mod_gutschein_count']; $i ++)
 				{
-					
+
 					$arProductGroups = array(); if (wpsg_isSizedArray($_REQUEST['wpsg_mod_gutschein_productgroups'])) $arProductGroups = $_REQUEST['wpsg_mod_gutschein_productgroups'];
 					$arProducts = array(); if (wpsg_isSizedArray($_REQUEST['wpsg_mod_gutschein_products'])) $arProducts = $_REQUEST['wpsg_mod_gutschein_products'];
-					 			 
+
 					if ($_REQUEST['wpsg_mod_gutschein_gen'] == '1')
 					{
-						
+
 						$setCode = $_REQUEST['wpsg_mod_gutschein_code'];
-						
+
 					}
 					else
 					{
-						
+
 						$setCode = false;
-						
-					}
-					
+
+					}
+
 					$this->genGS(
-						wpsg_tf($_REQUEST['wpsg_mod_gutschein_value']), 
-						$_REQUEST['wpsg_mod_gutschein_calc'], 
-						$tStart, 
-						$tEnd, 
-						$_REQUEST['wpsg_mod_gutschein_multi'], 
-						$this->shop->get_option('wpsg_mod_gutschein_size'), 
+						wpsg_tf($_REQUEST['wpsg_mod_gutschein_value']),
+						$_REQUEST['wpsg_mod_gutschein_calc'],
+						$tStart,
+						$tEnd,
+						$_REQUEST['wpsg_mod_gutschein_multi'],
+						$this->shop->get_option('wpsg_mod_gutschein_size'),
 						$_REQUEST['wpsg_mod_gutschein_comment'],
 						0,
@@ -467,11 +467,11 @@
 						0,
 						$arProductGroups,
-						$arProducts,						
+						$arProducts,
 						$_REQUEST['wpsg_mod_gutschein_minvalue'],
 						$setCode
 					);
-					
-				}
-				
+
+				}
+
 				if ($_REQUEST['wpsg_mod_gutschein_count'] > 1)
 				{
@@ -482,35 +482,35 @@
 					$this->shop->addBackendMessage(__('Gutschein wurde erfolgreich angelegt.', 'wpsg'));
 				}
-				
-				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Voucher&action=index');				
-				
-			}
-			
+
+				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Voucher&action=index');
+
+			}
+
 		} // public function saveAction()
-						
-		public function basket_row_end(&$basket_view) 
-		{ 
-			
+
+		public function basket_row_end(&$basket_view)
+		{
+
 			if ($this->shop->get_option('wpsg_mod_gutschein_hideInsert') == '1') return;
-			
+
 			$this->view['error'] = $basket_view['error'];
-			
+
 			$this->render(WPSG_PATH_VIEW.'/mods/mod_gutschein/basket_row_end.phtml');
-			
+
 		} // public function basket_row_end(&$basket)
 
-		public function basket_preInsert() 
-		{
-			
+		public function basket_preInsert()
+		{
+
 			if (!wpsg_isSizedArray($_SESSION['wpsg']['gs'])) return;
-			
+
 			$gs_db = $this->db->fetchRow("SELECT G.`id`, G.`productgroups`, G.`products` FROM `".WPSG_TBL_GUTSCHEIN."` AS G WHERE G.`id` = '".wpsg_q($_SESSION['wpsg']['gs']['id'])."'");
-			
+
 			if ($gs_db['id'] != $_SESSION['wpsg']['gs']['id']) throw new \Exception(__('In der Session befindet sich eine Gutschein ID, die es nicht in der Datenbank gibt', 'wpsg'));
-						
+
 			$product_id = $this->shop->getProduktID($_REQUEST['wpsg']['produkt_id']);
-			
+
 			$product_allowed = wpsg_explode(',', $gs_db['products']);
-					
+
 			$temp = wpsg_explode(',', $gs_db['productgroups']);
 			if (wpsg_isSizedArray($temp))
@@ -521,45 +521,45 @@
 					SELECT P.`id` FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE P.`pgruppe` IN (".wpsg_implode(',', $ProductGroupIDs).")
 				"));
-				
-			}
-			 
+
+			}
+
 			$product_allowed = wpsg_trim($product_allowed);
-			
+
 			if (wpsg_isSizedArray($product_allowed) && !in_array($product_id, $product_allowed))
 			{
-				
+
 				$product_data = $this->shop->loadProduktArray($product_id);
 				$this->shop->addFrontendError(wpsg_translate(__('Gutschein wurde entfernt, da er nicht mit Produkt #1# verwendet werden kann', 'wpsg'), $product_data['name']));
 				unset($_SESSION['wpsg']['gs']);
-				
-			}
-			
-		} // public function basket_preInsert() 
+
+			}
+
+		} // public function basket_preInsert()
 
 		public function basket_afterRemove()
 		{
-			
+
 			$arBasket = $this->shop->cache->getShopBasketArray();
-			
+
 			$this->_checkBasket($this->shop->cache->getShopBasketArray());
-			
+
 		} // public function basket_afterRemove()
-		
-		public function basket_afterUpdate(&$bError) 
-		{ 
-			
+
+		public function basket_afterUpdate(&$bError)
+		{
+
 			$this->_checkBasket($this->shop->cache->getShopBasketArray());
-						
+
 		} // public function basket_afterUpdate(&$bError)
 
-		public function checkCheckout(&$state, &$error, &$arCheckout) 
-		{ 
+		public function checkCheckout(&$state, &$error, &$arCheckout)
+		{
 
 			if (!$this->_checkBasket($this->shop->cache->getShopBasketArray())) $error = true;
-						
+
 		} // public function checkCheckout(&$state, &$error, &$arCheckout)
-		
+
 		/* Modulfunktionen */
-		
+
 		/**
 		 * Gutscheinberechnung im Warenkorb
@@ -567,7 +567,7 @@
 		public function basket_toArray_gs(&$basket, &$arReturn)
 		{
-			 		
+
 			// Analog Rabatt
-			
+
 			if ($basket->gs_value !== false)
 			{
@@ -575,5 +575,5 @@
 				{
 					// Berechnung Gutschein im Backend je nach netto/brutto im Frontend
-				
+
 					$arReturn['gs'] = array(
 							'value' => $arReturn['gs_value'],
@@ -581,28 +581,42 @@
 							'code' => $basket->gs_code
 					);
-						
+
 					$gs_value = $arReturn['gs_value'];
 					$gs_tax = 0;
-						
-					$gs_brutto = $basket->arOrder['price_gs_brutto'];
-					$gs_netto = $basket->arOrder['price_gs_netto'];
-					$gs_tax = $gs_brutto - $gs_netto;
-					$gs_value = $gs_brutto;
-					
+
+					//$gs_brutto = $basket->arOrder['price_gs_brutto'];
+					//$gs_netto = $basket->arOrder['price_gs_netto'];
+					//$gs_tax = $gs_brutto - $gs_netto;
+					//$gs_value = $gs_brutto;
+
 					//if ((isset($arReturn['price_frontend'])) && ($arReturn['price_frontend'] == WPSG_BRUTTO))
 					$price_option = $this->shop->get_option('wpsg_preisangaben');
-					
+					$gs_value = $basket->gs_value;
+
 					if ($price_option == WPSG_NETTO)
 					{
-						$gs_value = $basket->gs_value;
-				
+
 						if ($this->shop->get_option('wpsg_kleinunternehmer') != '1')
 						{
-				
+
 							$gs_tax = $this->shop->addMwSt($arReturn, $gs_netto);
-				
+
 						}
-						$gs_brutto = $gs_netto + $gs_tax;
-				
+
+						if ($this->shop->addRoundedValues === true)
+						{
+
+							$gs_brutto = round($gs_value + $gs_tax, 2);
+							$gs_netto = round($gs_value, 2);
+
+						}
+						else
+						{
+
+							$discount_brutto = $gs_value + $gs_tax;
+							$discount_netto = $gs_value;
+
+						}
+
 						$arReturn['sum']['gs'] = $gs_netto;
 						$arReturn['sum']['gs_netto'] = $gs_netto;
@@ -610,7 +624,7 @@
 						$arReturn['sum']['preis'] = $arReturn['sum']['preis_netto'];
 						$arReturn['sum']['preis_gesamt'] = $arReturn['sum']['preis_gesamt_netto'];
-						
-					}
-						
+
+					}
+
 					//if ((isset($arReturn['price_frontend'])) && ($arReturn['price_frontend'] == WPSG_NETTO))
 					if ($price_option == WPSG_BRUTTO)
@@ -618,11 +632,24 @@
 						if ($this->shop->get_option('wpsg_kleinunternehmer') != '1')
 						{
-				
-							$gs_tax = $this->shop->subMwSt($arReturn, $gs_brutto);
-				
+
+							$gs_tax = $this->shop->subMwSt($arReturn, $gs_value);
+
 						}
-						//$gs_value = $basket->gs_value + $gs_tax;
-						$gs_netto = $gs_brutto - $gs_tax;
-						
+
+						if ($this->shop->addRoundedValues === true)
+						{
+
+							$gs_brutto = round($gs_value, 2);
+							$gs_netto = round($gs_value - $gs_tax, 2);
+
+						}
+						else
+						{
+
+							$discount_brutto = $gs_value;
+							$discount_netto = $gs_value - $gs_tax;
+
+						}
+
 						$arReturn['sum']['gs'] = $gs_brutto;
 						$arReturn['sum']['gs_netto'] = $gs_netto;
@@ -630,12 +657,12 @@
 						$arReturn['sum']['preis'] = $arReturn['sum']['preis_brutto'];
 						$arReturn['sum']['preis_gesamt'] = $arReturn['sum']['preis_gesamt_brutto'];
-				
-					}
-					
+
+					}
+
 					$arReturn['sum']['preis_brutto'] -= $gs_brutto;
 					$arReturn['sum']['preis_netto'] -= $gs_netto;
 					$arReturn['sum']['preis_gesamt_brutto'] -= $gs_brutto;
 					$arReturn['sum']['preis_gesamt_netto'] -= $gs_netto;
-					
+
 				}
 				else	// if ((isset($arReturn['backend'])) && $arReturn['backend'])
@@ -646,65 +673,65 @@
 							'code' => $basket->gs_code
 					);
-					
+
 					$gs_value = $basket->gs_value;
 					$gs_tax = 0;
-					
+
 					// Bruttopreis des Gutscheins bestimmen
 					if ($basket->gs_calc == 'p')
 					{
-							
+
 						$gs_value = $arReturn['sum']['preis_gesamt_brutto'] / 100 * $basket->gs_value;
-							
+
 						if ($this->shop->get_option('wpsg_kleinunternehmer') != '1')
 						{
-					
+
 							$gs_tax = $this->shop->subMwSt($arReturn, $gs_value);
-					
+
 						}
-							
+
 					}
 					else
 					{
-							
+
 						if ($this->shop->get_option('wpsg_preisangaben') == WPSG_NETTO)
 						{
-					
+
 							if ($this->shop->get_option('wpsg_kleinunternehmer') != '1')
 							{
-					
+
 								$gs_tax = $this->shop->addMwSt($arReturn, $basket->gs_value);
-					
+
 							}
-					
+
 							$gs_value = $basket->gs_value + $gs_tax;
-					
+
 						}
 						else
 						{
-					
+
 							$gs_value = $basket->gs_value;
-					
+
 							if ($this->shop->get_option('wpsg_kleinunternehmer') != '1')
 							{
-									
+
 								$gs_tax = $this->shop->subMwSt($arReturn, $basket->gs_value);
-									
+
 							}
 							//die($gs_tax."=".$gs_value);
 						}
-					
-					}
-					
+
+					}
+
 					$gs_brutto = $gs_value;
 					$gs_netto = $gs_value - $gs_tax;
-					
+
 					$arReturn['sum']['preis_brutto'] -= $gs_brutto;
 					$arReturn['sum']['preis_netto'] -= $gs_netto;
 					$arReturn['sum']['preis_gesamt_brutto'] -= $gs_brutto;
 					$arReturn['sum']['preis_gesamt_netto'] -= $gs_netto;
-					
+
 					if ($this->shop->getFrontendTaxview() == WPSG_NETTO)
 					{
-					
+
 						$arReturn['sum']['gs'] = $gs_netto;
 						$arReturn['sum']['gs_netto'] = $gs_netto;
@@ -712,9 +739,9 @@
 						$arReturn['sum']['preis'] = $arReturn['sum']['preis_netto'];
 						$arReturn['sum']['preis_gesamt'] = $arReturn['sum']['preis_gesamt_netto'];
-							
+
 					}
 					else if ($this->shop->getFrontendTaxview() == WPSG_BRUTTO)
 					{
-							
+
 						$arReturn['sum']['gs'] = $gs_brutto;
 						$arReturn['sum']['gs_netto'] = $gs_netto;
@@ -722,13 +749,13 @@
 						$arReturn['sum']['preis'] = $arReturn['sum']['preis_brutto'];
 						$arReturn['sum']['preis_gesamt'] = $arReturn['sum']['preis_gesamt_brutto'];
-							
-					}
-						
+
+					}
+
 				}	// else if ((isset($arReturn['backend'])) && $arReturn['backend'])
-				
-			} // gs_value 
-			
+
+			} // gs_value
+
 		} // public function basket_toArray_gs(&$basket, &$arReturn)
-		
+
 		/**
 		 * PrÃŒft den Basket und entfernt den Gutschein, sollte irgendetwas nicht passen
@@ -736,29 +763,29 @@
 		private function _checkBasket($arBasket)
 		{
-			
+
 			if (!wpsg_isSizedArray($arBasket['gs'])) return true;
-			if (!wpsg_isSizedInt($_SESSION['wpsg']['gs']['id']))  throw new \wpsg\Exception(__('In der Session ist keine ID fÃŒr den Gutschein im Basket Array, sollte nicht passieren', 'wpsg'));			
-			
+			if (!wpsg_isSizedInt($_SESSION['wpsg']['gs']['id']))  throw new \wpsg\Exception(__('In der Session ist keine ID fÃŒr den Gutschein im Basket Array, sollte nicht passieren', 'wpsg'));
+
 			$gs_db = $this->db->fetchRow("SELECT G.`id`, G.`minvalue` FROM `".WPSG_TBL_GUTSCHEIN."` AS G WHERE G.`id` = '".wpsg_q($_SESSION['wpsg']['gs']['id'])."'");
 
-			if ($gs_db['id'] != $_SESSION['wpsg']['gs']['id']) throw new \wpsg\Exception(__('In der Session befindet sich eine Gutschein ID, die es nicht in der Datenbank gibt', 'wpsg')); 
-			
+			if ($gs_db['id'] != $_SESSION['wpsg']['gs']['id']) throw new \wpsg\Exception(__('In der Session befindet sich eine Gutschein ID, die es nicht in der Datenbank gibt', 'wpsg'));
+
 			if (wpsg_tf($gs_db['minvalue']) > 0 && ($arBasket['sum']['preis'] + $arBasket['sum']['gs']) < $gs_db['minvalue'])
 			{
-				
+
 				$this->shop->addFrontendError(wpsg_translate(__('Gutschein wurde entfernt, da der Mindestbestellwert von #1# unterschritten wurden.', 'wpsg'), wpsg_ff($gs_db['minvalue'], $this->shop->get_option('wpsg_currency'))));
 				unset($_SESSION['wpsg']['gs']);
-				
+
 				return false;
-				
-			}
-			
+
+			}
+
 			return true;
-			 			
+
 		} // private function _checkBasket($arBasket)
-		
+
 		/**
 		 * Generiert einen Gutschein in der Datenbank
-		 * 
+		 *
 		 * @param double $value der Wert des Gutscheins
 		 * @param varchar $calc_typ Typ 'p' = Prozentual, 'w' = Absoluter Wert
@@ -771,45 +798,45 @@
 		 * @param int $autocreate_product ID Des Produkts aus dem der Gutschein generiert wurde
 		 * @param <int>Array $productgroups Array mit IDs von Produktgruppen fÃŒr die der Gutschein gÃŒltig ist
-		 * @param <int>Array $products Array mit IDs von Produkten fÃŒr die der Gutschein gÃŒltig ist 
-		 * 
+		 * @param <int>Array $products Array mit IDs von Produkten fÃŒr die der Gutschein gÃŒltig ist
+		 *
 		 * @return Der generierte Code
 		 */
 		public function genGS($value, $calc_typ, $tStart, $tEnd, $multi, $laenge, $comment, $autocreate_order = 0, $autocreate_product = 0, $autocreate_order_product, $productgroups = array(), $products = array(), $minValue = false, $code = false)
 		{
-			
+
 			$value = wpsg_tf($value);
-			
+
 			if (wpsg_isSizedString($code))
 			{
-				
+
 				$strCode = $code;
-				
+
 			}
 			else
 			{
-			 
+
 				$laenge = get_option('wpsg_mod_gutschein_size');
 				if ($laenge <= 0) $size = 10;
-				
+
 				$zeichen = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
-				
+
 				while (true)
 				{
-					 
+
 					$arCode = array();
-					
+
 					for ($i = 1; $i <= $laenge; $i++) { $arCode[] = $zeichen[rand(0, (strlen($zeichen) - 1))]; }
-					
+
 					$strCode = implode('', @$arCode);
-	
+
 					$bExists = $this->db->fetchOne("SELECT COUNT(*) FROM `".WPSG_TBL_GUTSCHEIN."` WHERE `code` = '".wpsg_q($strCode)."'");
-					
+
 					if ($bExists <= 0) break;
 					break;
-										
-				}
-				
-			}
-			
+
+				}
+
+			}
+
 			$this->db->ImportQuery(WPSG_TBL_GUTSCHEIN, array(
 				'code' => wpsg_q($strCode),
@@ -828,9 +855,9 @@
 				'products' => wpsg_q(wpsg_implode(',', $products))
 			));
-			 
+
 			return $strCode;
-			
+
 		} // public function genGS($value, $calc_typ, $tStart, $tEnd, $multi, $laenge)
-		
+
 		/**
 		 * Ist fÃŒr die Ãbersicht der Gutscheine zustÃ€ndig
@@ -842,56 +869,56 @@
 			if (isset($_REQUEST['wpshopgermany-submit-gs_del']))
 			{
-				
+
 				if (sizeof($_REQUEST['wpsg_gs_cb']) > 0)
 				{
-					
+
 					$this->db->Query("DELETE FROM `".WPSG_TBL_GUTSCHEIN."` WHERE `id` IN (".implode(",", array_values($_REQUEST['wpsg_gs_cb'])).")");
-					
-				}
-				
+
+				}
+
 				$this->shop->addBackendMessage(__('Gutscheine erfolgreich gelÃ¶scht.', 'wpsg'));
 				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Voucher');
-				
-			}
-			
+
+			}
+
 			// Suchstring aufbauen
 			$strQueryWHERE = "";
-			
+
 			$this->shop->view['filter'] = array(
 				'search' => ''
 			);
-			
+
 			if (isset($_REQUEST['wpsg_search']))
 			{
-				
+
 				$this->shop->view['filter']['search'] = $_REQUEST['wpsg_search'];
 				$strQueryWHERE .= " AND `code` LIKE '%".wpsg_q($_REQUEST['wpsg_search'])."%' ";
-				
-			} 
-			
+
+			}
+
 			// Gefilterten Status fÃŒr das View definieren
 			if (isset($_REQUEST['wpsg_status']) && $_REQUEST['wpsg_status'] >= 0)
-			{	
+			{
 				$this->shop->view['filter']['status'] = $_REQUEST['wpsg_status'];
 			}
-						
+
 			$strQueryORDER = '';
-				
+
 			if (!isset($_REQUEST['filter']['order']))
 			{
-			
+
 				$this->shop->view['filter']['order'] = 'id';
-			
+
 			}
 			else
 			{
-			
+
 				$this->shop->view['filter']['order'] = $_REQUEST['filter']['order'];
-			
-			}
-			
+
+			}
+
 			switch ($this->shop->view['filter']['order'])
 			{
-			  
+
 				case 'code': $strQueryORDER = "G.`code`"; break;
 				case 'start_date': $strQueryORDER = "G.`start_date`"; break;
@@ -899,20 +926,20 @@
 				case 'value': $strQueryORDER = "G.`value`"; break;
 				default: $strQueryORDER = "G.`id`"; break;
-			
-			}
-			
+
+			}
+
 			if (!isset($_REQUEST['filter']['ascdesc']))
 			{
-			
+
 				$this->shop->view['filter']['ascdesc'] = 'asc';
-			
+
 			}
 			else
 			{
-			
+
 				$this->shop->view['filter']['ascdesc'] = $_REQUEST['filter']['ascdesc'];
-			
-			}
-			 
+
+			}
+
 			// Alle gefilterten holen
 			$arDataAll = $this->db->fetchAssoc("
@@ -924,14 +951,14 @@
 					1
 					".$strQueryWHERE."
-				ORDER BY 
+				ORDER BY
 					".wpsg_q($strQueryORDER)." ".wpsg_q($this->shop->view['filter']['ascdesc'])."
 			");
-			 
+
 			$this->shop->view['arStatus'] = array();
 			$this->shop->view['countAll'] = sizeof($arDataAll);
-			
+
 			foreach ($arDataAll as $k => $v)
 			{
-					
+
 				$tStart = strtotime($v['start_date']);
 				$tEnd = strtotime($v['end_date']);
@@ -951,32 +978,32 @@
 				else
 				{
-					
+
 					// Sollte eignetlich nich auftreten
 					$nStatus = 999; $strStatus = __('UngÃŒltig', 'wpsg');
-					
-				}
-				
+
+				}
+
 				if ($v['multi'] == '0' && $v['o_id'] > 0)
 				{
-					
+
 					$nStatus = 4; $strStatus = __('Verbraucht', 'wpsg');
-					
+
 				}
 				else
 				{
-					
+
 					$arDataAll[$k]['ordered'] = $this->db->fetchOne("SELECT COUNT(*) FROM `".WPSG_TBL_ORDER."` WHERE `gs_id` = '".wpsg_q($v['id'])."'");
-					
-				}
-				
+
+				}
+
 				if (array_key_exists($nStatus, $this->shop->view['arStatus']))
 				{
 					$this->shop->view['arStatus'][$nStatus][1] ++;
 				}
-				else 
+				else
 				{
 					$this->shop->view['arStatus'][$nStatus] = array($strStatus, 1);
 				}
-				
+
 				if (isset($this->shop->view['filter']['status']) && $this->shop->view['filter']['status'] > 0 && $nStatus != $this->shop->view['filter']['status'])
 				{
@@ -984,60 +1011,60 @@
 				}
 				else
-				{					
-					$arDataAll[$k]['status'] = $strStatus;					
-				}
-				 
-			}
-			
+				{
+					$arDataAll[$k]['status'] = $strStatus;
+				}
+
+			}
+
 			if (isset($_REQUEST['wpsg_voucher_export']) && $_REQUEST['wpsg_voucher_export'] == '1')
 			{
-				
-				$strCSV  = "code;value;start_date;end_date;comment;calc_typ;multi;products";				
+
+				$strCSV  = "code;value;start_date;end_date;comment;calc_typ;multi;products";
 				if ($this->shop->hasMod('wpsg_mod_productgroups')) $strCSV .= ";productgroups";
 				$strCSV .= "\r\n";
-				
+
 				$arData = array();
-				
-				
-				
+
+
+
 				foreach ($arDataAll as $d)
 				{
-					
+
 					$strCSV .= $d['code'].';'.$d['value'].';'.$d['start_date'].';'.$d['end_date'].';'.$d['comment'].';'.$d['calc_typ'].';'.$d['multi'].';'.$d['products'];
-					if ($this->shop->hasMod('wpsg_mod_productgroups')) $strCSV .= ';'.$d['productgroups'];					
+					if ($this->shop->hasMod('wpsg_mod_productgroups')) $strCSV .= ';'.$d['productgroups'];
 					$strCSV .= "\r\n";
-										
-				}
-		 
-				header("Content-Type: text/csv"); 
-				header("Content-Disposition: attachment; filename=gutscheine.csv"); 
-				header("Content-Description: csv File"); 
-				header("Pragma: no-cache"); 
-				header("Expires: 0"); 
-				
+
+				}
+
+				header("Content-Type: text/csv");
+				header("Content-Disposition: attachment; filename=gutscheine.csv");
+				header("Content-Description: csv File");
+				header("Pragma: no-cache");
+				header("Expires: 0");
+
 				die($strCSV);
-				
-			}
-			
+
+			}
+
 			// Anzahl an Elementen
 			$this->shop->view['count'] = sizeof($arDataAll);
-			
+
 			// Pro Seite / Fallback auf 25 wenn was falsches eingegeben wurde
 			$perPage = ((intval($this->shop->get_option('wpsg_mod_gutschein_perPage')) > 0)?intval($this->shop->get_option('wpsg_mod_gutschein_perPage')):25);
-			
+
 			// Anzahl an Seiten
 			$this->shop->view['pages'] = ceil($this->shop->view['count'] / $perPage);
-			
+
 			// Seite bestimmen
 			if (isset($_REQUEST['seite']) && intval($_REQUEST['seite']) > 0) $this->shop->view['page'] = intval($_REQUEST['seite']); else $this->shop->view['page'] = 1;
-			
+
 			// Aktuele Seite aus den DatensÃ€tzen herausnehmen
 			$this->shop->view['data'] = array_splice($arDataAll, (($this->shop->view['page'] - 1) * $perPage), $perPage);
-			
+
 			if ($this->shop->view['filter']['order'] == 'status')
 			{
-				
+
 				wpsg_array_csort($this->shop->view['data'], 'status');
-				
+
 			}
 			*/
@@ -1111,40 +1138,40 @@
 
 			$this->shop->view['arData'] = wpsg_voucher::find($this->shop->view['arFilter']);
-			
+
 			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_gutschein/index.phtml');
-			
+
 		} // public function indexAction()
-				
+
 		public function settings_edit()
 		{
-			
+
 			$this->render(WPSG_PATH_VIEW.'/mods/mod_gutschein/settings_edit.phtml');
-			
+
 		} // public function settings_edit()
-		
+
 		public function settings_save()
 		{
-			
+
 			$this->shop->update_option('wpsg_mod_gutschein_size', $_REQUEST['wpsg_mod_gutschein_size']);
 			$this->shop->update_option('wpsg_mod_gutschein_perPage', $_REQUEST['wpsg_mod_gutschein_perPage']);
-			
+
 		} // public function settings_save()
-				
-		public function admin_presentation() 
-		{ 
+
+		public function admin_presentation()
+		{
 
 			echo wpsg_drawForm_Checkbox('wpsg_mod_gutschein_hideInsert', __('Gutschein einfÃŒgen im Warenkorb verbergen', 'wpsg'), $this->shop->get_option('wpsg_mod_gutschein_hideInsert'), array('help' => 'wpsg_mod_gutschein_hideInsert'));
-			
+
 		} // public function admin_presentation()
-		
-		public function admin_presentation_submit() 
-		{ 
-			
+
+		public function admin_presentation_submit()
+		{
+
 			$this->shop->update_option('wpsg_mod_gutschein_hideInsert', $_REQUEST['wpsg_mod_gutschein_hideInsert']);
-			
+
 		} // public function admin_presentation_submit()
-		
+
 		/* Modulfunktionen */
-			 
+
 	} // class wpsg_mod_gutschein extends wpsg_mod_basic
 
Index: /mods/wpsg_mod_packagetracking.class.php
===================================================================
--- /mods/wpsg_mod_packagetracking.class.php	(revision 6349)
+++ /mods/wpsg_mod_packagetracking.class.php	(revision 6350)
@@ -236,5 +236,6 @@
 			$this->shop->view['wpsg_mod_packagetracking']['preset'] = 0;
 			
-			if (wpsg_isSizedInt($oOrder->wpsg_mod_packagetracking_provider)) 
+			$temp = $oOrder->wpsg_mod_packagetracking_provider;
+			if (wpsg_isSizedInt($temp)) 
 			{
 				
@@ -254,4 +255,7 @@
 			
 			$this->shop->view['wpsg_mod_packagetracking']['oOrder'] = $oOrder;
+			$temp = array('id' => 0, 
+					'name' => __('Keine Paketverfolgung', 'wpsg'), 'url' => '', 'deleted' => 0);
+			$artemp[] = $temp;
 			$this->shop->view['wpsg_mod_packagetracking']['provider'] = $this->db->fetchAssoc("
 				SELECT
@@ -264,4 +268,5 @@
 					`id` ASC
 			");
+			$this->shop->view['wpsg_mod_packagetracking']['provider'] = array_merge($artemp, $this->shop->view['wpsg_mod_packagetracking']['provider']);
 			
 			return $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_packagetracking/order_view_switchStatus.phtml');
@@ -313,5 +318,7 @@
 			$oOrder = wpsg_order::getInstance($order_id, true);
 			
-			if (!wpsg_isSizedString($oOrder->wpsg_mod_packagetracking_code) || !wpsg_isSizedInt($oOrder->wpsg_mod_packagetracking_provider)) return '';
+			$code = $oOrder->wpsg_mod_packagetracking_code;
+			$prov = $oOrder->wpsg_mod_packagetracking_provider;
+			if (!wpsg_isSizedString($code) || !wpsg_isSizedInt($prov)) return '';
 
 			$url = $this->db->fetchOne("SELECT `url` FROM `".WPSG_TBL_TRACKINGPROVIDER."` WHERE `id` = '".wpsg_q($oOrder->wpsg_mod_packagetracking_provider)."' ");
@@ -344,5 +351,5 @@
 			
 		} // public function renderTrackingList()
-		
+
 	} // class wpsg_mod_packagetracking extends wpsg_mod_basic
 
Index: /mods/wpsg_mod_productvars.class.php
===================================================================
--- /mods/wpsg_mod_productvars.class.php	(revision 6349)
+++ /mods/wpsg_mod_productvars.class.php	(revision 6350)
@@ -356,4 +356,5 @@
 		{
 
+			if (!isset($this->shop->view['data'])) return;
 			$this->shop->view['wpsg_mod_productvars']['data'] = $this->getAllProductVarValues($this->shop->view['data']['id'], $p['product_index']);
 
Index: /views/order/view.phtml
===================================================================
--- /views/order/view.phtml	(revision 6349)
+++ /views/order/view.phtml	(revision 6350)
@@ -23,5 +23,5 @@
 			</div>
 		</div>
-        
+
     </nav>
 
@@ -38,5 +38,5 @@
         </div>
 
-		<?php if(false) {?>
+		<?php if(true) {?>
         <a href="" id="LinkProduktNeu" onclick="return WPSG_BE_Product.addProduct(<?php echo $_REQUEST['edit_id']; ?>, 0);"><span class="glyphicon glyphicon-plus"></span>&nbsp;
 	 	<?php echo __("Neues Produkt", "wpsg"); ?>
@@ -46,9 +46,9 @@
         <br />
         <?php if ($this->hasMod('wpsg_mod_gutschein')) { ?>
-        	<?php //if (((array_key_exists('gs', $this->view['basket'])) && ($this->view['basket']['gs']['value'] == 0))) { ?>
+        	<?php if (((array_key_exists('gs', $this->view['basket'])) && ($this->view['basket']['gs']['value'] == 0))) { ?>
 		        <a href="" id="LinkGutscheinNeu" onclick="return wpsg_addVoucher(<?php echo $_REQUEST['edit_id']; ?>);"><span class="glyphicon glyphicon-plus"></span>&nbsp;
 			 	<?php echo __("Neuer Gutschein", "wpsg"); ?>
 			 	</a><br />
-            <?php //} ?>
+            <?php } ?>
         <?php } ?>
 
@@ -60,9 +60,9 @@
             <?php //} ?>
         <?php } ?>
-		
+
         <a href="" id="LinkSendMail" onclick="return wpsg_sendMail(<?php echo $_REQUEST['edit_id']; ?>);"><span class="glyphicon glyphicon-envelope"></span>&nbsp;
 	 	<?php echo __("Mail an Kunde", "wpsg"); ?>
 	 	</a><br />
-		
+
 		<div id='wpsg_kv_list'>
 		</div>
@@ -88,9 +88,9 @@
 	/**
 	 * Sendet eine eMail
-	 */	                                            	
+	 */
 	function wpsg_sendMail(oid)
 	{
 		jQuery('#wpsg_produkte_table').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-		
+
 		jQuery.ajax( {
 			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=sendMail&do=send&edit_id=' + oid + '&noheader=1',
@@ -100,16 +100,16 @@
 			}
 		} );
-	
+
 		return false;
-	
+
 	} // function wpsg_sendMail()
 
 	/**
 	 * FÃŒgt einen neuen Rabatt hinzu (nur wenn keiner da ist)
-	 */	                                            	
+	 */
 	function wpsg_addDiscount(oid)
 	{
 		jQuery('#wpsg_produkte_table').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-		
+
 		jQuery.ajax( {
 			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=discountData&do=add&edit_id=' + oid + '&noheader=1',
@@ -119,17 +119,17 @@
 			}
 		} );
-	
+
 		return false;
-	
-	} // function wpsg_addRabatt()
+
+	} // function wpsg_addDiscount()
 
 
 	/**
 	 * FÃŒgt einen neuen Gutschein hinzu (nur wenn keiner da ist)
-	 */	                                            	
+	 */
 	function wpsg_addVoucher(oid)
 	{
 		jQuery('#wpsg_produkte_table').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-		
+
 		jQuery.ajax( {
 			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=voucherData&do=add&edit_id=' + oid + '&noheader=1',
@@ -142,15 +142,15 @@
 			}
 		} );
-	
+
 		return false;
 
 	} // function wpsg_addVoucher()
 
-	
+
 
     jQuery(document).ready(function() {
 
     	wpsg_view_orderdata_hide();
-    	
+
         jQuery('#wpsg_order_view_tabs a.list-group-item').bind('click', function() {
 
@@ -159,5 +159,5 @@
 
             tab = jQuery(this).attr('wpsg-data-target');
-			if (tab == 'orderdata') { 
+			if (tab == 'orderdata') {
             	wpsg_view_orderdata_show();
 			} else {
@@ -176,5 +176,5 @@
 			jQuery("[wpsg-data-target='general']").trigger("click");
         } else {
-        	jQuery("[wpsg-data-target='" + co + "']").trigger("click");			
+        	jQuery("[wpsg-data-target='" + co + "']").trigger("click");
         }
 		//jQuery('#wpsg_order_view_tabs a').removeClass('active');
@@ -182,5 +182,5 @@
 		//jQuery('#tabgeneral').show();
 		//jQuery("[wpsg-data-target='general']").addClass('active');
-			
+
     } );
 
Index: /views/order/view_general.phtml
===================================================================
--- /views/order/view_general.phtml	(revision 6349)
+++ /views/order/view_general.phtml	(revision 6350)
@@ -24,5 +24,6 @@
 
     <br />
-
+	<?php $this->callMods('order_view_switchStatus', array(&$this->view['data']['id'])); ?>						
+	
     <?php echo wpsg_drawForm_TextStart(); ?>
     <input type="submit" class="button" value="<?php echo __('Status Ã€ndern', 'wpsg'); ?>" />
Index: /views/order/view_orderdata.phtml
===================================================================
--- /views/order/view_orderdata.phtml	(revision 6349)
+++ /views/order/view_orderdata.phtml	(revision 6350)
@@ -50,8 +50,8 @@
         <?php $this->callMods('order_view_row', array(&$p, $i)); ?>
         <?php } ?>
-        <?php $gs_id = 0; 
+        <?php $gs_id = 0;
         if ((isset($this->view['basket']['gs'])) && ($this->view['basket']['gs']['value'] > 0)) { ?>
         <tr class="wpsg_<?php echo (($i % 2 == 0)?'odd':'even'); ?> wpsg_gutschein">
-        	<?php 
+        	<?php
         		$gs_id = 0;
         		if (array_key_exists('gs_id', $_REQUEST))
@@ -67,5 +67,5 @@
         		$val = '-'.wpsg_ff($this->view['basket']['sum']['gs']);
         		$link2 = '<span id="gsvalue_'.$gs_id.'" class="editable editable-click" data-original-title="" title="">'.$val.'</span>';
-        		
+
         	?>
             <td class="wpsg_cell_name"><?php echo __('Gutschein', 'wpsg'); ?> <?php echo ($this->view['basket']['gs']['code'] != '')? '('.$link1.')':'' ?>
@@ -80,6 +80,6 @@
         </tr>
         <?php } ?>
-        <?php $prval = 0; 
-        if (isset($this->view['basket']['sum']['preis_rabatt']) && $this->view['basket']['sum']['preis_rabatt'] > 0) { 
+        <?php $prval = 0;
+        if (isset($this->view['basket']['sum']['preis_rabatt']) && $this->view['basket']['sum']['preis_rabatt'] > 0) {
         	$o_id = $_REQUEST['edit_id'];
         	$prval = '-'.wpsg_ff($this->view['basket']['sum']['preis_rabatt']);
@@ -101,5 +101,5 @@
                     <?php echo wpsg_translate(__('Summe (zzgl. #1#)', 'wpsg'), '<a href="'.$this->getURL(wpsg_ShopController::URL_VERSANDKOSTEN).'" target="_blank">'.__('Versandkosten', 'wpsg').'</a>'); ?>
                 <?php } else { ?>
-                    <?php //if ($this->getFrontendTaxview() == WPSG_NETTO) 
+                    <?php //if ($this->getFrontendTaxview() == WPSG_NETTO)
                     //if ($this->view['basket']['price_frontend'] == WPSG_NETTO)
                     if ($this->get_option('wpsg_preisangaben') == WPSG_NETTO)
@@ -119,5 +119,5 @@
             <td colspan="<?php echo $this->view['colspan']; ?>" class="wpsg_cell_shipping_label">
                 <a href="<?php echo $this->getURL(wpsg_ShopController::URL_VERSANDKOSTEN); ?>" target="_blank"><?php echo __('Versandkosten', 'wpsg'); ?></a>
-                <?php 
+                <?php
                 //$order = $this->view['oOrder'];
                 $o_id = $_REQUEST['edit_id'];
@@ -126,5 +126,5 @@
                 echo __('  ('.$this->arShipping[$sid]['name'].')', 'wpsg');
                 ?>
-                <a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Versandart Ã€ndern', 'wpsg'); ?>" 
+                <a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Versandart Ã€ndern', 'wpsg'); ?>"
                    onclick="return WPSG_BE_Pay_Ship.changeShipping('<?php echo $sid; ?>', <?php echo $o_id; ?>);"><span class="glyphicon glyphicon-pencil"></span></a>
             </td>
@@ -145,5 +145,5 @@
                 ?>
                 <!-- <a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Zahlungsart lÃ¶schen', 'wpsg'); ?>" onclick="return WPSG_BE_Pay_Ship.deletePayment('"<?php echo $pid; ?>"'", <?php echo $o_id; ?>);"><span class="glyphicon glyphicon-trash"></span></a> -->
-                <a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Zahlungsart Ã€ndern', 'wpsg'); ?>" 
+                <a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Zahlungsart Ã€ndern', 'wpsg'); ?>"
                    onclick="return WPSG_BE_Pay_Ship.changePayment('<?php echo $pid; ?>', <?php echo $o_id; ?>);"><span class="glyphicon glyphicon-pencil"></span></a>
             </td>
@@ -181,5 +181,5 @@
                     <?php echo $this->get_option('wpsg_kleinunternehmer_text'); ?>
                 <?php } else { ?>
-                    <?php 
+                    <?php
                     //if ($this->view['basket']['price_frontend'] == WPSG_NETTO) {
                     if ($this->get_option('wpsg_preisangaben') == WPSG_NETTO) {
@@ -205,9 +205,9 @@
 
 	jQuery('#gsname_<?php echo $gs_id; ?>').wpsg_editable('<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=voucherData&do=editname&noheader=1', {
-		submitdata: { 
+		submitdata: {
     		field: 'code',
     		gs_id: '<?php echo $gs_id; ?>',
     		edit_id: '<?php echo $o_id; ?>'
-		}, 					
+		},
 		submit  : '<?php echo __('Speichern', 'wpsg'); ?>',
 		placeholder: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>',
@@ -220,5 +220,5 @@
 
 	jQuery('#gsvalue_<?php echo $gs_id; ?>').wpsg_editable('<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=voucherData&do=editvalue&noheader=1', {
-		submitdata: { 
+		submitdata: {
     		field: 'value',
     		gs_id: '<?php echo $gs_id; ?>',
@@ -227,5 +227,5 @@
         	mwst: '<?php reset($this->view['basket']['mwst']); echo key($this->view['basket']['mwst']); ?>',
         	price_frontend: '<?php echo $this->view['basket']['price_frontend']; ?>'
-		}, 					
+		},
 		submit  : '<?php echo __('Speichern', 'wpsg'); ?>',
 		placeholder: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>',
@@ -244,5 +244,5 @@
 
 	jQuery('#discountvalue_<?php echo $o_id; ?>').wpsg_editable('<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=discountData&do=editvalue&noheader=1', {
-		submitdata: { 
+		submitdata: {
     		field: 'value',
     		edit_id: '<?php echo $o_id; ?>',
@@ -250,5 +250,5 @@
            	mwst: '<?php reset($this->view['basket']['mwst']); echo key($this->view['basket']['mwst']); ?>',
            	price_frontend: '<?php echo $this->view['basket']['price_frontend']; ?>'
-		}, 					
+		},
 		submit  : '<?php echo __('Speichern', 'wpsg'); ?>',
 		placeholder: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>',
@@ -262,5 +262,5 @@
 	<?php } ?>
 <?php } ?>
-		
+
 	/**
 	 * Wird aufgerufen wenn ein Gutschein gelÃ¶scht werden soll
@@ -280,5 +280,5 @@
 			}
 		} );
-	
+
 		return false;
 	}
@@ -293,5 +293,5 @@
 
 		jQuery('#wpsg_produkte_table').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-		
+
 		jQuery.ajax( {
 			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=discountData&do=remove&edit_id=' + o_id +'&noheader=1',
@@ -301,5 +301,5 @@
 			}
 		} );
-	
+
 		return false;
 	}
@@ -318,5 +318,5 @@
         jQuery('#LinkProduktNeu').show();
         jQuery('#LinkSendMail').show();
-		
+
 		if (gs_id > 0) { jQuery('#LinkGutscheinNeu').hide(); }
 		if (prval != 0) { jQuery('#LinkRabattNeu').hide(); }
@@ -329,5 +329,5 @@
         jQuery('#LinkSendMail').hide();
     }
-    
+
     var Modul2 = {
     	    eigenschaft : "wert",
@@ -340,5 +340,5 @@
     //Modul2.methode();
 
-    
+
     var WPSG_BE_Pay_Ship = {
 
@@ -355,15 +355,15 @@
 					n;
     			//jQuery('#wpsg_payment_dialog .modal-body').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-    			
+
     			jQuery('#wpsg_payment_dialog').modal( { } );
-    		
+
     			this.paymentinfos = <?php  echo json_encode($this->arPayment, JSON_FORCE_OBJECT); ?>;
     			this.oid = oid;
     			this.pidold = id;
-    			
+
     	 		jQuery('#zahlungsartid').empty();
     			jQuery.each(this.paymentinfos, function(i,n) {
     	    		console.log('element: ', n.name);
-    	    		if (id == n.id) { 
+    	    		if (id == n.id) {
     	    			jQuery('#zahlungsartid').append("<option value=" + n.id + ' "selected"="selected">' + n.name + "</option>");
     	    		} else {
@@ -372,12 +372,12 @@
     	    	});
     			jQuery('#zahlungsartid').val(id);
-    			
+
     			//this.preis = this.paymentinfos[id].preis;
     			//this.preis = jQuery('#wpsg_cell_payment_value').val();
     			this.preis = jQuery('#wpsg_cell_payment_value').html();
     			this.preisold = this.preis;
-    			if (this.preis == false) { this.preis = '0,00'; } 
+    			if (this.preis == false) { this.preis = '0,00'; }
     			jQuery('#zahlungsartvalue').val(this.preis);
-    	    	
+
     			return false;
 
@@ -386,5 +386,5 @@
     		/**
     		 * LÃ¶schen der Zahlungsdaten im Backend
-    		 */	                          
+    		 */
     		deletePayment: function(id, oid) {
     			var
@@ -395,5 +395,5 @@
     			pval = jQuery('#zahlungsartvalue').val();
     			//alert('delete : ' + pid + ' / ' + pval);
-    			
+
     			url1 = 'wp-admin/admin.php?page=wpsg-Admin&subaction=paymentData&do=delete&edit_id=' + this.oid + '&p_id=' + pid + '&noheader=1';
     			jQuery.ajax( {
@@ -406,12 +406,12 @@
     			    }
     			} );
-    		
+
     			return false;
-    		
+
     		}, // function deletePayment()
 
     		/**
     		 * Ãndern der Zahlungsdaten im Backend
-    		 */	                          
+    		 */
     		dialogPaymentOK: function() {
     			var
@@ -423,5 +423,5 @@
     			pval = jQuery('#zahlungsartvalue').val();
     			//alert('OK neu: ' + this.pidold + ' / ' + pid + ' / ' + pval);
-    			if ((this.pidold == pid) && (this.preisold == pval)) { 
+    			if ((this.pidold == pid) && (this.preisold == pval)) {
     				jQuery('#wpsg_payment_dialog').modal('hide');
 					//jQuery('#wpsg_payment_dialog').modal('close');
@@ -429,5 +429,5 @@
     			}
     			//alert('OK neu: ' + pid + ' / ' + pval);
-    			
+
     			url1 = 'wp-admin/admin.php?page=wpsg-Admin&subaction=paymentData&do=change&edit_id=' + this.oid + '&p_id=' + pid + '&p_value=' + pval + '&noheader=1';
     			jQuery.ajax( {
@@ -444,12 +444,12 @@
     			    }
     			} );
-    		
+
     			return false;
-    		
+
     		}, // function dialogPaymentOK()
 
     		/**
     		 * Ãndern der Zahlungsdaten im Backend
-    		 */	                          
+    		 */
     		dialogPaymentChange: function() {
     			var
@@ -469,15 +469,15 @@
 					n;
     			//jQuery('#wpsg_shipping_dialog .modal-body').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-    			
+
     			jQuery('#wpsg_shipping_dialog').modal( { } );
-    		
+
     			this.shippinginfos = <?php  echo json_encode($this->arShipping, JSON_FORCE_OBJECT); ?>;
     			this.oid = oid;
     			this.sidold = id;
-    			
+
     	 		jQuery('#versandartid').empty();
     			jQuery.each(this.shippinginfos, function(i,n) {
     	    		console.log('element: ', n.name);
-    	    		if (id == n.id) { 
+    	    		if (id == n.id) {
     	    			jQuery('#versandartid').append("<option value=" + n.id + ' "selected"="selected">' + n.name + "</option>");
     	    		} else {
@@ -486,10 +486,10 @@
     	    	});
     			jQuery('#versandartid').val(id);
-    			
+
     			this.preis = jQuery('#wpsg_cell_shipping_value').html();
     			this.preisold = this.preis;
-    			if (this.preis == false) { this.preis = '0,00'; } 
+    			if (this.preis == false) { this.preis = '0,00'; }
     			jQuery('#versandartvalue').val(this.preis);
-    	    	
+
     			return false;
 
@@ -498,5 +498,5 @@
     		/**
     		 * LÃ¶schen der Versanddaten im Backend
-    		 */	                          
+    		 */
     		deleteShipping: function(id, oid) {
     			var
@@ -507,5 +507,5 @@
     			sval = jQuery('#versandartvalue').val();
     			//alert('delete : ' + sid + ' / ' + sval);
-    			
+
     			url1 = 'wp-admin/admin.php?page=wpsg-Admin&subaction=shippingData&do=delete&edit_id=' + this.oid + '&s_id=' + sid + '&noheader=1';
     			jQuery.ajax( {
@@ -518,12 +518,12 @@
     			    }
     			} );
-    		
+
     			return false;
-    		
+
     		}, // function deleteShipping()
 
     		/**
     		 * Ãndern der Versanddaten im Backend
-    		 */	                          
+    		 */
     		dialogShippingOK: function() {
     			var
@@ -535,5 +535,5 @@
     			sval = jQuery('#versandartvalue').val();
     			//alert('OK neu: ' + this.sidold + ' / ' + sid + ' / ' + sval);
-    			if ((this.sidold == sid) && (this.preisold == sval)) { 
+    			if ((this.sidold == sid) && (this.preisold == sval)) {
     				jQuery('#wpsg_shipping_dialog').modal('hide');
 					//jQuery('#wpsg_shipping_dialog').modal('close');
@@ -541,5 +541,5 @@
     			}
     			//alert('OK neu: ' + sid + ' / ' + sval);
-    			
+
     			url1 = 'wp-admin/admin.php?page=wpsg-Admin&subaction=shippingData&do=change&edit_id=' + this.oid + '&s_id=' + sid + '&s_value=' + sval + '&noheader=1';
     			jQuery.ajax( {
@@ -556,12 +556,12 @@
     			    }
     			} );
-    		
+
     			return false;
-    		
+
     		}, // function dialogShippingOK()
 
     		/**
     		 * Ãndern der Versanddaten im Backend
-    		 */	                          
+    		 */
     		dialogShippingChange: function() {
     			var
@@ -574,5 +574,5 @@
 
     		},	// dialogShippingChange()
-    		
+
 		changePayment2: function (id, oid) {
 
@@ -580,8 +580,8 @@
 
 		} // function changePayment2(id, oid)
-		
+
     };	// WPSG_BE_Pay_Ship
     //WPSG_BE_Pay_Ship.changePayment2(1, 2);
-    
+
 
     var WPSG_BE_Product = {
@@ -606,9 +606,9 @@
     	removeProduct: function (op_id, o_id)
     	{
-    	
+
     		if (!confirm('<?php echo __("Sind Sie sich sicher, dass Sie dieses Produkt lÃ¶schen mÃ¶chten?", "wpsg"); ?>')) return false;
-    	
+
     		jQuery('#wpsg_produkte_table').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-    			
+
     		jQuery.ajax( {
     			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=productData&do=remove&edit_id=' + o_id + '&op_id=' + op_id + '&noheader=1',
@@ -617,5 +617,5 @@
     			}
     		} );
-    		
+
     		return false;
     	},	// function removeProduct
@@ -629,11 +629,11 @@
 			this.p_id = p_id;
 			this.o_id = o_id;
-    		
+
     		//alert('TEST');
     		jQuery('#wpsg_product_dialog').modal( { } );
-    		
+
     		this.modus = 1;		// neues Produkt
     		jQuery('#wpsg_product_data').hide();
-    		
+
     		jQuery('#productid').empty();
 			jQuery.each(this.allproductinfos, function (i,n) {
@@ -641,12 +641,71 @@
 			});
 			jQuery('#productid').val(p_id);
-    		
-    	
+
+
     		return false;
     	},	// function addProduct
 
+		/**
+		 * Bearbeiten der Produkt-Daten
+		 */
+		editProduct: function (op_id, p_id, o_id)
+		{
+			var
+				i,
+				id,
+				menge,
+				key,
+				mid,
+				n;
+
+			this.modus = 0;		// bearbeiten
+			this.op_id = op_id;
+			this.p_id = p_id;
+			this.o_id = o_id;
+			//jQuery('#wpsg_produkte_table').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+
+			jQuery('#wpsg_product_dialog').modal( { } );
+    		jQuery('#wpsg_product_data').show();
+
+			this.pidold = p_id;
+
+			jQuery('#productid').empty();
+			jQuery.each(this.allproductinfos, function (i,n) {
+				console.log('element: ', n.name);
+				if (p_id == n.id) {
+					jQuery('#productid').append("<option value=" + n.id + ' "selected"="selected">' + n.name + "</option>");
+					mid = n.mwst_key;
+				} else {
+					jQuery('#productid').append("<option value=" + n.id + ">" + n.name + "</option>");
+				}
+			});
+			jQuery('#productid').val(p_id);
+
+			jQuery('#productmwst').empty();
+			for (key in this.mwstinfos) {
+				if (p_id == key) {
+					jQuery('#productmwst').append("<option value=" + key + ' "selected"="selected">' + this.mwstinfos[key] + "</option>");
+				} else {
+					jQuery('#productmwst').append("<option value=" + key + ">" + this.mwstinfos[key] + "</option>");
+				}
+			}
+			jQuery('#productmwst').val(mid);
+
+			id = this.findIndex(op_id);
+			this.preis = this.productinfos[id].preis;
+
+			this.preisold = this.preis;
+			if (this.preis == false) { this.preis = '0,00'; }
+			jQuery('#productvalue').val(this.preis);
+			menge = this.productinfos[id].menge;
+			jQuery('#productmenge').val(menge);
+
+			return false;
+
+		}, // function editProduct()
+
     	/**
 		 * Ãndern der Produktdaten im Backend
-		 */	                          
+		 */
 		dialogProductOK: function () {
 			var
@@ -662,11 +721,11 @@
 			pmwst = jQuery('#productmwst').val();
 			//alert('OK neu: ' + this.pidold + ' / ' + pid + ' / ' + pval);
-			//if ((this.pidold == pid) && (this.preisold == pval)) { 
-			if ((pid == null)) { 
+			//if ((this.pidold == pid) && (this.preisold == pval)) {
+			if ((pid == null)) {
 				jQuery('#wpsg_product_dialog').modal('hide');
 				return false;
 			}
 			//alert('OK neu: ' + pid + ' / ' + pval);
-			
+
 			if (this.modus == 0) {
 				url1 = 'wp-admin/admin.php?page=wpsg-Admin&subaction=productData&do=change&edit_id=' + this.o_id + '&op_id=' + this.op_id + '&p_id=' + pid + '&noheader=1';
@@ -705,69 +764,10 @@
 			}
 			return false;
-		
+
 		}, // function dialogProduktOK()
-		
-		/**
-		 * Bearbeiten der Produkt-Daten
-		 */	                                            	
-		editProduct: function (op_id, p_id, o_id)
-		{
-			var
-				i,
-				id,
-				menge,
-				key,
-				mid,
-				n;
-
-			this.modus = 0;		// bearbeiten
-			this.op_id = op_id;
-			this.p_id = p_id;
-			this.o_id = o_id;
-			//jQuery('#wpsg_produkte_table').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-	
-			jQuery('#wpsg_product_dialog').modal( { } );
-    		jQuery('#wpsg_product_data').show();
-		
-			this.pidold = p_id;
-
-			jQuery('#productid').empty();
-			jQuery.each(this.allproductinfos, function (i,n) {
-				console.log('element: ', n.name);
-				if (p_id == n.id) { 
-					jQuery('#productid').append("<option value=" + n.id + ' "selected"="selected">' + n.name + "</option>");
-					mid = n.mwst_key;
-				} else {
-					jQuery('#productid').append("<option value=" + n.id + ">" + n.name + "</option>");
-				}
-			});
-			jQuery('#productid').val(p_id);
-
-			jQuery('#productmwst').empty();
-			for (key in this.mwstinfos) {
-				if (p_id == key) { 
-					jQuery('#productmwst').append("<option value=" + key + ' "selected"="selected">' + this.mwstinfos[key] + "</option>");
-				} else {
-					jQuery('#productmwst').append("<option value=" + key + ">" + this.mwstinfos[key] + "</option>");
-				}
-			}
-			jQuery('#productmwst').val(mid);
-
-			id = this.findIndex(op_id);
-			this.preis = this.productinfos[id].preis;
-
-			this.preisold = this.preis;
-			if (this.preis == false) { this.preis = '0,00'; } 
-			jQuery('#productvalue').val(this.preis);
-			menge = this.productinfos[id].menge;
-			jQuery('#productmenge').val(menge);
-			
-			return false;
-	
-		}, // function editProduct()
 
 		/**
 		 * Ãndern des Produktes im Backend
-		 */	                          
+		 */
 		dialogProductChange: function() {
 			var
@@ -775,4 +775,5 @@
 				id,
 				aid,
+				mid,
 				pval;
 			pid = jQuery('#productid').val();
@@ -786,4 +787,16 @@
 				pval = this.allproductinfos[aid].mwst_key;
 				jQuery('#productmwst').val(pval);
+
+				jQuery('#productmwst').empty();
+				for (key in this.mwstinfos) {
+					if (pval == key) {
+						jQuery('#productmwst').append("<option value=" + key + ' "selected"="selected">' + this.mwstinfos[key] + "</option>");
+					} else {
+						jQuery('#productmwst').append("<option value=" + key + ">" + this.mwstinfos[key] + "</option>");
+					}
+				}
+				jQuery('#productmwst').val(pval);
+
+				jQuery('#wpsg_product_data').show();
 			}
 
@@ -792,5 +805,5 @@
 		/**
 		 * Suchen des Indexes in allproductinfos an Hand der id
-		 */	                          
+		 */
 		findAllIndex: function(id) {
 			var
@@ -799,5 +812,5 @@
 			for (key in this.allproductinfos) {
 				if (id == this.allproductinfos[key].id) {
-					return key; 
+					return key;
 				}
 			}
@@ -805,8 +818,8 @@
 
 		},	// findAllIndex()
-		
+
 		/**
 		 * Suchen des Indexes in productinfos an Hand der order_product_id
-		 */	                          
+		 */
 		findIndex: function(id) {
 			var
@@ -815,5 +828,5 @@
 			for (key in this.productinfos) {
 				if (id == this.productinfos[key].order_product_id) {
-					return key; 
+					return key;
 				}
 			}
@@ -827,10 +840,10 @@
 
 		} // function changeProduct2(id, oid)
-		
+
     };	// WPSG_BE_Product
     //WPSG_BE_Product.changeProduct2(1, 2);
-    
-	/* ]]> */</script>		
-    
+
+	/* ]]> */</script>
+
 </div>
 
@@ -846,4 +859,8 @@
       <div class="modal-body">
       	<br />
+      	<?php
+      	$i = 0;
+      	// $this
+      	?>
         <div class="row">
           <div class="col-md-3 col-sm-6 control_label"><label for="productid" ><?php echo _("Produkt"); ?></label></div>
@@ -858,30 +875,30 @@
 
 		<div id="wpsg_product_data">
-        <div class="row">
-          <div class="col-md-3 col-sm-6 control_label"><label for="productvalue"><?php echo _("Preis"); ?></label></div>
-          <div class="col-md-3">
-			<input type="text" name="productvalue" id="productvalue" class="form-control input-sm" size="1" class="select">
-		  </div>
+	        <div class="row">
+	          <div class="col-md-3 col-sm-6 control_label"><label for="productvalue"><?php echo _("Preis"); ?></label></div>
+	          <div class="col-md-3">
+				<input type="text" name="productvalue" id="productvalue" class="form-control input-sm" size="1" class="select">
+			  </div>
+	        </div>
+	        <div class="clearfix wpsg_clear"></div>
+	        <div class="row">
+	          <div class="col-md-3 col-sm-6 control_label"><label for="productmenge"><?php echo _("Menge"); ?></label></div>
+	          <div class="col-md-3">
+				<input type="text" name="productmenge" id="productmenge" class="form-control input-sm" size="1" class="select">
+			  </div>
+	        </div>
+	        <div class="clearfix wpsg_clear"></div>
+	        <div class="row">
+	          <div class="col-md-3 col-sm-6 control_label"><label for="productid" ><?php echo _("MwSt:"); ?></label></div>
+	          <div class="col-md-3">
+				<select name="productmwst" id="productmwst" class="form-control input-sm" size="1" class="select">
+					<option value=0>"[unbekannt]"</option>
+				</select>
+			  </div>
+	        </div>
+	        <div class="clearfix wpsg_clear"></div>
+
         </div>
-        <div class="clearfix wpsg_clear"></div>
-        <div class="row">
-          <div class="col-md-3 col-sm-6 control_label"><label for="productmenge"><?php echo _("Menge"); ?></label></div>
-          <div class="col-md-3">
-			<input type="text" name="productmenge" id="productmenge" class="form-control input-sm" size="1" class="select">
-		  </div>
-        </div>
-        <div class="clearfix wpsg_clear"></div>
-        <div class="row">
-          <div class="col-md-3 col-sm-6 control_label"><label for="productid" ><?php echo _("MwSt:"); ?></label></div>
-          <div class="col-md-3">
-			<select name="productmwst" id="productmwst" class="form-control input-sm" size="1" class="select">
-				<option value=0>"[unbekannt]"</option>
-			</select>
-		  </div>
-        </div>
-        <div class="clearfix wpsg_clear"></div>
-        
-        </div>
-        
+
       </div>
       <div class="modal-footer">
@@ -922,5 +939,5 @@
         </div>
         <div class="clearfix wpsg_clear"></div>
-        
+
       </div>
       <div class="modal-footer">
@@ -961,5 +978,5 @@
         </div>
         <div class="clearfix wpsg_clear"></div>
-        
+
       </div>
       <div class="modal-footer">
@@ -970,4 +987,4 @@
   </div>
 </div>
-    
+
 <?php echo wpsg_drawForm_AdminboxEnd(); ?>
