Index: /controller/wpsg_BasketController.class.php
===================================================================
--- /controller/wpsg_BasketController.class.php	(revision 8007)
+++ /controller/wpsg_BasketController.class.php	(revision 8010)
@@ -256,4 +256,11 @@
 				$this->shop->basket->initFromSession();
 				
+				// Basket muss aufgebaut sein
+				$this->shop->checkShippingAvailable();
+				$this->shop->checkPaymentAvailable();            
+				$this->shop->checkCustomerPreset();
+				
+				\wpsg\wpsg_calculation::getSessionCalculation()->update();
+				
 				// Wenn keine Produkte drin sind, dann mit Fehlermeldung zum Warenkorb leiten
 				$temp = $this->shop->basket->getProductIDs();
@@ -286,5 +293,5 @@
 					
 				}
-				
+		 
 				$this->shop->view['pflicht'] = $this->shop->loadPflichtFeldDaten();
 				
@@ -293,8 +300,5 @@
 
 				$this->shop->view['basket'] = $this->shop->basket->toArray();
-				
-				$this->shop->checkShippingAvailable();
-				$this->shop->checkPaymentAvailable();
-
+								
 				if (!isset($this->shop->arShipping[$this->shop->view['basket']['checkout']['shipping']]) || !isset($this->shop->arShipping[$this->shop->view['basket']['checkout']['payment']])) {
 					
Index: /lib/wpsg_basket.class.php
===================================================================
--- /lib/wpsg_basket.class.php	(revision 8007)
+++ /lib/wpsg_basket.class.php	(revision 8010)
@@ -958,6 +958,5 @@
 		 * ÃberprÃŒft die Korrektheit der Kunden- und Bestelldaten
 		 */
-		public function checkCheckout($state = true)
-		{
+		public function checkCheckout($state = true) {
 			
 			$bError = false;
Index: /lib/wpsg_calculation.class.php
===================================================================
--- /lib/wpsg_calculation.class.php	(revision 8007)
+++ /lib/wpsg_calculation.class.php	(revision 8010)
@@ -1305,5 +1305,5 @@
 				
 			}
-
+			 
 			// Shipping 
 			if (isset($_SESSION['wpsg']['checkout']['shipping']) && array_key_exists($_SESSION['wpsg']['checkout']['shipping'], $this->shop->arShipping)) {
Index: /model/wpsg_exception.class.php
===================================================================
--- /model/wpsg_exception.class.php	(revision 8007)
+++ /model/wpsg_exception.class.php	(revision 8010)
@@ -61,4 +61,6 @@
 		public static function getSanitizeException() {
         	
+			debug_print_backtrace();
+			
         	return new \Exception('Parameterfehler');
         	
Index: /model/wpsg_product.class.php
===================================================================
--- /model/wpsg_product.class.php	(revision 8007)
+++ /model/wpsg_product.class.php	(revision 8010)
@@ -757,5 +757,5 @@
 		 */
 		public static function find($arFilter = array(), $load = true) {
-
+ 
 			list($strQuerySELECT, $strQueryWHERE, $strQueryJOIN, $strQueryHAVING, $strQueryORDER) = self::getQueryParts($arFilter);
 
@@ -791,5 +791,5 @@
 
 			// Wenn ich die nicht kaufbaren Produkte rausfiltern will, kann ich es nicht auf einen DB Query beschrÃ€nken, da ich die Module anfragen muss
-			//if (wpsg_isSizedInt($arFilter['hideNotBuyable'])) $force_load = true;
+			if (wpsg_isSizedInt($arFilter['hideNotBuyable'])) $force_load = true;
 
 			foreach ($arID as $id) {
@@ -799,5 +799,5 @@
 					$arReturn[$id] = self::getInstance($id);
 
-					//if (wpsg_isSizedInt($arFilter['hideNotBuyable']) && !$arReturn[$id]->canOrder()) { unset($arReturn[$id]); continue; }
+					if (wpsg_isSizedInt($arFilter['hideNotBuyable']) && !$arReturn[$id]->canOrder()) { unset($arReturn[$id]); continue; }
 
 					// StandardmÃ€Ãig werden nicht anzeigbare Produkte ausgeblendet
Index: /mods/mod_rechnungen/wpsg_invoice.php
===================================================================
--- /mods/mod_rechnungen/wpsg_invoice.php	(revision 8007)
+++ /mods/mod_rechnungen/wpsg_invoice.php	(revision 8010)
@@ -50,6 +50,20 @@
 			
 		}
+
+		public function getDate($format = null) {
+			
+			if ($format === null) return $this->__get('datum');
+			else if ($format === true) return $this->getDate('d.m.Y H:i:s');
+			else return date($format, strtotime($this->__get('datum')));
+			
+		}
 		
-		public function getNr($bLink = false) {
+		/**
+		 * @param bool $bLink
+		 * @param \wpsg_order_product $oOrderProduct
+		 *
+		 * @return string
+		 */
+		public function getNr($bLink = false, $oOrderProduct = null) {
 			
 			$strReturn = '';
@@ -57,5 +71,7 @@
 			if ($bLink) {
 				
-				$strReturn .= '<a class="link_invoice '.(($this->isStorno())?'bg_storno':'').' '.(($this->isInvoice())?'bg_invoice':'').'" href="';
+				$strTitle = wpsg_translate(__('Erstellt am #1#', 'wpsg'), wpsg_formatTimestamp(strtotime($this->__get('datum'))));
+				
+				$strReturn .= '<a title="'.$strTitle.'" class="link_invoice '.(($this->isStorno())?'bg_storno':'').' '.(($this->isInvoice())?'bg_invoice':'').'" href="';
 				$strReturn .= wp_nonce_url(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&action=ajax&noheader=1&mod=wpsg_mod_rechnungen&do=getRechnung&edit_id='.$this->getOrder()->getId().'&r_id='.$this->getId(), 'wpsg-mod_invoice-order_ajax-getRechnung-'.$this->getId());
 				$strReturn .= '" target="_blank">';
@@ -65,4 +81,23 @@
 			if ($this->isInvoice()) $strReturn .= 'R '.$this->__get('rnr');
 			else if ($this->isStorno()) $strReturn .= 'RK '.$this->__get('gnr');
+			
+			if ($oOrderProduct !== null) {
+				
+				$invoice_data = json_decode($oOrderProduct->getMeta('wpsg_mod_rechnungen_data', false, 'null'), true);
+				if ($invoice_data !== null) {
+					
+					foreach ($invoice_data as $id) {
+						
+						if ($id['invoice_id'] === $this->getId()) {
+							
+							$strReturn .= ' <span title="'.wpsg_translate(__('#1# StÃŒck enthalten', 'wpsg'), $id['amount']).'">('.$id['amount'].')</span>';
+							
+						}
+						
+					}
+					
+				}
+				
+			}
 			
 			if ($bLink) {
Index: /mods/wpsg_mod_rechnungen.class.php
===================================================================
--- /mods/wpsg_mod_rechnungen.class.php	(revision 8007)
+++ /mods/wpsg_mod_rechnungen.class.php	(revision 8010)
@@ -1091,4 +1091,19 @@
 			}
 			
+			if (!$bPreview) {
+				
+				$oInvoice = \wpsg\wpsg_invoice::getInstance($gnr_id);
+				
+				$oInvoice->setMeta('basket_data', json_encode($this->shop->view['basket']));
+				$oInvoice->setMeta('version', '2');
+			
+				if (($_REQUEST['storno_shippay']??'0') === '1') {
+				
+					$oInvoice->setMeta('include_shipping', '1');
+									
+				}
+				
+			}
+			
 			if (($_REQUEST['storno_shippay']??'0') === '1') {
 				
@@ -1107,4 +1122,19 @@
 		
 		public function writeRechnung($order_id, $preview, $bOutput = true) {
+			
+			$bOK = false;
+			
+			// PrÃŒfen das Produkte gesetzt sind
+			foreach ($_REQUEST['invoice_products']??[] as $order_product_id => $order_product_info) {
+			
+				if ($order_product_info['set'] === '1') {
+					
+					$bOK = true;
+					
+				}
+				
+			}
+			
+			if (!$bOK) throw new \Exception(__('Kein Produkt ausgewÃ€hlt!', 'wpsg'));
 			
 			$this->shop->view['output'] = $bOutput;
@@ -1309,5 +1339,7 @@
 				
 				$oInvoice = \wpsg\wpsg_invoice::getInstance($r_id);
+				
 				$oInvoice->setMeta('basket_data', json_encode($this->shop->view['basket']));
+				$oInvoice->setMeta('version', '2');
 				
 				if (($_REQUEST['wpsg_rechnungen_shippay']??'0') === '1') {
@@ -1421,4 +1453,19 @@
 		public function stornoAction() {
 			
+			$bOK = false;
+			
+			// PrÃŒfen das Produkte gesetzt sind
+			foreach ($_REQUEST['storno_products']??[] as $order_product_id => $order_product_info) {
+			
+				if ($order_product_info['set'] === '1') {
+					
+					$bOK = true;
+					
+				}
+				
+			}
+			
+			if (!$bOK) throw new \Exception(__('Kein Produkt ausgewÃ€hlt!', 'wpsg'));
+			
 			$order_id = intval($_REQUEST['edit_id']);
 			$order_data = $this->shop->cache->loadOrder($order_id);
@@ -1464,5 +1511,5 @@
 					"storno_fee" => wpsg_q($storno_fee)
 				));
-				
+												
 				$this->shop->update_option("wpsg_gutschrift_start", ($gnr_nr + 1));
 				
@@ -1498,6 +1545,8 @@
 					$file = $this->copyTemp($file, $gnr);
 				
+					$to = $_REQUEST['storno_mail'];
+					
 					$arFiles = array($file);						
-					$this->shop->sendMail($mail_text, $this->shop->view['kunde']['email'], 'accountingmail', $arFiles, false, false, $mail_html);
+					$this->shop->sendMail($mail_text, $to, 'accountingmail', $arFiles, false, false, $mail_html);
 				
 					// TemporÃ€re Rechnung lÃ¶schen
@@ -1508,6 +1557,5 @@
 				$this->shop->restoreTempLocale();
 				
-				if ($bPreview) $subject = wpsg_translate(__('Rechnungskorrekturmail an #1# (Vorschau)', 'wpsg'), $this->shop->view['kunde']['email']);
-				else {
+				if (!$bPreview) {
 					
 					$subject = wpsg_translate(__('Rechnungskorrekturmail an #1#', 'wpsg'), $this->shop->view['kunde']['email']);
@@ -1543,5 +1591,5 @@
 		 * @param wpsg_order_product $oOrderProduct
 		 */
-		private function getAmountToStorno($oOrderProduct) {
+		public function getAmountToStorno($oOrderProduct) {
 			
 			$invoice_data = json_decode($oOrderProduct->getMeta('wpsg_mod_rechnungen_data', false, 'null'), true);
@@ -1634,5 +1682,5 @@
 		 * @param wpsg_order_product $oOrderProduct
 		 */
-		private function getAmountToInvoice($oOrderProduct) {
+		public function getAmountToInvoice($oOrderProduct) {
 			
 			$invoice_data = json_decode($oOrderProduct->getMeta('wpsg_mod_rechnungen_data', false, 'null'), true);
@@ -2073,4 +2121,19 @@
  			$customer_data = $this->shop->cache->loadKunden($order_data['k_id']);
  			
+			$oOrder = wpsg_order::getInstance($order_id);
+			 
+			$_REQUEST['invoice_products'] = [];
+			$_REQUEST['wpsg_rechnungen_datum'] = date('Y-m-d');
+			
+			// Komplettauswahl simulieren
+		    foreach ($oOrder->getOrderProducts() as $oOrderProduct) {
+				
+				$_REQUEST['invoice_products'][$oOrderProduct->getId()] = [
+					'set' => '1',
+					'amount' => $oOrderProduct->getAmount()
+				];
+				
+		    }
+			 
  			$_REQUEST['wpsg_rechnungen_sendmail'] = '1';
  			//$_REQUEST['wpsg_rechnungen_email'] = wpsg_q($customer_data['email']);
@@ -2078,5 +2141,4 @@
  			$_REQUEST['wpsg_rechnungen_fusstext'] = '';
  			$_REQUEST['wpsg_rechnungen_faelligkeit'] = '0';
- 			$_REQUEST['wpsg_rechnungen_datum'] = date('d.m.Y');
  			$_REQUEST['wpsg_rechnungen_status'] = '1';
 			$_REQUEST['wpsg_rechnungen_status_neu'] = '110';
Index: /views/js/admin.js
===================================================================
--- /views/js/admin.js	(revision 8007)
+++ /views/js/admin.js	(revision 8010)
@@ -109,4 +109,6 @@
 		
 		var aktTab = 1;
+		
+		if (options.aktTab) aktTab = options.aktTab; 
 		
 		if (jQuery.cookie(options['cookiename']) != null && jQuery.cookie(options['cookiename']) > 0)
Index: /views/mods/mod_rechnungen/order_view.phtml
===================================================================
--- /views/mods/mod_rechnungen/order_view.phtml	(revision 8007)
+++ /views/mods/mod_rechnungen/order_view.phtml	(revision 8010)
@@ -6,304 +6,52 @@
 
 ?>
-
-<script type="text/javascript">
-
-	function wpsg_mod_rechnungen_storno()
-	{
-
-		if (jQuery('#wpsg_rechnungen_gutschrift1').attr('checked') || jQuery('#wpsg_rechnungen_gutschrift2').attr('checked'))
-		{
-
-			window.setTimeout(function() { 
-				location.href = '<?php 
-				
-					echo wpsg_admin_url('Order', 'view', ['edit_id' => $this->view['data']['id']]); 
-					
-				?>'; 
-			}, 1000);
-
-		}
-
-		return true;
-
-	}
-
-	jQuery(document).ready(function() { 
-		
-		jQuery("#wpsg_rechnungen_postbox_title").bind("click", function() { 
-			if (jQuery(this.parentNode).hasClass("closed"))
-			{
-			
-				jQuery.cookie("wpsg_rechnungen_field", "0", { expires: 999999 } );
-			
-			}
-			else
-			{
-			
-				jQuery.cookie("wpsg_rechnungen_field", "1", { expires: 999999 } );
-			
-			}
-		} );
-	
-		if (jQuery.cookie("wpsg_rechnungen_field") == "1")
-		{
-		
-			jQuery("#wpsg_rechnungen_postbox").removeClass("closed");
-		}
-
-		jQuery('.wpsg_rechnungen_gutschrift').bind('change', function() {
-
-			if (jQuery('#wpsg_rechnungen_gutschrift1').prop('checked') || jQuery('#wpsg_rechnungen_gutschrift2').prop('checked'))
-			{
-
-				jQuery('#wpsg_mod_rechnungen_fee_layer').show();
-				jQuery('#wpsg_mod_rechnungen_stornopreview').show();
-				jQuery('#wpsg_rechnungen_stornobutton').attr('value', '<?php echo __('Rechnungskorrektur erstellen', 'wpsg'); ?>');
-				
-			}
-			else
-			{
-
-				jQuery('#wpsg_mod_rechnungen_fee_layer').hide();
-				jQuery('#wpsg_mod_rechnungen_stornopreview').hide();
-				jQuery('#wpsg_rechnungen_stornobutton').attr('value', '<?php echo __('Rechnung stornieren', 'wpsg'); ?>');
-				
-			}
-			
-		} );
-
-		jQuery('#wpsg_rechnungen_gutschrift0').change();
-		
-	} );
-
-</script>
-
-<?php echo wpsg_drawForm_AdminboxStart(__('Rechnungen', 'wpsg'));  ?>
-
-    <?php if (sizeof($this->view['mod_rechnungen']['arRechnungen']) == 0 && sizeof($this->view['mod_rechnungen']['arRechnungen_storno']) == 0) { ?>
+ 
+<div id="wpsg_mod_rechnungen_order_view">
+    
+    <?php echo wpsg_drawForm_AdminboxStart(__('Rechnungen', 'wpsg'));  ?>
+    
+        <?php if (sizeof($this->view['mod_rechnungen']['arRechnungen']) == 0 && sizeof($this->view['mod_rechnungen']['arRechnungen_storno']) == 0) { ?>
+            
         <p><?php echo __('Bisher keine Rechnungen geschrieben.', 'wpsg'); ?></p>
-    <?php } else { ?>
-        <table>
-            <?php foreach ($this->view['mod_rechnungen']['arRechnungen_gesamt'] as $r) { ?>
-            <tr>
-                <td>#<?php echo (($r['rnr'] != '')?$r['rnr']:$r['gnr']); ?>
-
-                    <?php if ($r['storno'] == "0000-00-00 00:00:00") { ?>
-                        <?php if ($r['gnr'] != "") { ?>
-                            <?php echo wpsg_translate(__('Rechnungskorrektur vom #1#', 'wpsg'), date("d.m.Y", $r['ts_datum'])); ?>
-                        <?php } else { ?>
-                            <?php echo wpsg_translate(__('Rechnung geschrieben am #1#', 'wpsg'), date("d.m.Y", $r['ts_datum'])); ?>
-                        <?php } ?>
-                    <?php } else { ?>
-                        <?php echo wpsg_translate(__("Rechnung storniert am #1#", "wpsg"), date("d.m.Y", $r['ts_storno'])); ?>
-                    <?php } ?>
-
-                </td>
-                <td style="text-align:right;">
-
-                    <?php
-
-                        if ($r['rnr'] != "")
-                        {
-                            $rfile = $this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($this->view['data']['id'], true)).'R'.$r['rnr'].'.pdf';
-                        }
-                        else if ($r['gnr'] != "")
-                        {
-                            $rfile = $this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($this->view['data']['id'], true)).'G'.$r['gnr'].'.pdf';
-                        }
-
+        
+        <?php } else { ?>
+            
+            <div class="grid">
+            
+                <?php foreach ($this->view['mod_rechnungen']['arRechnungen_gesamt'] as $r) { 
+                    
+                    $oInvoice = \wpsg\wpsg_invoice::getInstance($r['id']);
+                    
                     ?>
-
-                    <a target="_blank" onclick="if (!confirm('<?php echo __('Sind Sie sicher, dass Sie eine Kopie dieser Rechnung/Rechnungskorrektur erneut an den Kunden senden mÃ¶chten?', 'wpsg'); ?>')) return false;" href="<?php 
-						
-						echo wp_nonce_url(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&mod=wpsg_mod_rechnungen&noheader=1&action=ajax&edit_id='.$this->view['data']['id'].'&r_id='.$r['id'].'&do=copy', 'wpsg-mod_invoice-order_ajax-copy-'.$this->view['data']['id']);
-
-					?>"><?php echo ' &nbsp;'.__("Kopie senden", "wpsg"); ?></a>&nbsp;
-                    <a target="_blank" href="<?php 
-						
-						echo wp_nonce_url(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&action=ajax&noheader=1&mod=wpsg_mod_rechnungen&do=getRechnung&edit_id='.$this->view['data']['id'].'&r_id='.$r['id'], 'wpsg-mod_invoice-order_ajax-getRechnung-'.$r['id']);						
-						
-					?>"><?php echo __("Ansehen", "wpsg"); ?></a>
-
-                </td>
-            </tr>
-            <?php } ?>
-        </table>
-        <br />
-    <?php } ?>
-
-    <?php if (sizeof($this->view['mod_rechnungen']['arRechnungen']) > 0 && sizeof($this->view['mod_rechnungen']['arRechnungen_gesamt']) != sizeof($this->view['mod_rechnungen']['arRechnungen_storno'])) { ?>
-        <fieldset style="border:0px solid #999999; width:100%;">
-            <legend ><?php echo __("Bestellstorno: Rechnungskorrektur erstellen", "wpsg"); ?></legend>
-            <div style="padding:10px;">
-                <form id="storno_form" target="_blank" method="post" action="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&noheader=1&action=ajax&mod=wpsg_mod_rechnungen&edit_id=<?php echo $this->view['data']['id']; ?>&do=storno">
-	
-					<?php \wp_nonce_field('wpsg-mod_invoice-order_ajax-storno-'.$this->view['data']['id']); ?>
-					
-                    <input type="hidden" name="send" value="1" />
-
-                    <label><input onclick="jQuery.cookie('wpsg_rechnungen_stornoradio', '0');" type="radio" value="0" class="wpsg_rechnungen_gutschrift" id="wpsg_rechnungen_gutschrift0" name="wpsg_rechnungen_gutschrift" />&nbsp;<?php echo __("Rechnung komplett stornieren und keine Rechnungskorrektur erstellen.", "wpsg"); ?></label><br />
-                    <label><input onclick="jQuery.cookie('wpsg_rechnungen_stornoradio', '1');" type="radio" value="1" class="wpsg_rechnungen_gutschrift" id="wpsg_rechnungen_gutschrift1" name="wpsg_rechnungen_gutschrift" />&nbsp;<?php echo __("Rechnungskorrektur erstellen.", "wpsg"); ?></label><br />
-                    <label><input onclick="jQuery.cookie('wpsg_rechnungen_stornoradio', '2');" type="radio" value="2" class="wpsg_rechnungen_gutschrift" id="wpsg_rechnungen_gutschrift2" name="wpsg_rechnungen_gutschrift" />&nbsp;<?php echo __("Rechnungskorrektur erstellen und an Kunden senden.", "wpsg"); ?></label><br />
-
-                    <div id="wpsg_mod_rechnungen_fee_layer" style="display:none;">
-                        <?php echo wpsg_drawForm_Input('wpsg_mod_rechnungen_fee', __('GebÃŒhr fÃŒr Rechnungskorrektur', 'wpsg'), ''); ?>
+                    
+                    <div>
+                        <?php echo $oInvoice->getDate(true); ?>
                     </div>
-
-                    <div class="wpsg_clear"></div><br />
-
-                    <br />
-
-                    <?php echo wpsg_drawForm_Select('wpsg_mod_rechnungen_new_state', __('Neuer Bestellstatus', 'wpsg'), ['-1' => __('Keine Ãnderung', 'wpsg')] + $this->arStatus, wpsg_ShopController::STATUS_STORNIERT); ?>
-
-                    <br />
-
-                    <input onclick="return wpsg_mod_rechnungen_storno();" id="wpsg_rechnungen_stornobutton" class="button" type="submit" name="form_submit" value="<?php echo __("Stornieren", "wpsg"); ?>" style="float:right;" />
-                    <input id="wpsg_mod_rechnungen_stornopreview" class="button" type="submit" name="form_submit_preview" value="<?php echo __('Vorschau', 'wpsg'); ?>" style="float:right; margin-right:10px;" />
-
-                    <script type="text/javascript">
-
-                        jQuery(document).ready(function() {
-
-                            jQuery("[name=wpsg_rechnungen_gutschrift]").filter("[value=" + jQuery.cookie("wpsg_rechnungen_stornoradio") + "]").prop("checked","checked");
-
-                            jQuery("#wpsg_rechnungen_stornobutton").bind("click", function() {
-
-                                if (jQuery("#wpsg_rechnungen_gutschrift1").prop("checked") || jQuery("#wpsg_rechnungen_gutschrift2").prop("checked"))
-                                {
-
-                                    //jQuery("#storno_form").attr("action", "<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&noheader=1&action=ajax&mod=wpsg_mod_rechnungen&edit_id=<?php echo $this->view['data']['id']; ?>&do=storno");
-                                    jQuery("#storno_form").attr("target", "_blank");
-
-                                    window.setTimeout(function() {
-                                        location.href = "<?php 
-											
-											echo wpsg_admin_url('Order', 'view', ['edit_id' => $this->view['data']['id']]); 
-											
-										?>";
-                                    }, 1500);
-
-                                }
-                                else
-                                {
-
-                                    //jQuery("#storno_form").attr("action", "<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_rechnungen&edit_id=<?php echo $this->view['data']['id']; ?>&do=storno");
-                                    jQuery("#storno_form").attr("target", "");
-
-                                }
-
-                            });
-
-                        });
-
-                    </script>
-
-                </form>
-
-                <div class="wpsg_clear"></div><br />
-
-                <div class="wpsg_hinweis"><?php echo __("Eine neue Rechnung kann erst geschrieben werden wenn alle bestehenden Rechnungen zu dieser Bestellung storniert wurden.", "wpsg"); ?></div>
-                <div class="wpsg_clear"></div>
+                    <div>
+                        <?php echo $oInvoice->getNr(true); ?>
+                    </div>
+                    <div style="text-align:right;">
+                        
+                        <a target="_blank" onclick="if (!confirm('<?php echo __('Sind Sie sicher, dass Sie eine Kopie dieser Rechnung/Rechnungskorrektur erneut an den Kunden senden mÃ¶chten?', 'wpsg'); ?>')) return false;" href="<?php 
+                            
+                            echo wp_nonce_url(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&mod=wpsg_mod_rechnungen&noheader=1&action=ajax&edit_id='.$this->view['data']['id'].'&r_id='.$r['id'].'&do=copy', 'wpsg-mod_invoice-order_ajax-copy-'.$this->view['data']['id']);
+    
+                        ?>"><?php echo ' &nbsp;'.__("Kopie senden", "wpsg"); ?></a>&nbsp; 
+                        
+                    </div>
+                    
+                <?php } ?>
+                
             </div>
-        </fieldset>
-    <?php } else { ?>
-
-        <fieldset>
-            <legend><?php echo __("Neue Rechnung", "wpsg"); ?></legend>
-
-            <div>
-
-                <form target="_blank" method="post" id="rechnungen_order_backend" action="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_rechnungen&cmd=rechnung&noheader=1&edit_id=<?php echo $this->view['data']['id']; ?>">
-	
-					<?php \wp_nonce_field('wpsg-mod_invoice-order_ajax-rechnung-'.$this->view['data']['id']); ?>
-					
-                    <input type="hidden" name="send" value="1" />
-
-                    <label style="height:25px; width:240px; float:left; margin-top:10px;">
-                        <input onchange="if (this.checked) jQuery('#wpsg_rechnungen_email').show(); else jQuery('#wpsg_rechnungen_email').hide();" type="checkbox" checked="checked" value="1" name="wpsg_rechnungen_sendmail" />
-                        &nbsp;<?php echo __("E-Mail an Kunden senden", "wpsg"); ?>
-                    </label>
-                    <input type="text" style="display:block; width:300px; float:right;" id="wpsg_rechnungen_email" name="wpsg_rechnungen_email" value="<?php echo wpsg_hspc($this->view['data']['email']); ?>" />
-                    <div style="clear:both; width:100%; height:5px;"></div>
-
-                    <label style="height:25px; width:240px; float:left;">
-                        <input checked="checked"  onchange="if (this.checked) jQuery('#wpsg_rechnungen_faelligkeitsdatum').show(); else jQuery('#wpsg_rechnungen_faelligkeitsdatum').hide();" type="checkbox" value="1" name="wpsg_rechnungen_faelligkeit" />
-                        &nbsp;<?php echo __("FÃ€lligkeit anzeigen", "wpsg"); ?>
-                    </label>
-                    <input type="text" style="display:block; width:300px; float:right;" id="wpsg_rechnungen_faelligkeitsdatum" name="wpsg_rechnungen_faelligkeitsdatum" value="<?php echo @date("d.m.Y", time() + ($this->get_option("wpsg_rechnungen_faelligkeit") * 86400)); ?>" />
-                    <div style="clear:both; width:100%; height:5px;"></div>
-
-                    <label style="height:25px; width:220px; float:left;">
-                        <input checked="checked" onchange="if (this.checked) jQuery('#wpsg_rechnungen_status').show(); else jQuery('#wpsg_rechnungen_status').hide();" type="checkbox" value="1" name="wpsg_rechnungen_status" />
-                        &nbsp;<?php echo __("Neuer Status", "wpsg"); ?>
-                    </label>
-                    <select style="width:300px; float:right;" id="wpsg_rechnungen_status_neu" name="wpsg_rechnungen_status_neu">
-                        <?php foreach ($this->arStatus as $k => $v) { ?>
-                        <option value="<?php echo $k; ?>" <?php echo (($k == 110)?'selected="selected"':''); ?>><?php echo $v; ?></option>
-                        <?php } ?>
-                    </select>
-                    <div style="clear:both; width:100%; height:5px;"></div>
-
-                    <label style="height:25px; width:240px; float:left;">
-                        <input <?php echo (($this->get_option("wpsg_rechnungen_url_std") === "1")?'checked="checked"':''); ?> type="checkbox" value="1" name="wpsg_rechnungen_url" />
-                        &nbsp;<?php echo __("URL Benachrichtigung", "wpsg"); ?>
-                    </label>
-                    <div style="clear:both; width:100%; height:5px;"></div>
-
-                    <label style="height:25px; width:240px; float:left; padding-left:22px;">
-                        <?php echo __("Rechnungsdatum", "wpsg"); ?>
-                    </label>
-                    <input style="display:block;float:right; width:300px;" type="text" id="wpsg_rechnungen_datum" name="wpsg_rechnungen_datum" value="<?php echo date("d.m.Y", time()); ?>" />
-                    <div style="clear:both; width:100%; height:5px;"></div>
-
-                    <label for="wpsg_rechnungen_fusstext" style="height:25px; width:220px; padding-left:22px; float:left">
-                        <?php echo __("FuÃtext", "wpsg"); ?>
-                    </label>
-
-                    <?php
-
-                        $wpsg_rechnungen_footer = $this->get_option("wpsg_rechnungen_footer");
-                        
-                        if (!is_array($wpsg_rechnungen_footer)) $wpsg_rechnungen_footer = unserialize($this->get_option("wpsg_rechnungen_footer"));
-                        if (!is_array($wpsg_rechnungen_footer)) $wpsg_rechnungen_footer = Array();
-
-                        $default = $this->get_option('wpsg_rechnungen_foottext_standard');
-                         
-                    ?>
-
-                    <?php if (sizeof($wpsg_rechnungen_footer) > 0) { ?>
-                    <select style="width:300px; float:right;" id="wpsg_rechnungen_select" onchange="jQuery('#wpsg_rechnungen_fusstext').val(this.value);">
-                        <?php foreach ($wpsg_rechnungen_footer as $k => $v) { ?>
-                        <option value="<?php echo wpsg_hspc($v[1]); ?>" <?php echo ((intval($default) === intval($k))?'selected="selected"':''); ?>><?php echo wpsg_hspc($v[0]); ?></option>
-                        <?php } ?>
-                    </select>
-                    <?php } ?>
-
-                    <div style="clear:both; width:100%; height:5px;"></div>
-                    <div style="padding-left:25px;"><input style="width:100%;" type="text" name="wpsg_rechnungen_fusstext" id="wpsg_rechnungen_fusstext" value="" /></div>
-                    <div style="clear:both; width:100%; height:15px;"></div>
-
-                    <script type="text/javascript">
-
-                        jQuery(document).ready(function() {
-                            jQuery('#wpsg_rechnungen_fusstext').val(jQuery("#wpsg_rechnungen_select").val());
-                        });
-
-                    </script>
-
-                    <input class="button" style="float:right;" onclick="window.setTimeout(function() { location.href = '<?php
-	
-						echo wpsg_admin_url('Order', 'view', ['edit_id' => $this->view['data']['id']]); 
-						
-					?>'; }, 1000);" name="wpsg_rechnungen_write" type="submit" value="<?php echo __("Rechnung schreiben", "wpsg"); ?>" />
-                    <input class="button" style="float:right; margin-right:10px;" name="wpsg_rechnungen_preview" type="submit" value="<?php echo __("Vorschau", "wpsg"); ?>" />
-
-                    <div style="clear:both; width:100%; height:5px;"></div>
-
-                </form>
-            </div>
-        </fieldset>
-
-    <?php } ?>
-
-<?php echo wpsg_drawForm_AdminboxEnd(); ?>
+              
+        <?php } ?>
+     
+    <?php echo wpsg_drawForm_AdminboxEnd(); ?>
+    
+</div>
+    
+<style>
+    
+    #wpsg_mod_rechnungen_order_view .grid { display:grid; width:100%; grid-template-columns:150px 1fr 100px; row-gap:0.25rem; }
+    
+</style>
Index: /views/mods/mod_rechnungen/order_view_orderdata_after.phtml
===================================================================
--- /views/mods/mod_rechnungen/order_view_orderdata_after.phtml	(revision 8007)
+++ /views/mods/mod_rechnungen/order_view_orderdata_after.phtml	(revision 8010)
@@ -24,4 +24,33 @@
     $default = $this->get_option('wpsg_rechnungen_foottext_standard');
     
+    /** @var \wpsg\wpsg_invoice[] $arInvoice */
+    $arInvoice = $this->callMod('wpsg_mod_rechnungen', 'getInvoiceToOrder', [$oOrder->getId()]);
+
+    $bCanInvoice = false;
+    $bCanStorno = false;
+    
+    foreach ($oOrder->getOrderProducts() as $oOrderProduct) {
+        
+        if ($this->callMod('wpsg_mod_rechnungen', 'getAmountToInvoice', [$oOrderProduct]) > 0) {
+            
+            $bCanInvoice = true; 
+            
+        }
+        
+        if ($this->callMod('wpsg_mod_rechnungen', 'getAmountToStorno', [$oOrderProduct]) > 0) {
+            
+            $bCanStorno = true;
+            
+        }
+        
+        if ($bCanInvoice && $bCanStorno) break;
+        
+    }
+    
+    $act = 0;
+    
+    if ($bCanInvoice) $act = 1;
+    else if ($bCanStorno) $act = 2;
+    
 ?>
 
@@ -30,181 +59,223 @@
     
     <ul class="nav nav-tabs" role="tablist">
-        <li role="presentation" class="tab akttab active" id="tab1"><a href="#tab1" role="tab" data-toggle="tab" class="bg_invoice"><?php echo __('Rechnung erstellen', 'wpsg'); ?></a></li>
-        <li role="presentation" class="tab" id="tab2"><a href="#tab2" role="tab" data-toggle="tab" class="bg_storno"><?php echo __('Gutschrift/Rechnungskorrektur erstellen', 'wpsg'); ?></a></li>
+        <?php if ($bCanInvoice) { ?>
+        <li role="presentation" class="tab <?php echo (($act === 1)?'akttab active':''); ?>" id="tab1"><a href="#tab1" role="tab" data-toggle="tab" class="bg_invoice"><?php echo __('Rechnung erstellen', 'wpsg'); ?></a></li>
+        <?php } ?>
+        <?php if ($bCanStorno) { ?>
+        <li role="presentation" class="tab <?php echo (($act === 2)?'akttab active':''); ?>" id="tab2"><a href="#tab2" role="tab" data-toggle="tab" class="bg_storno"><?php echo __('Gutschrift/Rechnungskorrektur erstellen', 'wpsg'); ?></a></li>
+        <?php } ?>
     </ul>
  
 	<div class="tab-content">
 		
-		<div role="tabpanel" class="tabcontent bg_invoice" id="tabcontent1">
-            
-            <form method="post" id="invoice_form" target="_blank" action="<?php 
+        <?php if ($bCanInvoice) { ?>
+            <div role="tabpanel" class="tabcontent bg_invoice" id="tabcontent1">
                 
-                echo WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_rechnungen&cmd=rechnung&noheader=1&edit_id='.$oOrder->getId(); 
+                <form method="post" id="invoice_form" target="_blank" action="<?php 
+                    
+                    echo WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_rechnungen&cmd=rechnung&noheader=1&edit_id='.$oOrder->getId(); 
+                    
+                ?>" class="grid">
+                    
+                    <?php \wp_nonce_field('wpsg-mod_invoice-order_ajax-rechnung-'.$this->view['data']['id']);
+                    
+                        $arInvoiceLabel = [];
+                        
+                        foreach ($arInvoice as $oInvoice) {
+                            
+                            if ($oInvoice->isInvoice() && $oInvoice->getMeta('include_shipping', false, '0') === '1') {
+                               
+                                $arInvoiceLabel[] = $oInvoice->getNr(true);    
+                                
+                            }
+                            
+                        }
+                    
+                    ?>
+                    
+                    <!-- Rechnung -->
+                    
+                    <input type="checkbox" name="wpsg_rechnungen_sendmail" value="1" id="invoice_sendmail" checked="checked" />
+                    <label for="invoice_sendmail"><?php echo __('E-Mail an Kunden senden', 'wpsg'); ?></label>
+                    <input type="email" name="wpsg_rechnungen_email" value="<?php echo $oCustomer->getEMail(); ?>" />
+                    
+                    <input type="checkbox" name="wpsg_rechnungen_faelligkeit" value="1" id="invoice_faelligkeit" checked="checked" />
+                    <label for="invoice_faelligkeit"><?php echo __('FÃ€lligkeit anzeigen', 'wpsg'); ?></label>
+                    <input type="date" name="wpsg_rechnungen_faelligkeitsdatum" value="<?php echo date('Y-m-d'); ?>" />
+                    
+                    <input type="checkbox" name="wpsg_rechnungen_status" value="1" id="invoice_state" />
+                    <label for="invoice_state"><?php echo __('Neuer Status', 'wpsg'); ?></label>
+                    <select name="wpsg_rechnungen_status_neu">
+                        <?php foreach ($this->arStatus as $status_key => $status_label) { ?>
+                        <option value="<?php echo $status_key; ?>"><?php echo $status_label; ?></option>
+                        <?php } ?>
+                    </select>
+                    
+                    <input type="checkbox" name="wpsg_rechnungen_shippay" value="1" id="invoice_shippay" <?php 
+                      
+                        if (sizeof($arInvoiceLabel) <= 0) echo ' checked="checked" ';
+                        
+                    ?> />
+                    <label style="grid-column:2 / span 2;" for="invoice_shippay"><?php 
+                            
+                        echo __('Versand-/Zahlungskosten abrechnen', 'wpsg'); 
+                                        
+                        if (sizeof($arInvoiceLabel) > 0) {
+                            
+                            echo wpsg_translate(__(' (Enthalten in #1#)', 'wpsg'), implode(', ', $arInvoiceLabel));
+                            
+                        }
+                        
+                    ?></label>
+                    
+                    <input type="checkbox" name="wpsg_rechnungen_url" value="1" id="invoice_url" />
+                    <label  for="invoice_url" style="grid-column: 2 / span 2;"><?php echo __('URL Benachrichtigung', 'wpsg'); ?></label>
+                    
+                    <span></span>
+                    <label for="invoice_date"><?php echo __('Rechnungsdatum', 'wpsg') ;?></label>
+                    <input type="date" value="<?php echo date('Y-m-d'); ?>" name="wpsg_rechnungen_datum" id="invoice_date" />
+                    
+                    <span></span>
+                    <label for="invoice_foottext_select"><?php echo __('FuÃtext', 'wpsg'); ?></label>
+                    
+                    <?php if (sizeof($wpsg_rechnungen_footer) > 0) { ?>
+                    <select id="invoice_foottext_select">
+                        <?php foreach ($wpsg_rechnungen_footer as $k => $v) { ?>
+                        <option value="<?php echo wpsg_hspc($v[1]); ?>" <?php echo ((intval($default) === intval($k))?'selected="selected"':''); ?>><?php echo wpsg_hspc($v[0]); ?></option>
+                        <?php } ?>
+                    </select>
+                    <?php } else { ?>
+                    <span></span>
+                    <?php } ?>
+                    
+                    <span></span>
+                    <input type="text" name="wpsg_rechnungen_fusstext" id="wpsg_rechnungen_fusstext" value="" style="grid-column: 2 / span 2;" />
+                                    
+                    <span style="grid-column:1 / span 3;"></span>
+                    
+                    <span style="display:flex; justify-content:flex-end; gap:0.5rem; grid-column:1/span 3;">
+                        
+                        <input class="button" style="" id="invoice_wpsg_rechnungen_preview" name="wpsg_rechnungen_preview" type="submit" value="Vorschau">
+                        <input class="button" style="" id="invoice_wpsg_rechnungen_submit" onclick="window.setTimeout(function() { location.href = '<?php 
+                        
+                            echo wpsg_admin_url('Order', 'view', ['edit_id' => $oOrder->getId()]);
+                        
+                        ?>'; }, 1000);" name="wpsg_rechnungen_write" type="submit" value="Rechnung schreiben">
+                        
+                    </span>
+                    
+                    <script>
+                        
+                        let el_invoice_foottext_select = document.getElementById('invoice_foottext_select');
+                        let el_invoice_form = document.getElementById('invoice_form');
+                        
+                        if (el_invoice_foottext_select) {
+                            
+                            el_invoice_foottext_select.addEventListener('change', (event) => {
+                            
+                                document.getElementById('wpsg_rechnungen_fusstext').value = event.target.value;
+                                
+                            });
+                            
+                            el_invoice_foottext_select.dispatchEvent(new Event('change'));
+                            
+                        };
+                        
+                        let el_invoice_wpsg_rechnungen_preview = document.getElementById('invoice_wpsg_rechnungen_preview');
+                        let el_invoice_wpsg_rechnungen_submit = document.getElementById('el_invoice_wpsg_rechnungen_submit');
+                                                                
+                    </script>
+                                    
+                </form>
                 
-            ?>" class="grid">
+            </div>
+        <?php } ?>
+        
+        <?php if ($bCanStorno) { ?>
+            <div role="tabpanel" class="tabcontent bg_storno" id="tabcontent2">
                 
-                <?php \wp_nonce_field('wpsg-mod_invoice-order_ajax-rechnung-'.$this->view['data']['id']); ?>
+                <form method="post" id="storno_form" target="_blank" action="<?php 
+                    
+                    echo WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&noheader=1&action=ajax&mod=wpsg_mod_rechnungen&edit_id='.$oOrder->getId().'&do=storno'; 
+                    
+                ?>" class="grid">
+                    
+                    <?php \wp_nonce_field('wpsg-mod_invoice-order_ajax-storno-'.$this->view['data']['id']); 
+                    
+                        $arInvoiceLabel = [];
+                        
+                        foreach ($arInvoice as $oInvoice) {
+                            
+                            if ($oInvoice->isStorno() && $oInvoice->getMeta('include_shipping', false, '0') === '1') {
+                               
+                                $arInvoiceLabel[] = $oInvoice->getNr(true);    
+                                
+                            }
+                            
+                        }
+                    
+                    ?>
+                    
+                    <!-- Gutschrift -->
+                    
+                    <input type="checkbox" name="storno_send" id="storno_send" value="1" checked="checked" />
+                    <label for="storno_send"><?php echo __('E-Mail an Kunden senden', 'wpsg'); ?></label>
+                    <input type="email" name="storno_mail" value="<?php echo $oCustomer->getEMail(); ?>" />
+                    
+                    <input type="checkbox" id="storno_shippay" name="storno_shippay" value="1" id="invoice_shippay" <?php 
+                      
+                        if (sizeof($arInvoiceLabel) <= 0) echo ' checked="checked" ';
+                        
+                    ?> />
+                    <label style="grid-column:2 / span 2;" for="storno_shippay"><?php 
+                        
+                        echo __('Versand-/Zahlungskosten stornieren', 'wpsg'); 
+                     
+                        if (sizeof($arInvoiceLabel) > 0) {
+                            
+                            echo wpsg_translate(__(' (Enthalten in #1#)', 'wpsg'), implode(', ', $arInvoiceLabel));
+                            
+                        }
+                        
+                    ?></label>
+                    
+                    <input type="checkbox" name="storno_state" value="1" id="storno_state" checked="checked" />
+                    <label for="storno_state"><?php echo __('Neuer Status', 'wpsg'); ?></label>
+                    <select name="storno_state_new">
+                        <?php foreach ($this->arStatus as $status_key => $status_label) { ?>
+                        <option value="<?php echo $status_key; ?>"><?php echo $status_label; ?></option>
+                        <?php } ?>
+                    </select>
+                    
+                    <input type="checkbox" name="storno_fee_set" id="storno_fee_set" value="1" id="storno_fee_set" />
+                    <label for="storno_fee_set"><?php echo __('StornierungsgebÃŒhr in % oder EUR', 'wpsg'); ?></label>
+                    <input type="text" value="" name="storno_fee_value" />
+                    
+                    <span style="grid-column:1 / span 3;"></span>
+                    
+                    <span style="display:flex; justify-content:flex-end; gap:0.5rem; grid-column:1/span 3;">
+                        
+                        <input class="button" style="" id="invoice_wpsg_storno_preview" name="wpsg_storno_preview" type="submit" value="Vorschau">
+                        <input class="button" style="" id="invoice_wpsg_storno_submit" onclick="window.setTimeout(function() { location.href = '<?php 
+                        
+                            echo wpsg_admin_url('Order', 'view', ['edit_id' => $oOrder->getId()]);
+                        
+                        ?>'; }, 1000);" name="wpsg_storno_write" type="submit" value="Rechnungskorrektur schreiben">
+                        
+                    </span>
+                    
+                    <script>
+                         
+                        let el_storno_form = document.getElementById('storno_form');
+                        
+                        let el_invoice_wpsg_storno_preview = document.getElementById('invoice_wpsg_storno_preview');
+                        let el_invoice_wpsg_storno_submit = document.getElementById('invoice_wpsg_storno_submit');
+                                             
+                    </script>
+                    
+                </form>
                 
-                <!-- Rechnung -->
-                
-                <input type="checkbox" name="wpsg_rechnungen_sendmail" value="1" id="invoice_sendmail" checked="checked" />
-                <label for="invoice_sendmail"><?php echo __('E-Mail an Kunden senden', 'wpsg'); ?></label>
-                <input type="email" name="wpsg_rechnungen_email" value="<?php echo $oCustomer->getEMail(); ?>" />
-                
-                <input type="checkbox" name="wpsg_rechnungen_faelligkeit" value="1" id="invoice_faelligkeit" checked="checked" />
-                <label for="invoice_faelligkeit"><?php echo __('FÃ€lligkeit anzeigen', 'wpsg'); ?></label>
-                <input type="date" name="wpsg_rechnungen_faelligkeitsdatum" value="<?php echo date('Y-m-d'); ?>" />
-                
-                <input type="checkbox" name="wpsg_rechnungen_status" value="1" id="invoice_state" checked="checked" />
-                <label for="invoice_state"><?php echo __('Neuer Status', 'wpsg'); ?></label>
-                <select name="wpsg_rechnungen_status_neu">
-                    <?php foreach ($this->arStatus as $status_key => $status_label) { ?>
-                    <option value="<?php echo $status_key; ?>"><?php echo $status_label; ?></option>
-                    <?php } ?>
-                </select>
-                
-                <input type="checkbox" name="wpsg_rechnungen_shippay" value="1" id="invoice_shippay" checked="checked" />
-                <label style="grid-column:2 / span 2;" for="invoice_shippay"><?php 
-                        
-                    echo __('Versand-/Zahlungskosten abrechnen', 'wpsg'); 
-                
-                    /** @var \wpsg\wpsg_invoice[] $arInvoice */
-                    $arInvoice = $this->callMod('wpsg_mod_rechnungen', 'getInvoiceToOrder', [$oOrder->getId()]);
-                    $arInvoiceLabel = [];
-                    
-                    foreach ($arInvoice as $oInvoice) {
-                        
-                        if ($oInvoice->getMeta('include_shipping', false, '0')) {
-                           
-                            $arInvoiceLabel[] = $oInvoice->getNr(true);    
-                            
-                        }
-                        
-                    }
-                    
-                    if (sizeof($arInvoiceLabel) > 0) {
-                        
-                        echo wpsg_translate(__(' (Enthalten in #1#)', 'wpsg'), implode(', ', $arInvoiceLabel));
-                        
-                    }
-                    
-                ?></label>
-                
-                <input type="checkbox" name="wpsg_rechnungen_url" value="1" id="invoice_url" />
-                <label  for="invoice_url" style="grid-column: 2 / span 2;"><?php echo __('URL Benachrichtigung', 'wpsg'); ?></label>
-                
-                <span></span>
-                <label for="invoice_date"><?php echo __('Rechnungsdatum', 'wpsg') ;?></label>
-                <input type="date" value="<?php echo date('Y-m-d'); ?>" name="wpsg_rechnungen_datum" id="invoice_date" />
-                
-                <span></span>
-                <label for="invoice_foottext_select"><?php echo __('FuÃtext', 'wpsg'); ?></label>
-                
-                <?php if (sizeof($wpsg_rechnungen_footer) > 0) { ?>
-                <select id="invoice_foottext_select">
-                    <?php foreach ($wpsg_rechnungen_footer as $k => $v) { ?>
-                    <option value="<?php echo wpsg_hspc($v[1]); ?>" <?php echo ((intval($default) === intval($k))?'selected="selected"':''); ?>><?php echo wpsg_hspc($v[0]); ?></option>
-                    <?php } ?>
-                </select>
-                <?php } else { ?>
-                <span></span>
-                <?php } ?>
-                
-                <span></span>
-                <input type="text" name="wpsg_rechnungen_fusstext" id="wpsg_rechnungen_fusstext" value="" style="grid-column: 2 / span 2;" />
-                                
-                <span style="grid-column:1 / span 3;"></span>
-                
-                <span style="display:flex; justify-content:flex-end; gap:0.5rem; grid-column:1/span 3;">
-                    
-                    <input class="button" style="" id="invoice_wpsg_rechnungen_preview" name="wpsg_rechnungen_preview" type="submit" value="Vorschau">
-                    <input class="button" style="" id="invoice_wpsg_rechnungen_submit" onclick="window.setTimeout(function() { location.href = '<?php 
-                    
-                        echo wpsg_admin_url('Order', 'view', ['edit_id' => $oOrder->getId()]);
-                    
-                    ?>'; }, 1000);" name="wpsg_rechnungen_write" type="submit" value="Rechnung schreiben">
-                    
-                </span>
-                
-                <script>
-                    
-                    let el_invoice_foottext_select = document.getElementById('invoice_foottext_select');
-					let el_invoice_form = document.getElementById('invoice_form');
-					
-					if (el_invoice_foottext_select) {
-						
-						el_invoice_foottext_select.addEventListener('change', (event) => {
-						
-							document.getElementById('wpsg_rechnungen_fusstext').value = event.target.value;
-							
-						});
-						
-						el_invoice_foottext_select.dispatchEvent(new Event('change'));
-						
-                    };
-					
-					let el_invoice_wpsg_rechnungen_preview = document.getElementById('invoice_wpsg_rechnungen_preview');
-					let el_invoice_wpsg_rechnungen_submit = document.getElementById('el_invoice_wpsg_rechnungen_submit');
-					 					                    
-                </script>
-                                
-            </form>
-            
-        </div>
-        
-        <div role="tabpanel" class="tabcontent bg_storno" id="tabcontent2">
-            
-            <form method="post" id="storno_form" target="_blank" action="<?php 
-                
-                echo WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&noheader=1&action=ajax&mod=wpsg_mod_rechnungen&edit_id='.$oOrder->getId().'&do=storno'; 
-                
-            ?>" class="grid">
-                
-                <?php \wp_nonce_field('wpsg-mod_invoice-order_ajax-storno-'.$this->view['data']['id']); ?>
-                
-                <input type="checkbox" name="storno_send" id="storno_send" value="1" />
-                <label for="storno_send"><?php echo __('E-Mail an Kunden senden', 'wpsg'); ?></label>
-                <input type="email" name="storno_mail" value="<?php echo $oCustomer->getEMail(); ?>" />
-                
-                <input type="checkbox" id="storno_shippay" name="storno_shippay" value="1" id="invoice_shippay" checked="checked" />
-                <label style="grid-column:2 / span 2;" for="storno_shippay"><?php echo __('Versand-/Zahlungskosten stornieren', 'wpsg'); ?></label>
-                
-                <input type="checkbox" name="storno_state" value="1" id="storno_state" checked="checked" />
-                <label for="storno_state"><?php echo __('Neuer Status', 'wpsg'); ?></label>
-                <select name="storno_state_new">
-                    <?php foreach ($this->arStatus as $status_key => $status_label) { ?>
-                    <option value="<?php echo $status_key; ?>"><?php echo $status_label; ?></option>
-                    <?php } ?>
-                </select>
-                
-                <input type="checkbox" name="storno_fee_set" id="storno_fee_set" value="1" id="storno_fee_set" />
-                <label for="storno_fee_set"><?php echo __('StornierungsgebÃŒhr in % oder EUR', 'wpsg'); ?></label>
-                <input type="text" value="" name="storno_fee_value" />
-                
-                <span style="grid-column:1 / span 3;"></span>
-                
-                <span style="display:flex; justify-content:flex-end; gap:0.5rem; grid-column:1/span 3;">
-                    
-                    <input class="button" style="" id="invoice_wpsg_storno_preview" name="wpsg_storno_preview" type="submit" value="Vorschau">
-                    <input class="button" style="" id="invoice_wpsg_storno_submit" onclick="window.setTimeout(function() { location.href = '<?php 
-                    
-                        echo wpsg_admin_url('Order', 'view', ['edit_id' => $oOrder->getId()]);
-                    
-                    ?>'; }, 1000);" name="wpsg_storno_write" type="submit" value="Rechnungskorrektur schreiben">
-                    
-                </span>
-                
-                <script>
-                     
-                    let el_storno_form = document.getElementById('storno_form');
-					
-					let el_invoice_wpsg_storno_preview = document.getElementById('invoice_wpsg_storno_preview');
-					let el_invoice_wpsg_storno_submit = document.getElementById('invoice_wpsg_storno_submit');
-					                     
-                </script>
-                
-            </form>
-            
-        </div>
+            </div>
+        <?php } ?>
         
     </div>
@@ -231,5 +302,10 @@
     
     .link_invoice { transform:translateX(-5px); padding:2px 5px; font-siz:12px; text-decoration:underline; }
-    label[for="invoice_shippay"] .link_invoice { padding:0; }
+    label[for="invoice_shippay"] .link_invoice,
+    label[for="storno_shippay"] .link_invoice { padding:0; }
+
+    .wpsg_mod_rechnungen_row { display:block; width:100%; padding:5px; }
+    .wpsg_mod_rechnungen_row .invoice_wrap:not(:only-child) { margin-top:0.5rem; }
+    .wpsg_mod_rechnungen_row .invoice_wrap > a:first-child { padding-left:0; }
     
 </style>
@@ -238,5 +314,5 @@
     
     jQuery('#wpsg_mod_invoice_tabs').wpsg_tab( {
-    
+        aktTab: <?php echo $act; ?>
 	} );
   
Index: /views/mods/mod_rechnungen/order_view_row.phtml
===================================================================
--- /views/mods/mod_rechnungen/order_view_row.phtml	(revision 8007)
+++ /views/mods/mod_rechnungen/order_view_row.phtml	(revision 8010)
@@ -13,13 +13,27 @@
     $p = $this->view['wpsg_mod_rechnungen']['product'];
     $product_index = $this->view['wpsg_mod_rechnungen']['product']['product_index'];
-  
+
+	/** @var \wpsg\wpsg_invoice[] $arInvoice */
+	$arInvoice = $this->callMod('wpsg_mod_rechnungen', 'getInvoiceToOrderProduct', [$oOrderProduct]);
+    $arInvoiceInvoice = [];
+    $arInvoiceStorno = [];
+    
+    foreach ($arInvoice as $oInvoice) { 
+        
+        if ($oInvoice->isStorno()) $arInvoiceStorno[] = $oInvoice;
+        else if ($oInvoice->isInvoice()) $arInvoiceInvoice[] = $oInvoice;
+
+    }
+    
 ?>
 <tr class="wpsg_<?php echo (($this->view['wpsg_mod_rechnungen']['i'] == 0)?'odd':'even'); ?>">	
 	<td colspan="<?php echo ((sizeof($this->view['arCalculation']['tax']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1')?'5':'4'); ?>">
-		<div style="display:flex; flex-direction:row; margin-bottom:0px; gap:2rem;">		
-            
+                
+        <!-- Rechnungen -->
+        <label class="bg_invoice wpsg_mod_rechnungen_row" style="font-weight:normal;">   
+       
             <?php if ($invoice_amount > 0) { ?>
-             
-                <label style="display:flex; flex-direction:row; padding:5px; margin-left:-5px; gap:0.5rem; font-weight:normal; align-items:center;" class="bg_invoice">   
+                <div style="display:flex; flex-direction:row; gap:0.5rem; font-weight:normal; align-items:center;">
+                    <span><?php echo __('Menge'); ?></span>
                     
                     <input form="invoice_form" type="hidden" name="invoice_products[<?php echo $p['order_product_id']; ?>][set]" value="0" />
@@ -28,34 +42,46 @@
                     <input form="invoice_form" name="invoice_products[<?php echo $p['order_product_id']; ?>][amount]" type="number" max="<?php echo $invoice_amount; ?>" min="1" value="<?php echo min($invoice_amount, $p['amount']); ?>" style="padding:0; font-size:14px; line-height:22px; min-height:initial; height:22px; width:50px; text-indent:5px; border:1px solid black; margin:0;" />
                     
-                    <span>&nbsp;<?php echo __('StÃŒck auf Rechnung', 'wpsg'); ?></span>
-                    
-                </label>
-            
+                    <span>&nbsp;<?php echo __('auf Rechnung', 'wpsg'); ?></span>
+                </div>
+            <?php } ?>
+   
+            <?php if (sizeof($arInvoiceInvoice) > 0) { ?>
+            <div class="invoice_wrap">
+                <span><?php echo __('Rechnungen', 'wpsg'); ?>:</span>
+                <?php foreach ($arInvoiceInvoice as $oInvoice) { ?>
+                    <?php echo $oInvoice->getNr(true, $oOrderProduct); ?>        
+                <?php } ?>
+            </div>    
             <?php } ?>
             
+        </label>
+                                        
+        <!-- Gutschriften -->        
+        <label class="bg_storno wpsg_mod_rechnungen_row" style="font-weight:normal;">   
+            
             <?php if ($storno_amount > 0) { ?>
-            
-                <label style="display:flex; flex-direction:row; padding:5px; margin-left:-5px; gap:0.5rem; font-weight:normal; align-items:center;" class="bg_storno">   
+                <div style="display:flex; flex-direction:row; gap:0.5rem; font-weight:normal; align-items:center;">
+                    <span><?php echo __('Menge'); ?></span>
                     
                     <input form="storno_form" type="hidden" name="storno_products[<?php echo $p['order_product_id']; ?>][set]" value="0" />
-                    <input form="storno_form" checked="checked" type="checkbox" class="wpsg_mod_deliverynote_product" name="storno_products[<?php echo $p['order_product_id']; ?>][set]" value="1" style="margin:0;" />
+                    <input form="storno_form" type="checkbox" class="wpsg_mod_deliverynote_product" name="storno_products[<?php echo $p['order_product_id']; ?>][set]" value="1" style="margin:0;" />
                     
-                    <input form="storno_form" name="storno_products[<?php echo $p['order_product_id']; ?>][amount]" type="number" max="<?php echo $storno_amount; ?>" min="1" value="<?php echo min($storno_amount, $p['amount']); ?>" style="padding:0; font-size:14px; line-height:22px; min-height:initial; height:22px; width:50px; text-indent:5px; border:1px solid black; margin:0;" />
+                    <input form="storno_form" oninput="event.target.previousElementSibling.checked = true;" onchange="event.target.previousElementSibling.checked = true;" name="storno_products[<?php echo $p['order_product_id']; ?>][amount]" type="number" max="<?php echo $storno_amount; ?>" min="1" value="<?php echo min($storno_amount, $p['amount']); ?>" style="padding:0; font-size:14px; line-height:22px; min-height:initial; height:22px; width:50px; text-indent:5px; border:1px solid black; margin:0;" />
                     
                     <span>&nbsp;<?php echo __('StÃŒck auf Gutschrift', 'wpsg'); ?></span>
-                    
-                </label>
-            
+                </div>
             <?php } ?>
             
-		</div>
-        <?php /** @var \wpsg\wpsg_invoice[] $arInvoice */ $arInvoice = $this->callMod('wpsg_mod_rechnungen', 'getInvoiceToOrderProduct', [$oOrderProduct]); ?>
-        <?php if (sizeof($arInvoice) > 0) { ?>
-            <div style="display:flex; gap:0.5rem; justify-content:flex-start; flex-wrap:wrap;">
-            <?php foreach ($arInvoice as $oInvoice) { ?>
-                <?php echo $oInvoice->getNr(true); ?>
+            <?php if (sizeof($arInvoiceStorno) > 0) { ?>
+            <div class="invoice_wrap">
+                <span><?php echo __('Rechnungskorrekturen', 'wpsg'); ?>:</span>
+                <?php foreach ($arInvoiceStorno as $oInvoice) { ?>
+                    <?php echo $oInvoice->getNr(true, $oOrderProduct); ?>        
+                <?php } ?>
+            </div>    
             <?php } ?>
-            </div>
-        <?php } ?>
+            
+        </label>
+            
 	</td>
 </tr>
