Index: /changelog
===================================================================
--- /changelog	(revision 7588)
+++ /changelog	(revision 7589)
@@ -273,2 +273,4 @@
 - Bugfix: Bereits gezahlte PayPal Bestellungen zeigen dies jetzt auf der BestellabschluÃseite an
 - Bugfix: Das Standard LÃ¶schen Icon fÃŒr Wertgutscheine wird im Warenkob angezeigt
+- Feature: Gutscheinprodukte - Preis fÃŒr den Gutschein kann vom Kunden frei definiert werden
+- Feature: Gutscheinprodukte - Optionale Mindest- und Maximalschranken fÃŒr den Flexiblen Preis
Index: /controller/wpsg_AdminController.class.php
===================================================================
--- /controller/wpsg_AdminController.class.php	(revision 7588)
+++ /controller/wpsg_AdminController.class.php	(revision 7589)
@@ -101,6 +101,5 @@
 		 * Index des Backends
 		 */
-		public function indexAction()
-		{
+		public function indexAction() {
 
 			$this->shop->view = array(
@@ -211,7 +210,7 @@
 
 			}
-
+			
 			if (isset($_REQUEST['submit'])) { $this->submitAction(); }
-
+			
 			if (isset($_REQUEST['subaction']))
 			{
@@ -225,5 +224,5 @@
 			else
 			{
-
+				
 				if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'update') { $this->updateAction(); }
 				else if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'loadHelp') { $this->loadHelpAction(); }
@@ -2047,6 +2046,5 @@
 			global $wpdb;
 
-			if (@$_REQUEST['subaction'] == 'konfiguration')
-			{
+			if (@$_REQUEST['subaction'] == 'konfiguration') {
 
                 \check_admin_referer('wpsg-save-config');
@@ -2089,6 +2087,5 @@
 				$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin');
 
-			}
-			else if (@$_REQUEST['subaction'] == "dataprotection") {
+			} else if (@$_REQUEST['subaction'] == "dataprotection") {
 				
 				check_admin_referer('wpsg-admin-dataprotection');
@@ -2112,7 +2109,5 @@
 				$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=dataprotection');
 				
-			}
-			
-			else if (@$_REQUEST['subaction'] == 'extended') {
+			} else if (@$_REQUEST['subaction'] == 'extended') {
 				
 				\check_admin_referer('wpsg-save-admin-extended');
@@ -2143,6 +2138,5 @@
 				$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=extended');
 
-			}
-			else if (@$_REQUEST['subaction'] == 'presentation') {
+			} else if (@$_REQUEST['subaction'] == 'presentation') {
 				
 				\check_admin_referer('wpsg-save-admin-presentation');
@@ -2163,7 +2157,5 @@
 				$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=presentation');
 
-			}
-			else if (@$_REQUEST['subaction'] == 'path')
-			{
+			} else if (@$_REQUEST['subaction'] == 'path') {
 
 				$this->shop->update_option('wpsg_path_upload_multiblog', $_REQUEST['wpsg_path_upload_multiblog'], true);
@@ -2173,6 +2165,5 @@
 				$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=path');
 
-			}
-			else if (@$_REQUEST['subaction'] == 'loadsavesettings') {
+			} else if (@$_REQUEST['subaction'] == 'loadsavesettings') {
 								
 				if (isset($_REQUEST['wpsg_do']) && $_REQUEST['wpsg_do'] == 'downloadsettings') {
@@ -2312,6 +2303,5 @@
 				$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=loadsavesettings');
 
-			}
-			else if (@$_REQUEST['subaction'] == 'includes') {
+			} else if (@$_REQUEST['subaction'] == 'includes') {
 
 				check_admin_referer('wpsg-admin-includes');
@@ -2331,7 +2321,5 @@
 				$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=includes');
 
-			}
-			else if (@$_REQUEST['subaction'] == 'blognetzwerk')
-			{
+			} else if (@$_REQUEST['subaction'] == 'blognetzwerk') {
 
 				$this->update_option('wpsg_multiblog_standalone', $_REQUEST['wpsg_multiblog_standalone'], true);
@@ -2342,6 +2330,5 @@
 				$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=blognetzwerk');
 
-			}
-			else if (@$_REQUEST['subaction'] == 'kalkulation') {
+			} else if (@$_REQUEST['subaction'] == 'kalkulation') {
 				
 				check_admin_referer('wpsg-admin-kalkulation');
@@ -2417,6 +2404,5 @@
 				$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction='.$_REQUEST['subaction']);
 
-			}
-			else if (@$_REQUEST['subaction'] == 'seiten') {
+			} else if (@$_REQUEST['subaction'] == 'seiten') {
 
 				check_admin_referer('wpsg-admin-seiten');
@@ -2439,7 +2425,5 @@
 				$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction='.$_REQUEST['subaction']);
 
-			}
-			else if (@$_REQUEST['action'] == 'module')
-			{
+			} else if (@$_REQUEST['action'] == 'module') {
 
 				$global = false;
@@ -2487,7 +2471,5 @@
 				$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&modul='.$_REQUEST['modul']);
 
-			}
-			else
-			{
+			} else {
 
 				if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'update') {
Index: /controller/wpsg_ShopController.class.php
===================================================================
--- /controller/wpsg_ShopController.class.php	(revision 7588)
+++ /controller/wpsg_ShopController.class.php	(revision 7589)
@@ -3886,5 +3886,5 @@
 				$this->addBackendError('nohspc_'.wpsg_translate(
 					__('Ihre Datenbankversion ist nicht auf dem aktuellen Stand, aktualisieren Sie die Datenbank, indem Sie <a href="#1#">hier</a> klicken.<br />Klicken Sie <a href="#1#">hier</a>, um die Meldung auszublenden.', 'wpsg'),
-					WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=allgemein&do=update&submit=1&noheader=1',
+						wp_nonce_url(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=allgemein&do=update&submit=1&noheader=1', 'wpsg-admin-db-update'),
 					WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&noheader=1&action=clearMessage&wpsg_message=wpsg_message_soaphint&wpsg_redirect='.rawurlencode($_SERVER['REQUEST_URI'])
 				));
Index: /mods/wpsg_mod_voucherproduct.class.php
===================================================================
--- /mods/wpsg_mod_voucherproduct.class.php	(revision 7588)
+++ /mods/wpsg_mod_voucherproduct.class.php	(revision 7589)
@@ -33,5 +33,8 @@
 			  	wpsg_mod_voucherproduct_gslaenge INT(11) NOT NULL,
 			  	wpsg_mod_voucherproduct_available INT(11) NOT NULL,
-			  	wpsg_mod_voucherproduct_coupon INT(1) NOT NULL COMMENT 'Wenn 1, dann wird ein Wertgutschein generiert.'
+			  	wpsg_mod_voucherproduct_coupon INT(1) NOT NULL COMMENT 'Wenn 1, dann wird ein Wertgutschein generiert.',
+			  	wpsg_mod_voucherproduct_flexprice INT(1) NOT NULL COMMENT '1 Wenn der Preis fÃŒr dieses Gutscheinprodukt flexibel durch den Kunden definiert werden kann',
+			  	wpsg_mod_voucherproduct_flexprice_min DOUBLE(10, 2) NOT NULL COMMENT 'Minimaler Preis bei Flexiblem Preis',
+			  	wpsg_mod_voucherproduct_flexprice_max DOUBLE(10, 2) NOT NULL COMMENT 'Maximaler Preis bei Flexiblem Preis'
 			) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
 			
@@ -157,4 +160,18 @@
 			if (wpsg_checkInput($_REQUEST['wpsg_mod_voucherproduct_available'], WPSG_SANITIZE_INT)) $produkt_data['wpsg_mod_voucherproduct_available'] = wpsg_q($_REQUEST['wpsg_mod_voucherproduct_available']);			
 			if (wpsg_checkInput($_REQUEST['wpsg_mod_voucherproduct_coupon'], WPSG_SANITIZE_CHECKBOX)) $produkt_data['wpsg_mod_voucherproduct_coupon'] = wpsg_q($_REQUEST['wpsg_mod_voucherproduct_coupon']);
+			
+			wpsg_checkRequest('wpsg_mod_voucherproduct_flexprice', [WPSG_SANITIZE_CHECKBOX], __('Flexibler Preis', 'wpsg'), $produkt_data);
+			wpsg_checkRequest('wpsg_mod_voucherproduct_flexprice_min', [WPSG_SANITIZE_FLOAT], __('Minimaler flexibler Preis', 'wpsg'), $produkt_data);
+			wpsg_checkRequest('wpsg_mod_voucherproduct_flexprice_max', [WPSG_SANITIZE_FLOAT], __('Maximaler flexibler Preis', 'wpsg'), $produkt_data);
+			
+			if ($produkt_data['wpsg_mod_voucherproduct_flexprice'] === '1') {
+				
+				if (!in_array(wpsg_getStr($produkt_data['basket_multiple']), ['1', '2'])) {
+					
+					$this->shop->addBackendError(__('Das Produkt sollte bei flexiblem Preis bei "Verhalten im Warenkorb" auf "Mehrfach" stehen.', 'wpsg'));
+					
+				}
+								
+			}
 			
 		} // public function produkt_save_before(&$produkt_data)
@@ -341,13 +358,95 @@
 		} // public function setOrderStatus($order_id, $status_id, $inform)
 		
+		public function product_bottom(&$product_id, $template_index) { 
+			
+			$oProduct = wpsg_product::getInstance($product_id);
+			
+			if ($oProduct->__get('wpsg_mod_voucherproduct_flexprice') === '1') {
+			
+				$this->shop->view['oProduct'] = $oProduct;
+				
+				echo $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_voucherproduct/product_bottom.phtml');
+				
+			}
+			
+		}
+		
+		public function basket_produkttosession($produkt_key, &$menge, &$ses_data) {
+			 
+			$oProduct = wpsg_product::getInstance($produkt_key);
+			
+			$flex = intval($oProduct->__get('wpsg_mod_voucherproduct_flexprice'));
+			$flex_min = wpsg_tf($oProduct->__get('wpsg_mod_voucherproduct_flexprice_min'));
+			$flex_max = wpsg_tf($oProduct->__get('wpsg_mod_voucherproduct_flexprice_max'));
+			
+			if ($flex === 1) {
+			
+				if (wpsg_checkInput($_REQUEST['wpsg_mod_voucherproduct_value'], WPSG_SANITIZE_FLOAT)) {
+					
+					$value = wpsg_tf($_REQUEST['wpsg_mod_voucherproduct_value']);
+					
+					if ($flex_min > 0 && $value < $flex_min) {
+						
+						$this->shop->addFrontendError(wpsg_translate(
+							__('Der Gutscheinwert muss mindestens #1# #2# betragen.', 'wpsg'),
+							wpsg_ff($flex_min),
+							$this->shop->get_option('wpsg_currency')
+						));
+						
+						return -2;
+						
+					} else if ($flex_max > 0 && $value > $flex_max) {
+						
+						$this->shop->addFrontendError(wpsg_translate(
+							__('Der Gutscheinwert darf nicht mehr als #1# #2# betragen.', 'wpsg'),
+							wpsg_ff($flex_max),
+							$this->shop->get_option('wpsg_currency')
+						));
+						
+						return -2;
+						
+					}
+					
+				} else {
+					
+					$this->shop->addFrontendError(__('UngÃŒltige Eingabe im Feld "Gutscheinwert".', 'wpsg'));
+					
+					return -2;					
+					
+				}
+				
+				$code = openssl_encrypt(json_encode([
+					'price' => wpsg_tf($value),					
+				]),'AES128', $this->shop->get_option('wpsg_salt'));
+				
+				$ses_data['price_code'] = $code;
+				
+			}
+			
+			return 0;
+						
+		}
+		
+		public function calculation_addProduct(&$product_data, $ses_data) {
+			
+			if (isset($ses_data['price_code'])) {
+				
+				$data = \json_decode(\openssl_decrypt($ses_data['price_code'],'AES128', $this->shop->get_option('wpsg_salt')), true);
+				
+				$product_data['set'] = $data['price'];
+				$product_data['bruttonetto'] = $this->shop->getFrontendTaxview();
+				
+			}
+			
+		} // public function calculation_addProduct(&$product_data, $ses_data)
+		
 		/*
 		 * zeigt die Gutscheinprodukte im Produktbackend an
 		*/
-		public function product_addedit_content(&$product_content, &$product_data)
-		{
+		public function product_addedit_content(&$product_content, &$product_data) {
 		
 			$product_content['wpsg_mod_voucherprudct'] = array(
-					'title' => __('Gutscheinprodukte', 'wpsg'),
-					'content' => $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_voucherproduct/produkt_edit_sidebar.phtml', false)
+				'title' => __('Gutscheinprodukte', 'wpsg'),
+				'content' => $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_voucherproduct/produkt_edit_sidebar.phtml', false)
 			);
 		
@@ -780,3 +879,2 @@
 	} // class wpsg_mod_voucherproduct extends wpsg_mod_basic
 
-?>
Index: /views/mods/mod_voucherproduct/product_bottom.phtml
===================================================================
--- /views/mods/mod_voucherproduct/product_bottom.phtml	(revision 7589)
+++ /views/mods/mod_voucherproduct/product_bottom.phtml	(revision 7589)
@@ -0,0 +1,33 @@
+<?php
+	
+	declare(strict_types=1);
+	
+	/**
+	 * User: Daschmi (daschmi@daschmi.de)
+	 * Date: 25.10.2019
+	 * Time: 09:35
+	 */ 
+    
+	/** @var wpsg_product $oProduct */
+	$oProduct = $this->view['oProduct'];
+	
+    $min = wpsg_tf($oProduct->__get('wpsg_mod_voucherproduct_flexprice_min'));
+    $max = wpsg_tf($oProduct->__get('wpsg_mod_voucherproduct_flexprice_max'));
+    
+    if ($min > 0 && $max > 0) $strInterval = __('#1# bis #2# #3#', 'wpsg');
+    else if ($min > 0) $strInterval = __('Mindestens #1# #3#', 'wpsg');
+	else if ($max > 0) $strInterval = __('Maximal #2# #3#', 'wpsg');
+	else throw new \Exception(__('Systemfehler'));
+    
+	$strInterval = wpsg_translate($strInterval, wpsg_ff($min), wpsg_ff($max), $this->get_option('wpsg_currency'));
+	
+?>
+
+<div class="wpsg_product_buttonarea">
+	<label>
+		<strong><?php echo wpsg_translate(__('Gutscheinwert (#1#)', 'wpsg'), $strInterval); ?></strong><br />
+		<input class="wpsg_menge" type="text" name="wpsg_mod_voucherproduct_value" />	
+	</label>
+</div>
+
+<div class="wpsg_clear"></div><br />
Index: /views/mods/mod_voucherproduct/produkt_edit_sidebar.phtml
===================================================================
--- /views/mods/mod_voucherproduct/produkt_edit_sidebar.phtml	(revision 7588)
+++ /views/mods/mod_voucherproduct/produkt_edit_sidebar.phtml	(revision 7589)
@@ -23,4 +23,23 @@
 			<?php echo wpsg_drawForm_Input('wpsg_mod_voucherproduct_available', __('GÃŒltigkeit (Tage)', 'wpsg'), $this->view['data']['wpsg_mod_voucherproduct_available']); ?>
 			<?php echo wpsg_drawForm_Checkbox('wpsg_mod_voucherproduct_coupon', __('Gutschein als Wertgutschein generieren', 'wpsg'), $this->view['data']['wpsg_mod_voucherproduct_coupon']); ?>
+			<?php echo wpsg_drawForm_Checkbox('wpsg_mod_voucherproduct_flexprice', __('Flexibler Preis', 'wpsg'), $this->view['data']['wpsg_mod_voucherproduct_flexprice']); ?>
+						
+			<div class="wpsg_mod_voucherproduct_flexprice_layer wpsg_mod_voucherproduct_flexprice_layer_1" style="display:none;">
+				
+				<?php echo wpsg_drawForm_Input('wpsg_mod_voucherproduct_flexprice_min', __('Minimaler Preis', 'wpsg'), ((wpsg_tf($this->view['data']['wpsg_mod_voucherproduct_flexprice_min']) > 0)?wpsg_ff($this->view['data']['wpsg_mod_voucherproduct_flexprice_min']):'')); ?>
+				<?php echo wpsg_drawForm_Input('wpsg_mod_voucherproduct_flexprice_max', __('Maximaler Preis', 'wpsg'), ((wpsg_tf($this->view['data']['wpsg_mod_voucherproduct_flexprice_max']) > 0)?wpsg_ff($this->view['data']['wpsg_mod_voucherproduct_flexprice_max']):'')); ?>
+				
+			</div>
+			
+			<script>
+				
+				jQuery('#wpsg_mod_voucherproduct_flexprice').on('change', function() {
+					
+					jQuery('.wpsg_mod_voucherproduct_flexprice_layer').hide();
+					jQuery('.wpsg_mod_voucherproduct_flexprice_layer_' + ((jQuery(this).prop('checked') === true)?'1':'0')).show();
+					
+				}).change();
+				
+			</script>
 			
 		</div>
Index: /views/produkttemplates/standard.phtml
===================================================================
--- /views/produkttemplates/standard.phtml	(revision 7588)
+++ /views/produkttemplates/standard.phtml	(revision 7589)
@@ -284,5 +284,5 @@
 		<?php $this->callMods('product_bottom', array(&$this->view['data']['product_key'], $this->getTemplateIndex())); ?>
 		
-		<div class="wpsg_product_buttonarea">
+		<div class="wpsg_product_buttonarea">			
 			<div class="wpsg_product_buttons_add_basket">
 				<?php if ($this->view['oProduct']->canOrder()) { ?>
