Index: /controller/wpsg_OrderController.class.php
===================================================================
--- /controller/wpsg_OrderController.class.php	(revision 8067)
+++ /controller/wpsg_OrderController.class.php	(revision 8068)
@@ -1507,5 +1507,5 @@
 		public function indexAction() {
 
-			if (wpsg_isSizedString($_REQUEST['do'], 'writeMultiRechnung') || wpsg_isSizedString($_REQUEST['wpsg_action'], 'showRechnung')) {
+			if (wpsg_isSizedString($_REQUEST['do'], 'writeRechnung') || wpsg_isSizedString($_REQUEST['wpsg_action'], 'showRechnung')) {
 
 				// Mehrere Rechnungen schreiben/anzeigen
@@ -1569,6 +1569,5 @@
 				}
 
-			}
-			else if (isset($_REQUEST['wpsg_order_doaction'])) {
+			} else if (isset($_REQUEST['wpsg_order_doaction'])) {
 
 				if ($_REQUEST['wpsg_action'] == '-1') $this->addBackendError(__('Bitte eine Aktion wÃ€hlen!', 'wpsg'));
@@ -1586,4 +1585,6 @@
 
 					} else if ($_REQUEST['wpsg_action'] == 'writeRechnung') {
+
+						// Buggy
 
 						$nWriteRechnung = 0;
@@ -1677,5 +1678,84 @@
 
 						}
-
+	
+					} else if ($_REQUEST['wpsg_action'] == 'writeMultiRechnung') {
+					
+						$nWriteRechnung = 0;
+
+						// Status setzen
+						$_REQUEST['wpsg_Multirechnung_status'] = '1';
+						
+						// Neuer Status
+						$_REQUEST['wpsg_Multirechnung_status_neu'] = '120';
+
+						// URL Benachrichtigung
+						$_REQUEST['wpsg_Multirechnung_url'] = '0';
+
+						// FuÃtext
+						if ($this->shop->get_option('wpsg_rechnungen_foottext_standard') !== false)
+						{
+
+							$wpsg_rechnungen_footer = $this->get_option("wpsg_rechnungen_footer");
+							if (!is_array($wpsg_rechnungen_footer)) $wpsg_rechnungen_footer = unserialize($this->get_option("wpsg_Multirechnung_footer"));
+							if (!is_array($wpsg_rechnungen_footer)) $wpsg_rechnungen_footer = Array();
+
+							$_REQUEST['wpsg_Multirechnung_fusstext'] = wpsg_getStr($wpsg_rechnungen_footer[$this->shop->get_option('wpsg_rechnungen_foottext_standard')][1]);
+
+						}
+						else
+						{
+
+							$_REQUEST['wpsg_Multirechnung_fusstext'] = '';
+
+						}
+
+						// Sortieren nach CDDATE
+						$arIDs = $this->db->fetchAssocField("SELECT `id` FROM `".WPSG_TBL_ORDER."` WHERE `id` IN (".wpsg_q(implode(',', array_keys($_REQUEST['wpsg_multido']))).") ORDER BY `cdate` ASC");
+
+						// Rechnung fÃŒr mehrere Bestellungen schreiben
+						foreach ($arIDs as $k)
+						{
+
+							$bRechnungExists = $this->db->fetchOne("SELECT COUNT(*) FROM `".WPSG_TBL_RECHNUNGEN."` WHERE `rnr` != '' AND `o_id` = '".wpsg_q($k)."' AND `storno` = '0000-00-00 00:00:00'");
+
+							// E-Mail aus Bestellung
+							$_REQUEST['wpsg_Multirechnung_email'] = $this->db->fetchOne("SELECT K.`email` FROM `".WPSG_TBL_ORDER."` AS O LEFT JOIN `".WPSG_TBL_KU."` AS K ON (O.`k_id` = K.`id`) WHERE O.`id` = '".wpsg_q($k)."'");
+
+							if ($bRechnungExists <= 0)
+							{
+								
+								try
+								{
+
+									$nWriteRechnung ++;
+
+								}
+								catch (Exception $e)
+								{
+
+									die($e->getMessage());
+
+								}
+
+							}
+
+						}
+
+						if ($nWriteRechnung <= 0)
+						{
+
+							$this->addBackendError(__('FÃŒr die gewÃ€hlten Bestellungen konnten keine Sammelrechnungen geschrieben werden, bestehende Rechnungen mÃŒssen erst storniert werden.', 'wpsg'));
+
+						}
+						else 
+						{
+
+							$this->shop->callMod('wpsg_mod_rechnungen', 'writeMultiRechnung', [$arIDs, false, false]); 
+							$this->addBackendMessage('nohspc_'.wpsg_translate(__('Sammelechnung geschrieben', 'wpsg')));
+
+						}
+						
+						die('test');
+					
 					} else if (is_numeric($_REQUEST['wpsg_action']) || preg_match('/\d+\_\d+/', $_REQUEST['wpsg_action'])) {
 
@@ -1801,3 +1881,2 @@
 
 	} // class wpsg_OrderController extends wpsg_SystemController
-
Index: /mods/wpsg_mod_rechnungen.class.php
===================================================================
--- /mods/wpsg_mod_rechnungen.class.php	(revision 8067)
+++ /mods/wpsg_mod_rechnungen.class.php	(revision 8068)
@@ -24,5 +24,5 @@
 			$this->group = __('Bestellung', 'wpsg');
 			$this->desc = __('ErmÃ¶glicht es PDF Rechnungen zu Bestellungen zu generieren.', 'wpsg');
-						
+
 			$this->fields = array(
 				'firma' => __('Firmenname', 'wpsg'),
@@ -48,4 +48,6 @@
 			
 			require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'mod_rechnungen'.DIRECTORY_SEPARATOR.'wpsg_invoice.php';
+
+			$this->shop->arStatus['120'] = __('Sammelrechnung geschrieben', 'wpsg');
 			
 		} // public function __construct()
@@ -752,6 +754,4 @@
 		
 		private function _writeGutschrift($order_id, $gnr_id, $storno_fee, $bPreview) {
-					
-			die(wpsg_debug($_REQUEST));
 			
 			$this->shop->view['invoice'] = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_RECHNUNGEN."` WHERE `id` = '".wpsg_q($gnr_id)."' ");
@@ -1629,4 +1629,365 @@
 			
 		}
+
+		///////////////
+		////  NEW  ////
+		///////////////
+
+		public function writeMultiRechnung($order_ids, $preview, $bOutput = true) {
+
+			$this->shop->view['multi_data']['oids'] = $order_ids;
+
+			// Select first order for Multiinvoice header and footer
+			$order_id = array_values($order_ids)[0];
+
+			$this->shop->view['output'] = $bOutput;	
+			$this->shop->view['data'] = $this->db->fetchRow("
+				SELECT
+					O.*
+				FROM
+					`".WPSG_TBL_ORDER."` AS O
+				WHERE
+					O.`id` = '".wpsg_q($order_id)."'
+			");
+
+			// Wurde die Bestellung in einer anderen Sprache gemacht
+			if (trim($this->shop->view['data']['language']) != '') $this->shop->setTempLocale($this->shop->view['data']['language']);
+			
+			// GET Kundenadresse
+			$this->getAdresse($this->shop->view['data']['k_id']);
+
+			$oOrder = wpsg_order::getInstance($order_id);
+
+			$custom_data = @unserialize($this->shop->view['data']['custom_data']);
+
+			$this->shop->view['kunde']['land'] = $this->db->fetchRow("SELECT L.* FROM `".WPSG_TBL_LAND."` AS L WHERE L.`id` = '".wpsg_q($this->shop->view['kunde']['land'])."'");
+			$this->shop->view['data']['shipping_land'] = $this->db->fetchRow("SELECT L.* FROM `".WPSG_TBL_LAND."` AS L WHERE L.`id` = '".wpsg_q(wpsg_getStr($this->shop->view['data']['shipping_land']))."'");
+			
+			// GET Rechnungsdatum
+			if (wpsg_checkInput($_REQUEST['wpsg_Multirechnung_datum'], WPSG_SANITIZE_DATE_EN)) $this->shop->view['rDatum'] = date('d.m.Y', strtotime($_REQUEST['wpsg_Multirechnung_datum']));
+			else throw \wpsg\Exception::getSanitizeException();
+
+			// GET Faelligkeitsdatum
+			if ($_REQUEST['wpsg_Multirechnung_faelligkeit'] == '1') {
+	
+				if (wpsg_checkInput($_REQUEST['wpsg_Multirechnung_faelligkeitsdatum'], WPSG_SANITIZE_DATE_EN)) $this->shop->view['faelligkeitdatum'] = date('d.m.Y', strtotime($_REQUEST['wpsg_Multirechnung_faelligkeitsdatum']));
+				else throw \wpsg\Exception::getSanitizeException();
+				
+			}
+		
+			// GET Shipping Adress
+			if ($this->shop->hasMod('wpsg_mod_shippingadress') && $this->shop->callMod('wpsg_mod_shippingadress', 'check_different_shippingadress', array('k_id' => @$this->shop->view['data']['k_id'], 'order_id' => @$this->shop->view['data']['id']))) {
+				
+				$temp = $this->db->fetchRow("
+					SELECT 
+						*
+					FROM
+						`".WPSG_TBL_ADRESS."` AS A
+					WHERE
+						A.`id` = '".wpsg_q($this->shop->view['data']['shipping_adress_id'])."'
+				");
+				
+				$this->shop->view['data']['shipping_firma'] = $temp['firma'];
+				$this->shop->view['data']['shipping_vname'] = $temp['vname'];
+				$this->shop->view['data']['shipping_name'] = $temp['name'];
+				$this->shop->view['data']['shipping_strasse'] = $temp['strasse'];
+				$this->shop->view['data']['shipping_nr'] = $temp['nr'];
+				$this->shop->view['data']['shipping_plz'] = $temp['plz'];
+				$this->shop->view['data']['shipping_ort'] = $temp['ort'];
+				
+				$t = $this->db->fetchRow("SELECT L.* FROM `".WPSG_TBL_LAND."` AS L WHERE L.`id` = '".wpsg_q($temp['land'])."'");
+				
+				$this->shop->view['data']['shipping_land'] = array();
+				$this->shop->view['data']['shipping_land']['name'] = $t['kuerzel'];
+				
+			}
+
+			// GET FuÃtext
+			$this->shop->view['fussText'] = $this->shop->replaceUniversalPlatzhalter(wpsg_sinput("text_field", @$_REQUEST['wpsg_Multirechnung_fusstext']), $order_id);
+
+			$price_sum_brutto = 0;
+			$price_sum_netto = 0;
+
+			$payment_sum_brutto = 0;
+			$payment_sum_netto = 0;
+
+			$shipping_sum_brutto = 0;
+			$shipping_sum_netto = 0;
+
+			// DATA FOREACH ORDER IN INVOICE
+			foreach ( $order_ids as $o_id ) {
+
+				$this->shop->view['data'] = $this->db->fetchRow("
+					SELECT
+						O.*
+					FROM
+						`".WPSG_TBL_ORDER."` AS O
+					WHERE
+						O.`id` = '".wpsg_q($o_id)."'
+				");
+
+				// GET ORDER
+				$oOrder = wpsg_order::getInstance($o_id);
+
+				// GET ORDERPRODUCTS
+				$arOrderProducts = $oOrder->getOrderProducts();
+
+				// GET Zahlungsart
+				$this->shop->view['payment'] = $this->shop->getPaymentName(@$this->shop->view['data']['type_payment'], $o_id);
+
+				// NEW CALCULATION
+				$oCalculation = new \wpsg\wpsg_calculation();
+
+				// GET Versandland
+				$oDefaultCountry = $oOrder->getInvoiceCountry();	
+
+				// GET SteuersÃ€tze von Versandland	
+				$oCalculation->addCountry($oDefaultCountry->id, $oDefaultCountry->mwst, $oDefaultCountry->mwst_a,$oDefaultCountry->mwst_b, $oDefaultCountry->mwst_c, $oDefaultCountry->mwst_d, true);
+				
+				if (($_REQUEST['wpsg_Multirechnung_shippay']??'0') === '1') {
+					
+					$oCalculation->addShipping(
+						$oOrder->__get('shipping_set'), 
+						$oOrder->__get('shipping_bruttonetto'),
+						$oOrder->__get('shipping_tax_key'),
+						$oOrder->__get('shipping_key')
+					);
+					
+					$oCalculation->addPayment(
+						$oOrder->__get('payment_set'), 
+						$oOrder->__get('payment_bruttonetto'),
+						$oOrder->__get('payment_tax_key'),
+						$oOrder->__get('payment_key')
+					);
+					
+				}
+				
+				$arProduct = [];
+				$tax_view = WPSG_BRUTTO;
+
+				// GET Produkte aus einzelner Bestellung
+				foreach ($arOrderProducts as $oOrderProduct) {
+
+					// wpsg_debug($oOrderProduct);
+
+					$oCalculation->addProduct(
+						$oOrderProduct->getPrice($tax_view),
+						$tax_view,
+						$oOrderProduct->getProduct()->__get('mwst_key'),
+						$oOrderProduct->getCount(),
+						$oOrderProduct->getProductKey()
+					); 
+					
+					$p = [
+						'oOrderProduct' => $oOrderProduct,
+						'id' => $oOrderProduct->getProductKey(),
+						'product_index' => $oOrderProduct->getProductIndex(),
+						'productkey' => $oOrderProduct->getProductKey(),
+						'menge' => $oOrderProduct->getCount(),
+						'price' => $oOrderProduct->getPrice($tax_view),
+						'anr' => $oOrderProduct->getProduct()->getNr(), 
+						'mwst_value' => 0,
+						'preis_netto' => $oOrderProduct->getPrice(WPSG_NETTO),
+						'preis_brutto' => $oOrderProduct->getPrice(WPSG_BRUTTO),
+						'name' => $oOrderProduct->getProduct()->getProductName(false),
+						'detailname' => $oOrderProduct->getProduct()->getProductName(true),
+						'beschreibung' => $oOrderProduct->getDescription()						
+					];
+					
+					// Ãbersetzung
+					if ($this->shop->isOtherLang()) {
+					
+						$produkt_trans = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `lang_parent` = '".wpsg_q($oOrderProduct->getProduct()->getId())."' AND `lang_code` = '".wpsg_q($this->shop->getCurrentLanguageCode())."'");
+					
+						if ($produkt_trans['id'] > 0) {
+								
+							$p['name'] = $produkt_trans['name'];
+							$p['beschreibung'] = $produkt_trans['beschreibung'];
+							$p['detailname'] = $produkt_trans['detailname'];
+					
+						}
+					
+					}
+
+					$arProduct[] = $p;
+
+				}
+
+				$this->shop->view['basket'] = [
+					'data' => $this->shop->view['data'],
+					'arCalculation' => $oCalculation->getCalculationArray(),
+					'produkte' => $arProduct,
+				];
+
+				$this->shop->view['multi_data']['orders'][] = $this->shop->view['basket'];
+
+				// Abfrage ob Versandkosten mit einberechnen
+				if (($_REQUEST['wpsg_Multirechnung_shippay']??'0') === '1') {
+
+					// Versankosten setzen
+					$this->shop->view['basket']['sum']['preis_shipping'] = $oCalculation->getShippingSum(WPSG_BRUTTO);
+					
+				}
+
+			}
+
+			// Rechnungsnummer bilden
+			$rnr_format = $this->shop->get_option("wpsg_rechnungen_format");
+			if ($rnr_format == "") $rnr_format = "%nr%";
+				
+			// Neue Fortlaufende Nummer				
+			$rnr_nr = intval($this->shop->get_option("wpsg_rechnungen_start"));
+			if ($rnr_nr <= 0) $rnr_nr = 1;
+				
+			// Ersetzungen
+			$rnr = preg_replace("/\%nr\%/i", $rnr_nr, $rnr_format);
+			$rnr = preg_replace("/\%Jahr\%/i", date("Y"), $rnr);
+			$rnr = preg_replace("/\%Monat\%/i", date("m"), $rnr);
+			$rnr = preg_replace("/\%Tag\%/i", date("d"), $rnr);
+							
+			$rnr = $this->shop->replaceUniversalPlatzhalter($rnr, $order_id);
+			$oInvoice = null;
+
+			if ($preview) {
+				
+				$this->shop->view['preview'] = true;
+				$this->shop->view['rnr'] = $rnr.' - '.__('Vorschau', 'wpsg');
+				$r_id = "Vorschau";
+												
+			} else {
+				 
+				$this->shop->view['preview'] = false;
+				$this->shop->view['rnr'] = $rnr;
+				
+				$this->shop->update_option("wpsg_rechnungen_start", ($rnr_nr + 1));
+				
+				// Status Ã€ndern
+				if ($_REQUEST['wpsg_Multirechnung_status'] == "1") {
+						
+					$this->shop->setOrderStatus($order_id, wpsg_sinput("key", $_REQUEST['wpsg_Multirechnung_status_neu']), false);
+											
+				}
+ 
+				$r_id = $this->db->importQuery(
+					WPSG_TBL_RECHNUNGEN,
+					array(
+						"rnr" => $rnr,
+						"o_id" => $order_id,
+						"datum" => "NOW()"
+					)
+				);
+				
+				$oInvoice = \wpsg\wpsg_invoice::getInstance($r_id);
+				
+				$oInvoice->setMeta('basket_data', json_encode($this->shop->view['basket']));
+				$oInvoice->setMeta('version', '2');
+				
+				if (($_REQUEST['wpsg_Multirechnung_shippay']??'0') === '1') {
+				
+					$oInvoice->setMeta('include_shipping', '1');
+									
+				}
+				
+			}
+			
+			$this->shop->view['filename'] = $r_id;
+			$this->shop->view['filename_out'] = $rnr.'.pdf';
+			
+			$this->shop->view['oOrder'] = $this->shop->cache->loadOrderObject($order_id);
+			$this->shop->view['storno'] = false;
+			$this->shop->view['invoice'] = true;
+			
+			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_rechnungen/multi_invoice_pdf.phtml');	
+ 
+			if (!$preview) {
+				 
+				foreach ($this->shop->view['basket']['produkte'] as $p) {
+					
+					/** @var wpsg_order_product $oOrderProduct */
+					$oOrderProduct = $p['oOrderProduct'];
+					
+					$invoice_data = json_decode($oOrderProduct->getMeta('wpsg_mod_rechnungen_data', false, 'null'), true);
+					if (!is_array($invoice_data)) $invoice_data = [];
+					
+					$invoice_data[] = [						
+						'amount' => $p['menge'],
+						'invoice_id' => $r_id						
+					];
+					
+					$oOrderProduct->setMeta('wpsg_mod_rechnungen_data', json_encode($invoice_data));
+					
+				}
+				
+				if (@$_REQUEST['wpsg_Multirechnung_sendmail'] == "1") {
+					
+					//Mail versenden
+					
+					/**
+					 * Damit alte Rechnungen noch versendet werden
+					 */
+					if (file_exists($this->getFilePath($order_id).$r_id.'.pdf')) { $file = $this->getFilePath($order_id).$r_id.'.pdf'; }
+					else if (file_exists($this->getFilePath($order_id).$rnr.'.pdf')) { $file = $this->getFilePath($order_id).$rnr.'.pdf'; }
+					else if (file_exists($this->getFilePath($order_id).'R'.$r_id.'.pdf')) { $file = $this->getFilePath($order_id).'R'.$r_id.'.pdf'; }
+					else { $file = $this->getFilePath($order_id).'R'.$rnr.'.pdf'; }  
+ 
+					$file = $this->copyTemp($file, $rnr);
+					
+					$mail_text = $this->shop->render(WPSG_PATH_VIEW."/mods/mod_rechnungen/Multi_invoicemail.phtml", false);
+
+					if ($this->shop->get_option('wpsg_htmlmail') === '1') { $mail_html = $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_rechnungen/multi_invoicemail_html.phtml', false); }
+					else { $mail_html = false; }
+					
+					$empfaenger = $_REQUEST['wpsg_Multirechnung_email']; 
+													 
+					$header = "";
+					$arFiles = array($file);
+	 
+					if ($this->shop->get_option('wpsg_widerrufsformular_invoice') === '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)) {
+								
+							$arFiles[] = $revocationFile;
+								
+						}
+					
+					}
+					
+					$this->shop->sendMail($mail_text, $empfaenger, 'invoicemail', $arFiles, $order_id, false, $mail_html);
+
+					// TemporÃ€re Rechnung lÃ¶schen
+					@unlink($file);
+					
+					$this->shop->restoreTempLocale();
+					
+					// In Log eintragen
+					$this->db->importQuery(WPSG_TBL_OL, array(
+						"cdate" => "NOW()",
+						"o_id" => wpsg_q($this->shop->view['data']['id']),
+					    "title" => wpsg_q(wpsg_translate(__('Rechnungsmail an #1#', 'wpsg'), $empfaenger)),				
+						"mailtext" => wpsg_q($mail_text)
+					));						
+									
+				}
+								
+				// Url Benachrichtigung
+				if (wpsg_isSizedString($_REQUEST['wpsg_Multirechnung_url'], '1')) {
+					
+					$this->shop->notifyURL(
+						$this->shop->get_option('wpsg_rechnungen_url'), 
+						false, 
+						false, 
+						$this->shop->view['data']['id'], 
+						2						
+					);
+					
+				}
+				
+			}
+			
+			$this->shop->restoreTempLocale();
+
+		} // public function writeMultiRechnung()
 
 		public function stornoAction() {
@@ -2363,3 +2724,2 @@
  		
 	} // class wpsg_mod_rechnungen extends wpsg_mod_basic
-
Index: /views/mods/mod_rechnungen/multi_invoice_pdf.phtml
===================================================================
--- /views/mods/mod_rechnungen/multi_invoice_pdf.phtml	(revision 8068)
+++ /views/mods/mod_rechnungen/multi_invoice_pdf.phtml	(revision 8068)
@@ -0,0 +1,1049 @@
+<?php
+	
+	/**
+	 * Template fÃŒr die PDF Rechnung
+	 */
+	
+	require_once WPSG_PATH_LIB.'FPDF_1.81/fpdf.php';
+	require_once WPSG_PATH_LIB.'FPDI_2.2.0/autoload.php';
+	 
+	require_once WPSG_PATH_LIB.'wpsg_fpdf.class.php';
+	
+	global $absender_left, $absender_top, $adress_left, $adress_top, $rdata_left, $rdata_top, $rhead_left, $rhead_top, $sum_multi_offset;
+	
+	// Positionierung der Absenderadresszeile
+	$absender_left				= 25;
+	$absender_top				= 50;
+	
+	// Positionierung der Zieladress
+	$adress_left 				= 25;
+	$adress_top					= 55;
+	
+	// Positionierung des Rechnungskopfes
+	$rdata_left					= 25;
+	$rdata_top					= 90;
+
+    // Positionierung des Teilrechnungskopfes
+    $rhead_left					= 25;
+	$rhead_top					= 110;
+	
+	// Positionierung der Produktdaten
+	$prod_left					= 25;
+	$prod_top					= 120;
+	
+	// Anzahl an Produkten pro Seite
+	$prod_break					= $this->get_option('wpsg_rechnungen_pdfperpage');
+	
+	$arCalculation = $this->view['basket']['arCalculation'];
+    $data = $this->view['multi_data']['orders'][0]['data'];
+    $sum = $this->view['multi_data']['orders'][0]['sum'];
+	
+	if ($this->getFrontendTaxView() === WPSG_NETTO) $taxdisplay = 'netto';
+	else $taxdisplay = 'brutto';
+	
+	// Damit die Steuer bei der Kleinunternehmerregelung nicht angezeigt wird leer ich den Array sicherheitshalber
+	if ($this->get_option('wpsg_kleinunternehmer') == '1')
+	{
+		
+		unset($this->view['basket']['mwst']);
+		
+	}
+	
+	if (!function_exists('AddRechnungPage'))
+	{
+		
+		function AddRechnungPage($shop, $pdf) 
+		{
+
+			global $absender_left, $absender_top, $adress_left, $adress_top, $rdata_left, $rdata_top, $offset, $sum_multi_offset;
+			
+			$pdf->AddPage();
+            $sum_multi_offset = 0;
+			
+			if (file_exists($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_bp.pdf")) {
+				
+				$pdf->setSourceFile($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_bp.pdf");
+				$tplidx = $pdf->importPage(1, '/MediaBox');
+				$pdf->useTemplate($tplidx, 0, 0, 210);
+				
+			} else if (file_exists($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_bp.jpg")) {
+				
+				$pdf->image($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_bp.jpg", 0, 0, 210, 297, 'jpg');
+				
+			}
+			
+			
+			if (file_exists($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_logo.jpg"))
+			{
+				
+				list($width, $height, $type, $attr) = getimagesize($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_logo.jpg");
+				
+				// Umrechnung von Inch zu Pixel
+				$wPix = (25.4 * (int)$width) / 96;
+				$hPix = (25.4 * (int)$height) / 96;
+				
+				$leftPos = 110 - $wPix;
+				$midPos = $wPix * 2.6 - $width / 2;
+				$rightPos = 210 - $wPix;
+				
+				$abscissa = $rightPos;
+				$ordinate = 0;
+				
+				$transparency = str_replace("%", "", $shop->get_option('wpsg_rechnungen_logo_transparency'));
+				if($transparency !== "100") $transparency = str_replace(array("0", "00"), "", $transparency);
+				
+				$alpha = 1;
+				if(!is_null($transparency) && $transparency !== "100") $alpha = "0.$transparency";
+				if(!is_null($transparency) && $transparency === "100") $alpha = $transparency;
+				
+				$logo_pos = $shop->get_option('wpsg_rechnungen_logo_position');
+				
+				if(isset($logo_pos) && $logo_pos === "left") { $abscissa = $leftPos; $ordinate = 20; }
+				if(isset($logo_pos) && $logo_pos === "center") { $abscissa = $midPos; $ordinate = 20; }
+				if(isset($logo_pos) && $logo_pos === "right") { $abscissa = $rightPos; }
+				
+				$pdf->SetAlpha($alpha);
+				$pdf->image($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_logo.jpg", $abscissa, $ordinate, $wPix, $hPix);
+				$pdf->SetAlpha(1);
+				
+			}
+			
+			// Absenderadresszeile (Wird in der Konfiguration hinterlegt)
+			$pdf->SetFont('Arial', '', 6);
+			$pdf->Text($absender_left, $absender_top, $shop->replaceUniversalPlatzhalter(__($shop->get_option("wpsg_rechnungen_adresszeile"), 'wpsg'), $data['id']));
+			
+			if (wpsg_getStr($shop->view['kunde']['kuerzel']) != "") $shop->view['kunde']['kuerzel'] = $shop->view['kunde']['kuerzel'].'-';
+			
+			// Adresse des Kunden
+			$pdf->SetFont('Arial', '', 12);
+			$pdf->Text($adress_left, $adress_top, $shop->view['kunde']['firma']);
+			$pdf->Text($adress_left, $adress_top + 5, $shop->view['kunde']['vname'].' '.$shop->view['kunde']['name']);
+			$pdf->Text($adress_left, $adress_top + 10, $shop->view['kunde']['strasse'].' '.wpsg_getStr($shop->view['kunde']['nr']));
+			$pdf->Text($adress_left, $adress_top + 15, $shop->view['kunde']['plz'].' '.$shop->view['kunde']['ort']);
+			if ($shop->get_option("wpsg_mod_rechnungen_hideCountry") == '0')
+				$pdf->Text($adress_left, $adress_top + 20, strtoupper($shop->view['oOrder']->getInvoiceCountryName()));
+			
+			// Rechnungsdaten
+			$pdf->SetFont('Arial', 'B', 16);
+			$pdf->Text($rdata_left, $rdata_top, __('Rechnung', 'wpsg'));
+			$pdf->SetFont('Arial', 'B', 9);
+			$pdf->Text($rdata_left, $rdata_top + 6, $shop->view['rnr']);
+			$pdf->SetFont('Arial', '', 9);
+			
+            // FÃ€lligkeitsdatum
+			if (isset($shop->view['faelligkeitdatum']))
+			{
+				
+				$pdf->Text($rdata_left + 35, $rdata_top, __("FÃ€llig am", "wpsg"));
+				$pdf->Text($rdata_left + 35, $rdata_top + 6, $shop->view['faelligkeitdatum']);
+				
+			}
+
+            // Kunden-Nr
+			$pdf->Text($rdata_left + 55, $rdata_top, __("Kunden-Nr", "wpsg"));
+			$pdf->Text($rdata_left + 55, $rdata_top + 6, (($shop->view['kunde']['knr'] != '')?$shop->view['kunde']['knr']:$shop->view['kunde']['id']));
+
+            // Datum
+            $pdf->Text($rdata_left + 75, $rdata_top, __("Datum", "wpsg"));
+			$pdf->Text($rdata_left + 75, $rdata_top + 6, $shop->view['rDatum']);
+
+            // InnerEu Hinweistext
+            if ($shop->view['oOrder']->isInnerEu())
+			{
+				
+				$pdf->SetFont('Arial', '', 9);
+				$pdf->Text($adress_left, $rdata_top + 11.5, __("Innergemeinschaftliche Lieferung.", "wpsg"));
+				
+			}
+
+            // Benutzerdefinierte Felder
+			$arTexte = $shop->callMod('wpsg_mod_rechnungen', 'getRechnungstexte', array($data['id']));
+			
+			foreach ((array)$arTexte as $text)
+			{
+				
+				if (isset($text['aktiv']) && $text['aktiv'] == 1)
+				{
+					
+					$pdf->SetFont('Arial', 'B', ((intval($text['fontsize']) > 0)?intval($text['fontsize']):10));
+					$pdf->wpsg_SetTextColor($text['color']);
+					$pdf->wpsg_MultiCell($text['x'], $text['y'], 5, $text['text']);
+					$pdf->wpsg_SetTextColor("#000000");
+					
+				}
+				
+			}	
+			
+		}
+		
+	}
+
+    // wpsg_debug($this->view['basket']); // DEBUG
+    // wpsg_debug($this->view['kunde']); // DEBUG
+    // wpsg_debug($this->view['data']); // DEBUG
+    // wpsg_debug($this->view['multi_data']['orders']); // DEBUG
+
+    $pdf = new wpsg_fpdf();
+    $pdf->SetAutoPageBreak(true, 5);
+    AddRechnungPage($this, $pdf);
+
+    $rhead_count = 1;
+    $sum_multi_offset = 0;
+    $orders = $this->view['multi_data']['orders']; 
+
+    $sum_topay_brutto = 0;
+    $sum_topay_netto = 0;
+    $sum_productsum_brutto = 0;
+    $sum_productsum_netto = 0;
+    $sum_shipping_brutto = 0;
+    $sum_shipping_netto = 0;
+    $sum_payment_brutto = 0;
+    $sum_payment_netto = 0;
+    
+    foreach ($orders as $oSum) {
+
+        // Produktgesamtsumme
+        foreach ($oSum['arCalculation']['product'] as $p) {
+            $sum_productsum_brutto += $p['brutto'];
+            $sum_productsum_netto += $p['netto'];
+        }
+
+        // Zahlungssumme gesamt
+        $sum_topay_brutto += $oSum['arCalculation']['sum']['topay_brutto'];
+        $sum_topay_netto += $oSum['arCalculation']['sum']['topay_netto'];
+
+        // Gesamtzahlungskosten
+        $sum_payment_brutto += $oSum['arCalculation']['sum']['payment_brutto'];
+        $sum_payment_netto += $oSum['arCalculation']['sum']['payment_netto'];
+
+        // Gesamtversandkosten
+        $sum_shipping_brutto += $oSum['arCalculation']['sum']['shipping_brutto'];
+        $sum_shipping_netto += $oSum['arCalculation']['sum']['shipping_netto'];
+
+    }
+
+    // FOREACH ORDER START
+    foreach ($orders as $oOrder) {
+
+        // Sammelrechnung ZÃ€hler
+        $pdf->SetFont('Arial', 'B', 12);
+        $pdf->Text($rhead_left, $rhead_top + $sum_multi_offset, $rhead_count);
+        $pdf->Text($rhead_left + 6, $rhead_top + $sum_multi_offset, __("Bestellung", "wpsg"));
+        $rhead_count++;
+        $pdf->SetFont('Arial', '', 9);
+
+        // Zahlungsbedingung anzeigen
+        if (isset($oOrder['arCalculation']['payment'][0]['payment_key']))
+        {
+            
+            $pdf->Text($rhead_left + 120, $rhead_top + $sum_multi_offset, __("Zahlungsbedingungen", "wpsg"));
+            $pdf->Text($rhead_left + 120, $rhead_top + $sum_multi_offset + 6, $this->arPayment[$oOrder['arCalculation']['payment'][0]['payment_key']]['name']);
+            
+        }
+        
+        // Bestellnummer anzeigen
+        $pdf->Text($rhead_left + 155, $rhead_top + $sum_multi_offset, __("Best. Nr.", "wpsg"));
+        $pdf->Text($rhead_left + 155, $rhead_top + $sum_multi_offset + 6, ((trim($oOrder['data']['onr']) != '')?$oOrder['data']['onr']:$oOrder['data']['id']));
+        
+        $summe = 0;
+        $mwst_value = array_values($oOrder['arCalculation']['tax'])[0];
+
+        $bKopf = false; $pnr = 1; $offset = 0; $count = 0; 
+        
+        foreach ($oOrder['produkte'] as $p)
+        {
+
+            if (!$bKopf)
+            {
+                
+                $pdf->SetFont('Arial', 'B', 9);
+                $pdf->setXY($prod_left, $prod_top + $sum_multi_offset);
+                $pdf->Cell(10, 8, __("Nr.", "wpsg"), 1, 0, 'C');
+                
+                $pdf->setXY($prod_left + 10, $prod_top + $sum_multi_offset);
+                if(is_array($mwst_value['tax_value'])) {	
+                    $pdf->Cell( ((sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, "Name", 1, 0, 'L');
+                }		
+
+                if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')
+                {
+                    
+                    $pdf->setXY($prod_left + 97, $prod_top + $sum_multi_offset);
+                    $pdf->Cell(15, 8, __("MwSt.", "wpsg"), 1, 0, 'C');
+                    
+                }
+                
+                $pdf->setXY($prod_left + 112, $prod_top + $sum_multi_offset);
+                $pdf->Cell(15, 8, __("Menge", "wpsg"), 1, 0, 'C');
+                
+                $pdf->setXY($prod_left + 127, $prod_top + $sum_multi_offset);
+                $pdf->Cell(25, 8, __("Einzelpreis", "wpsg"), 1, 0, 'R');
+                
+                $pdf->setXY($prod_left + 152, $prod_top + $sum_multi_offset);
+                $pdf->Cell(25, 8, __("Gesamtpreis", "wpsg"), 1, 0, 'R');
+                
+                $offset = 8;
+                $bKopf = true;
+                
+            }
+            
+            $pdf->SetFont('Arial', '', 9);
+            $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
+            
+            if ($this->get_option('wpsg_mod_rechnungen_anr') == '1')
+            {
+                
+                $pdf->Cell(10, 8,  $p['anr'], 0, 0, 'C');
+                
+            }
+            else
+            {
+                
+                $pdf->Cell(10, 8, $pnr.".", 0, 0, 'C');
+                
+            }
+            
+            /* Wenn Detailname vorhanden, wird der Detailname auf Rechnung verwendet */
+            $produkt_text = $this->getProductName($this->getProduktID($p['id']), true);
+            
+            /* Falls Detailname vorhanden, wird jetzt der Produktname verwendet */
+            /* $produkt_text = $this->getProductName($this->getProduktID($p['id']), false); */
+            
+            $produktBeschreibung = trim(strip_tags($p['beschreibung']));
+            
+            if ($this->isOtherLang())
+            {
+                
+                $trans_db = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `lang_parent` = '".wpsg_q($this->getProduktID($p['id']))."' AND `lang_code` = '".wpsg_q($this->getCurrentLanguageCode())."'");
+                
+                if (is_array($trans_db) && sizeof($trans_db) > 0)
+                {
+                    
+                    $produkt_text = $trans_db['name'];
+                    $produktBeschreibung = trim(strip_tags($trans_db['beschreibung']));
+                    
+                }
+                
+            }
+            
+            $height = 0; // HÃ¶he der Zeile fÃŒr den Rahmen
+            
+            $pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
+            
+            // Produktvariablen 
+            if ($this->hasMod('wpsg_mod_productvars') && $this->get_option("wpsg_mod_rechnungen_showpv") == "1")
+            {
+                
+                $arPV = $this->callMod('wpsg_mod_productvars', 'getAllProductVarValues', array($oOrder['data']['id'], $p['product_index']));
+                
+                if (wpsg_isSizedArray($arPV))
+                {
+                    
+                    foreach ($arPV as $pv)
+                    {
+                        
+                        $produkt_text .= "\r\n".$pv['name'].': '.$pv['value'];
+                        $height += 5;
+                        
+                    }
+                    
+                }
+                
+            }
+            
+            if ($this->get_option('wpsg_mod_rechnungen_anr') === '2')
+            {
+                
+                $anr = $this->getProductAnr($p['productkey']);
+                $produkt_text .= "\r\n".wpsg_translate(__('Artikelnummer: #1#', 'wpsg'), $anr);
+                
+            }
+            
+            $produkt_text_cell_width = 102;
+            if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')
+            {
+                $produkt_text_cell_width = 87;
+            }
+            
+            $produkt_text_width = $pdf->GetStringWidth($produkt_text);
+            //$produkt_text_cell_width = (($this->arMwSt == "-1")?87:102);
+            
+            $height += 5 * ceil($produkt_text_width / $produkt_text_cell_width) + 3;
+            
+            $height_y = $pdf->getY();
+            $height = 2 + $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $offset + 1.5 + $sum_multi_offset, 5, $produkt_text, 0, 'L', 0, $produkt_text_cell_width);
+            
+            //$height += 3 + 5 + $pdf->getY() - $height_y;
+            //$pdf->Cell((($this->arMwSt == "-1")?102:87), 8, $produkt_text, 0, 0, 'L');
+            
+            if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1') {
+                
+                $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
+                $pdf->Cell(15, 8, (($this->view['basket']['noMwSt'] == '1')?'0.00 %':wpsg_ff($p['mwst_value'], '%')), 0, 0, 'C');
+                
+            }
+            
+            $pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(15, 8, $p['menge'], 0, 0, 'C');
+            
+            if (wpsg_ShopController::get_option('wpsg_preisangaben') == WPSG_NETTO)
+            {
+                $preis = $p['preis_netto'];
+                
+                //TODO
+            }
+            else
+            {
+                $preis = $p['preis_brutto'];
+            }
+            
+            $pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(25, 8, wpsg_ff($preis, $this->get_option('wpsg_currency')), 0, 0, 'R');
+            
+            $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(25, 8, wpsg_ff($preis * $p['menge'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+            
+            /**
+             * Produktbeschreibung anzeigen Ja/Nein
+             */
+            $pBeschreibungHeight = 0;
+            if ($this->get_option("wpsg_rechnungen_pbeschreibung") == "1" && trim(strip_tags($p['beschreibung'])) != '')
+            {
+                
+                $produktBeschreibung = nl2br($produktBeschreibung);
+                preg_match_all('/\<br \/\>/', $produktBeschreibung, $treffer);
+                $produktBeschreibung = strip_tags($produktBeschreibung);
+                
+                $pBeschreibungWidth = $pdf->getStringWidth($produktBeschreibung);
+                $pBeschreibungHeight = 5 * (ceil($pBeschreibungWidth / $produkt_text_cell_width) + @sizeof($treffer[0]));
+                
+                $pdf->SetFont('Arial', 'I', 9);
+                
+                $cellY = $pdf->getY();
+                $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 1 + $sum_multi_offset, 5, $produktBeschreibung, 0, 'L', 0, $produkt_text_cell_width);
+                $pBeschreibungHeight = $pdf->getY() - $cellY - $height + 1;
+                $pdf->SetFont('Arial', '', 9);
+                
+            }
+            
+            $height += $pBeschreibungHeight;
+            
+            /**
+             * Produktattribute ?
+             */
+            if ($this->get_option('wpsg_rechnungen_produktattribute') == '1')
+            {
+                
+                $attributeInfo = $this->callMod('wpsg_mod_produktattribute', 'getProductAttributeByProductId', array($this->getProduktId($p['id'])));
+                
+                foreach ($attributeInfo as $pa)
+                {
+                    
+                    $pa_text = $pa['name'].': '.$pa['value'];
+                    $height += $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 0.5 + $sum_multi_offset, 5, $pa_text, 0, 'L', 0, $produkt_text_cell_width);
+                    
+                }
+            }
+            
+            /**
+             * Variante ?
+             */
+            if (preg_match('/pv_(.*)/', $p['productkey']))
+            {
+                
+                $variInfo = $this->callMod('wpsg_mod_productvariants', 'getVariantenInfoArray', array($p['productkey']));
+                
+                $height += $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 0.5 + $sum_multi_offset, 5, wpsg_translate(__('Variante: #1#', 'wpsg'), $variInfo['key']), 0, 'L', 0, $produkt_text_cell_width);
+                
+                //$height += 5;
+                
+            }
+            
+            /**
+             * Lieferschein ?
+             */ 
+            if ($this->hasMod('wpsg_mod_deliverynote'))
+            {
+                
+                $arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($oOrder['data']['id']));
+                
+                if (sizeof($arDN_order) > 1)
+                {
+                    
+                    $deliveryTimeProduct = $this->callMod('wpsg_mod_deliverynote', 'getProductDeliveryTime', array($oOrder['data']['id'], $p['product_index']));
+                    
+                    if ($deliveryTimeProduct !== false)
+                    {
+                        
+                        $height += $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 0.5 + $sum_multi_offset, 5, wpsg_translate(__('Lieferdatum: #1#', 'wpsg'), date('d.m.Y', $deliveryTimeProduct)), 0, 'L', 0, $produkt_text_cell_width);
+                        
+                    }
+                    
+                }
+                
+            }
+            
+            // Jetzt die Rahmen zeichnen
+            $pdf->Rect($prod_left, $prod_top + $offset + $sum_multi_offset, 10, $height);
+            
+            $pdf->Rect($prod_left + 10, $prod_top + $offset + $sum_multi_offset, ((sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), $height);
+            
+            if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')
+            {
+                
+                $pdf->Rect($prod_left + 97, $prod_top + $offset + $sum_multi_offset, 15, $height);
+                
+            }
+            
+            $pdf->Rect($prod_left + 112, $prod_top + $offset + $sum_multi_offset, 15, $height);
+            $pdf->Rect($prod_left + 127, $prod_top + $offset + $sum_multi_offset, 25, $height);
+            $pdf->Rect($prod_left + 152, $prod_top + $offset + $sum_multi_offset, 25, $height);
+            
+            $offset += $height;
+            
+            $pnr ++;
+            $count ++;
+            
+            $summe += $p['price'] * $p['menge'];
+            
+            if ($pdf->getY() > 220 || ($count >= $prod_break && sizeof($oOrder['arCalculation']['produkte']) > ($pnr - 1)))
+            {
+                
+                AddRechnungPage($this, $pdf);
+                $bKopf = false; $count = 0; $offset = 0;
+                
+            }
+            
+        } // produkte
+	wpsg_debug($oOrder['arCalculation']);
+        // Gutschein
+        if (wpsg_isSizedArray($oOrder['arCalculation']['voucher'])) {
+            
+            foreach ($oOrder['arCalculation']['voucher'] as $v) {
+                
+                $pdf->SetFont('Arial', '', 9);
+                $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
+                $pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
+                
+                $pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
+                $pdf->Cell( ((sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, wpsg_translate(__('Gutschein (#1#)', 'wpsg'), $v['code']), 1, 0, 'L');
+                
+                if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')
+                {
+                    
+                    $mwst = __('anteilig', 'wpsg');
+                    
+                    $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
+                    $pdf->Cell(15, 8, $mwst, 1, 0, 'C');
+                    
+                }
+                
+                $pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
+                $pdf->Cell(15, 8, '1', 1, 0, 'C');
+                
+                $gs_value_einzel = wpsg_ff($v[$taxdisplay.'_single'], $this->get_option('wpsg_currency'));
+                $gs_value_gesamt = wpsg_ff($v[$taxdisplay], $this->get_option('wpsg_currency'));
+                
+                $pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
+                $pdf->Cell(25, 8, $gs_value_einzel, 1, 0, 'R');
+                
+                $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
+                $pdf->Cell(25, 8, $gs_value_gesamt, 1, 0, 'R');
+                
+                $offset += 8;
+                
+            }
+            
+        }
+
+        // Versandkosten
+        if ($oOrder['arCalculation']['sum']['preis_shipping'] != '' && $oOrder['arCalculation']['sum']['preis_shipping'] != 0)
+        {
+            
+            $pdf->SetFont('Arial', '', 9);
+            $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
+            
+            $pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell( ((sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, wpsg_translate(__('Versandkosten "#1#"', 'wpsg'), $this->view['oOrder']->getShippingLabel()), 1, 0, 'L');
+            
+            if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')
+            {
+                
+                if ($this->arShipping[$oOrder['data']['type_shipping']]['mwst_null'] == '1' && $oOrder['basket']['noMwSt'] == '1')
+                {
+                    
+                    $mwst = 0;
+                    
+                }
+                else
+                {
+                    
+                    if ($oOrder['arCalculation']['shipping'][0]['tax_key'] === '0') {
+                    
+                        $mwst = _('anteilig');
+                        
+                    } else {
+                                            
+                        $mwst = wpsg_ff($oOrder['arCalculation']['shipping'][0]['tax'], '%');
+                        $mwst = wpsg_ff($oOrder['arCalculation']['tax'][$oOrder['arCalculation']['shipping'][0]['tax_key']]['tax_value'], '%');
+                        
+                    }
+                    
+                }
+                
+                $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
+                $pdf->Cell(15, 8, $mwst, 1, 0, 'C');
+                
+            }
+            
+            $pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(15, 8, '1', 1, 0, 'C');
+            
+            $pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(25, 8, wpsg_ff($oOrder['arCalculation']['sum']['preis_shipping'], $this->get_option('wpsg_currency')), 1, 0, 'R');
+            
+            $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(25, 8, wpsg_ff($oOrder['arCalculation']['sum']['preis_shipping'], $this->get_option('wpsg_currency')), 1, 0, 'R');
+            
+            $offset += 8;
+            
+            // Zusammengesetzte Versandarten darstellen
+            /*
+            if (wpsg_isSizedArray($this->view['basket']['shipping']['methods'])) {
+            
+                foreach ($this->view['basket']['shipping']['methods'] as $shipping) {
+                        
+                    $pdf->SetFont('Arial', '', 9);
+                    $pdf->setXY($prod_left, $prod_top + $offset);
+                    $pdf->Cell(10, 8, '', 1, 0, 'C'); $pnr ++;
+                        
+                    $pdf->setXY($prod_left + 10, $prod_top + $offset);
+                    $pdf->Cell( ((sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, $this->getShippingName($shipping), 1, 0, 'L');
+                        
+                    if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')
+                    {
+                    
+                        if ($this->view['basket']['shipping'][$shipping]['tax_rata'] == 1) { $mwst = __('Anteilig', 'wpsg'); }
+                        else { $mwst = wpsg_ff($this->view['basket']['shipping'][$shipping]['mwst'], '%'); }
+                        
+                        $pdf->setXY($prod_left + 97, $prod_top + $offset);
+                        $pdf->Cell(15, 8, $mwst, 1, 0, 'C');
+                        
+                    }
+                    
+                    $pdf->setXY($prod_left + 112, $prod_top + $offset);
+                    $pdf->Cell(15, 8, '1', 1, 0, 'C');
+                        
+                    $pdf->setXY($prod_left + 127, $prod_top + $offset);
+                    $pdf->Cell(25, 8, wpsg_ff($this->view['basket']['shipping'][$shipping]['preis_shipping_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R');
+                    
+                    $pdf->setXY($prod_left + 152, $prod_top + $offset);
+                    $pdf->Cell(25, 8, wpsg_ff($this->view['basket']['shipping'][$shipping]['preis_shipping_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R');
+                        
+                    $offset += 8;
+                    
+                }
+            
+            }
+            */
+            
+            
+        }
+        
+        // Zahlungskosten
+        if ($oOrder['arCalculation']['sum']['preis_payment'] != '' && $oOrder['arCalculation']['sum']['preis_payment'] != 0)
+        {
+            
+            $pdf->SetFont('Arial', '', 9);
+            $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
+            
+            $pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell( ((sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, $this->arPayment[$oOrder['data']['type_payment']]['name'], 1, 0, 'L');
+            
+            if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')
+            {
+                
+                if ($this->arPayment[$oOrder['data']['type_payment']]['mwst_null'] == '1' && $this->view['basket']['noMwSt'] == '1')
+                {
+                    $mwst = 0;
+                }
+                else
+                {
+                    
+                    if ($oOrder['arCalculation']['payment'][0]['tax_key'] === '0') {
+                        
+                        $mwst = _('anteilig');
+                        
+                    } else {
+                        
+                        $mwst = wpsg_ff($oOrder['arCalculation']['payment'][0]['tax'], '%');
+                        $mwst = wpsg_ff($oOrder['arCalculation']['tax'][$oOrder['arCalculation']['payment'][0]['tax_key']]['tax_value'], '%');
+                        
+                    }
+                    
+                }
+                
+                $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
+                $pdf->Cell(15, 8, $mwst, 1, 0, 'C');
+                
+            }
+            
+            $pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(15, 8, '1', 1, 0, 'C');
+            
+            $pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(25, 8, wpsg_ff($oOrder['arCalculation']['sum']['preis_payment'], $this->get_option('wpsg_currency')), 1, 0, 'R');
+            
+            $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(25, 8, wpsg_ff($oOrder['arCalculation']['sum']['preis_payment'], $this->get_option('wpsg_currency')), 1, 0, 'R');
+            
+            $offset += 8;
+            
+        }
+        
+        // GebÃŒhr
+        if (wpsg_tf(wpsg_getStr($this->view['storno_fee'])) > 0)
+        {
+            
+            $pdf->SetFont('Arial', '', 9);
+            $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
+            
+            $label = __('BearbeitungsgebÃŒhr', 'wpsg');
+            
+            if (strpos($this->view['storno_fee'], '%') !== false) $label .= ' ('.wpsg_ff($this->view['storno_fee'], '%').')';
+            
+            $pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell( ((sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, $label, 1, 0, 'L');
+            
+            if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')
+            {
+                
+                if ($this->view['basket']['noMwSt'] == '1')
+                {
+                    $mwst = 0;
+                }
+                else
+                {
+                    
+                    
+                    $mwst = wpsg_ff($this->view['storno_fee_tax_value'], '%');
+                    
+                }
+                
+                $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
+                $pdf->Cell(15, 8, $mwst, 1, 0, 'C');
+                
+            }
+            
+            $pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(15, 8, '1', 1, 0, 'C');
+            
+            $pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
+            
+            $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
+            $pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
+            
+            $offset += 8;
+
+        }
+
+        // Bestellbetrag einer einzelnen Bestellung
+        if ($arCalculation['noMwSt'] == '1')
+		{
+            $pdf->Text($prod_left + 115, $prod_top + $offset + $sum_multi_offset + 6, __("Bestellbetrag (NETTO):", "wpsg"));
+			$pdf->setXY($prod_left + 140, $prod_top + $offset + $sum_multi_offset + 1);
+			$pdf->Cell(37, 8, wpsg_ff($oOrder['arCalculation']['sum']['productsum_netto'] + $oOrder['arCalculation']['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+        } 
+        else 
+        {
+            $pdf->Text($prod_left + 115, $prod_top + $offset + $sum_multi_offset + 6, __("Bestellbetrag (BRUTTO):", "wpsg"));
+			$pdf->setXY($prod_left + 140, $prod_top + $offset + $sum_multi_offset + 1);
+			$pdf->Cell(37, 8, wpsg_ff($oOrder['arCalculation']['sum']['productsum_brutto'] + $oOrder['arCalculation']['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+        }
+
+
+        $sum_multi_offset += ($offset + 30);
+
+    } // FOREACH ORDER END
+	
+	$pdf->SetFont('Arial', '', 9);
+	
+	if ($this->view['kunde']['ustidnr'] != "")
+	{
+		$offset += 10;
+		$pdf->Text($prod_left, $prod_top + $offset, __("Ihre Umsatzsteuer-Identifikationsnummer:", "wpsg"));
+		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
+		$pdf->Cell(37, 8, $this->view['kunde']['ustidnr'], 0, 0, 'R');
+	}
+
+	$offset += 10;
+	if ($this->get_option('wpsg_kleinunternehmer'))
+	{
+		
+		$pdf->Text($prod_left, $prod_top + $offset + 10, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
+		$pdf->Text($prod_left + 80, $prod_top + $offset, __("Summe", "wpsg"));
+		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
+		$pdf->Cell(37, 8, wpsg_ff($sum_productsum_brutto + $arCalculation['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+		$offset += 5;
+		
+	}
+	else
+	{
+		
+		if ($arCalculation['noMwSt'] == '1')
+		{
+			
+			$pdf->Text($prod_left, $prod_top + $offset + 10, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
+			$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("BRUTTOBETRAG", "wpsg"));
+			$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
+			$pdf->Cell(37, 8, wpsg_ff($sum_topay_brutto + $arCalculation['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+			$offset += 5;
+			
+			$pdf->Text($prod_left + 80, $prod_top + $offset, __("MwSt. GESAMT", "wpsg"));
+			$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
+			$pdf->Cell(37, 8, wpsg_ff(0, $this->get_option('wpsg_currency')), 0, 0, 'R');
+			
+		}
+		else
+		{
+			
+			$pdf->Text($prod_left, $prod_top + $offset + 10, __("Der Gesamtbetrag setzt sich wie folgt zusammen", "wpsg"));
+			
+			$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("NETTOBETRAG GESAMT", "wpsg"));
+			$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
+			$pdf->Cell(37, 8, wpsg_ff($sum_topay_netto + $arCalculation['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+			
+			if (sizeof($arCalculation['tax']) >= 1)
+			{
+				
+				foreach ($arCalculation['tax'] as $mw)
+				{
+					
+					$offset += 5;
+					$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("MwSt. ", "wpsg").wpsg_ff($mw['value'], '%'));
+					$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
+					$pdf->Cell(37, 8, wpsg_ff($mw['sum'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+					
+				}
+				
+			}
+			
+			if (sizeof($arCalculation['tax']) > 1)
+			{
+				
+				$offset += 5;
+				$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("MwSt. GESAMT", "wpsg"));
+				$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
+				$pdf->Cell(37, 8, wpsg_ff($sum_productsum_brutto - $sum_productsum_netto, $this->get_option('wpsg_currency')), 0, 0, 'R');
+				
+			}
+			
+		}
+		
+	}
+	
+	// Rabatt
+	if ($arCalculation['sum']['preis_rabatt'] > 0)
+	{
+		
+		$offset += 5;
+		
+		$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("Rabatt", "wpsg"));
+		$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
+		$pdf->Cell(37, 8, '-'.wpsg_ff($arCalculation['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+		
+	}
+		
+	// Wertgutschein
+	if ($arCalculation['sum']['topay_brutto'] !== $arCalculation['sum']['brutto']) {
+		
+		$offset += 5;
+		$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("Bruttobetrag GESAMT", "wpsg"));
+		$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
+		
+		$pdf->setFont('Arial', '', '9');
+		$pdf->Cell(37, 8, wpsg_ff($sum_productsum_brutto, $this->get_option('wpsg_currency')), 0, 0, 'R');
+		$pdf->setFont('Arial', '', '9');
+
+        foreach ($orders as $oCoupons){
+
+            foreach ($arCalculation['coupon'] as $c) {
+                
+                $offset += 5;
+                $pdf->Text($prod_left + 80, $prod_top + $offset + 10, __('Wertgutschein', 'wpsg').' '.((wpsg_isSizedString($c['code']))?'('.$c['code'].')':''));
+                $pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
+                
+                $pdf->setFont('Arial', '', '9');
+                $pdf->Cell(37, 8, wpsg_ff($c[$taxdisplay], $this->get_option('wpsg_currency')), 0, 0, 'R');
+                $pdf->setFont('Arial', '', '9');
+                
+            }
+
+        }
+		
+		$offset += 5;
+		$pdf->setFont('Arial', 'B', '9');
+		$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("ZU ZAHLEN", "wpsg"));
+		$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
+		
+		/* Endbetrag wird fett ausgegeben */
+		$pdf->setFont('Arial', 'B', '9');
+		$pdf->Cell(37, 8, wpsg_ff($sum_topay_brutto, $this->get_option('wpsg_currency')), 0, 0, 'R');
+		$pdf->setFont('Arial', '', '9');
+		
+	} else {
+	
+		$offset += 5;
+		$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("GESAMTSUMME", "wpsg"));
+		$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
+		/* Endbetrag wird fett ausgegeben */
+		$pdf->setFont('Arial', 'B', '9');
+		$pdf->Cell(37, 8, wpsg_ff($sum_topay_brutto, $this->get_option('wpsg_currency')), 0, 0, 'R');
+		$pdf->setFont('Arial', '', '9');
+				
+	}
+	
+	if ($this->get_option('wpsg_kleinunternehmer') == '1')
+	{
+		
+		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 15, 5, $this->get_option('wpsg_kleinunternehmer_text'));
+		$offset += 15;
+		
+	}
+	
+	if ($this->hasMod('wpsg_mod_deliverynote'))
+	{
+		
+		$arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($data['id']));
+		$delivery_date = $this->callMod('wpsg_mod_deliverynote', 'getDeliveryTime', array($data['id']));
+		
+		// Wenn es ein Gesamtlieferdatum gibt und nur einen Lieferschein, dann unter der Bestellung anzeigen
+		if ($delivery_date !== false && sizeof($arDN_order) == 1)
+		{
+			
+			$offset += 10;
+			
+			$pdf->wpsg_MultiCell($prod_left, $prod_top + $offset + 10, 5, wpsg_translate(__('Lieferung: #1#', 'wpsg'), date('d.m.Y', $delivery_date)));
+			
+			$offset += 5;
+			
+		}
+		
+	}
+	
+	$offset += 5;
+	
+	if ($this->view['fussText'] != "")
+	{
+		
+		//$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, utf8_encode($this->view['fussText']));		
+		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 10, 5, $this->view['fussText']);
+		$pdf->SetFont('Arial', 'B', 9);
+		$offset += 10;
+		
+	}
+	
+	$shipping_adress = false;
+	
+	if ($this->hasMod('wpsg_mod_shippingadress') && $this->callMod('wpsg_mod_shippingadress', 'check_different_shippingadress', array('k_id' => $data['k_id'], 'o_id' => $data['id']))) {
+		
+		$pdf->setFont('Arial', 'B', 9);
+		$pdf->Text($prod_left, $prod_top + $offset + 10, __("Lieferanschrift", "wpsg").":");
+		$offset += 5;
+		
+		$pdf->setFont('Arial', '', 9);
+		
+		$shipping_adress = "";
+		if ($data['shipping_firma'] != "")
+		{
+			$shipping_adress .= $data['shipping_firma']."\r\n";
+		}
+		$shipping_adress .= $data['shipping_vname'].' '.$data['shipping_name']."\r\n";
+		$shipping_adress .= $data['shipping_strasse'].' '.$data['shipping_nr']."\r\n";
+		//$shipping_adress .= $data['shipping_land']['kuerzel'].'-';
+		
+		$shipping_adress .= $data['shipping_plz'].' '.$data['shipping_ort']."\r\n";
+		$shipping_adress .= $data['shipping_land']['name'];
+		
+		
+		$start = $pdf->getY();
+		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 10, 5, $shipping_adress, 0, 'L', 0, 100);
+		$offset += $pdf->getY() - $start;
+		
+		$shipping_adress = true;
+		
+	}
+	
+	$offset += 5;
+	
+	// Bestellvariablen
+	if ($this->hasMod('wpsg_mod_ordervars') && $this->get_option('wpsg_mod_rechnungen_showov') == '1')
+	{
+		
+		$bvars = @unserialize($data['bvars']);
+		if (!is_array($bvars)) $bvars = array();
+		
+		$strBVars = "";
+		foreach ($bvars as $bvars_id => $bvars_value)
+		{
+			
+			$bvars = $this->db->fetchRow("SELECT * FROM `".wpsg_q(WPSG_TBL_ORDERVARS)."` WHERE `id` = '".wpsg_q($bvars_id)."' ORDER BY `pos` ASC, `id` ASC ");
+			
+			if ($bvars['typ'] == "1") // Auswahl
+			{
+				if ($bvars_value <= 0) $bvars_value = __("Keine Angabe", "wpsg");
+			}
+			else if ($bvars['typ'] == "2") // Texteingabe
+			{
+				if (trim($bvars_value) == "") $bvars_value = __("Keine Angabe", "wpsg");
+			}
+			else if ($bvars['typ'] == "3") // Checkbox
+			{
+				if ($bvars_value <= 0) $bvars_value = __("Keine Angabe", "wpsg");
+			}
+			
+			$bvars_name = $this->callMod('wpsg_mod_ordervars', 'getNameById', array($bvars_id));
+			$strBVars .= "\r\n".$bvars_name.": ".$bvars_value;
+			
+		}
+		
+		$pdf->SetFont('Arial', 'B', 9);
+		$pdf->Text($prod_left, $prod_top + $offset + 10, __("Angaben wÃ€hrend der Bestellung", "wpsg").":");
+		$pdf->SetFont('Arial', '', 9);
+		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 10, 5, $strBVars);
+		
+	}
+	
+	if (!file_exists($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($data['id']))))
+	{
+		
+		mkdir($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($data['id'])), 0777, true);
+		
+	}
+	
+	$this->callMods('wpsg_mod_rechnungen_pdf', array(&$pdf, &$data['id'], &$this->view['preview'], &$this->view['invoice']));
+	
+	$filename = $this->view['filename'].".pdf";
+	
+	//ob_end_clean();
+	
+    // wpsg_debug("Generierter Dateipfad: ".$this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($data['id'])).$filename, 'F'); // DEBUG
+
+	if ($this->view['preview']) {
+		
+		$pdf->Output($filename, 'I');
+		
+	} else {
+		
+		$pdf->Output($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($data['id'])).$filename, 'F');
+		
+		// Hier wird der Dateiname an FPD ÃŒbergeben. Er soll sich aus der Rechnungsnummer ergeben, auch wenn das Dokument ÃŒber die ID gespeichert ist.
+		if ($this->view['output'] === true) $pdf->Output($this->view['filename_out'], 'I');
+		
+	}
+
+?>
Index: /views/order/index.phtml
===================================================================
--- /views/order/index.phtml	(revision 8067)
+++ /views/order/index.phtml	(revision 8068)
@@ -429,4 +429,7 @@
                     <?php if ($this->hasMod('wpsg_mod_rechnungen')) { ?>
                     <option value="writeRechnung"><?php echo __('Rechnung schreiben', 'wpsg'); ?></option>
+                    <?php if ($this->view['arFilter']['k_id'] != '') { ?>
+                    <option value="writeMultiRechnung"><?php echo __('Sammelrechnung schreiben', 'wpsg'); ?></option>
+                    <?php } ?>
                     <option value="showRechnung"><?php echo __('Rechnung ansehen', 'wpsg'); ?></option>
                     <?php } ?>
@@ -463,4 +466,44 @@
                     
                 </script>
+
+                <div class="multiRechnung_tab" id="multiRechnung_inform" style="display:none;">
+                    <br />
+                    <input type="checkbox" name="wpsg_Multirechnung_sendmail" value="1" id="invoice_sendmail" />
+                    <label for="invoice_sendmail"><?php echo __('E-Mail an Kunden senden', 'wpsg'); ?></label>
+                    <input type="email" name="wpsg_Multirechnung_email" value="" />
+                    <br />
+                    <input type="checkbox" name="wpsg_Multirechnung_faelligkeit" value="1" id="invoice_faelligkeit" />
+                    <label for="invoice_faelligkeit"><?php echo __('FÃ€lligkeit anzeigen', 'wpsg'); ?></label>
+                    <input type="date" name="wpsg_Multirechnung_faelligkeitsdatum" value="<?php echo date('Y-m-d'); ?>" />
+                    <br />
+                    <input type="checkbox" name="wpsg_Multirechnung_shippay" value="1" id="invoice_shippay"/>
+                    <label for="invoice_shippay"><?php echo __('Versand-/Zahlungskosten abrechnen', 'wpsg'); ?></label>
+                    <br />
+                    <input type="checkbox" name="wpsg_Multirechnung_url" value="1" id="invoice_url" />
+                    <label for="invoice_url"><?php echo __('URL Benachrichtigung', 'wpsg'); ?></label>
+                    <br />
+                    <label for="invoice_date"><?php echo __('Rechnungsdatum', 'wpsg') ;?></label>
+                    <input type="date" value="<?php echo date('Y-m-d'); ?>" name="wpsg_Multirechnung_datum" id="invoice_date" />
+                </div>
+
+                <script>
+                    
+                    let el_multiRechnung_inform = document.getElementById('multiRechnung_inform');
+                    
+                    document.getElementById('wpsg_action').addEventListener('change', (event) => {
+                    	
+                        if (event.target.value === 'writeMultiRechnung') {
+                            
+                            el_multiRechnung_inform.style.display = 'block';
+                            
+                        } else {
+                    		
+                    		el_multiRechnung_inform.style.display = 'none';
+                    		
+                        }
+                    	
+                    });
+                    
+                </script>
                 
             </div>
