Index: /controller/wpsg_AdminController.class.php
===================================================================
--- /controller/wpsg_AdminController.class.php	(revision 6058)
+++ /controller/wpsg_AdminController.class.php	(revision 6066)
@@ -1486,5 +1486,4 @@
 					if ($noMwSt === true) $tax_value = 0; else $tax_value = $country->getTax($tax_key);
 				}
-				//TODO
 				
 				$price = $pval;
Index: /controller/wpsg_BasketController.class.php
===================================================================
--- /controller/wpsg_BasketController.class.php	(revision 6058)
+++ /controller/wpsg_BasketController.class.php	(revision 6066)
@@ -878,5 +878,8 @@
 					
 					// Ãnderungen bei der Lieferadresse nach dem "overview" beachten
-					if ($_REQUEST['wpsg']['checkout']['act_checkout_shippingadress'] !== 'act') unset($_SESSION['wpsg']['checkout']['act_checkout_shippingadress']);
+					if (isset($_REQUEST['wpsg']['checkout']['act_checkout_shippingadress']))
+					{
+						if ($_REQUEST['wpsg']['checkout']['act_checkout_shippingadress'] !== 'act') unset($_SESSION['wpsg']['checkout']['act_checkout_shippingadress']);
+					}
 					
 					if ($this->shop->hasMod('wpsg_mod_onepagecheckout'))
@@ -927,5 +930,5 @@
 				
 				// Speziell fÃŒr PayPal PLUS, da an den IFrame gesendet wird
-				if ($_REQUEST['wpsg_checkout'] === 'ppp')
+				if (wpsg_getStr($_REQUEST['wpsg_checkout']) === 'ppp')
 				{
 					
Index: /controller/wpsg_ShopController.class.php
===================================================================
--- /controller/wpsg_ShopController.class.php	(revision 6058)
+++ /controller/wpsg_ShopController.class.php	(revision 6066)
@@ -1799,5 +1799,5 @@
 				wpsg_debug($_SESSION);
 				echo '<pre>';debug_print_backtrace();echo '</pre>';
-				die();
+				//die();
 				
 				return 0;
@@ -3694,5 +3694,5 @@
 			if (wpsg_isSizedArray($arDebugOut)) wpsg_debug($arDebugOut);
 
-			echo wpsg_translate(__('Systemfehler! Fehlercode:#1#', 'wpsg'), $code);
+			echo wpsg_translate(__('Systemfehler! Fehlercode::#1#', 'wpsg'), $code);
 			
 			debug_print_backtrace();
Index: /lib/wpsg_basket.class.php
===================================================================
--- /lib/wpsg_basket.class.php	(revision 6058)
+++ /lib/wpsg_basket.class.php	(revision 6066)
@@ -1649,5 +1649,5 @@
 				
 				/*
-//TODO
+
 				if ($this->shop->getFrontendTaxview() == WPSG_BRUTTO)
 				{
Index: /mods/wpsg_mod_addressvalidation.class.php
===================================================================
--- /mods/wpsg_mod_addressvalidation.class.php	(revision 6058)
+++ /mods/wpsg_mod_addressvalidation.class.php	(revision 6066)
@@ -173,5 +173,5 @@
 					$ort = $arCheckout['shipping_ort'];
 					$plz = $arCheckout['shipping_plz'];
-					$nr = $arCheckout['shipping_nr'];
+					$nr = wpsg_getStr($arCheckout['shipping_nr']);
 					$land = $arCheckout['shipping_land'];
 					
Index: /mods/wpsg_mod_deliverynote.class.php
===================================================================
--- /mods/wpsg_mod_deliverynote.class.php	(revision 6058)
+++ /mods/wpsg_mod_deliverynote.class.php	(revision 6066)
@@ -226,5 +226,5 @@
 			
 			}
-			else if ($_REQUEST['do'] == 'get')
+			else if (wpsg_getStr($_REQUEST['do']) == 'get')
 			{
 				
@@ -584,9 +584,10 @@
 			
 			// Rechnungsadresse		
+			$this->shop->view['data']['id'] = $this->shop->view['customer']['id'];
 			$this->shop->view['data']['firma'] = $this->shop->view['customer']['firma'];
 			$this->shop->view['data']['vname'] = $this->shop->view['customer']['vname'];
 			$this->shop->view['data']['name'] = $this->shop->view['customer']['name'];
 			$this->shop->view['data']['strasse'] = $this->shop->view['customer']['strasse'];
-			$this->shop->view['data']['hausnr'] = $this->shop->view['customer']['hausnr'];
+			$this->shop->view['data']['hausnr'] = $this->shop->view['customer']['nr'];
 			$this->shop->view['data']['plz'] = $this->shop->view['customer']['plz'];
 			$this->shop->view['data']['ort'] = $this->shop->view['customer']['ort'];
@@ -756,5 +757,5 @@
 			$liefer_id = $this->db->getNextAutoincrementValue(WPSG_TBL_DELIVERYNOTE);
 			
-			$strReturn = $this->shop->replaceUniversalPlatzhalter($format, $order_id, false, fase, false, array(
+			$strReturn = $this->shop->replaceUniversalPlatzhalter($format, $order_id, false, false, false, array(
 				'/%lid%/' => $liefer_id,
 				'/%lnr%/' => $this->shop->get_option('wpsg_mod_deliverynote_nr')	
Index: /mods/wpsg_mod_productvars.class.php
===================================================================
--- /mods/wpsg_mod_productvars.class.php	(revision 6058)
+++ /mods/wpsg_mod_productvars.class.php	(revision 6066)
@@ -691,4 +691,5 @@
 		{ 
 			
+			if ($produkt_key == false) return false;
 			$product_id = $this->shop->getProduktID($produkt_key);
 
Index: /mods/wpsg_mod_produktattribute.class.php
===================================================================
--- /mods/wpsg_mod_produktattribute.class.php	(revision 6058)
+++ /mods/wpsg_mod_produktattribute.class.php	(revision 6066)
@@ -418,4 +418,5 @@
 		{
 			
+			if ($produkt_key == false) return false;
 			$product_id = $this->shop->getProduktID($produkt_key);
 			
Index: /mods/wpsg_mod_rechnungen.class.php
===================================================================
--- /mods/wpsg_mod_rechnungen.class.php	(revision 6058)
+++ /mods/wpsg_mod_rechnungen.class.php	(revision 6066)
@@ -1132,5 +1132,5 @@
 				);
 							
-				if ($_REQUEST['wpsg_rechnungen_gutschrift'] == "0")
+				if (isset($_REQUEST['wpsg_rechnungen_gutschrift']) && ($_REQUEST['wpsg_rechnungen_gutschrift'] == "0"))
 				{
 				
@@ -1142,5 +1142,5 @@
 			}
 			
-			if ($_REQUEST['wpsg_rechnungen_gutschrift'] == "1" || $_REQUEST['wpsg_rechnungen_gutschrift'] == "2")
+			if (isset($_REQUEST['wpsg_rechnungen_gutschrift']) && ($_REQUEST['wpsg_rechnungen_gutschrift'] == "1" || $_REQUEST['wpsg_rechnungen_gutschrift'] == "2"))
 			{
  									
Index: /mods/wpsg_mod_shippingadress.class.php
===================================================================
--- /mods/wpsg_mod_shippingadress.class.php	(revision 6058)
+++ /mods/wpsg_mod_shippingadress.class.php	(revision 6066)
@@ -115,5 +115,5 @@
 			{
 		 
-				if ($_REQUEST['wpsg']['checkout']['diff_shippingadress'] == '1')
+				if (wpsg_getStr($_REQUEST['wpsg']['checkout']['diff_shippingadress']) == '1')
 				{
 	
Index: /mods/wpsg_mod_stock.class.php
===================================================================
--- /mods/wpsg_mod_stock.class.php	(revision 6058)
+++ /mods/wpsg_mod_stock.class.php	(revision 6066)
@@ -171,8 +171,9 @@
 		{
 
-			if (in_array($status_id, array(500)) || $this->shop->view['order']['status'] == 500)
-			{
-				
-				// Entweder ist die Bestellvon von Storniert in einen anderen Status gewÃ€chselt oder in Storniert
+			if (in_array($status_id, array(500)) || 
+				(isset($this->shop->view['order']) && ($this->shop->view['order']['status'] == 500)))
+			{
+				
+				// Entweder ist die Bestellung von Storniert in einen anderen Status gewÃ€chselt oder in Storniert
 				
 				// Lagerbestand zurÃŒcksetzen
@@ -575,4 +576,5 @@
 		{ 
 			
+			return;		// Bestand wird sonst doppelt verringert
 			if ($finish_order !== true) return;
 			
@@ -643,6 +645,9 @@
 			
 			// Fehlerbehandlung fÃŒr Produktbestand
-			if ($product_data['stock_count'] == '1' && $stock > $product_data['stock']) return false;
-			
+			//if ($product_data['stock_count'] == '1' && $stock > $product_data['stock']) return false;
+			if ($product_data['stock_count'] == '1' && 
+				(($this->shop->get_option('wpsg_mod_stock_allow') === '1') && ($stock > $product_data['stock']))) return false;
+				
+			/* Produktgruppe runterzÃ€hlen */
 			if ($this->shop->hasMod('wpsg_mod_productgroups'))
 			{
@@ -653,6 +658,7 @@
 				{
 					
-					if ($pgroup['stock_aktiv'] == '1' && $stock > $pgroup['stock_value']) return false;
-			
+					//if ($pgroup['stock_aktiv'] == '1' && ($stock > $pgroup['stock_value'])) return false;
+					if (($this->shop->get_option('wpsg_mod_stock_allow') === '1') && ($stock > $pgroup['stock_value'])) return false;
+						
 					$this->db->Query("
 						UPDATE `".WPSG_TBL_PRODUCTS_GROUP."` SET `stock_value` = `stock_value` - '".wpsg_q($stock)."' WHERE `id` = '".wpsg_q($product_data['pgruppe'])."'
@@ -680,7 +686,9 @@
 				if (wpsg_isSizedInt($this->shop->get_option('wpsg_mod_stock_minstockproduct')))
 				{
-						
+					
+					$product_data = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".wpsg_q($product_id)."' ");
+					$aktStock = $product_data['stock'];
 					// Wenn Mindestbestellmenge unterschritten oder gleich
-					if ($stock <= $product_data['minstockproduct_count']) $this->sendMinStockMail($data['productkey']);
+					if ($aktstock <= $product_data['minstockproduct_count']) $this->sendMinStockMail($data['productkey']);
 						
 				}
Index: /views/mods/mod_deliverynote/deliverynote_pdf.phtml
===================================================================
--- /views/mods/mod_deliverynote/deliverynote_pdf.phtml	(revision 6058)
+++ /views/mods/mod_deliverynote/deliverynote_pdf.phtml	(revision 6066)
@@ -19,31 +19,32 @@
 			global $absender_left, $absender_top, $adress_left, $adress_top, $dndata_left, $dndata_top;
 							
+			$rdata_left = 0;
 			$pdf->AddPage();
 			
-			if (file_exists($shop->callMod('wpsg_mod_deliverynote', getFilePath, array(''))."wpsg_deliverynote_bp.pdf"))
-			{
-				
-				$pagecount = $pdf->setSourceFile($shop->callMod('wpsg_mod_deliverynote', getFilePath, array(''))."wpsg_deliverynote_bp.pdf");
+			if (file_exists($shop->callMod('wpsg_mod_deliverynote', 'getFilePath', array(''))."wpsg_deliverynote_bp.pdf"))
+			{
+				
+				$pagecount = $pdf->setSourceFile($shop->callMod('wpsg_mod_deliverynote', 'getFilePath', array(''))."wpsg_deliverynote_bp.pdf");
 				$tplidx = $pdf->importPage(1, '/MediaBox');
 				$pdf->useTemplate($tplidx, 0, 0, 210);
 			
 			}
-			else if (file_exists($shop->callMod('wpsg_mod_deliverynote', getFilePath, array(''))."wpsg_deliverynote_bp.jpg"))
-			{
-				
-				$pdf->image($shop->callMod('wpsg_mod_deliverynote', getFilePath, array(''))."wpsg_deliverynote_bp.jpg", 0, 0, 210, 297, 'jpg');
-				
-			}
-				
-				
-			if (file_exists($shop->callMod('wpsg_mod_deliverynote', getFilePath, array(''))."wpsg_deliverynote_logo.jpg"))
-			{
-			
-				list($width, $height, $type, $attr) = getimagesize($shop->callMod('wpsg_mod_deliverynote', getFilePath, array(''))."wpsg_deliverynote_logo.jpg");
+			else if (file_exists($shop->callMod('wpsg_mod_deliverynote', 'getFilePath', array(''))."wpsg_deliverynote_bp.jpg"))
+			{
+				
+				$pdf->image($shop->callMod('wpsg_mod_deliverynote', 'getFilePath', array(''))."wpsg_deliverynote_bp.jpg", 0, 0, 210, 297, 'jpg');
+				
+			}
+				
+				
+			if (file_exists($shop->callMod('wpsg_mod_deliverynote', 'getFilePath', array(''))."wpsg_deliverynote_logo.jpg"))
+			{
+			
+				list($width, $height, $type, $attr) = getimagesize($shop->callMod('wpsg_mod_deliverynote', 'getFilePath', array(''))."wpsg_deliverynote_logo.jpg");
 			 
 				$wPix = (25.4 * $width) / 96;
 				$hPix = (25.4 * $height) / 96;
 			
-				$pdf->image($shop->callMod('wpsg_mod_deliverynote', getFilePath, array(''))."wpsg_deliverynote_logo.jpg", 210 - $wPix, 0, $wPix, $hPix);
+				$pdf->image($shop->callMod('wpsg_mod_deliverynote', 'getFilePath', array(''))."wpsg_deliverynote_logo.jpg", 210 - $wPix, 0, $wPix, $hPix);
 			
 			}
@@ -53,5 +54,5 @@
 			$pdf->Text($absender_left, $absender_top, $shop->replaceUniversalPlatzhalter($shop->get_option("wpsg_mod_deliverynote_adressrow"), $shop->view['order']['id']));
 			
-			if ($shop->view['kunde']['kuerzel'] != "") $shop->view['kunde']['kuerzel'] = $shop->view['kunde']['kuerzel'].'-';
+			if (wpsg_getStr($shop->view['kunde']['kuerzel']) != "") $shop->view['kunde']['kuerzel'] = $shop->view['kunde']['kuerzel'].'-';
 				
 			// Adresse des Kunden
Index: /views/mods/mod_statistics/chartturnover/quarter.phtml
===================================================================
--- /views/mods/mod_statistics/chartturnover/quarter.phtml	(revision 6058)
+++ /views/mods/mod_statistics/chartturnover/quarter.phtml	(revision 6066)
@@ -20,5 +20,5 @@
 			$chartJS['legend'][$i] .= "	highlighter: {";
 			
-			$chartJS['legend'][$i] .= "		formatString: '<table><tr><td>KW %s ".$this->view['chart']['data'][$i]['year'].", %s ".$this->get_option('wpsg_currency')."</td></tr></table>'";
+			$chartJS['legend'][$i] .= "		formatString: '<table><tr><td>KW %s ".wpsg_getStr($this->view['chart']['data'][$i]['year']).", %s ".$this->get_option('wpsg_currency')."</td></tr></table>'";
 			
 			$chartJS['legend'][$i] .= "	}";
Index: /views/order/view.phtml
===================================================================
--- /views/order/view.phtml	(revision 6058)
+++ /views/order/view.phtml	(revision 6066)
@@ -148,4 +148,6 @@
     jQuery(document).ready(function() {
 
+    	wpsg_view_orderdata_hide();
+    	
         jQuery('#wpsg_order_view_tabs a.list-group-item').bind('click', function() {
 
@@ -153,4 +155,10 @@
             jQuery('.wpsg_order_view_tab_content').hide();
 
+            tab = jQuery(this).attr('wpsg-data-target');
+			if (tab == 'orderdata') { 
+            	wpsg_view_orderdata_show();
+			} else {
+				wpsg_view_orderdata_hide();
+			}
             jQuery(this).addClass('active');
             jQuery('#tab' + jQuery(this).attr('wpsg-data-target')).show();
@@ -161,4 +169,15 @@
         } );
 
+        co = jQuery.cookie('wpsg_order_view_tab');
+        if (co === undefined) {
+			jQuery("[wpsg-data-target='general']").trigger("click");
+        } else {
+        	jQuery("[wpsg-data-target='" + co + "']").trigger("click");			
+        }
+		//jQuery('#wpsg_order_view_tabs a').removeClass('active');
+        //jQuery('.wpsg_order_view_tab_content').hide();
+		//jQuery('#tabgeneral').show();
+		//jQuery("[wpsg-data-target='general']").addClass('active');
+			
     } );
 
Index: /views/order/view_orderdata.phtml
===================================================================
--- /views/order/view_orderdata.phtml	(revision 6058)
+++ /views/order/view_orderdata.phtml	(revision 6066)
@@ -309,10 +309,25 @@
 		prval = <?php echo $prval; ?>;
 
+		wpsg_view_orderdata_show();
+
+    } );
+
+    function wpsg_view_orderdata_show() {
+        jQuery('#LinkGutscheinNeu').show();
+        jQuery('#LinkRabattNeu').show();
+        jQuery('#LinkProduktNeu').show();
+        jQuery('#LinkSendMail').show();
+		
 		if (gs_id > 0) { jQuery('#LinkGutscheinNeu').hide(); }
 		if (prval != 0) { jQuery('#LinkRabattNeu').hide(); }
-
-    } );
-
-
+    }
+
+    function wpsg_view_orderdata_hide() {
+    	jQuery('#LinkGutscheinNeu').hide();
+        jQuery('#LinkRabattNeu').hide();
+        jQuery('#LinkProduktNeu').hide();
+        jQuery('#LinkSendMail').hide();
+    }
+    
     var Modul2 = {
     	    eigenschaft : "wert",
