Index: /controller/wpsg_OrderController.class.php
===================================================================
--- /controller/wpsg_OrderController.class.php	(revision 7177)
+++ /controller/wpsg_OrderController.class.php	(revision 7179)
@@ -1141,5 +1141,5 @@
 		public function viewAction()
 		{
-		    
+			 
 		    if (wpsg_isSizedString($_REQUEST['subaction'], 'removeProduct')) {
 
@@ -1157,4 +1157,81 @@
                 ]);
 
+			} else if (wpsg_isSizedString($_REQUEST['subaction'], 'sendMail')) {
+		    	
+		    	$oBasket = new wpsg_basket();
+		    	$oBasket->initFromDB($_REQUEST['edit_id']);
+		    	
+		    	//die(wpsg_debug($oBasket->toArray()));
+		    	
+		    	$oBasket->sendOrderSaveMails($_REQUEST['edit_id'], $oBasket->toArray(), true, false, false);
+		    						
+		    	die(__('Mail wurde erfolgreich versendet.', 'wpsg'));
+                
+			} else if (wpsg_isSizedString($_REQUEST['subaction'], 'editVoucher')) {
+			
+		    	/** @var \wpsg\wpsg_calculation */
+				$this->shop->view['oCalculation'] = new \wpsg\wpsg_calculation();
+				$this->shop->view['oCalculation']->fromDb($_REQUEST['edit_id']);
+			
+				if (isset($_REQUEST['do'])) {
+					
+					if ($_REQUEST['do'] === 'remove') {
+						
+						$this->shop->view['oCalculation']->removeVoucher();
+						
+					} else if ($_REQUEST['do'] === 'submit') {
+						
+						$oDefaultCountry = $this->shop->getDefaultCountry();
+						
+						if (strpos($_REQUEST['be_voucher_amount'], '%') !== false) $voucher_netto = wpsg_ff(wpsg_tf($_REQUEST['be_voucher_amount']), $this->shop->get_option('wpsg_currency'));
+						else {
+							
+							if ($this->shop->getBackendTaxview() === WPSG_BRUTTO) $voucher_netto = wpsg_calculatePreis(wpsg_tf($_REQUEST['be_voucher_amount']), WPSG_NETTO, $oDefaultCountry->getTax('c'));
+							else $voucher_netto = $_REQUEST['be_voucher_amount'];
+							
+						}
+						
+						if (wpsg_tf($voucher_netto) <= 0) $this->shop->view['oCalculation']->removeVoucher();
+						else $this->shop->view['oCalculation']->addVoucher($voucher_netto, wpsg_tf($_REQUEST['be_voucher_amount'],true), $_REQUEST['be_voucher_code'], $_REQUEST['be_voucher_id']);
+						
+					} else if ($_REQUEST['do'] === 'search') {
+						
+						$arVoucher = $this->db->fetchAssoc("
+							SELECT
+								V.`id`, V.`value` AS `gs_value`, V.`code`, V.`calc_typ`, V.`id`, 
+								CONCAT(V.`code`) AS `value`
+							FROM
+								`".WPSG_TBL_GUTSCHEIN."` AS V
+							WHERE
+								V.`code` LIKE '%".wpsg_q($_REQUEST['term'])."%' AND
+								(V.`o_id` <= 0 OR V.`multi` = '1') AND
+								NOW() BETWEEN V.`start_date` AND V.`end_date`
+							ORDER BY
+								V.`code` ASC 
+						");
+						
+						foreach ($arVoucher as $k => $v) {
+							
+							if ($v['calc_type'] === 'p') $arVoucher[$k]['gs_value'] = wpsg_ff($arVoucher[$k]['gs_value'], '%');
+							else $arVoucher[$k]['gs_value'] = wpsg_ff($arVoucher[$k]['gs_value'], $this->shop->get_option('wpsg_currency'));
+							
+						}
+						
+						wpsg_header::JSONData($arVoucher);
+						
+					}
+					
+					$this->shop->view['oCalculation']->toDB($_REQUEST['edit_id']);
+					
+					wpsg_header::JSONData([
+						'product_table' => $this->shop->render(WPSG_PATH_VIEW.'order/product_table.phtml', false)
+					]);
+					
+				}
+				
+				$this->shop->render(WPSG_PATH_VIEW.'/order/backendEdit/addVoucher.phtml');
+			
+				exit;
+                
             } else if (wpsg_isSizedString($_REQUEST['subaction'], 'editDiscount')) {
 
@@ -1175,5 +1252,5 @@
                     
                     if (wpsg_tf($discount_netto) <= 0) $this->shop->view['oCalculation']->removeDiscount(); 
-                    else $this->shop->view['oCalculation']->addDiscount($discount_netto, $_REQUEST['be_discount_tax'], $_REQUEST['be_discount_amount']);
+                    else $this->shop->view['oCalculation']->addDiscount($discount_netto, wpsg_tf($_REQUEST['be_discount_amount'],true));
 
                     $this->shop->view['oCalculation']->toDB($_REQUEST['edit_id']);
@@ -1183,5 +1260,15 @@
                     ]);
                     
-                }
+                } else if (wpsg_isSizedString($_REQUEST['do'], 'remove')) {
+	
+					$this->shop->view['oCalculation']->removeDiscount();
+                	
+					$this->shop->view['oCalculation']->toDB($_REQUEST['edit_id']);
+	
+					wpsg_header::JSONData([
+						'product_table' => $this->shop->render(WPSG_PATH_VIEW.'order/product_table.phtml', false)
+					]);
+					
+				}
                 
                 $this->shop->render(WPSG_PATH_VIEW.'/order/backendEdit/addDiscount.phtml');
Index: /lib/install.php
===================================================================
--- /lib/install.php	(revision 7177)
+++ /lib/install.php	(revision 7179)
@@ -152,4 +152,5 @@
    		dp_cron_done datetime NOT NULL,
    		gs_id INT(11) NOT NULL,
+   		gs_code VARCHAR(1000) NOT NULL COMMENT 'Der Gutscheincode',
    		kleinunternehmer INT(1) NOT NULL,
    		custom_data MEDIUMBLOB NOT NULL,
@@ -158,4 +159,6 @@
    		adress_id INT(11) NOT NULL COMMENT 'Link zu WPSG_TBL_ADRESS (Rechnungsadresse)',
    		shipping_adress_id INT(11) NOT NULL COMMENT 'Link zu WPSG_TBL_ADRESS (Lieferanschrift)',
+   		gs_set VARCHAR(100) NOT NULL COMMENT 'Eventuell in % (Wert des Gutscheins)',
+   		gs_tax_key VARCHAR(10) NOT NULL COMMENT 'Steuersatz des Gutscheins',
    		KEY adress_id (adress_id),
    		KEY shipping_adress_id (shipping_adress_id),
Index: /lib/wpsg_calculation.class.php
===================================================================
--- /lib/wpsg_calculation.class.php	(revision 7177)
+++ /lib/wpsg_calculation.class.php	(revision 7179)
@@ -40,4 +40,7 @@
         private $arDiscount = null;
         
+        /** @var array */
+        private $arVoucher = null;
+        
         public function __construct() {
             
@@ -58,4 +61,29 @@
         }
         
+        public function removeVoucher() {
+        	
+        	$this->arVoucher = null;
+        	
+		}
+	
+		/**
+		 * @param $voucher_value Der Netto Betrg
+		 * @param $voucher_set Der Wert der ÃŒbergeben wurde, eventuell mit %
+		 * 
+		 */
+		public function addVoucher($voucher_value, $voucher_set, $voucher_code = "", $voucher_id = 0) {
+			
+			$this->arVoucher = [
+				[
+					'set' => $voucher_set,
+					'value' => $voucher_value,
+					'tax_key' => '0',
+					'code' => $voucher_code,
+					'id' => $voucher_id
+				]
+			];
+        	
+		}
+        
         public function removeDiscount() {
             
@@ -64,5 +92,5 @@
         }
         
-        public function addDiscount($discount_value, $discount_tax_key, $discount_set) {
+        public function addDiscount($discount_value, $discount_set) {
             
             $this->arDiscount = [
@@ -70,5 +98,5 @@
                     'set' => $discount_set,
                     'value' => $discount_value,
-                    'tax_key' => $this->normalizeTaxKey($discount_tax_key)
+                    'tax_key' => '0'
                 ]
             ];
@@ -175,5 +203,9 @@
                     'tax' => 0,
                     'discount_netto' => 0,
-                    'discount_brutto' => 0
+                    'discount_brutto' => 0,
+					'prevoucher_netto' => 0,
+					'prevoucher_brutto' => 0,
+					'voucher_netto' => 0,
+					'voucher_brutto' => 0
                 ];
 
@@ -190,4 +222,7 @@
 
                 }
+                
+                // Gutscheine einbeziehen
+				$this->calculateVoucher();
 
                 $this->arCalculation['shipping'] = $this->shipping;
@@ -199,5 +234,5 @@
                 $this->arCalculation['sum']['netto'] += $this->payment['netto'];
                 $this->addTax($this->payment['netto'], $this->payment['tax_key']);
-
+                                
                 // Rabatte einbeziehen
                 $this->calculateDiscount();
@@ -225,4 +260,6 @@
         public function toDB($id = false, $db_data = []) {
            
+        	$this->setTaxView($this->shop->getFrontendTaxview());
+        	
             $arCalculation = $this->getCalculationArray();
 
@@ -254,5 +291,5 @@
             $db_data['price_rabatt_netto'] = wpsg_q($arCalculation['sum']['discount_netto']);
             $db_data['price_rabatt_brutto'] = wpsg_q($arCalculation['sum']['discount_brutto']);
-            
+                        
             if (wpsg_isSizedArray($this->arDiscount)) {
             
@@ -265,4 +302,20 @@
                     
             }
+	
+			$db_data['price_gs_netto'] = wpsg_q($arCalculation['sum']['voucher_netto']);
+			$db_data['price_gs_brutto'] = wpsg_q($arCalculation['sum']['voucher_brutto']);
+	
+			if (wpsg_isSizedArray($this->arVoucher)) {
+		
+				foreach ($this->arVoucher as $v) {
+			
+					$db_data['gs_tax_key'] = $v['tax_key'];
+					$db_data['gs_set'] = $v['set'];
+					$db_data['gs_id'] = intval($v['id']);
+					$db_data['gs_code'] = $v['code'];
+			 					
+				}
+		
+			}
                         
             if (wpsg_isSizedInt($id)) {
@@ -277,4 +330,20 @@
                 
             }
+            
+            if (wpsg_isSizedArray($this->arVoucher)) {
+				
+				foreach ($this->arVoucher as $v) {
+										
+					if (wpsg_isSizedInt($v['id'])) {
+						
+						$this->db->UpdateQuery(WPSG_TBL_GUTSCHEIN, [
+							'o_id' => wpsg_q($id)							
+						], " `id` = '".wpsg_q($v['id'])."' ");
+						
+					} 
+					
+				}
+				
+			}
 
             $arOrderProductID = [];
@@ -291,4 +360,6 @@
                     'price_netto' => wpsg_q($p['netto']),
                     'price_brutto' => wpsg_q($p['brutto']),
+					'price' => wpsg_q($p['price']),
+					'mwst_value' => wpsg_q($p['brutto'] - $p['netto']),
                     'mwst_key' => wpsg_q($p['tax_key'])
                 ];
@@ -336,8 +407,14 @@
             if (wpsg_tf($db_order['price_rabatt_netto']) > 0) {
                 
-                $this->addDiscount($db_order['price_rabatt_netto'], $db_order['discount_tax_key'], $db_order['discount_set']);
-                
-            }
-            
+                $this->addDiscount($db_order['price_rabatt_netto'], $db_order['discount_set']);
+                
+            }
+            
+            // Gutschein
+			if (wpsg_tf($db_order['price_gs_netto']) > 0) {
+            	
+            	$this->addVoucher($db_order['price_gs_netto'], $db_order['gs_set'], $db_order['gs_code'], $db_order['gs_id']);
+            	
+			}            
             
         } // public function fromDB($id)
@@ -426,5 +503,8 @@
             $this->arCalculation['payment']['price'] = $this->arCalculation['payment'][$suffix];
             $this->arCalculation['sum']['discount_display'] = $this->arCalculation['sum']['discount_'.$suffix];
-            $this->arCalculation['sum']['prediscount_display'] = $this->arCalculation['sum']['prediscount_'.$suffix];            
+            $this->arCalculation['sum']['prediscount_display'] = $this->arCalculation['sum']['prediscount_'.$suffix];
+	
+			$this->arCalculation['sum']['voucher_display'] = $this->arCalculation['sum']['voucher_'.$suffix];
+			$this->arCalculation['sum']['prevoucher_display'] = $this->arCalculation['sum']['prevoucher_'.$suffix];
             
             foreach ($this->arCalculation['products'] as $k => $p) {
@@ -436,5 +516,46 @@
 
         }
-
+	
+		/**
+		 * Bezieht die Gutscheine in die Berechnung ein
+		 */
+        private function calculateVoucher() {
+        	
+        	$this->arCalculation['sum']['prevoucher_netto'] = $this->arCalculation['sum']['netto'];
+        	$this->arCalculation['sum']['voucher_netto'] = 0;
+        	
+        	if (wpsg_isSizedArray($this->arVoucher)) {
+        		
+        		$this->arCalculation['voucher'] = $this->arVoucher;
+        		
+        		foreach ($this->arVoucher as $k => $v) {
+			
+        			$this->addTax(0,$v['tax_key']);
+        			
+					if (strpos($v['value'], '%') !== false) {
+				
+						// Prozentualer Wert
+						$voucher_netto = $this->arCalculation['sum']['netto'] / 100 * wpsg_tf($v['value']);
+				
+					} else {
+				
+						// Absoluter Netto Wert
+						$voucher_netto = wpsg_tf($v['value']);
+				
+					}
+			
+					$this->arCalculation['voucher'][$k]['netto'] = $voucher_netto;
+					$this->arCalculation['tax'][$v['tax_key']]['netto'] -= $voucher_netto;
+			
+					$this->arCalculation['sum']['voucher_netto'] += $voucher_netto;
+					$this->arCalculation['sum']['netto'] -= $voucher_netto; 
+					$this->arCalculation['sum']['product_netto'] -= $voucher_netto;
+					
+				}
+        		
+			}
+        	
+		}
+        
         /**
          * Bezieht die Rabatte in die Berechnung ein
@@ -450,5 +571,7 @@
                                                 
                 foreach ($this->arDiscount as $k => $d) {
-                    
+	
+					$this->addTax(0,$d['tax_key']);
+                	
                     if (strpos($d['value'], '%') !== false) {
                         
@@ -499,4 +622,5 @@
             }
                  
+            // Produkte
             foreach ($this->arCalculation['products'] as $k => $p) {
 
@@ -511,7 +635,30 @@
                 $this->arCalculation['sum']['brutto'] += $this->arCalculation['products'][$k]['brutto'] * $this->arCalculation['products'][$k]['amount'];
                 $this->arCalculation['sum']['prediscount_brutto'] += $this->arCalculation['products'][$k]['brutto'] * $this->arCalculation['products'][$k]['amount'];
+				$this->arCalculation['sum']['prevoucher_brutto'] += $this->arCalculation['products'][$k]['brutto'] * $this->arCalculation['products'][$k]['amount'];
                 $this->arCalculation['sum']['product_brutto'] += $this->arCalculation['products'][$k]['brutto'] * $this->arCalculation['products'][$k]['amount'];
                 
             }
+	
+			// Gutscheine
+			if (wpsg_isSizedArray($this->arCalculation['voucher'])) {
+		
+				foreach ($this->arCalculation['voucher'] as $k => $v) {
+			
+					$this->arCalculation['voucher'][$k]['brutto'] = $this->calculateTaxPart($v['netto'], $v['tax_key']);
+					
+					if ($this->arCalculation['voucher'][$k]['brutto'] > 0) $this->arCalculation['voucher'][$k]['sum_tax'] = $this->arCalculation['voucher'][$k]['brutto'] - $this->arCalculation['voucher'][$k]['netto'];
+					else $this->arCalculation['voucher'][$k]['sum_tax'] = 0;
+			
+					$this->arCalculation['tax'][$v['tax_key']]['sum_tax'] -= $this->arCalculation['voucher'][$k]['sum_tax'];
+			
+					$this->arCalculation['sum']['tax'] -= $this->arCalculation['voucher'][$k]['sum_tax'];
+					$this->arCalculation['sum']['brutto'] -= $this->arCalculation['voucher'][$k]['brutto'];
+					$this->arCalculation['sum']['voucher_brutto'] += $this->arCalculation['voucher'][$k]['brutto'];
+					$this->arCalculation['sum']['product_brutto'] -= $this->arCalculation['voucher'][$k]['brutto'];
+					$this->arCalculation['sum']['prediscount_brutto'] -= $this->arCalculation['voucher'][$k]['brutto'];
+					
+				}
+		
+			}
 
             // Versand
@@ -538,18 +685,22 @@
             
             // Rabatte
-            foreach ($this->arCalculation['discount'] as $k => $d) {
-                
-                $this->arCalculation['discount'][$k]['brutto'] = $this->calculateTaxPart($d['netto'], $d['tax_key']);
-
-                if ($this->arCalculation['discount'][$k]['brutto'] > 0) $this->arCalculation['discount'][$k]['sum_tax'] = $this->arCalculation['discount'][$k]['brutto'] - $this->arCalculation['discount'][$k]['netto'];
-                else $this->arCalculation['discount'][$k]['sum_tax'] = 0;
-
-                $this->arCalculation['tax'][$d['tax_key']]['sum_tax'] -= $this->arCalculation['discount'][$k]['sum_tax'];
-
-                $this->arCalculation['sum']['tax'] -= $this->arCalculation['discount'][$k]['sum_tax'];
-                $this->arCalculation['sum']['brutto'] -= $this->arCalculation['discount'][$k]['brutto'];                
-                $this->arCalculation['sum']['discount_brutto'] += $this->arCalculation['discount'][$k]['brutto'];
-                
-            }
+			if (wpsg_isSizedArray($this->arCalculation['discount'])) {
+            
+				foreach ($this->arCalculation['discount'] as $k => $d) {
+                
+					$this->arCalculation['discount'][$k]['brutto'] = $this->calculateTaxPart($d['netto'], $d['tax_key']);
+	
+					if ($this->arCalculation['discount'][$k]['brutto'] > 0) $this->arCalculation['discount'][$k]['sum_tax'] = $this->arCalculation['discount'][$k]['brutto'] - $this->arCalculation['discount'][$k]['netto'];
+					else $this->arCalculation['discount'][$k]['sum_tax'] = 0;
+	
+					$this->arCalculation['tax'][$d['tax_key']]['sum_tax'] -= $this->arCalculation['discount'][$k]['sum_tax'];
+	
+					$this->arCalculation['sum']['tax'] -= $this->arCalculation['discount'][$k]['sum_tax'];
+					$this->arCalculation['sum']['brutto'] -= $this->arCalculation['discount'][$k]['brutto'];                
+					$this->arCalculation['sum']['discount_brutto'] += $this->arCalculation['discount'][$k]['brutto'];
+					
+				}
+				
+			}
             
             // Gesamt
Index: /views/order/backendEdit/addDiscount.phtml
===================================================================
--- /views/order/backendEdit/addDiscount.phtml	(revision 7177)
+++ /views/order/backendEdit/addDiscount.phtml	(revision 7179)
@@ -10,6 +10,4 @@
     $oCalculation = $this->view['oCalculation'];
     
-    $arTax = $oCalculation->getTaxLabelArray();
-    
     if ($this->getBackendTaxView() === WPSG_NETTO) $strBN = 'NETTO';
     else $strBN = 'BRUTTO';
@@ -22,6 +20,5 @@
 
     <?php echo wpsg_drawForm_Input('be_discount_amount', wpsg_translate(__('Rabattwert in #1# (#2#) oder % ', 'wpsg'), $this->get_option('wpsg_currency'), $strBN), @$arCalculation['discount'][0]['set']); ?>
-    <?php echo wpsg_drawForm_Select('be_discount_tax', __('Steuersatz', 'wpsg'), $arTax, @$arCalculation['discount'][0]['tax_key']); ?>
-
+    
 </form>
 
Index: /views/order/backendEdit/addVoucher.phtml
===================================================================
--- /views/order/backendEdit/addVoucher.phtml	(revision 7179)
+++ /views/order/backendEdit/addVoucher.phtml	(revision 7179)
@@ -0,0 +1,66 @@
+<?php
+	
+	/**
+	 * User: Daschmi (daschmi@daschmi.de)
+	 * Date: 05.10.2018
+	 * Time: 08:24
+	 */
+	
+	namespace wpsg;
+	
+	/** @var wpsg_calculation $oCalculation */
+	$oCalculation = $this->view['oCalculation'];
+	 
+	if ($this->getBackendTaxView() === WPSG_NETTO) $strBN = 'NETTO';
+	else $strBN = 'BRUTTO';
+	
+	$arCalculation = $oCalculation->getCalculationArray();
+	
+	$strVal = ((isset($arCalculation['voucher'][0]['set']))?$arCalculation['voucher'][0]['set']:0); 
+	
+	if (strpos($strVal, '%') !== false) $strVal = wpsg_ff(wpsg_tf($strVal), '%');
+	else $strVal = wpsg_ff(wpsg_tf($strVal), $this->get_option('wpsg_currency'));
+	
+?>
+
+<form id="wpsg_be_voucher_form">
+	
+	<div class="autocomplete_wrap">
+		<?php echo wpsg_drawForm_Input('be_voucher_search', __('Gutscheinsuche', 'wpsg'), ''); ?>
+	</div>
+	
+	<br />
+				
+	<?php echo wpsg_drawForm_Input('be_voucher_code', __('Code (Optional)', 'wpsg'), @$arCalculation['voucher'][0]['code']); ?>
+	<?php echo wpsg_drawForm_Input('be_voucher_id', __('Guschein ID (Optional)', 'wpsg'), @$arCalculation['voucher'][0]['id']); ?>
+	<?php echo wpsg_drawForm_Input('be_voucher_amount', wpsg_translate(__('Gutscheinwert in #1# (#2#) oder % ', 'wpsg'), $this->get_option('wpsg_currency'), $strBN), $strVal); ?>
+		
+</form>
+
+<script>
+
+	jQuery('#wpsg_be_voucher_form').on('submit', function() { return false; } );
+	jQuery('#be_voucher_search').focus();
+	
+	jQuery(document).ready(function() {
+
+		jQuery('#be_voucher_search').autocomplete( {
+			source: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=editVoucher&do=search&noheader=1&edit_id=<?php echo $_REQUEST['edit_id']; ?>',
+			minLength: 2,
+			appendTo: ".autocomplete_wrap",
+			select: function(event, ui) {
+
+				jQuery('#be_voucher_code').val(ui.item.code);
+				jQuery('#be_voucher_id').val(ui.item.id);				
+				jQuery('#be_voucher_amount').val(ui.item.gs_value);
+				
+				jQuery('#be_voucher_search').val('');
+				
+				return false;
+
+			}
+		} );
+		
+	} );
+
+</script>
Index: /views/order/product_table.phtml
===================================================================
--- /views/order/product_table.phtml	(revision 7177)
+++ /views/order/product_table.phtml	(revision 7179)
@@ -1,18 +1,4 @@
 <?php
-
-/*
-    $oC = new \wpsg\wpsg_calculation();
-    $oC->setCountry(\wpsg_country::getInstance(1));
-    
-    $oC->addProduct('1', 0, '100', '1','c');
-    //$oC->addProduct('1', 1, '100', '1','b');
-    $oC->setShipping('1', '0', '0');
-    $oC->setPayment('1', '0', 'c_1');
-        
-    $oC->addDiscount('10%','c_1');
-    
-    $ar = $oC->getCalculationArray();
-wpsg_debug($ar);*/
-
+ 
     /**
      * Template fÃŒr die Produkttabelle im Backend der Bestellverwaltung
@@ -22,5 +8,5 @@
     $arTax = $this->view['oCalculation']->getTaxLabelArray();
     $arTaxShort = $this->view['oCalculation']->getTaxLabelArray(true);
-    
+ 
     $this->view['colspan'] = 3;
     if ($this->get_option('wpsg_showMwstAlways') == '1' || sizeof($arCalculation['tax']) > 1) $this->view['colspan'] ++;
@@ -33,4 +19,5 @@
 
     .wpsg_row_small td { font-size:0.8em; }
+	#wpsg-bs .wpsg_row_small  .wpsg-glyphlink-td > span { margin-top:0px; }
     
 </style>
@@ -78,35 +65,47 @@
         <tr><td colspan="<?php echo $this->view['colspan'] + 1; ?>" style="line-height:2px; height:2px; background-color:#999999; padding:0px;"></td></tr>
     <?php } ?>
-    <?php /* $gs_id = 0;
-    if ((isset($this->view['basket']['gs'])) && ($this->view['basket']['gs']['value'] > 0)) { ?>
-        <tr class="wpsg_<?php echo (($i % 2 == 0)?'odd':'even'); ?> wpsg_gutschein">
-            <?php
-            $gs_id = 0;
-            if (array_key_exists('gs_id', $_REQUEST))
-            {
-                $gs_id = wpsg_getInt($_REQUEST['gs_id']);
-            }
-            else
-            {
-                $gs_id = wpsg_getInt($this->view['data']['gs_id']);
-            }
-            $o_id = $_REQUEST['edit_id'];
-            $link1 = '<span id="gsname_'.$gs_id.'" class="editable editable-click" data-original-title="" title="">'.$this->view['basket']['gs']['code'].'</span>';
-            $val = '-'.wpsg_ff($this->view['basket']['sum']['gs']);
-            $link2 = '<span id="gsvalue_'.$gs_id.'" class="editable editable-click" data-original-title="" title="">'.$val.'</span>';
-
-            ?>
-            <td class="wpsg_cell_name"><?php echo __('Gutschein', 'wpsg'); ?> <?php echo ($this->view['basket']['gs']['code'] != '')? '('.$link1.')':'' ?>
-                <a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Gutschein lÃ¶schen', 'wpsg'); ?>" onclick="return wpsg_removeVoucher(<?php echo $gs_id; ?>, <?php echo $o_id; ?>);"><span class="glyphicon glyphicon-trash"></span></a>
-            </td>
-            <td class="wpsg_cell_preis"><?php echo $link2.' '.$this->get_option('wpsg_currency'); ?></td>
-            <?php if (sizeof($this->view['basket']['mwst']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') { ?>
-                <td class="wpsg_cell_mwst"><?php echo __('anteilig', 'wpsg'); ?></td>
-            <?php } ?>
-            <td class="wpsg_cell_menge">1</td>
-            <td class="wpsg_cell_gesamtpreis"><?php echo '-'.wpsg_ff($this->view['basket']['sum']['gs'], $this->get_option('wpsg_currency')); ?></td>
-        </tr>
-    <?php } ?>
-    */ ?>
+	
+	<?php /* Gutscheine */ ?>
+	<?php if (wpsg_isSizedArray($arCalculation['voucher'])) { ?>
+
+		<?php foreach ($arCalculation['voucher'] as $v) { ?>
+
+			<tr class="wpsg_row_discount wpsg_row_small">
+				<td colspan="" class="wpsg_cell_mwst_label">
+					
+					<div>
+						<?php echo __('Gutschein', 'wpsg'); ?>
+						
+						<?php if ($this->getBackendTaxView() === WPSG_BRUTTO) { ?>
+							<?php echo __('(inkl. MwSt.)', 'wpsg'); ?>
+						<?php } else { ?>
+							<?php echo __('(zzgl. MwSt.)', 'wpsg'); ?>
+						<?php } ?>
+	
+						<a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Gutschein bearbeiten', 'wpsg'); ?>" onclick="return WPSG_BE_Voucher.editVoucher();"><span class="glyphicon glyphicon-pencil"></span></a>
+						<a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Gutschein lÃ¶schen', 'wpsg'); ?>" onclick="return WPSG_BE_Voucher.removeVoucher();"><span class="glyphicon glyphicon-trash"></span></a>
+					</div>
+					<div>
+						Code: <?php echo $v['code']; ?>
+					</div>
+
+				</td>
+				<td class="wpsg_cell_preis">
+					<?php echo wpsg_ff($v['set'], $this->get_option('wpsg_currency'), true); ?>
+				</td>
+				<?php if (sizeof($arCalculation['tax']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') { ?>
+					<td class="wpsg_cell_mwst"><?php echo $arTaxShort[$v['tax_key']]; ?></td>
+				<?php } ?>				
+				<td>1</td>
+				<td class="wpsg_cell_mwst_value wpsg_cell_gesamtpreis">
+					<?php echo wpsg_ff($arCalculation['sum']['voucher_display']); ?> <?php echo $this->get_option('wpsg_currency'); ?>
+				</td>
+			</tr>
+			
+		<?php } ?>		
+		<tr><td colspan="<?php echo $this->view['colspan'] + 1; ?>" style="line-height:2px; height:2px; background-color:#999999; padding:0px;"></td></tr>
+		
+	<?php } ?>
+	
     <tr class="wpsg_row_summe">
         <td colspan="<?php echo $this->view['colspan']; ?>" class="wpsg_cell_summe_label">
@@ -197,10 +196,14 @@
         <tr class="wpsg_row_discount wpsg_row_small">
             <td colspan="" class="wpsg_cell_mwst_label">
-                <?php echo __('Rabatt', 'wpsg'); ?>
-                <?php if ($this->getBackendTaxView() === WPSG_BRUTTO) { ?>
-                    <?php echo __('(inkl. MwSt.)', 'wpsg'); ?>
-                <?php } else { ?>
-                    <?php echo __('(zzgl. MwSt.)', 'wpsg'); ?>
-                <?php } ?>
+               <?php echo __('Rabatt', 'wpsg'); ?>
+               <?php if ($this->getBackendTaxView() === WPSG_BRUTTO) { ?>
+               	<?php echo __('(inkl. MwSt.)', 'wpsg'); ?>
+               <?php } else { ?>
+                  <?php echo __('(zzgl. MwSt.)', 'wpsg'); ?>
+					<?php } ?>
+
+					<a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Rabatt bearbeiten', 'wpsg'); ?>" onclick="return WPSG_BE_Discount.editDiscount();"><span class="glyphicon glyphicon-pencil"></span></a>
+					<a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Rabatt lÃ¶schen', 'wpsg'); ?>" onclick="return WPSG_BE_Discount.removeDiscount();"><span class="glyphicon glyphicon-trash"></span></a>
+					
             </td>
             <td class="wpsg_cell_preis">
@@ -249,4 +252,2 @@
     <?php } ?>
 </table>
-
-<?php wpsg_debug($arCalculation); ?>
Index: /views/order/view.phtml
===================================================================
--- /views/order/view.phtml	(revision 7177)
+++ /views/order/view.phtml	(revision 7179)
@@ -49,32 +49,35 @@
             <a class="list-group-item <?php echo ((wpsg_getStr($_COOKIE['wpsg_order_view_tab'], 'general') == $k)?'active':''); ?>" wpsg-data-target="<?php echo $k; ?>" href="#"><?php echo $v['title']; ?></a>
             <?php } ?>
+			
         </div>
 
-        <a href="" id="LinkProduktNeu" onclick="return WPSG_BE_Product.addProduct();"><span class="glyphicon glyphicon-plus"></span>
-    	 	<?php echo __("Neues Produkt", "wpsg"); ?>
-	 	</a><div class="wpsg_clear"></div>
-	 
-        <?php if ($this->hasMod('wpsg_mod_gutschein')) { ?>
-        	<?php if (((array_key_exists('gs', $this->view['basket'])) && ($this->view['basket']['gs']['value'] == 0))) { ?>
-		        <a href="" id="LinkGutscheinNeu" onclick="return wpsg_addVoucher(<?php echo $_REQUEST['edit_id']; ?>);"><span class="glyphicon glyphicon-plus"></span>
-			 	    <?php echo __("Gutschein bearbeiten", "wpsg"); ?>
-			 	</a><div class="wpsg_clear"></div>
-            <?php } ?>
-        <?php } ?>
+		<div class="tag_actions orderdata_action">
+        
+			<a href="" id="LinkProduktNeu" onclick="return WPSG_BE_Product.addProduct();"><span class="glyphicon glyphicon-plus"></span>
+				<?php echo __("Neues Produkt", "wpsg"); ?>
+			</a><div class="wpsg_clear"></div>
+		 
+			<?php if ($this->hasMod('wpsg_mod_gutschein')) { ?>        	
+				<a href="" id="LinkGutscheinNeu" onclick="return WPSG_BE_Voucher.editVoucher(<?php echo $_REQUEST['edit_id']; ?>);"><span class="glyphicon glyphicon-plus"></span>
+					<?php echo __("Gutschein bearbeiten", "wpsg"); ?>
+				</a><div class="wpsg_clear"></div>
+			<?php } ?>
+	
+			<div class="wpsg_clear"></div>
+			<?php if ($this->hasMod('wpsg_mod_discount')) { ?>
+				<a href="" id="LinkRabattNeu" onclick="return WPSG_BE_Discount.editDiscount(<?php echo $_REQUEST['edit_id']; ?>);"><span class="glyphicon glyphicon-plus"></span>
+					<?php echo __("Rabatt bearbeiten", "wpsg"); ?>
+				</a><div class="wpsg_clear"></div>
+			<?php } ?>
+		
+        	<a href="" id="LinkSendMail" onclick="return WPSG_BE_Mail.sendCustomerMail(<?php echo $_REQUEST['edit_id']; ?>);"><span class="glyphicon glyphicon-envelope"></span>
+	 			<?php echo __("BestellbestÃ€tigung", "wpsg"); ?><br /><?php echo __("erneut versenden", "wpsg"); ?>
+	 		</a><br />
 
-		<div class="wpsg_clear"></div>
-        <?php if ($this->hasMod('wpsg_mod_discount')) { ?>
-        	<a href="" id="LinkRabattNeu" onclick="return WPSG_BE_Discount.editDiscount(<?php echo $_REQUEST['edit_id']; ?>);"><span class="glyphicon glyphicon-plus"></span>
-			 	<?php echo __("Rabatt bearbeiten", "wpsg"); ?>
-			</a><div class="wpsg_clear"></div>
-        <?php } ?>
-
-		
-        <a href="" id="LinkSendMail" onclick="return wpsg_sendMail(<?php echo $_REQUEST['edit_id']; ?>);"><span class="glyphicon glyphicon-envelope"></span>
-	 	<?php echo __("BestellbestÃ€tigung", "wpsg"); ?><br /><?php echo __("erneut versenden", "wpsg"); ?>
-	 	</a><br />
+		</div>
 
 		<div id='wpsg_kv_list'>
 		</div>
+		
     </div>
 
@@ -93,7 +96,6 @@
 </div>
 
-<script type="text/javascript">/* <![CDATA[ */
-
-
+<script type="text/javascript">
+	
 	/**
 	 * Sendet eine eMail
@@ -115,53 +117,5 @@
 	} // function wpsg_sendMail()
 
-	/**
-	 * FÃŒgt einen neuen Rabatt hinzu (nur wenn keiner da ist)
-	 */
-	function wpsg_addDiscount(oid)
-	{
-		jQuery('#wpsg_produkte_table').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-
-		jQuery.ajax( {
-			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&subaction=discountData&do=add&edit_id=' + oid + '&noheader=1',
-			success: function(data) {
-			    
-				jQuery('#wpsg_produkte_table').replaceWith(data);
-				jQuery('#LinkRabattNeu').hide();
-				
-			}
-		} );
-
-		return false;
-
-	} // function wpsg_addDiscount()
-
-
-	/**
-	 * FÃŒgt einen neuen Gutschein hinzu (nur wenn keiner da ist)
-	 */
-	function wpsg_addVoucher(oid)
-	{
-		jQuery('#wpsg_produkte_table').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-
-		jQuery.ajax( {
-			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&subaction=voucherData&do=add&edit_id=' + oid + '&noheader=1',
-			success: function(data) {
-				jQuery('#wpsg_produkte_table').replaceWith(data);
-				jQuery('#LinkGutscheinNeu').hide();
-				//jQuery('#wpsg_kv_list').html(data);
-				//location.href = location.href;
-				//jQuery('#wpsg_kv_list').html('');
-			}
-		} );
-
-		return false;
-
-	} // function wpsg_addVoucher()
-
-
-
     jQuery(document).ready(function() {
-
-    	wpsg_view_orderdata_hide();
 
         jQuery('#wpsg_order_view_tabs a.list-group-item').bind('click', function() {
@@ -170,11 +124,8 @@
             jQuery('.wpsg_order_view_tab_content').hide();
 
-            tab = jQuery(this).attr('wpsg-data-target');
-			if (tab == 'orderdata') {
-            	wpsg_view_orderdata_show();
-			} else {
-				wpsg_view_orderdata_hide();
-			}
-            jQuery(this).addClass('active');
+			jQuery('.tag_actions').hide(); //ordertab_action
+			jQuery('.' + jQuery(this).attr('wpsg-data-target') + '_action').show();
+			
+			jQuery(this).addClass('active');
             jQuery('#tab' + jQuery(this).attr('wpsg-data-target')).show();
 
@@ -184,16 +135,17 @@
         } );
 
-        co = jQuery.cookie('wpsg_order_view_tab');
+        var co = jQuery.cookie('wpsg_order_view_tab');
+        
         if (co === undefined) {
+        	
 			jQuery("[wpsg-data-target='general']").trigger("click");
+			
         } else {
+        	
         	jQuery("[wpsg-data-target='" + co + "']").trigger("click");
+        	
         }
-		//jQuery('#wpsg_order_view_tabs a').removeClass('active');
-        //jQuery('.wpsg_order_view_tab_content').hide();
-		//jQuery('#tabgeneral').show();
-		//jQuery("[wpsg-data-target='general']").addClass('active');
-
+		
     } );
 
-/* ]]> */</script>
+</script>
Index: /views/order/view_orderdata.phtml
===================================================================
--- /views/order/view_orderdata.phtml	(revision 7177)
+++ /views/order/view_orderdata.phtml	(revision 7179)
@@ -9,355 +9,303 @@
 ?>
 <div id="wpsg_produkte_table">
-<?php echo wpsg_drawForm_AdminboxStart(__('Bestelldaten', 'wpsg')); ?>
-    <div id="wpsg_product_table_wrap">
+
+	<?php echo wpsg_drawForm_AdminboxStart(__('Bestelldaten', 'wpsg')); ?>
+    
+	<div id="wpsg_product_table_wrap">
         <?php $this->render(WPSG_PATH_VIEW.'order/product_table.phtml'); ?>
     </div>
 
-<script type="text/javascript">/* <![CDATA[ */
-
-<?php if ($this->hasMod('wpsg_mod_gutschein')) { ?>
-	<?php if ((array_key_exists('gs', $this->view['basket'])) && ($this->view['basket']['gs']['value'] > 0)) { ?>
-
-	jQuery('#gsname_<?php echo $gs_id; ?>').wpsg_editable('<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&subaction=voucherData&do=editname&noheader=1', {
-		submitdata: {
-    		field: 'code',
-    		gs_id: '<?php echo $gs_id; ?>',
-    		edit_id: '<?php echo $o_id; ?>'
-		},
-		submit  : '<?php echo __('Speichern', 'wpsg'); ?>',
-		placeholder: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>',
-		indicator: '<?php echo __('Speicher ...', 'wpsg'); ?>',
-    	tooltip: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>',
-    	callback: function(data, config) {
-    		jQuery('#wpsg_produkte_table').replaceWith(data);
-    	}
-	});
-
-	jQuery('#gsvalue_<?php echo $gs_id; ?>').wpsg_editable('<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&subaction=voucherData&do=editvalue&noheader=1', {
-		submitdata: {
-    		field: 'value',
-    		gs_id: '<?php echo $gs_id; ?>',
-    		edit_id: '<?php echo $o_id; ?>',
-        	noMwSt: '<?php echo $this->view['basket']['noMwSt']; ?>',
-        	mwst: '<?php reset($this->view['basket']['mwst']); echo key($this->view['basket']['mwst']); ?>',
-        	price_frontend: '<?php echo $this->view['basket']['price_frontend']; ?>'
-		},
-		submit  : '<?php echo __('Speichern', 'wpsg'); ?>',
-		placeholder: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>',
-		indicator: '<?php echo __('Speicher ...', 'wpsg'); ?>',
-    	tooltip: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>',
-    	callback: function(data, config) {
-    		jQuery('#wpsg_produkte_table').replaceWith(data);
-    		wpsg_be_act_orderdata();
-    	}
-	});
-
-	<?php } ?>
-<?php } ?>
-
-<?php if ($this->hasMod('wpsg_mod_discount')) { ?>
-	<?php if (isset($this->view['basket']['sum']['preis_rabatt']) && $this->view['basket']['sum']['preis_rabatt'] > 0) { ?>
-
-	jQuery('#discountvalue_<?php echo $o_id; ?>').wpsg_editable('<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&subaction=discountData&do=editvalue&noheader=1', {
-		submitdata: {
-    		field: 'value',
-    		edit_id: '<?php echo $o_id; ?>',
-           	noMwSt: '<?php echo $this->view['basket']['noMwSt']; ?>',
-           	mwst: '<?php reset($this->view['basket']['mwst']); echo key($this->view['basket']['mwst']); ?>',
-           	price_frontend: '<?php echo $this->view['basket']['price_frontend']; ?>'
-		},
-		submit  : '<?php echo __('Speichern', 'wpsg'); ?>',
-		placeholder: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>',
-		indicator: '<?php echo __('Speicher ...', 'wpsg'); ?>',
-    	tooltip: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>',
-    	callback: function(data, config) {
-    		jQuery('#wpsg_produkte_table').replaceWith(data);
-    		wpsg_be_act_orderdata();
-    	}
-	});
-
-	<?php } ?>
-<?php } ?>
-
-	/**
-	 * Wird aufgerufen wenn ein Gutschein gelÃ¶scht werden soll
-	 */
-	function wpsg_removeVoucher(gs_id, o_id)
-	{
-
-		if (!confirm('<?php echo __('Sind Sie sich sicher, dass sie diesen Gutschein lÃ¶schen mÃ¶chten?', 'wpsg'); ?>')) return false;
-
-		jQuery('#wpsg_produkte_table').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-
-		jQuery.ajax( {
-			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&subaction=voucherData&do=remove&gs_id=' + gs_id + '&edit_id=' + o_id +'&noheader=1',
-			success: function(data) {
-				jQuery('#wpsg_produkte_table').replaceWith(data);
-				jQuery('#LinkGutscheinNeu').show();
-	    		wpsg_be_act_orderdata();
+	<script type="text/javascript">
+	
+		var WPSG_BE_Pay_Ship = {
+				 
+			changeShippingPayment: function (id, oid) {
+	
+				jQuery('#wpsg_shipping_dialog .modal-body').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+				jQuery('#wpsg_shipping_dialog').modal( { } ).modal('show');
+								
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=editPayShipping&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
+					success: function(data) {
+	
+						jQuery('#wpsg_shipping_dialog .modal-body').html(data);
+	
+					}
+				} );
+	
+				return false;
+				 
+			}, // function changeShipping(id, oid)
+	
+			/**
+			 * Ãndern der Versanddaten im Backend
+			 */
+			updateShippingPayment: function() {
+				
+				var data = {
+					submit: '1',
+					shipping_key: jQuery('#edit_shipping_type').val(),
+					shipping_price: jQuery('#edit_shipping_price').val(),
+					payment_key: jQuery('#edit_payment_type').val(),
+					payment_price: jQuery('#edit_payment_price').val()
+				};
+				
+				jQuery('#wpsg_shipping_dialog').modal('hide');
+				
+				jQuery('#wpsg_product_table_wrap').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+				
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=updateOrder&subaction=editPayShipping&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
+					data: data,
+					success: function(data) {
+						
+						jQuery('#wpsg_product_table_wrap').html(data.product_table);
+						
+					}
+				} );
+				
+				return false; 
+	
+			} // function dialogShippingOK()
+	  
+		}	 
+	
+		var WPSG_BE_Product = {
+	
+			addProduct: function() {
+		
+				jQuery('#wpsg_product_dialog .modal-body').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+				jQuery('#wpsg_product_dialog').modal( { } ).modal('show');
+				jQuery('#wpsg_product_dialog .btn-primary').prop('disabled', true);
+				
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=addProduct&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
+					success: function(data) {
+		
+						jQuery('#wpsg_product_dialog .modal-body').html(data);
+		
+					}
+				} );
+		
+				return false;
+				
+			},
+			
+			remvoeProduct: function(order_product_id) {
+	
+				jQuery('#wpsg_product_table_wrap').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+				
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=removeProduct&noheader=1&edit_id=<?php echo $_REQUEST['edit_id']; ?>',
+					data: { 
+						order_product_id: order_product_id
+					},
+					success: function(data) {
+	
+						jQuery('#wpsg_product_table_wrap').html(data.product_table);
+	
+					}
+				} );
+				
+				return false;
+				
+			},
+			
+			editProduct: function(order_product_id) {
+	
+				jQuery('#wpsg_product_dialog .modal-body').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+				jQuery('#wpsg_product_dialog').modal( { } ).modal('show');
+				jQuery('#wpsg_product_dialog .btn-primary').prop('disabled', true);
+	
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=addProduct&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
+					data: {
+						order_product_id: order_product_id  
+					},
+					success: function(data) {
+	
+						jQuery('#wpsg_product_dialog .modal-body').html(data);
+	
+					}
+				} );
+	
+				return false;
+				
+			},
+	
+			saveProduct: function() {
+	 
+				jQuery('#wpsg_product_dialog').modal('hide');
+				jQuery('#wpsg_product_table_wrap').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+	
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=addProduct&do=submit&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
+					data: jQuery('#wpsg_product_add_form').serialize(),
+					success: function(data) {
+	
+						jQuery('#wpsg_product_table_wrap').html(data.product_table);
+	
+					}
+				} );
+	
+				return false;
+	
 			}
-		} );
-
-		return false;
-	}
-
-	/**
-	 * Wird aufgerufen wenn ein Rabatt gelÃ¶scht werden soll
-	 */
-	function wpsg_removeDiscount(o_id)
-	{
-
-		if (!confirm('<?php echo __('Sind Sie sich sicher, dass sie diesen Rabatt lÃ¶schen mÃ¶chten?', 'wpsg'); ?>')) return false;
-
-		jQuery('#wpsg_produkte_table').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-
-		jQuery.ajax( {
-			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&subaction=discountData&do=remove&edit_id=' + o_id +'&noheader=1',
-			success: function(data) {
-				jQuery('#wpsg_produkte_table').replaceWith(data);
-				jQuery('#LinkRabattNeu').show();
-	    		wpsg_be_act_orderdata();
+		
+		}
+	
+		var WPSG_BE_Voucher = {
+			
+			editVoucher: function() {
+	
+				jQuery('#wpsg_voucher_dialog .modal-body').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+				jQuery('#wpsg_voucher_dialog').modal( { } ).modal('show');
+	
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=editVoucher&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
+					success: function(data) {
+	
+						jQuery('#wpsg_voucher_dialog .modal-body').html(data);
+	
+					}
+				} );
+	
+				return false;
+				
+			},
+			
+			removeVoucher: function() {
+	
+				jQuery('#wpsg_product_table_wrap').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+	
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=editVoucher&do=remove&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
+					success: function(data) {
+	
+						jQuery('#wpsg_product_table_wrap').html(data.product_table);
+	
+					}
+				} );
+	
+				return false;
+				
+			},
+			
+			saveVoucher: function() {
+	
+				jQuery('#wpsg_voucher_dialog').modal('hide');
+				jQuery('#wpsg_product_table_wrap').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+	
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=editVoucher&do=submit&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
+					data: jQuery('#wpsg_be_voucher_form').serialize(),
+					success: function(data) {
+	
+						jQuery('#wpsg_product_table_wrap').html(data.product_table);
+	
+					}
+				} );
+	
+				return false;
+				
 			}
-		} );
-
-		return false;
-	}
-
-	function wpsg_be_act_orderdata() {
-
-		var o_id = 0;
-		//alert('wpsg_be_act_orderdata');
-		jQuery.ajax( {
-			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&subaction=orderData&do=actual&edit_id=' + o_id +'&noheader=1',
-			success: function(data) {
-				data = JSON.parse(data);
-				jQuery('#wpsg_be_orderamount').html(data.preis);
-				odata = data.vname + ' ' + data.name + ' / ' + data.preis;
-				jQuery('#wpsg_be_orderdata').html(odata);
-				
+			
+		}
+		
+		var WPSG_BE_Discount = {
+		
+			editDiscount: function() {
+	
+				jQuery('#wpsg_discount_dialog .modal-body').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+				jQuery('#wpsg_discount_dialog').modal( { } ).modal('show'); 
+	
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=editDiscount&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',                 
+					success: function(data) {
+	
+						jQuery('#wpsg_discount_dialog .modal-body').html(data);
+	
+					}
+				} );
+	
+				return false;
+			
+			},
+		 
+			removeDiscount: function() {
+	
+				jQuery('#wpsg_product_table_wrap').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+	
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=editDiscount&do=remove&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
+					success: function(data) {
+	
+						jQuery('#wpsg_product_table_wrap').html(data.product_table);
+	
+					}
+				} );
+				
+				return false;
+				
+			},
+		
+			saveDiscount: function() {
+	
+				jQuery('#wpsg_discount_dialog').modal('hide');
+				jQuery('#wpsg_product_table_wrap').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+	
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=editDiscount&do=submit&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
+					data: jQuery('#wpsg_be_discount_form').serialize(),
+					success: function(data) {
+	
+						jQuery('#wpsg_product_table_wrap').html(data.product_table);
+	
+					}
+				} );
+	
+				return false;
+			
 			}
-		} );
-
-
-		return false;
-		
-	}
-	
-    jQuery(document).ready(function() {
-		 
-
-		//wpsg_view_orderdata_show();
-
-    } );
-
-    function wpsg_view_orderdata_show() {
-                
-        jQuery('#LinkGutscheinNeu').show();
-        jQuery('#LinkRabattNeu').show();
-        jQuery('#LinkProduktNeu').show();
-        jQuery('#LinkSendMail').show();
-
-		//if (gs_id > 0) { jQuery('#LinkGutscheinNeu').hide(); }
-		//if (prval != 0) { jQuery('#LinkRabattNeu').hide(); }
-    }
-
-    function wpsg_view_orderdata_hide() {
-    	jQuery('#LinkGutscheinNeu').hide();
-        jQuery('#LinkRabattNeu').hide();
-        jQuery('#LinkProduktNeu').hide();
-        jQuery('#LinkSendMail').hide();
-    }
-
-    var Modul2 = {
-    	    eigenschaft : "wert",
-    	    methode : function () {
-    	        alert("Modul-Eigenschaft (ÃŒber window.Modul): " + Modul2.eigenschaft);
-    	        // Alternativ:
-    	        alert("Modul-Eigenschaft (ÃŒber this): " + this.eigenschaft);
-    	    }
-    };
-    //Modul2.methode();
-
-
-    var WPSG_BE_Pay_Ship = {
-    		 
-        changeShippingPayment: function (id, oid) {
-
-            jQuery('#wpsg_shipping_dialog .modal-body').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-            jQuery('#wpsg_shipping_dialog').modal( { } ).modal('show');
-                            
-            jQuery.ajax( {
-                url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=editPayShipping&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
-                success: function(data) {
-
-                    jQuery('#wpsg_shipping_dialog .modal-body').html(data);
-
-                }
-            } );
-
-            return false;
-             
-        }, // function changeShipping(id, oid)
-
-        /**
-         * Ãndern der Versanddaten im Backend
-         */
-        updateShippingPayment: function() {
-            
-            var data = {
-                submit: '1',
-                shipping_key: jQuery('#edit_shipping_type').val(),
-                shipping_price: jQuery('#edit_shipping_price').val(),
-                payment_key: jQuery('#edit_payment_type').val(),
-                payment_price: jQuery('#edit_payment_price').val()
-            };
-            
-            jQuery('#wpsg_shipping_dialog').modal('hide');
-            
-            jQuery('#wpsg_product_table_wrap').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-            
-            jQuery.ajax( {
-                url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=updateOrder&subaction=editPayShipping&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
-                data: data,
-                success: function(data) {
-                    
-                    jQuery('#wpsg_product_table_wrap').html(data.product_table);
-                    
-                }
-            } );
-            
-            return false; 
-
-        } // function dialogShippingOK()
-  
-    };	// WPSG_BE_Pay_Ship
-
-    var WPSG_BE_Product = {
-
-        addProduct: function() {
-    
-            jQuery('#wpsg_product_dialog .modal-body').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-            jQuery('#wpsg_product_dialog').modal( { } ).modal('show');
-            jQuery('#wpsg_product_dialog .btn-primary').prop('disabled', true);
-            
-            jQuery.ajax( {
-                url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=addProduct&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
-                success: function(data) {
-    
-                    jQuery('#wpsg_product_dialog .modal-body').html(data);
-    
-                }
-            } );
-    
-            return false;
-            
-        },
-        
-        remvoeProduct: function(order_product_id) {
-
-            jQuery('#wpsg_product_table_wrap').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-            
-            jQuery.ajax( {
-                url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=removeProduct&noheader=1&edit_id=<?php echo $_REQUEST['edit_id']; ?>',
-                data: { 
-                    order_product_id: order_product_id
-                },
-                success: function(data) {
-
-                    jQuery('#wpsg_product_table_wrap').html(data.product_table);
-
-                }
-            } );
-            
-            return false;
-            
-        },
-        
-        editProduct: function(order_product_id) {
-
-            jQuery('#wpsg_product_dialog .modal-body').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-            jQuery('#wpsg_product_dialog').modal( { } ).modal('show');
-            jQuery('#wpsg_product_dialog .btn-primary').prop('disabled', true);
-
-            jQuery.ajax( {
-                url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=addProduct&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
-                data: {
-                    order_product_id: order_product_id  
-                },
-                success: function(data) {
-
-                    jQuery('#wpsg_product_dialog .modal-body').html(data);
-
-                }
-            } );
-
-            return false;
-            
-        },
-
-        saveProduct: function() {
- 
-            jQuery('#wpsg_product_dialog').modal('hide');
-            jQuery('#wpsg_product_table_wrap').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-
-            jQuery.ajax( {
-                url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=addProduct&do=submit&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
-                data: jQuery('#wpsg_product_add_form').serialize(),
-                success: function(data) {
-
-                    jQuery('#wpsg_product_table_wrap').html(data.product_table);
-
-                }
-            } );
-
-            return false;
-
-        }
-        
-    }
-    
-    var WPSG_BE_Discount = {
-        
-        editDiscount: function() {
-
-            jQuery('#wpsg_discount_dialog .modal-body').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-            jQuery('#wpsg_discount_dialog').modal( { } ).modal('show'); 
-
-            jQuery.ajax( {
-                url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=editDiscount&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',                 
-                success: function(data) {
-
-                    jQuery('#wpsg_discount_dialog .modal-body').html(data);
-
-                }
-            } );
-
-            return false;
-            
-        },
-        
-        saveDiscount: function() {
-
-            jQuery('#wpsg_discount_dialog').modal('hide');
-            jQuery('#wpsg_product_table_wrap').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
-
-            jQuery.ajax( {
-                url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=editDiscount&do=submit&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
-                data: jQuery('#wpsg_be_discount_form').serialize(),
-                success: function(data) {
-
-                    jQuery('#wpsg_product_table_wrap').html(data.product_table);
-
-                }
-            } );
-
-            return false;
-            
-        }
-        
-    }
-    
-	/* ]]> */</script>
-
+		
+		}
+
+		var WPSG_BE_Mail = {
+			
+			sendCustomerMail: function(order_id) {
+
+				jQuery.ajax( {
+					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=sendMail&do=customer&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1',
+					data: jQuery('#wpsg_be_discount_form').serialize(),
+					success: function(data) { alert(data); }
+				} );
+
+				return false;
+				
+			}
+			
+		}
+		
+	</script>
+	
+	<?php wpsg_drawForm_AdminboxEnd(); ?>
+
+</div>
+
+<!-- Modaldialog fÃŒr Gutscheine -->
+<div class="modal fade" id="wpsg_voucher_dialog" tabindex="-1" role="dialog">
+	<div class="modal-dialog" role="document">
+		<div class="modal-content">
+			<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" id="myModalLabel"><?php echo __('Gutschein hinzufÃŒgen/bearbeiten', 'wpsg'); ?></h4>
+			</div>
+			<div class="modal-body"></div>
+			<div class="modal-footer">
+				<button type="button" class="btn btn-default" data-dismiss="modal">Abbrechen</button>
+				<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="return WPSG_BE_Voucher.saveVoucher();">OK</button>
+			</div>
+		</div>
+	</div>
 </div>
 
