Index: /changelog
===================================================================
--- /changelog	(revision 8511)
+++ /changelog	(revision 8512)
@@ -655,4 +655,5 @@
 - Feature: Gutschein Produktauswahl alphabetisch sortiert und inaktive Produkte werden nicht angezeigt
 - Feature: GutscheinÃŒbersicht neue Spalte "Produkte"
+- Feature: Gutscheine duplizierbar
 - Feature: Exportprofile/Statistik - Export von KÃ€ufen
 - Feature: Exportprofile/Staffelpreise - Export von minimalen Brutto-/Netto Produktpreis
Index: /mods/mod_gutschein/wpsg_voucher.php
===================================================================
--- /mods/mod_gutschein/wpsg_voucher.php	(revision 8511)
+++ /mods/mod_gutschein/wpsg_voucher.php	(revision 8512)
@@ -130,4 +130,9 @@
 
         }
+
+		public function getCode() { return $this->__get('code'); }
+
+		public function getStartDate(string $strFormat = 'Y-m-d'): string { $date = $this->__get('start_date'); return (new DateTime($date))->format($strFormat); }
+		public function getEndDate(string $strFormat = 'Y-m-d'): string { $date = $this->__get('end_date'); return (new DateTime($date))->format($strFormat); }
 
 		/**
@@ -335,5 +340,5 @@
 			$strQueryORDER = "";
 
- 			if (wpsg_isSizedString($arFilter['s'])) $strQueryWHERE .= " AND V.`code` LIKE '%".wpsg_q($arFilter['s'])."%' ";
+ 			if (wpsg_isSizedString($arFilter['s'])) $strQueryWHERE .= " AND ( V.`code` LIKE '%".wpsg_q($arFilter['s'])."%' OR V.`comment` LIKE '%".wpsg_q($arFilter['s'])."%' ) ";
 
 			if (wpsg_isSizedString($arFilter['code'])) $strQueryWHERE .= " AND V.`code` LIKE '%".wpsg_q($arFilter['code'])."%' ";
Index: /mods/wpsg_mod_gutschein.class.php
===================================================================
--- /mods/wpsg_mod_gutschein.class.php	(revision 8511)
+++ /mods/wpsg_mod_gutschein.class.php	(revision 8512)
@@ -438,37 +438,66 @@
 		public function be_ajax_duplicate() {
 
-			$oVoucher = wpsg_voucher::getInstance(intval($_REQUEST['voucher_id']));
-
-			$productgroups = array();
-			$products = array();
+			if (!isset($_POST['wpsg_voucher_clone_dialog']) || !wp_verify_nonce($_POST['wpsg_voucher_clone_dialog'], 'wpsg_voucher_clone_dialog' ) ) {
+
+				$this->shop->addBackendError(__('Fehler beim Duplizieren des Gutscheins!', 'wpsg'));
+				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Voucher&action=index'); exit;
+
+			}
+
+			$voucher_id = intval($_POST['voucher_id']);
+			$wpsg_mod_gutschein_clone_start = \sanitize_text_field($_REQUEST['wpsg_mod_gutschein_clone_start']);
+			$wpsg_mod_gutschein_clone_end = \sanitize_text_field($_REQUEST['wpsg_mod_gutschein_clone_end']);
+			$wpsg_mod_gutschein_clone_count = intval($_REQUEST['wpsg_mod_gutschein_clone_count']??1);
+			$wpsg_mod_gutschein_clone_comment = \sanitize_text_field($_REQUEST['wpsg_mod_gutschein_clone_comment']??'');
+
+			$oVoucher = wpsg_voucher::getInstance($voucher_id);
+
+			$productgroups = [];
+			$products = [];
 
 			$pgStr = $oVoucher->__get('productgroups');
 			$prStr = $oVoucher->__get('products');
+
 			if (wpsg_isSizedString($pgStr)) {
+
 				foreach (explode(',', $pgStr) as $id) { if (wpsg_isSizedInt($id)) $productgroups[] = intval($id); }
-			}
+
+			}
+
 			if (wpsg_isSizedString($prStr)) {
+
 				foreach (explode(',', $prStr) as $id) { if (wpsg_isSizedInt($id)) $products[] = intval($id); }
-			}
-
-			$code = $this->genGS(
-				$oVoucher->__get('value'),
-				$oVoucher->__get('calc_typ'),
-				strtotime($oVoucher->__get('start_date')),
-				strtotime($oVoucher->__get('end_date')),
-				$oVoucher->__get('multi'),
-				$this->shop->get_option('wpsg_mod_gutschein_size'),
-				$oVoucher->__get('comment'),
-				$oVoucher->__get('autocreate_order'),
-				$oVoucher->__get('autocreate_product'),
-				$oVoucher->__get('autocreate_order_product'),
-				$productgroups,
-				$products,
-				$oVoucher->__get('minvalue'),
-				false,
-				($oVoucher->__get('coupon') == '1')
-			);
-
-			$this->shop->addBackendMessage(wpsg_translate(__('Gutschein erfolgreich dupliziert. Neuer Code: #1#', 'wpsg'), $code)); echo '1';
+
+			}
+
+			$start_date = DateTime::createFromFormat('d.m.Y', $wpsg_mod_gutschein_clone_start)->getTimestamp();
+			$end_date = DateTime::createFromFormat('d.m.Y', $wpsg_mod_gutschein_clone_end)->getTimestamp();
+
+			for ($i = 1; $i <= $wpsg_mod_gutschein_clone_count; $i ++) {
+
+				$code = $this->genGS(
+					$oVoucher->__get('value'),
+					$oVoucher->__get('calc_typ'),
+					$start_date,
+					$end_date,
+					$oVoucher->__get('multi'),
+					$this->shop->get_option('wpsg_mod_gutschein_size'),
+					$wpsg_mod_gutschein_clone_comment,
+					$oVoucher->__get('autocreate_order'),
+					$oVoucher->__get('autocreate_product'),
+					$oVoucher->__get('autocreate_order_product'),
+					$productgroups,
+					$products,
+					$oVoucher->__get('minvalue'),
+					false,
+					($oVoucher->__get('coupon') == '1')
+				);
+
+			}
+
+			if ($wpsg_mod_gutschein_clone_count === 1) $this->shop->addBackendMessage(wpsg_translate(__('Gutschein erfolgreich dupliziert. Neuer Code: #1#', 'wpsg'), $code));
+			else $this->shop->addBackendMessage(wpsg_translate(__('Gutscheine erfolgreich dupliziert.', 'wpsg'), $code));
+
+			$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Voucher&action=index');
 
 		}
Index: /views/mods/mod_gutschein/index.phtml
===================================================================
--- /views/mods/mod_gutschein/index.phtml	(revision 8511)
+++ /views/mods/mod_gutschein/index.phtml	(revision 8512)
@@ -38,5 +38,5 @@
 						<input id="wpsg_ascdesc" type="hidden" name="filter[ascdesc]" value="<?php echo @$this->view['arFilter']['ascdesc']; ?>" />
 
-						<?php echo wpsg_drawForm_Input('filter[s]', __('Suchfeld', 'wpsg'), wpsg_getStr($this->view['arFilter']['s'])); ?>
+						<?php echo wpsg_drawForm_Input('filter[s]', __('Suchfeld', 'wpsg'), stripslashes(wpsg_getStr($this->view['arFilter']['s']))); ?>
 
 						<?php echo wpsg_drawForm_SubmitButton(__('Gutscheine suchen')); ?><br />
@@ -106,5 +106,10 @@
 									<span><a title="<?php echo __('Bestellungen anzeigen', 'wpsg'); ?>" href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&filter[status]=-1&filter[voucher_id]=<?php echo $oVoucher->getId(); ?>"><?php echo __('Bestellungen suchen', 'wpsg'); ?></a></span>
 									|
-									<span class="duplicate"><a title="<?php echo __("Diesen Gutschein mit anderem Code duplizieren", "wpsg"); ?>" href="#" class="wpsg_voucher_duplicate" onclick="return false;" data-voucher_id="<?php echo $oVoucher->getId(); ?>"><?php echo __("Duplizieren", "wpsg"); ?></a></span>
+									<span class="duplicate"><a title="<?php echo __("Diesen Gutschein mit anderem Code duplizieren", "wpsg"); ?>" href="#" class="wpsg_voucher_duplicate"
+										data-voucher_id="<?php echo $oVoucher->getId(); ?>"
+										data-voucher_start_date="<?php echo $oVoucher->getStartDate('d.m.Y'); ?>"
+										data-code="<?php echo $oVoucher->getCode(); ?>"
+										data-voucher_end_date="<?php echo $oVoucher->getEndDate('d.m.Y'); ?>"
+									><?php echo __("Duplizieren", "wpsg"); ?></a></span>
 								</div>
                                                         
@@ -214,5 +219,32 @@
 </div>
 
-<script type="text/javascript">/* <![CDATA[ */
+<!-- Modaldialog fÃŒr Gutscheine duplizieren -->
+<div class="modal fade" id="wpsg_voucher_clone_dialog" tabindex="-1" role="dialog">
+	<div class="modal-dialog" role="document">
+		<form class="modal-content" method="POST" action="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_gutschein&subaction=duplicate&noheader=1">
+
+			<?php wp_nonce_field('wpsg_voucher_clone_dialog', 'wpsg_voucher_clone_dialog'); ?>
+
+			<div class="modal-header">
+				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+				<h4 class="modal-title"><?php echo __('Gutschein duplizieren', 'wpsg'); ?></h4>
+			</div>
+			<div class="modal-body">
+				<input name="voucher_id" type="hidden" id="wpsg_mod_gutschein_clone_id" />
+				<?php echo wpsg_drawForm_Input('wpsg_mod_gutschein_clone_start', __('GÃŒltig ab', 'wpsg'), '', array('datepicker' => true)); ?>
+				<?php echo wpsg_drawForm_Input('wpsg_mod_gutschein_clone_end', __('GÃŒltig bis', 'wpsg'), '', array('datepicker' => true)); ?>
+				<?php echo wpsg_drawForm_Input('wpsg_mod_gutschein_clone_count', __('Anzahl', 'wpsg'), 1, array('size' => 3)); ?>
+				<?php echo wpsg_drawForm_Textarea('wpsg_mod_gutschein_clone_comment', __('Kommentar der neuen Gutscheine', 'wpsg'), ''); ?>
+			</div>
+			<div class="modal-footer">
+				<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Abbrechen', 'wpsg'); ?></button>
+				<button type="submit" class="btn btn-primary" id="wpsg-voucher-clone"><?php echo __('OK', 'wpsg'); ?></button>
+			</div>
+		</form>
+	</div>
+</div>
+
+
+<script type="text/javascript">
 
     <?php if (wpsg_isSizedString($this->view['arFilter']['order']) && wpsg_isSizedString($this->view['arFilter']['ascdesc'])) { ?>
@@ -335,23 +367,31 @@
     } );
 
-
-	jQuery('.wpsg_voucher_duplicate').on('click', function() {
-		if (!confirm('<?php echo __('Diesen Gutschein duplizieren?', 'wpsg'); ?>')) return false;
-		var id = jQuery(this).data('voucher_id');
+	document.querySelectorAll('.wpsg_voucher_duplicate').forEach(function(btn) {
+
+		btn.addEventListener('click', function(e) {
+
+			e.preventDefault();
+
+			const id = this.dataset.voucher_id;
+			const start_date = this.dataset.voucher_start_date;
+			const end_date = this.dataset.voucher_end_date;
+			const code = this.dataset.code;
+
+			document.getElementById('wpsg_mod_gutschein_clone_id').value = id;
+			document.getElementById('wpsg_mod_gutschein_clone_start').value = start_date;
+			document.getElementById('wpsg_mod_gutschein_clone_end').value = end_date;
+			document.getElementById('wpsg_mod_gutschein_clone_comment').value = 'Kopie aus Gutschein "' + code + '" / ' + new Date().toLocaleDateString('de-DE');
+
+			jQuery('#wpsg_voucher_clone_dialog').modal('show');
+
+		});
+
+	});
+
+	document.getElementById('wpsg-voucher-clone').addEventListener('click', function() {
+
 		wpsg_loading('body');
-		jQuery.ajax({
-			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_gutschein&subaction=duplicate&noheader=1&voucher_id=' + id,
-			success: function(data) {
-				wpsg_loading_done('body');
-				if (data !== '1') { alert(data); }
-				else { location.reload(); }
-			},
-			error: function() {
-				wpsg_loading_done('body');
-				alert('<?php echo __('Unbekannter Fehler beim Duplizieren.', 'wpsg'); ?>');
-			}
-		});
-		return false;
-	}).attr('onclick', null);
-
-/* ]]> */</script>
+
+	});
+
+</script>
