Index: /changelog
===================================================================
--- /changelog	(revision 8130)
+++ /changelog	(revision 8131)
@@ -526,2 +526,4 @@
 - Bugfix: Multirechnung schreiben
 - Feature: DSGVO Layer fÃŒr das Registrierungsrecaptcha
+- Feature: Exportprofile: XML Erstellung verbessert
+- Feature: Exportprofile: Automatischer Export bei Bestellung
Index: /model/wpsg_order.class.php
===================================================================
--- /model/wpsg_order.class.php	(revision 8130)
+++ /model/wpsg_order.class.php	(revision 8131)
@@ -195,11 +195,33 @@
 		}
 		
-		public function getShippingTaxAmount()
-		{
+		public function getShippingTaxAmount() {
 			
 			return wpsg_tf($this->mwst_shipping);
 			
 		} // public function getShippingTaxAmount()
-		
+
+		/**
+		 * Steuersatz z.B. 19.00 
+		 * @return void
+		 */
+		public function getShippingTaxValue() {
+			
+			if ($this->shipping_tax_key === '0') {
+					
+				return __('Anteilig', 'wpsg');
+					
+			} else {
+				
+				$oCountry = $this->getInvoiceCountry();
+				
+				if ($this->shipping_tax_key === 'a') return $oCountry->mwst_a; 
+				else if ($this->shipping_tax_key === 'b') return $oCountry->mwst_b; 
+				else if ($this->shipping_tax_key === 'c') return $oCountry->mwst_c; 
+				else if ($this->shipping_tax_key === 'd') return $oCountry->mwst_d; 
+				else return null;
+			
+			}
+			
+		}
 		
 		public function getToPay($brutto_netto = WPSG_BRUTTO) {
@@ -1152,4 +1174,5 @@
 			$bJoinOrderAdress = false;
 
+			if (wpsg_isSizedInt($arFilter['id'])) $strQueryWHERE .= " AND O.`id` = '".wpsg_q($arFilter['id'])."' ";
 			if (wpsg_isSizedInt($arFilter['k_id'])) $strQueryWHERE .= " AND O.`k_id` = '".wpsg_q($arFilter['k_id'])."' ";
 			if (wpsg_isSizedInt($arFilter['cdate_from'])) $strQueryWHERE .= " AND O.`cdate` > '".wpsg_date('Y-m-d', $arFilter['cdate_from'])."' ";
Index: /model/wpsg_order_product.class.php
===================================================================
--- /model/wpsg_order_product.class.php	(revision 8130)
+++ /model/wpsg_order_product.class.php	(revision 8131)
@@ -19,7 +19,13 @@
 			$this->data = $this->db->fetchRow("SELECT OP.* FROM `".WPSG_TBL_ORDERPRODUCT."` AS OP WHERE OP.`id` = '".wpsg_q($order_product_id)."' ");
 			
-			if ($this->data === null || $this->data['id'] != $order_product_id) throw new \wpsg\Exception(
-				wpsg_translate(__('Die Daten eines bestellten Produktes (order_product_id: #1#) konnten nicht geladen werden', 'wpsg'), $order_product_id)
-			);
+			if ($this->data === null || $this->data['id'] != $order_product_id) {
+				
+				debug_print_backtrace();
+				
+				throw new \wpsg\Exception(
+					wpsg_translate(__('Die Daten eines bestellten Produktes (order_product_id: #1#) konnten nicht geladen werden', 'wpsg'), $order_product_id)
+				);
+				
+			}
 			
 		} // public function load($order_product_id)
Index: /mods/wpsg_mod_export.class.php
===================================================================
--- /mods/wpsg_mod_export.class.php	(revision 8130)
+++ /mods/wpsg_mod_export.class.php	(revision 8131)
@@ -44,4 +44,5 @@
         const CRON_WEEKLY = '3';
         const CRON_MONTHLY = '4';
+        const CRON_ORDER = '5';
 
         /**
@@ -61,7 +62,9 @@
                 500 => __('Zeit (hh:mm:ss)', 'wpsg'),
                 600 => __('Datum und Zeit (TT.MM.YYYY hh:mm:ss)', 'wpsg'),
+				610 => __('Datum und Zeit (ISO 8601)', 'wpsg'),
                 700 => __('Benutzerdefiniert', 'wpsg'),
                 800 => __('Text', 'wpsg'),
-                900 => __('Text Excel 2007', 'wpsg')
+                900 => __('Text Excel 2007', 'wpsg'),
+                950 => __('CDATA', 'wpsg')	            
             );
 
@@ -81,5 +84,6 @@
                 wpsg_mod_export::CRON_DAILY => __('TÃ€glich', 'wpsg'),
                 wpsg_mod_export::CRON_WEEKLY => __('WÃ¶chentlich', 'wpsg'),
-                wpsg_mod_export::CRON_MONTHLY => __('Monatlich', 'wpsg')
+                wpsg_mod_export::CRON_MONTHLY => __('Monatlich', 'wpsg'),
+                wpsg_mod_export::CRON_ORDER => __('Einmal je Bestellung', 'wpsg'),
             );
 
@@ -138,4 +142,5 @@
 				userformat VARCHAR(255) NOT NULL COMMENT 'Benutzerdefiniertes Format',
 				clear_spaces INT(1) NOT NULL COMMENT 'Leerzeichen entfernen',
+				static TEXT NOT NULL COMMENT 'Statischer Text',
 				INDEX profil_id (profil_id),
 				PRIMARY KEY  (id)
@@ -180,37 +185,35 @@
             $arFiles = array();
 
-            if (sizeof($arProfile) >= 1)
-            {
+            if (sizeof($arProfile) >= 1) {
 
                 $this->loadFields();
 
-                foreach ($arProfile as $profil_id)
-                {
+                foreach ($arProfile as $profil_id) {
 
                     $profil = $this->loadProfil($profil_id);
-
-                    if ($profil['export_type'] === self::TYPE_ORDER)
-                    {
-
-                        if ($profil['format'] == self::FORMAT_CSV) $file = $this->handleExportCSV($profil_id, $filter['filter']);
-                        else if ($profil['format'] == self::FORMAT_XML) $file = $this->handleExportXML($profil_id, $filter['filter']);
-
-                    }
-                    else if ($profil['export_type'] === self::TYPE_PRODUCT)
-                    {
+					$filename = $profil['filename'];
+
+                    if ($profil['export_type'] === self::TYPE_ORDER) {
+
+                        if ($profil['format'] == self::FORMAT_CSV) list($arData, $file) = $this->handleExportCSV($profil_id, $filter['filter']);
+                        else if ($profil['format'] == self::FORMAT_XML) list($arData, $file) = $this->handleExportXML($profil_id, $filter['filter']);
+								
+						if (sizeof($arData) === 1) {
+							
+							$filename = wpsg_ShopController::getShop()->replaceUniversalPlatzhalter($filename, array_values($arData)[0]->getId());
+							
+						}
+						
+                    } else if ($profil['export_type'] === self::TYPE_PRODUCT) {
 
                         if ($profil['format'] == self::FORMAT_CSV) $file = $this->handleExportProductCSV($profil_id, $filter['filter']);
                         else if ($profil['format'] == self::FORMAT_XML) $file = $this->handleExportProductXML($profil_id, $filter['filter']);
 
-                    }
-                    else if ($profil['export_type'] === self::TYPE_CUSTOMER)
-                    {
+                    } else if ($profil['export_type'] === self::TYPE_CUSTOMER) {
 
                         if ($profil['format'] == self::FORMAT_CSV) $file = $this->handleExportCustomerCSV($profil_id, $filter['filter']);
                         else if ($profil['format'] == self::FORMAT_XML) $file = $this->handleExportCustomerXML($profil_id, $filter['filter']);
 
-                    }
-                    else if ($profil['export_type'] === self::TYPE_ABO)
-                    {
+                    } else if ($profil['export_type'] === self::TYPE_ABO) {
 
                         if ($profil['format'] == self::FORMAT_CSV) $file = $this->handleExportAboCSV($profil_id, $filter['filter']);
@@ -218,8 +221,8 @@
 
                     }
-
+					
                     $arFiles[] = array(
                         $file,
-                        $profil['filename'],
+                        $filename,
                         $profil['cron_path'],
                         $profil['format']
@@ -442,9 +445,7 @@
 
             }
-            else if ($_REQUEST['do'] == 'inlinedit')
-            {
-
-                if (preg_match('/field_/', $_REQUEST['name']) && !in_array($_REQUEST['name'], ['field_delimiter', 'field_enclosure', 'field_escape']))
-                {
+            else if ($_REQUEST['do'] == 'inlinedit') {
+
+                if (preg_match('/field_/', $_REQUEST['name']) && !in_array($_REQUEST['name'], ['field_delimiter', 'field_enclosure', 'field_escape'])) {
 
                     // Feldwert wurde bearbeitet
@@ -452,6 +453,5 @@
                     $col = preg_replace('/\_\d+$/', '', $_REQUEST['name']);
 
-                    switch ($col)
-                    {
+                    switch ($col) {
 
                         case 'field_name': $col = 'name'; $_REQUEST['value'] = wpsg_sinput("text_field", $_REQUEST['value']); break;
@@ -460,6 +460,7 @@
                         case 'field_typ': $col = 'value_key'; break;
                         case 'field_xml_att': $col = 'xml_att'; break;
-
-                        default: throw new \Exception(__('UngÃŒltiger Feldname (Feld)', 'wpsg'));
+	                    case 'field_static': $col = 'static'; break;
+						
+                        default: throw new \Exception(__('UngÃŒltiger Feldname (Feld)', 'wpsg').' '.$col);
 
                     }
@@ -472,13 +473,10 @@
                     exit;
 
-                }
-                else if (preg_match('/orderfilter_/', $_REQUEST['name']))
-                {
+                } else if (preg_match('/orderfilter_/', $_REQUEST['name'])) {
 
                     // Wert aus dem Bestellfilter wurde bearbeitet					
                     $col = substr($_REQUEST['name'], 12);
 
-                    switch ($col)
-                    {
+                    switch ($col) {
 
                         case 's': $col = 's'; $_REQUEST['value'] = wpsg_sinput("text_field", $_REQUEST['value']); break;
@@ -609,4 +607,42 @@
         } // public function be_ajax()
 
+	    public function basket_save_done($order_id, $customer_id, $oBasket) {
+			
+			$arProfile = $this->db->fetchAssoc("
+				SELECT
+					EXP.`id`, EXP.`cron_interval`, EXP.`cron_lastrun`, EXP.`orderfilter`, EXP.`cron_path`, EXP.`filename`, EXP.`format`, EXP.`export_type`
+				FROM
+					`".WPSG_TBL_EXPORTPROFILE."` AS EXP 
+				WHERE
+					EXP.`cron_interval` = '".wpsg_q(self::CRON_ORDER)."' AND
+					EXP.`export_type` = '".wpsg_q(self::TYPE_ORDER)."'
+			");
+			
+			foreach ($arProfile as $profil) {
+				
+				$arFilter = ['id' => $order_id];
+				
+				if ($profil['format'] == self::FORMAT_CSV) list($arData, $file) = $this->handleExportCSV($profil['id'], $arFilter);
+                else if ($profil['format'] == self::FORMAT_XML) list($arData, $file) = $this->handleExportXML($profil['id'], $arFilter);
+				 
+				if (sizeof($arData) === 1) {
+							
+					$profil['filename'] = wpsg_ShopController::getShop()->replaceUniversalPlatzhalter($profil['filename'], array_values($arData)[0]->getId());
+					
+				}
+	 
+				if (wpsg_remoteconnection::handleConenctionString($profil['cron_path'], $profil['filename'], $file) !== true) {
+
+                    $target_path = $profil['cron_path'];
+                    if (is_dir($target_path)) $target_path = $target_path.'/'.$profil['filename'];
+
+                    file_put_contents($target_path, file_get_contents($file));
+
+                }
+				
+			}
+						
+	    }
+	    
         public function cron()
         {
@@ -669,6 +705,6 @@
                     {
 
-                        if ($profil['format'] == self::FORMAT_CSV) $file = $this->handleExportCSV($profil['id'], $arFilter);
-                        else if ($profil['format'] == self::FORMAT_XML) $file = $this->handleExportXML($profil['id'], $arFilter);
+                        if ($profil['format'] == self::FORMAT_CSV) list($arData, $file) = $this->handleExportCSV($profil['id'], $arFilter);
+                        else if ($profil['format'] == self::FORMAT_XML) list($arData, $file) = $this->handleExportXML($profil['id'], $arFilter);
 
                     }
@@ -841,4 +877,8 @@
             foreach ($arData as $order_id) {
 
+				$oOrder = wpsg_order::getInstance($order_id);
+				
+				if (intval($profil['order_onetime']) === 1 && intval($oOrder->getMeta('wpsg_mod_export_order_onetime_'.$profil_id, false, 0)) > 0) continue;
+				
                 $row = array();
 
@@ -891,4 +931,6 @@
                 $this->shop->callMods('wpsg_mod_export_handleRowOrder', [$order_id, $profil, &$arExportData]);
 
+				$oOrder->setMeta('wpsg_mod_export_order_onetime_'.$profil_id, time());
+				
 				/*
                 wpsg_product::clearCache();
@@ -903,5 +945,5 @@
                 gc_collect_cycles ();
 				*/
-
+	            
             } // foreach arData
 
@@ -926,5 +968,5 @@
             }
 
-            return $tmpfname;
+            return [$arData, $tmpfname];
 
         } // private function handleExportCSV($arProfile, $arOrderFilter = array(), $cron = false)
@@ -1023,6 +1065,5 @@
          * @throws Exception
          */
-        private function handleExportProductXML($profil_id, $arProductFilter = array())
-        {
+        private function handleExportProductXML($profil_id, $arProductFilter = array()) {
 
             $this->loadFields();
@@ -1033,6 +1074,6 @@
             if (!wpsg_isSizedString($profil['xml_roottag'])) throw new \Exception(wpsg_translate(__('Kein XML Root Tagname fÃŒr Profil "#1#" gesetzt!', 'wpsg'), $profil['name']));
             if (!wpsg_isSizedString($profil['xml_producttag'])) throw new \Exception(wpsg_translate(__('Kein XML Produkt Tagname fÃŒr Profil "#1#" gesetzt!', 'wpsg'), $profil['name']));
-
-            $doc = new DOMDocument('1.0');
+ 
+            $doc = new DOMDocument('1.0', 'utf-8');
             $doc->formatOutput = true;
 
@@ -1051,6 +1092,5 @@
                     $value = $this->getValue($f, $profil['field_delimiter'], false, $oProduct->id);
 
-                    if (wpsg_isSizedInt($f['xml_att']))
-                    {
+                    if (wpsg_isSizedInt($f['xml_att'])) {
 
                         $att = $doc->createAttribute($this->clearXML($f['name']));
@@ -1060,12 +1100,19 @@
 
 
-                    }
-                    else
-                    {
+                    } else {
 
                         $tag = $doc->createElement($this->clearXML($f['name']));
                         $tag = $tag_product->appendChild($tag);
 
-                        $tag_value = $doc->createTextNode(htmlspecialchars($value));
+						if (intval($f['format']) === 950) {
+							
+							$tag_value = $doc->createCDATASection($value);
+							
+						} else {
+							
+							$tag_value = $doc->createTextNode(htmlspecialchars($value));
+							
+						} 
+						
                         $tag->appendChild($tag_value);
 
@@ -1097,6 +1144,5 @@
          * @param array $arOrderFilter
          */
-        private function handleExportXML($profil_id, $arOrderFilter = array())
-        {
+        private function handleExportXML($profil_id, $arOrderFilter = array()) {
 
             $this->loadFields();
@@ -1111,5 +1157,5 @@
             if (!wpsg_isSizedString($profil['xml_producttag'])) throw new \Exception(wpsg_translate(__('Kein XML Produkt Tagname fÃŒr Profil "#1#" gesetzt!', 'wpsg'), $profil['name']));
 
-            $doc = new DOMDocument('1.0');
+            $doc = new DOMDocument('1.0', 'utf-8');
             $doc->formatOutput = true;
 
@@ -1117,7 +1163,30 @@
             $root = $doc->appendChild($root);
 
-            foreach ($arData as $oOrder)
-            {
-
+			foreach ($profil['fields'] as $field_index => $f) {
+				
+				if ($this->getFieldGroup($f['value_key']) === 5) {
+				
+					if (strpos($f['name'], '/') !== false) {
+						
+						$value = $this->getValue($f, $profil['field_delimiter'], 0);
+						
+						$arRootline = explode('/', $f['name']);
+						if ($arRootline[0] !== $profil['xml_ordertag'] && $arRootline[0] !== $profil['xml_productroottag']) {
+						
+							$this->addXMLNode($doc, $root, $f['name'], $value, $f);
+							unset($profil['fields'][$field_index]);
+
+						}
+						
+					}
+					
+				}				 
+				
+			}
+			
+            foreach ($arData as $oOrder) {
+
+				if (intval($profil['order_onetime']) === 1 && intval($oOrder->getMeta('wpsg_mod_export_order_onetime_'.$profil_id, false, 0)) > 0) continue;
+				
                 $tag_order = $doc->createElement($this->clearXML($profil['xml_ordertag']));
                 $tag_order = $root->appendChild($tag_order);
@@ -1125,6 +1194,5 @@
                 $tag_product_root = false;
 
-                if (wpsg_isSizedString($profil['xml_productroottag']))
-                {
+                if (wpsg_isSizedString($profil['xml_productroottag'])) {
 
                     $tag_product_root = $doc->createElement($this->clearXML($profil['xml_productroottag']));
@@ -1133,15 +1201,14 @@
                 }
 
-                foreach ($profil['fields'] as $f)
-                {
-
+                foreach ($profil['fields'] as $f) {
+
+					$arRootline = explode('/', $f['name']);
+					
                     // Wert ist kein Produktfeld
-                    if ($this->getFieldGroup($f['value_key']) != 20)
-                    {
+                    if ($this->getFieldGroup($f['value_key']) != 20) {
 
                         $value = $this->getValue($f, $profil['field_delimiter'], $oOrder->id);
 
-                        if (wpsg_isSizedInt($f['xml_att']))
-                        {
+                        if (wpsg_isSizedInt($f['xml_att'])) {
 
                             $att = $doc->createAttribute($this->clearXML($f['name']));
@@ -1150,14 +1217,36 @@
                             $tag_order->appendChild($att);
 
-
-                        }
-                        else
-                        {
-
-                            $tag = $doc->createElement($this->clearXML($f['name']));
-                            $tag = $tag_order->appendChild($tag);
-
-                            $tag_value = $doc->createTextNode(htmlspecialchars($value));
-                            $tag->appendChild($tag_value);
+                        } else {
+
+							if (strpos($f['name'], '/') !== false) {
+ 
+								if ($arRootline[0] === $profil['xml_ordertag'] && wpsg_getStr($arRootline[1]) === $profil['xml_productroottag']) {
+				
+									$this->addXMLNode($doc, $tag_product_root, implode('/', array_slice($arRootline, 2)), $value, $f);
+									
+								} else if ($arRootline[0] === $profil['xml_ordertag']) {
+									
+									$this->addXMLNode($doc, $tag_order, implode('/', array_slice($arRootline, 1)), $value, $f);
+									
+								}
+								 
+							} else {
+								
+	                            $tag = $doc->createElement($this->clearXML($f['name']));
+	                            $tag = $tag_order->appendChild($tag);
+	
+								if (intval($f['format']) === 950) {
+						
+									$tag_value = $doc->createCDATASection($value);
+									
+								} else {
+									
+									$tag_value = $doc->createTextNode(htmlspecialchars($value));
+									
+								}
+								 								
+	                            $tag->appendChild($tag_value);
+
+							}
 
                         }
@@ -1170,15 +1259,14 @@
                 $arOrderProducts = $oOrder->getOrderProducts();
 
-                foreach ($arOrderProducts as $oOrderProduct)
-                {
-
+                foreach ($arOrderProducts as $oOrderProduct) {
+					
                     $tag_product = false;
 
-                    foreach ($profil['fields'] as $f)
-                    {
-
+                    foreach ($profil['fields'] as $f) {
+
+						$arRootline = explode('/', $f['name']);
+						
                         // Wert ist ein Produktfeld
-                        if ($this->getFieldGroup($f['value_key']) == 20)
-                        {
+                        if ($this->getFieldGroup($f['value_key']) == 20 || (sizeof($arRootline) > 0 && $arRootline[0] === $profil['xml_productroottag'] && $arRootline[1] === $profil['xml_producttag'])) {
 
                             if ($tag_product === false) $tag_product = $doc->createElement($this->clearXML($profil['xml_producttag']));
@@ -1186,6 +1274,5 @@
                             $value = $this->getValue($f, $profil['field_delimiter'], $oOrder->id, $oOrderProduct->getProductId(), null, $oOrderProduct->getId());
 
-                            if (wpsg_isSizedInt($f['xml_att']))
-                            {
+                            if (wpsg_isSizedInt($f['xml_att'])) {
 
                                 $att = $doc->createAttribute($this->clearXML($f['name']));
@@ -1195,21 +1282,39 @@
 
 
+                            } else {
+
+								if (strpos($f['name'], '/') !== false) {
+									 
+									if ($arRootline[0] === $profil['xml_productroottag'] && $arRootline[1] === $profil['xml_producttag']) {
+									
+										$this->addXMLNode($doc, $tag_product, implode('/', array_slice($arRootline, 1)), $value, $f);
+										
+									}  
+									
+								} else {
+								
+	                                $tag = $doc->createElement($this->clearXML($f['name']));
+	                                $tag = $tag_product->appendChild($tag);
+	
+									if (intval($f['format']) === 950) {
+						
+										$tag_value = $doc->createCDATASection($value);
+										
+									} else {
+										
+										$tag_value = $doc->createTextNode(htmlspecialchars($value));
+										
+									} 
+									
+	                                $tag->appendChild($tag_value);
+
+								}
+
                             }
-                            else
-                            {
-
-                                $tag = $doc->createElement($this->clearXML($f['name']));
-                                $tag = $tag_product->appendChild($tag);
-
-                                $tag_value = $doc->createTextNode(htmlspecialchars($value));
-                                $tag->appendChild($tag_value);
-
-                            }
 
                         }
                     }
 
-                    if ($tag_product !== false)
-                    {
+                    if ($tag_product !== false) {
 
                         $tag_product_root->appendChild($tag_product);
@@ -1219,6 +1324,11 @@
                 } // foreach Produkte
 
+	            $oOrder->setMeta('wpsg_mod_export_order_onetime_'.$profil_id, time());
+	            
             } // foreach Order
 
+	        //Debug Out
+	        //die('<pre>'.htmlspecialchars($doc->saveXML()).'</pre>');
+	        
             $tmpfname = tempnam($this->getTmpFilePath(), "wpsg");
             file_put_contents($tmpfname, $doc->saveXML());
@@ -1232,5 +1342,5 @@
             }
 
-            return $tmpfname;
+            return [$arData, $tmpfname];
 
         } // private function handleExportXML($arProfile, $arOrderFilter = array(), $cron = false)
@@ -1285,6 +1395,15 @@
                         $tag = $doc->createElement($this->clearXML($f['name']));
                         $tag = $tag_product->appendChild($tag);
-
-                        $tag_value = $doc->createTextNode(htmlspecialchars($value));
+ 
+						if (intval($f['format']) === 950) {
+						
+							$tag_value = $doc->createCDATASection($value);
+							
+						} else {
+							
+							$tag_value = $doc->createTextNode(htmlspecialchars($value));
+							
+						}
+						
                         $tag->appendChild($tag_value);
 
@@ -1313,6 +1432,5 @@
          * Bereinigt Daten an XML fÃŒr Tagname / Attributname
          */
-        private function clearXML($value)
-        {
+        private function clearXML($value) {
 
             $value = preg_replace('/\040+/', '_', $value);
@@ -1323,14 +1441,11 @@
         }
 
-        private function getFieldGroup($key)
-        {
+        private function getFieldGroup($key) {
 
             if (!wpsg_isSizedArray($this->fields)) $this->loadFields();
 
-            foreach ($this->fields as $group_key => $group)
-            {
-
-                foreach ($group['fields'] as $field_key => $field_label)
-                {
+            foreach ($this->fields as $group_key => $group) {
+
+                foreach ($group['fields'] as $field_key => $field_label) {
 
                     if ($field_key == $key) return $group_key;
@@ -1339,5 +1454,5 @@
 
             }
-
+			
             return false;
 
@@ -1411,5 +1526,5 @@
                     'fields' => array(
                         'allgemein_empty' => __('Leer', 'wpsg'),
-                        //'allgemein_statisch' => __('Statisch', 'wpsg'),
+                        'general_static' => __('Statisch', 'wpsg'),
                         'allgemein_currency' => __('WÃ€hrung', 'wpsg')
                     )
@@ -1437,6 +1552,9 @@
                         'order_price_netto_d' => __('Summe Nettobetrag MwSt D', 'wpsg'),
                         'order_tax_d' => __('Steuer MwSt MwSt D', 'wpsg'),
+						'order_tax' => __('Steuer Summe (A+B+C+D)', 'wpsg'),
 
                         'order_invoice_title' => __('Rechnungsadresse Anrede', 'wpsg'),
+						'order_invoice_address1' => __('Rechnungsadresse Vorname und Name oder Firmenname', 'wpsg'),
+						'order_invoice_address2' => __('Rechnungsadresse Name, Vorname oder Firmenbezeichung', 'wpsg'),
                         'order_invoice_firma' => __('Rechnungsadresse Firma', 'wpsg'),
                         'order_invoice_vorname' => __('Rechnungsadresse Vorname', 'wpsg'),
@@ -1453,4 +1571,6 @@
 
                         'order_title' => __('Lieferadresse Anrede', 'wpsg'),
+						'order_address1' => __('Lieferadresse Vorname und Name oder Firmenname', 'wpsg'),
+						'order_address2' => __('Lieferadresse Name, Vorname oder Firmenbezeichung', 'wpsg'),
                         'order_firma' => __('Lieferadresse Firma', 'wpsg'),
                         'order_vorname' => __('Lieferadresse Vorname', 'wpsg'),
@@ -1465,5 +1585,7 @@
 
                         'order_payment_method' => __('Name der Zahlart', 'wpsg'),
+                        'order_payment_id' => __('Transaktions-ID des Zahlungsdienstleisters', 'wpsg'),
                         'order_shipping_method' => __('Name der Versandart', 'wpsg'),
+                        'order_shipping_tax' => __('Steuerwert (z.b. 19.00) der Versandart', 'wpsg'),
                         'order_count' => __('Anzahl Produkte', 'wpsg'),
                         'order_bname' => __('Name der Bank (Bankeinzug)', 'wpsg'),
@@ -1494,5 +1616,6 @@
                         'product_preis_order_netto' => __('Produktpreis aus Bestellung (Netto)', 'wpsg'),
                         'produkt_mwst' => __('Mehrwertsteuer (SchlÃŒssel)', 'wpsg'),
-                        'produkt_mwst_satz' => __('Mehrwertsteuer (Satz z.B. 19%)', 'wpsg'),
+                        'produkt_mwst_satz' => __('Mehrwertsteuer (Satz z.B. 19)', 'wpsg'),
+                        'produkt_mwst_satz_100' => __('Mehrwertsteuer/100 (Satz z.B. 0.19)', 'wpsg'),
                         'produkt_mwst_value' => __('Mehrwertsteuer (Wert in â¬)', 'wpsg'),
                         'produkt_order_mwst_value' => __('Mehrwertsteuer (Wert in â¬ aus Bestellung)', 'wpsg'),
@@ -1778,5 +1901,5 @@
 						
 			if ($p_id !== null) {
-				
+				 
 				if (isset($this->arCache['product'][$p_id])) {
 					
@@ -1794,5 +1917,5 @@
 			
 			if ($customer_id !== null) {
-				
+				 
 				if (isset($this->arCache['customer'][$customer_id])) {
 					
@@ -1819,5 +1942,5 @@
 			 
 			if ($order_product_id !== null) {
-				
+				 
 				if (isset($this->arCache['order_product_id'][$order_product_id])) {
 					
@@ -1864,5 +1987,5 @@
 
                 case 'allgemein_empty': $return = ''; break;
-                case 'allgemein_statisch': $return = $f['static']; break;
+                case 'general_static': $return = $f['static']; break;
                 case 'allgemein_currency': $return = get_option('wpshopgermany_currency'); break;
 
@@ -1875,5 +1998,6 @@
 	            case 'order_price_netto_d': $return = $getTaxSum('d')['netto']; break;
 	            case 'order_tax_d': $return = $getTaxSum('d')['sum']; break;
-
+	            case 'order_tax': $return = $getTaxSum('a')['sum'] + $getTaxSum('b')['sum'] + $getTaxSum('c')['sum'] + $getTaxSum('d')['sum']; break;
+				
                 case 'order_id': $return = $oOrder->getId(); break;
                 case 'order_cdate':
@@ -1911,4 +2035,19 @@
 
                 case 'order_invoice_title': $return = $oOrder->getInvoiceTitle(); break;
+				
+	            case 'order_invoice_address1': 
+					
+					if ($oOrder->getInvoiceCompany() !== '') $return = trim($oOrder->getInvoiceCompany());
+					else $return = trim($oOrder->getInvoiceFirstName().' '.$oOrder->getInvoiceName());
+					
+				break;
+				
+				case 'order_invoice_address2': 
+					
+					if ($oOrder->getInvoiceCompany() !== '') $return = trim($oOrder->getInvoiceCompany());
+					else $return = trim($oOrder->getInvoiceName().', '.$oOrder->getInvoiceFirstName());
+					
+				break;
+				
                 case 'order_invoice_firma': $return = $oOrder->getInvoiceCompany(); break;
                 case 'order_invoice_vorname': $return = $oOrder->getInvoiceFirstName(); break;
@@ -1925,4 +2064,19 @@
 
                 case 'order_title': $return = $oOrder->getShippingTitle(); break;
+				
+				case 'order_address1': 
+					
+					if ($oOrder->getShippingCompany() !== '') $return = trim($oOrder->getShippingCompany());
+					else $return = trim($oOrder->getShippingFirstName().' '.$oOrder->getShippingName());
+					
+				break;
+				
+				case 'order_address2': 
+					
+					if ($oOrder->getShippingCompany() !== '') $return = trim($oOrder->getShippingCompany());
+					else $return = trim($oOrder->getShippingName().', '.$oOrder->getShippingFirstName());
+					
+				break;
+				
                 case 'order_firma': $return = $oOrder->getShippingCompany(); break;
                 case 'order_vorname': $return = $oOrder->getShippingFirstName(); break;
@@ -1937,5 +2091,14 @@
 
                 case 'order_payment_method': $return = $oOrder->getPaymentLabel(); break;
+	            case 'order_payment_id':
+					
+					if (intval($oOrder->getPaymentID()) === 2) { $return = $oOrder->getMeta('wpsg_mod_paypal_paymentid'); }
+					else if (intval($oOrder->getPaymentID()) === $return = $oOrder->getMeta('wpsg_mod_paypalapi_paymentid'));
+					else $return = '';
+					
+					break;
+					
                 case 'order_shipping_method': $return = $oOrder->getShippingLabel(); break;
+	            case 'order_shipping_tax': $return = $oOrder->getShippingTaxValue(); break;
                 case 'order_count': $return = $oOrder->getProductCount(); break;
                 case 'order_firma': $return = $oOrder->getInvoiceCompany(); break;
@@ -2035,4 +2198,5 @@
                 case 'produkt_mwst': $return = $oOrderProduct->getTaxKey(); break;
                 case 'produkt_mwst_satz': $return = wpsg_ff($oFrontendCountry->getTax($oProduct->__get('mwst_key'))); break;
+                case 'produkt_mwst_satz_100': $return = wpsg_ff($oFrontendCountry->getTax($oProduct->__get('mwst_key')) / 100); break;
                 case 'produkt_mwst_value': $return = wpsg_ff($oProduct->getPrice(false, WPSG_BRUTTO) - $oProduct->getPrice(false, WPSG_NETTO)); break;
  
@@ -2055,5 +2219,5 @@
                     break;
                 case 'produkt_anr': $return = $oProduct->__get('anr'); break;
-                case 'produkt_menge': $return = $oProduct->__get('menge'); break;
+                case 'produkt_menge': $return = $oOrderProduct->__get('menge'); break;
                 case 'produkt_ean': $return = $oProduct->__get('ean'); break;
                 case 'produkt_gtin': $return = $oProduct->__get('gtin'); break;
@@ -2157,4 +2321,5 @@
                     case 500: $return = date('H:i:s', strtotime($return)); break;
                     case 600: $return = date('d.m.Y H:i:s', strtotime($return)); break;
+                    case 610: $return = date('c', strtotime($return)); break;
                     case 700: $return = strftime($this->shop->replaceUniversalPlatzhalter($f['userformat'], $order['id'], $kunde['id'], false, $p_id), strtotime($return)); break;
                     case 800: $return = '"'.$return.'"'; break;
@@ -2169,5 +2334,66 @@
             return $return;
 
-        }  
-
+        }
+
+	    /**
+	     *
+	     * @param DOMNode &$node_root
+	     * @param string $tag
+	     * @param string $value
+	     * @param array $f
+	     *
+	     * @return void
+	     * @parem String $value
+	     */
+		private function addXMLNode(DOMDOcument $doc, DOMNode &$node_root, string $tag, string $value, array $f) {
+		
+			$arRootline = explode('/', $tag);
+			$node = $node_root;
+			
+			foreach ($arRootline as $k => $tag) {
+				
+				$add = true;
+				
+				for ($i = 0; $i <= $node->childNodes->length; $i ++) {
+					
+					if ($node->childNodes->item($i)->nodeName === $tag) {
+				
+						$add = false;
+						$node = $node->childNodes->item($i);
+						
+						break;
+						
+					}
+					
+				}
+				
+				if ($add) {
+					
+					$new_node = $doc->createElement($this->clearXML($tag));
+                    $new_node = $node->appendChild($new_node);
+					
+					$node = $new_node;
+					
+				}
+				
+				if ($k === sizeof($arRootline) - 1) {
+					
+					if (intval($f['format']) === 950) {
+						
+						$tag_value = $doc->createCDATASection($value);
+						
+					} else {
+						
+						$tag_value = $doc->createTextNode(htmlspecialchars($value));
+						
+					}
+					
+					$node->appendChild($tag_value);
+					
+				}
+				
+			}
+			
+		}
+		
     } 
Index: /mods/wpsg_mod_productvariants.class.php
===================================================================
--- /mods/wpsg_mod_productvariants.class.php	(revision 8130)
+++ /mods/wpsg_mod_productvariants.class.php	(revision 8131)
@@ -2377,4 +2377,6 @@
         public function wpsg_mod_export_getValue(&$return, $field_value, $o_id, $p_id, $order_product_id, $profil_separator) {
 
+			if ($order_product_id === null) return;
+			
 			$oOrderProduct = wpsg_order_product::getInstance($order_product_id);
 			
Index: /views/mods/mod_export/fields.phtml
===================================================================
--- /views/mods/mod_export/fields.phtml	(revision 8130)
+++ /views/mods/mod_export/fields.phtml	(revision 8131)
@@ -37,12 +37,9 @@
             <td class="wpsg_mod_export_col_field"><div class="wpsg_editable" id="field_typ_<?php echo $f_id; ?>"><?php
     
-                foreach ($this->view['fields'] as $fieldgroup)
-                {
+                foreach ($this->view['fields'] as $fieldgroup) {
     
-                    foreach ($fieldgroup['fields'] as $field_key => $field)
-                    {
+                    foreach ($fieldgroup['fields'] as $field_key => $field) {
     
-                        if ($field_key == $f['value_key'])
-                        {
+                        if ($field_key == $f['value_key']) {
                             
                             echo $field;
@@ -75,6 +72,16 @@
             
         </tr>
+        <tr id="staticformat_<?php echo $f_id; ?>" style="<?php echo (($f['value_key'] != 'general_static')?'display:none;':''); ?>" class="wpsg_mod_export_row2 wpsg_tablerow wpsg_mod_export_fieldrow_<?php echo $f_id; ?> <?php echo (($i % 2 == 0)?'odd':'even'); ?>">
+            <td class="wpsg_mod_export_col_format_user" colspan="4">
+                
+                <?php echo __('Statischer Wert', 'wpsg'); ?>:
+                
+                <div class="wpsg_editable" id="field_static_<?php echo $f_id; ?>"><?php echo wpsg_hspc(wpsg_getStr($f['static'])); ?></div>
+                
+            </td>
+            <td></td>
+        </tr>
         <tr id="userformatrow_<?php echo $f_id; ?>" style="<?php echo (($f['format'] != 700)?'display:none;':''); ?>" class="wpsg_mod_export_row2 wpsg_tablerow wpsg_mod_export_fieldrow_<?php echo $f_id; ?> <?php echo (($i % 2 == 0)?'odd':'even'); ?>">
-            <td class="wpsg_mod_export_col_format_user" colspan="4">
+            <td class="wpsg_mod_export_col_format_user" colspan="4">                
             
                 <?php echo __('Format', 'wpsg'); ?>:
@@ -95,5 +102,11 @@
                         jQuery('#field_typ_<?php echo $f_id; ?>').wpsg_editable('<?php echo $inlineEdit_url; ?>', { 
                             'type': 'multiarray',
-                            'data': '<?php echo addslashes(json_encode($this->view['fields'], JSON_UNESCAPED_SLASHES)); ?>'                            
+                            'data': '<?php echo addslashes(json_encode($this->view['fields'], JSON_UNESCAPED_SLASHES)); ?>',
+                            'callback': function(response, newValue) {
+								
+								if (newValue === 'general_static') jQuery('#staticformat_<?php echo $f_id; ?>').show();
+								else jQuery('#staticformat_<?php echo $f_id; ?>').hide();
+								
+                            }
                         } );
                         
@@ -111,4 +124,6 @@
                         jQuery('#field_userformat_<?php echo $f_id; ?>').wpsg_editable('<?php echo $inlineEdit_url; ?>', { } );
                         
+						jQuery('#field_static_<?php echo $f_id; ?>').wpsg_editable('<?php echo $inlineEdit_url; ?>', { } );
+						
                     } );
                 
@@ -150,2 +165,8 @@
     
 /* ]]> */</script>
+
+<style>
+
+    .wpsg_mod_export_col_format { min-width:100px; }
+    
+</style>
Index: /views/mods/mod_export/profil.phtml
===================================================================
--- /views/mods/mod_export/profil.phtml	(revision 8130)
+++ /views/mods/mod_export/profil.phtml	(revision 8131)
@@ -90,8 +90,11 @@
                 <?php echo wpsg_drawForm_Text(__('Pfad', 'wpsg'), $this->view['profil']['cron_path'], 'cron_path', array('inlineEdit' => true, 'inlineEdit_url' => $inlineEdit_url)); ?>                
                 <?php echo wpsg_drawForm_Text(__('Letzte AusfÃŒhrung', 'wpsg'), (($this->view['profil']['cron_lastrun'] == '0000-00-00')?__('Noch nie', 'wpsg'):wpsg_formatTimestamp($this->view['profil']['cron_lastrun'], true)), false, array('noP' => false)); ?>
-				<?php echo wpsg_drawForm_Text(__('Cron URL', 'wpsg'), '<a href="'.site_url().'/?wpsg_cron=1">'.site_url().'/?wpsg_cron=1</a>', false, array('noP' => false)); ?>
-                
+				
+                <fieldset id="wpsg_mod_export_cron_url" style="display:<?php echo (($this->view['profil']['cron_interval'] !== wpsg_mod_export::CRON_ORDER)?'block':'none'); ?>;">
+                    <?php echo wpsg_drawForm_Text(__('Cron URL', 'wpsg'), '<a href="'.site_url().'/?wpsg_cron=1">'.site_url().'/?wpsg_cron=1</a>', false, array('noP' => false)); ?>
+                </fieldset>
+                    
                 <?php if ($this->view['profil']['export_type'] === wpsg_mod_export::TYPE_ORDER) { ?>
-                <fieldset id="wpsg_mod_export_orderfilter">                                                
+                <fieldset id="wpsg_mod_export_orderfilter" style="display:<?php echo (($this->view['profil']['cron_interval'] !== wpsg_mod_export::CRON_ORDER)?'block':'none'); ?>;">                                                
                     
                     <legend><div class="col-sm-offset-6"><?php echo __('Bestellfilter', 'wpsg'); ?></div></legend>
@@ -234,7 +237,18 @@
 <script type="text/javascript">/* <![CDATA[ */
 
-    function switchCronType(response, newValue)
-    {
-       
+    function switchCronType(response, newValue) {
+		
+		if (parseInt(newValue) === parseInt("<?php echo wpsg_mod_export::CRON_ORDER; ?>")) {
+			
+			jQuery('#wpsg_mod_export_cron_url').hide();
+			jQuery('#wpsg_mod_export_orderfilter').hide();
+			
+        } else {
+			
+			jQuery('#wpsg_mod_export_cron_url').show();
+			jQuery('#wpsg_mod_export_orderfilter').show();
+			
+        }
+		
         if (newValue != "0") jQuery('.cron_interval_1').show();
         else jQuery('.cron_interval_1').hide();
