Index: /changelog
===================================================================
--- /changelog	(revision 8343)
+++ /changelog	(revision 8344)
@@ -597,5 +597,5 @@
 #4.4.6
 - Feature: Modul Vorkasse: QR-Code ist nun deaktivierbar
-- Feature: Modul Vorkasse: QR-Code wird nun in der BestellbestÃ€tigung (E-Mail) dargestellt
-- Feature: Modul Vorkasse: QR-Code von QR-Rechnung (Schweiz) kann nun auf der Bestellabschlussseite/BestellbestÃ€tigung (E-Mail) angezeigt werden.
+- Feature: Modul Vorkasse: QR-Rechnung ist nun an BestellbestÃ€tigung (E-Mail) anhÃ€ngbar
+- Feature: Modul Vorkasse: Girocode und QR-Code von QR-Rechnung wird nun in der BestellbestÃ€tigung (E-Mail) dargestellt
 - Bugfix: Modul Produktvarianten: Produktvariationen mit einen "ungesetzten" Preis fÃŒhren nun zu keinem Fehler in der Bestellverwaltung mehr  
Index: /lib/wpsg_basket.class.php
===================================================================
--- /lib/wpsg_basket.class.php	(revision 8343)
+++ /lib/wpsg_basket.class.php	(revision 8344)
@@ -668,4 +668,27 @@
 					
 				}
+
+				// QR-Rechnung an die Mail anhÃ€ngen
+				if ($this->shop->hasMod('wpsg_mod_prepayment') && $this->shop->get_option('wpsg_mod_prepayment_mailattachment') === '1') {
+
+					require_once WPSG_PATH_LIB.'phpgirocode.class.php';
+
+					$qrbillFile = $this->shop->callMod('wpsg_mod_prepayment', 'getFilePath', array($oOrder->getId));
+
+					if (file_exists($qrbillFile) && is_file($qrbillFile))
+					{		
+
+						$arAttachments[] = $qrbillFile;
+
+					} else {
+
+						// generate the qr-bill
+						$this->shop->callMod('wpsg_mod_prepayment', 'genQRCode', array($order_id, $this->shop->view['wpsg_mod_prepayment']['subject'], $this->shop->view['basket']['sum']['preis_gesamt_brutto'], 10, PhpGirocode::OUTPUT_BASE64, $this->shop->get_option('wpsg_mod_prepayment_qrcode_country'), $this->shop->view['basket']));
+					
+						$arAttachments[] = $this->shop->callMod('wpsg_mod_prepayment', 'getFilePath', array($order_id));
+
+					}
+					
+				}
 				
 				if ($bDebug === true) $empfaenger = $this->shop->get_option('wpsg_adminmail_empfaenger');
Index: /mods/wpsg_mod_prepayment.class.php
===================================================================
--- /mods/wpsg_mod_prepayment.class.php	(revision 8343)
+++ /mods/wpsg_mod_prepayment.class.php	(revision 8344)
@@ -2,5 +2,4 @@
 
 	use Sprain\SwissQrBill as QrBill;		
-	// use Sprain\SwissQrBill\QrCode\QrCode as QrCode;
 
 	/**
@@ -65,4 +64,5 @@
 			$this->shop->update_option('wpsg_mod_prepayment_qrcode', $_REQUEST['wpsg_mod_prepayment_qrcode'], false, false, WPSG_SANITIZE_CHECKBOX);
 			$this->shop->update_option('wpsg_mod_prepayment_qrcode_country', $_REQUEST['wpsg_mod_prepayment_qrcode_country'], false, false, WPSG_SANITIZE_VALUES, [wpsg_mod_prepayment::QRCODE_BOTH, wpsg_mod_prepayment::QRCODE_EPC, wpsg_mod_prepayment::QRCODE_SWISS]);
+			$this->shop->update_option('wpsg_mod_prepayment_mailattachment', $_REQUEST['wpsg_mod_prepayment_mailattachment'], false, false, WPSG_SANITIZE_CHECKBOX);
 			$this->shop->update_option('wpsg_mod_prepayment_hint', $_REQUEST['wpsg_mod_prepayment_hint'], false, false, WPSG_SANITIZE_TEXTFIELD);
 			$this->shop->update_option('wpsg_mod_prepayment_gebuehr', $_REQUEST['wpsg_mod_prepayment_gebuehr'], false, false, WPSG_SANITIZE_FLOAT);
@@ -176,4 +176,53 @@
 
 		/**
+		 * @throws \Exception
+		 */
+		public function getFilePath($order_id) {
+
+            $ym = date('Y/m');
+
+			if ($this->shop->isMultiBlog()) $path = WP_CONTENT_DIR.'/'.WPSG_MB_UPLOADS.'/wpsg/wpsg_qrrechnungen/'.$ym.'/';
+			else $path = WPSG_PATH_CONTENT.'uploads/wpsg/wpsg_qrrechnungen/'.$ym.'/';
+
+			$path .= $order_id.'.pdf';
+
+			\wpsg_ShopController::getShop()->protectDirectory(dirname($path));
+
+			return $path;
+			
+		} // public function getFilePath()
+
+		/**
+		 * QR-Rechnung PDF fÃŒr eMail erzeugen
+		 */
+		public function genQRBill(QrBill\QrBill $qrBill, $order_id) {
+
+			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';
+
+			if (!file_exists(WPSG_PATH_UPLOADS.'wpsg_qrrechnungen/')) mkdir(WPSG_PATH_UPLOADS.'wpsg_qrrechnungen/', 0755, true);
+
+			$fpdf = new wpsg_fpdf('P', 'mm', 'A4');
+			// if (ini_get('allow_url_fopen')) $fpdf = new wpsg_fpdf('P', 'mm', 'A4');
+			// else {
+
+			// 	$fpdf = new class('P', 'mm', 'A4') extends wpsg_fpdf {
+			// 		use \Fpdf\Traits\MemoryImageSupport\MemImageTrait;
+			// 	};
+
+			// }
+
+			$fpdf->AddPage();
+
+			$output = new QrBill\PaymentPart\Output\FpdfOutput\FpdfOutput($qrBill, 'en', $fpdf);
+			$output->setPrintable(false)->getPaymentPart();
+
+			$path = $this->getFilePath($order_id);
+			$fpdf->Output($path, 'F');
+
+		} // public function genQRBill($qrBill)
+
+		/**
 		 * Funktion zum Generieren des Base64-Strings aus dem Schweizer QR-Code
 		 */
@@ -325,4 +374,6 @@
 					$ret[] = $qrCode; 
 
+					if (!file_exists($this->getFilePath($order_id).'/'.$order_id.'.pdf')) $this->genQRBill($qrBill, $order_id);
+
 				}
 
@@ -452,7 +503,8 @@
 						'invoiceAmount' => $betrag
 					);		
-				
 					$ret = $qrCode;
 
+					if (!file_exists($this->getFilePath($order_id).'/'.$order_id.'.pdf')) $this->genQRBill($qrBill, $order_id);
+
 				}
 
Index: /views/mods/mod_prepayment/mail_html.phtml
===================================================================
--- /views/mods/mod_prepayment/mail_html.phtml	(revision 8343)
+++ /views/mods/mod_prepayment/mail_html.phtml	(revision 8344)
@@ -32,5 +32,5 @@
 	</tr>
 	<?php 
-
+	
 		if (isset($this->view['mod_prepayment']['subject']) && ($this->get_option('wpsg_mod_prepayment_qrcode') == true)) {
 
@@ -43,7 +43,7 @@
 				$qrcodes = array();
 				$qrcodes = $this->callMod('wpsg_mod_prepayment', 'genQRCode', array($this->view['o_id'], $this->view['wpsg_mod_prepayment']['subject'], $this->view['basket']['sum']['preis_gesamt_brutto'], 3, PhpGirocode::OUTPUT_BASE64, $this->get_option('wpsg_mod_prepayment_qrcode_country'), $this->view['basket']));
+				
 				foreach ($qrcodes as $qr) {
 
-					// Base64 QR-Image
 					if ($qr['title'] == 'QR-Rechnung') echo '<tr style="margin-top:25px;" >';
 					else echo '<tr>';
@@ -61,5 +61,5 @@
 					<tr>
 						<td>'.__($qrcode['title'], 'wpsg').':</td>
-						<td style="float:right;">'.$qrcode['hash'].'</td>
+						<td style="float:right;" alt="qrcode">'.$qrcode['hash'].'</td>
 					</tr>
 				';
@@ -72,5 +72,5 @@
 					<tr>
 						<td>'.__($qrcode['title'], 'wpsg').':</td>
-						<td style="float:right;">'.$qrcode['hash'].'</td>
+						<td style="float:right;" alt="qrcode">'.$qrcode['hash'].'</td>
 					</tr>
 				';
Index: /views/mods/mod_prepayment/order_done.phtml
===================================================================
--- /views/mods/mod_prepayment/order_done.phtml	(revision 8343)
+++ /views/mods/mod_prepayment/order_done.phtml	(revision 8344)
@@ -31,5 +31,5 @@
 			$img = array();
 			$img = $this->callMod('wpsg_mod_prepayment', 'genQRCode', array($this->view['o_id'], $this->view['wpsg_mod_prepayment']['subject'], $this->view['basket']['sum']['preis_gesamt_brutto'], 10, PhpGirocode::OUTPUT_BASE64, $this->get_option('wpsg_mod_prepayment_qrcode_country'), $this->view['basket']));
-		
+
 		?>
 
Index: /views/mods/mod_prepayment/settings_edit.phtml
===================================================================
--- /views/mods/mod_prepayment/settings_edit.phtml	(revision 8343)
+++ /views/mods/mod_prepayment/settings_edit.phtml	(revision 8344)
@@ -10,5 +10,5 @@
 <?php echo wpsg_drawForm_Checkbox('wpsg_mod_prepayment_aktiv', __('Aktiv', 'wpsg'), $this->get_option('wpsg_mod_prepayment_aktiv'), array('help' => 'wpsg_mod_prepayment_aktiv')); ?>
 <?php echo wpsg_drawForm_Checkbox('wpsg_mod_prepayment_qrcode', __('QR-Code anzeigen', 'wpsg'), $this->get_option('wpsg_mod_prepayment_qrcode'), array('help' => 'wpsg_mod_prepayment_qrcode')); ?>
-<div id="wpsg_mod_prepayment_qrcode_country_layer" style="display: none;">
+<div id="wpsg_mod_prepayment_qrcode_options_layer" style="display: none;">
 	<?php echo wpsg_drawForm_Select('wpsg_mod_prepayment_qrcode_country', __('QR-Code fÃŒr', 'wpsg'), Array(
 					wpsg_mod_prepayment::QRCODE_BOTH => __('Beide', 'wpsg'),
@@ -16,4 +16,5 @@
 					wpsg_mod_prepayment::QRCODE_SWISS => __('QR-Rechnung', 'wpsg')
 				), $this->get_option('wpsg_mod_prepayment_qrcode_country'), array('help' => 'wpsg_mod_prepayment_qrcode_country')); ?>
+	<?php echo wpsg_drawForm_Checkbox('wpsg_mod_prepayment_mailattachment', __('QR-Rechnung an BestellbestÃ€tigung anhÃ€ngen', 'wpsg'), $this->get_option('wpsg_mod_prepayment_mailattachment'), array('help' => 'wpsg_mod_prepayment_mailattachment')); ?>
 </div>
 
@@ -39,5 +40,5 @@
 
 		var qrcodeAktiveCheckbox = document.getElementById('wpsg_mod_prepayment_qrcode');
-		var qrcodeSelectDiv = document.getElementById('wpsg_mod_prepayment_qrcode_country_layer');
+		var qrcodeSelectDiv = document.getElementById('wpsg_mod_prepayment_qrcode_options_layer');
 
 		
