Index: /changelog
===================================================================
--- /changelog	(revision 7855)
+++ /changelog	(revision 7856)
@@ -425,4 +425,5 @@
 - Feature: Template je Variante fÃŒr Downloadplus anpassbar
 - Feature: parallele Erstellung eines Dokumentes ohne Vorlage (Briefbogenfunktion)
+- Feature: Stornieren einer Rechnug Ã€ndert den Bestellstatus der Bestellung auf Storniert
 - Feature: Globale Bilder in globalen Variationen
 - Bugfix: Anzeige von Name/Titel in den Passwort Vergessen Mails
Index: /mods/wpsg_mod_rechnungen.class.php
===================================================================
--- /mods/wpsg_mod_rechnungen.class.php	(revision 7855)
+++ /mods/wpsg_mod_rechnungen.class.php	(revision 7856)
@@ -356,6 +356,5 @@
 		} // public function settings_edit()
 		
-		public function order_view($order_id, &$arSidebarArray)
-		{
+		public function order_view($order_id, &$arSidebarArray) {
 			
 			$oOrder = wpsg_order::getInstance($order_id);
@@ -1207,8 +1206,9 @@
 		} // public function setOrderStatus($order_id, $status_id, $inform)
 		
-		public function stornoAction()
-		{
-
-			$order_data = $this->shop->cache->loadOrder($_REQUEST['edit_id']);
+		public function stornoAction() {
+
+			$order_id = intval($_REQUEST['edit_id']);
+
+			$order_data = $this->shop->cache->loadOrder($order_id);
 			
 			// Wurde die Bestellung in einer anderen Sprache gemacht
@@ -1219,5 +1219,5 @@
 			
 			// Rechnung laden die storniert werden soll
-			$rechnung = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_RECHNUNGEN."` WHERE `o_id` = '".wpsg_q($_REQUEST['edit_id'])."' AND `storno` = '0000-00-00 00:00:00'");
+			$rechnung = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_RECHNUNGEN."` WHERE `o_id` = '".wpsg_q($order_id)."' AND `storno` = '0000-00-00 00:00:00'");
 
 			// Letzte Rechnungsnummer
@@ -1230,5 +1230,5 @@
 					`storno` = '0000-00-00 00:00:00' AND 
 					`rnr` != '' AND
-					`o_id` = '".wpsg_q($_REQUEST['edit_id'])."'
+					`o_id` = '".wpsg_q($order_id)."'
 			"); 
 						
@@ -1236,7 +1236,6 @@
 			else $bPreview = false;
 			
-			if (!$bPreview)
-			{
-			
+			if (!$bPreview) {
+
 				$this->db->UpdateQuery(
 					WPSG_TBL_RECHNUNGEN,
@@ -1246,7 +1245,8 @@
 					"`o_id` = '".wpsg_q($_REQUEST['edit_id'])."' AND `gnr` = ''"
 				);
-							
-				if (isset($_REQUEST['wpsg_rechnungen_gutschrift']) && ($_REQUEST['wpsg_rechnungen_gutschrift'] == "0"))
-				{
+
+				$this->shop->setOrderStatus($order_id, wpsg_ShopController::STATUS_STORNIERT, false);
+
+				if (isset($_REQUEST['wpsg_rechnungen_gutschrift']) && ($_REQUEST['wpsg_rechnungen_gutschrift'] == "0")) {
 				
 					// Status der Bestellung auf storniert Ã€ndern
@@ -1257,6 +1257,5 @@
 			}
 			
-			if (isset($_REQUEST['wpsg_rechnungen_gutschrift']) && ($_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")) {
  									
 				// Gutschriftnummer bilden
@@ -1279,6 +1278,5 @@
 				$gnr = $this->shop->replaceUniversalPlatzhalter($gnr, $_REQUEST['edit_id']);
 				
-				if (!$bPreview)
-				{
+				if (!$bPreview) {
 				
 					$g_id = $this->db->ImportQuery(WPSG_TBL_RECHNUNGEN, array(
@@ -1292,7 +1290,5 @@
 					$this->shop->update_option("wpsg_gutschrift_start", ($gnr_nr + 1));
 					
-				}
-				else
-				{
+				} else {
 									
 					$g_id = $gnr_nr;
@@ -1302,6 +1298,5 @@
 				$this->writeGutschrift($_REQUEST['edit_id'], $g_id, $storno_fee, $bPreview);
 				
-				if ($_REQUEST['wpsg_rechnungen_gutschrift'] == "2")
-				{
+				if ($_REQUEST['wpsg_rechnungen_gutschrift'] == "2") {
 												
 					// Mail an Kunden senden
@@ -1311,12 +1306,9 @@
 					$mail_text = $this->shop->render(WPSG_PATH_VIEW."/mods/mod_rechnungen/accountingmail.phtml", false);
 
-					if ($this->shop->get_option('wpsg_htmlmail') == '1')
-					{
+					if ($this->shop->get_option('wpsg_htmlmail') == '1') {
 						
 						$mail_html = $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_rechnungen/accountingmail_html.phtml', false);
 						
-					}
-					else
-					{
+					} else {
 						
 						$mail_html = false;
@@ -1324,6 +1316,5 @@
 					}
 					
-					if (!$bPreview) 
-					{
+					if (!$bPreview) {
 
 						$file = $this->getFilePath($_REQUEST['edit_id']).'/'.$g_id.'.pdf';						
@@ -1553,6 +1544,5 @@
 		 * Gibt false (Wenn keine Rechnung aktiv) oder den Datensatz der aktuellen Rechnung zurÃŒck
 		 */
-		public function getOrderInvoice($order_id)
-		{
+		public function getOrderInvoice($order_id) {
 			
 			$invoice_db = $this->db->fetchRow("
@@ -1571,6 +1561,5 @@
 			");
 			
-			if ($invoice_db['id'] > 0)
-			{
+			if (!wpsg_isSizedArray($invoice_db) || $invoice_db['id'] > 0) {
 				
 				return $invoice_db;
