Index: /changelog
===================================================================
--- /changelog	(revision 5767)
+++ /changelog	(revision 5774)
@@ -838,4 +838,5 @@
  - Bugfix - Speichert man die Einstellungen eines aktiviertes Modul, bei dem der DEMO Modus abgelaufen wird kein Fehler mehr erzeugt.
  - Bugfix - korrekte Lieferzeitanzeige bei individuellen Lieferzeiten
+ - Bugfix - Export von Produktveriantenpreisen korrigiert
 
 #4.0.0 / 5259
Index: /mods/wpsg_mod_export.class.php
===================================================================
--- /mods/wpsg_mod_export.class.php	(revision 5767)
+++ /mods/wpsg_mod_export.class.php	(revision 5774)
@@ -2,5 +2,5 @@
 
 	/**
-	 * Modul fÃŒr die verschiedenen Export Profile
+	 * Modul für die verschiedenen Export Profile
 	 */
 	class wpsg_mod_export extends wpsg_mod_basic 
@@ -11,8 +11,8 @@
 		var $inline = true;
 		
-		/** Hier sind alle mÃ¶glichen Typen drin, wird von loadFields gefÃŒllt */
+		/** Hier sind alle möglichen Typen drin, wird von loadFields gefüllt */
 		var $fields = array();
 		
-		/** Array fÃŒr die mÃ¶glichen Format Umwandlungen */
+		/** Array für die möglichen Format Umwandlungen */
 		var $arFormats = array();
 		
@@ -43,8 +43,8 @@
 						
 			$this->arFormats = array(
-				0 => __('UnverÃ€ndert', 'wpsg'),
+				0 => __('Unverändert', 'wpsg'),
 				100 => __('Zahl (99.99)', 'wpsg'),
 				200 => __('Zahl (99,99)', 'wpsg'),
-				300 => __('WÃ€hrung (99,99 â¬)', 'wpsg'),
+				300 => __('Währung (99,99 )', 'wpsg'),
 				400 => __('Datum (TT.MM.YYYY)', 'wpsg'),
 				500 => __('Zeit (hh:mm:ss)', 'wpsg'),
@@ -57,5 +57,5 @@
 			$this->name = __('Exportprofile', 'wpsg');
 			$this->group = __('Sonstiges', 'wpsg');
-			$this->desc = __('ErmÃ¶glicht es Produkte, Bestellungen und Kunden bezogen auf Bestellungen in verschiedene CSV Formate zu exportieren.', 'wpsg');
+			$this->desc = __('Ermöglicht es Produkte, Bestellungen und Kunden bezogen auf Bestellungen in verschiedene CSV Formate zu exportieren.', 'wpsg');
 
 		} // public function __construct()
@@ -67,5 +67,5 @@
 			
 			/*
-		   	 * Tabelle fÃŒr die Exportprofile
+		   	 * Tabelle für die Exportprofile
 		   	 */
 		   	$sql = "CREATE TABLE ".WPSG_TBL_EXPORTPROFILE." (
@@ -78,5 +78,5 @@
 		   	dbDelta($sql);
 			
-		   	// StandardmÃ€Ãig einen Export vorgeben sollte keiner existieren
+		   	// Standardmäßig einen Export vorgeben sollte keiner existieren
 		   	$existsID1 = $this->db->fetchOne("SELECT COUNT(*) FROM `".WPSG_TBL_EXPORTPROFILE."` WHERE `id` = '1'");
 		   	
@@ -130,190 +130,187 @@
 			
 		} // public function profilList()
-
-		public function order_ajax()
+		
+		public function handleExport()
 		{
-
-			parse_str($_REQUEST['filter'], $arFilter);
-
-			if (!wpsg_isSizedArray($_REQUEST['wpsg_mod_export_profile']))
-			{
-
-				$this->shop->addBackendError(__('Bitte mindestens ein Export Profil anlegen.', 'wpsg'));
-				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order');
-
-			}
-
-			$arProfile = $_REQUEST['wpsg_mod_export_profile'];
-
-			$this->loadFields();
-
-			foreach ($arProfile as $profil_id)
-			{
-
-				$profil = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_EXPORTPROFILE."` WHERE `id` = '".wpsg_q($profil_id)."'");
-				$profil['data'] = @unserialize($profil['data']);
-				$profil['filename'] = $profil['data']['filename'];
-
-				$tmpfname = tempnam($this->getTmpFilePath(), "wpsg");
-
-				$filehandler = fopen($tmpfname, 'w');
-
-				// Kopf
-				if ($profil['data']['firstlinecolname'] == '1')
-				{
-
-					$row = array();
-
-					foreach ($profil['data']['fields'] as $f)
-					{
-
-						$row[] = $f['name'];
-
-					}
-
-					fputcsv($filehandler, $row, $profil['data']['separator']);
-
-				}
-
-				$arOrder = wpsg_order::find($arFilter['filter']);
-
-				//foreach ($this->shop->view['data'] as $d)
-				foreach ($arOrder as $oOrder)
-				{
-
-					$d = $oOrder->data;
-
-					$row = array();
-
-					if ($profil['data']['oneline'] == '1')
-					{
-
+						
+			$arProfile = explode(",", $_REQUEST['wpsg_mod_export_profile']);
+			
+			if (sizeof($arProfile) >= 1)
+			{
+				
+				$this->loadFields();
+
+				foreach ($arProfile as $profil_id)
+				{
+					
+					$profil = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_EXPORTPROFILE."` WHERE `id` = '".wpsg_q($profil_id)."'");
+					$profil['data'] = @unserialize($profil['data']);
+					$profil['filename'] = $profil['data']['filename'];
+					
+					$tmpfname = tempnam($this->getTmpFilePath(), "wpsg");
+					
+					$filehandler = fopen($tmpfname, 'w');
+					
+					// Kopf
+					if ($profil['data']['firstlinecolname'] == '1')
+					{
+					
+						$row = array();
+						
 						foreach ($profil['data']['fields'] as $f)
 						{
-
-							$row[] = $this->getValue($f, $profil['data']['separator'], $d['id']);
-
+							
+							$row[] = $f['name'];
+							
 						}
-
+						
 						fputcsv($filehandler, $row, $profil['data']['separator']);
-
+						
+					}
+					
+					foreach ($this->shop->view['data'] as $d) 
+					{
+												
+						$row = array();
+						
+						if ($profil['data']['oneline'] == '1')
+						{
+						
+							foreach ($profil['data']['fields'] as $f) 
+							{
+
+								$row[] = $this->getValue($f, $profil['data']['separator'], $d['id']);
+								
+							}
+							
+							fputcsv($filehandler, $row, $profil['data']['separator']);
+							
+						}
+						else 
+						{
+							
+							$arProdukte = $this->db->fetchAssoc("
+								SELECT 
+									OP.`p_id`, 
+									OP.`productkey`, 
+									OP.`product_index`,
+									OP.`id` AS `order_product_id`
+								FROM 
+									`".WPSG_TBL_ORDERPRODUCT."` AS OP 
+								WHERE 
+									OP.`o_id` = '".wpsg_q($d['id'])."'
+							");
+							
+							foreach ($arProdukte as $p)
+							{
+							
+								$row = array();
+								
+								foreach ($profil['data']['fields'] as $f)
+								{
+
+									$row[] = $this->getValue($f, $profil['data']['separator'], $d['id'], $p['p_id'], $p['product_index'], $p['productkey'], $p['order_product_id']);
+																		
+								}
+
+								fputcsv($filehandler, $row, $profil['data']['separator']);
+																	
+							}
+							
+						}
+	    				
+					}
+					
+					fclose($filehandler);
+					
+					// In ISO wandeln
+					if ($profil['data']['iso'] == '1')
+					{
+						
+						file_put_contents($tmpfname, utf8_decode(file_get_contents($tmpfname)));
+												
+					}
+					
+					$arFiles[] = array(strval($profil['data']['filename']), $tmpfname);
+					
+				}
+				
+				if (sizeof($arFiles) == 1)
+				{
+					
+					header("Content-Type: text/csv"); 
+					header("Content-Disposition: attachment; filename=".$arFiles[0][0]); 
+					header("Pragma: no-cache"); 
+					header("Expires: 0"); 
+					
+					die(file_get_contents($arFiles[0][1]));
+						
+				}
+				else if (sizeof($arFiles) > 1)
+				{
+					
+					$zip = new ZipArchive();
+					
+					$tmpfname = tempnam($this->getTmpFilePath(), "wpsg").'.zip';			
+
+					if ($zip->open($tmpfname, ZIPARCHIVE::CREATE) == true) 
+					{
+    
+						foreach ($arFiles as $f)
+						{
+						
+							$zip->addFile($f[1], $f[0]);
+							
+						}
+						
+						$zip->close();
+						
+						header("Content-Type: application/octet-stream"); 
+						header("Content-Disposition: attachment; filename=export.zip"); 
+						header("Pragma: no-cache"); 
+						header("Expires: 0"); 
+						
+						die(file_get_contents($tmpfname));
+						
 					}
 					else
 					{
-
-						$arProdukte = $this->db->fetchAssoc("
-							SELECT 
-								OP.`p_id`, 
-								OP.`productkey`, 
-								OP.`product_index`,
-								OP.`id` AS `order_product_id`
-							FROM 
-								`".WPSG_TBL_ORDERPRODUCT."` AS OP 
-							WHERE 
-								OP.`o_id` = '".wpsg_q($d['id'])."'
-						");
-
-						foreach ($arProdukte as $p)
-						{
-
-							$row = array();
-
-							foreach ($profil['data']['fields'] as $f)
-							{
-
-								$row[] = $this->getValue($f, $profil['data']['separator'], $d['id'], $p['p_id'], $p['product_index'], $p['productkey'], $p['order_product_id']);
-
-							}
-
-							fputcsv($filehandler, $row, $profil['data']['separator']);
-
-						}
-
-					}
-
-				}
-
-				fclose($filehandler);
-
-				// In ISO wandeln
-				if ($profil['data']['iso'] == '1')
-				{
-
-					file_put_contents($tmpfname, utf8_decode(file_get_contents($tmpfname)));
-
-				}
-
-				$arFiles[] = array(strval($profil['data']['filename']), $tmpfname);
-
-			}
-
-			if (sizeof($arFiles) == 1)
-			{
-
-				header("Content-Type: text/csv");
-				header("Content-Disposition: attachment; filename=".$arFiles[0][0]);
-				header("Pragma: no-cache");
-				header("Expires: 0");
-
-				die(file_get_contents($arFiles[0][1]));
-
-			}
-			else if (sizeof($arFiles) > 1)
-			{
-
-				$zip = new ZipArchive();
-
-				$tmpfname = tempnam($this->getTmpFilePath(), "wpsg").'.zip';
-
-				if ($zip->open($tmpfname, ZIPARCHIVE::CREATE) == true)
-				{
-
-					foreach ($arFiles as $f)
-					{
-
-						$zip->addFile($f[1], $f[0]);
-
-					}
-
-					$zip->close();
-
-					header("Content-Type: application/octet-stream");
-					header("Content-Disposition: attachment; filename=export.zip");
-					header("Pragma: no-cache");
-					header("Expires: 0");
-
-					die(file_get_contents($tmpfname));
-
-				}
-				else
-				{
-
-					die(__('Konnte Zip Archiv nicht erstellen!', 'wpsg'));
-
-				}
-
-			}
-
-			return true;
+						
+						die(__('Konnte Zip Archiv nicht erstellen!', 'wpsg'));
+						
+					}
+					
+				}
+				
+				return true;
+				
+			}
 			
 			return false;			
 			
-		} // public function order_ajax()
-
-		public function product_index_tab(&$arTabs)
+		} // public function handleExport()
+		
+		public function produkt_index_head()
 		{
 
 			$this->shop->view['wpsg_mod_export']['arProfile'] = $this->db->fetchAssoc("SELECT * FROM `".WPSG_TBL_EXPORTPROFILE."`");
-
+			
 			if (sizeof($this->shop->view['wpsg_mod_export']['arProfile']) <= 0) return;
-
-			$arTabs['right'][$this->id] = array(
-				'tab_title' => __('Export', 'wpsg'),
-				'tab_icon' => 'glyphicon glyphicon-export',
-				'tab_content' => $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_export/order_index_tab.phtml', false)
-			);
-
-		} // public function product_index_tab(&$arTabs) { }
-
+			
+			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_export/produkt_index_head.phtml');
+			
+		} // public function produkt_index_head()
+		 
+		public function produkt_index_aftersearch()
+		{
+			
+			$this->shop->view['wpsg_mod_export']['arProfile'] = $this->db->fetchAssoc("SELECT * FROM `".WPSG_TBL_EXPORTPROFILE."`");
+			
+			if (sizeof($this->shop->view['wpsg_mod_export']['arProfile']) <= 0) return;
+			
+			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_export/produkt_index_aftersearch.phtml');
+			
+		} // public function produkt_index_aftersearch()
+		
 		public function be_ajax()
 		{
@@ -360,8 +357,6 @@
 				 
 				$this->shop->view['profil']['data'] = unserialize($this->shop->view['profil']['data']);
-
-				if (!isset($this->shop->view['profil']['data']['fields']) ||  !is_array($this->shop->view['profil']['data']['fields'])) $this->shop->view['profil']['data']['fields'] = array();
-
-				foreach ($this->shop->view['profil']['data']['fields'] as $k => $v)
+											
+				foreach ((array)$this->shop->view['profil']['data']['fields'] as $k => $v)
 				{
 					if (!isset($v['format'])) $this->shop->view['profil']['data']['fields'][$k]['format'] = 0;
@@ -442,5 +437,5 @@
 				{
 					
-					$this->shop->addBackendError(__('UngÃŒltiges Trennzeichen angegeben!', 'wpsg'));
+					$this->shop->addBackendError(__('Ungültiges Trennzeichen angegeben!', 'wpsg'));
 					die('<script type="text/javascript">parent.wpsg_mod_export_profilSwitch();</script>');
 						
@@ -525,5 +520,5 @@
 						'allgemein_empty' => __('Leer', 'wpsg'),
 						//'allgemein_statisch' => __('Statisch', 'wpsg'),
-						'allgemein_currency' => __('WÃ€hrung', 'wpsg')
+						'allgemein_currency' => __('Währung', 'wpsg')
 					)
 				),
@@ -544,9 +539,9 @@
 						'order_name' => __('Lieferadresse Name', 'wpsg'),
 						'order_firma' => __('Lieferadresse Firma', 'wpsg'),
-						'order_strasse' => __('Lieferadresse StraÃe', 'wpsg'),
+						'order_strasse' => __('Lieferadresse Straße', 'wpsg'),
 						'order_plz' => __('Lieferadresse PLZ', 'wpsg'),
 						'order_ort' => __('Lieferadresse Ort', 'wpsg'),
 						'order_land' => __('Lieferadresse Land (Name)', 'wpsg'),
-						'order_land_krzl' => __('Lieferadresse Land (KÃŒrzel)', 'wpsg'),
+						'order_land_krzl' => __('Lieferadresse Land (Kürzel)', 'wpsg'),
 						//'order_hausnr' => __('Lieferadresse Hausnummer', 'wpsg'),
 						'order_payment_method' => __('Name der Zahlart', 'wpsg'),
@@ -560,5 +555,5 @@
 						'order_iban' => __('IBAN Nummer (Bankeinzug)', 'wpsg'),						
 						'order_status' => __('Status der Bestellung', 'wpsg'),
-						'order_menge' => __('Anzahl an Artikeln', 'wpsg'),
+						'order_menge' => __('Anzahl an Artikeln', 'wpsg'),	
 						'order_weight' => __('Gesamtgewicht', 'wpsg')
 					)
@@ -575,8 +570,8 @@
 						'product_preis_order' => __('Produktpreis aus Bestellung', 'wpsg'),
 						'product_preis_order_netto' => __('Produktpreis aus Bestellung (Netto)', 'wpsg'),
-						'produkt_mwst' => __('Mehrwertsteuer (SchlÃŒssel)', 'wpsg'),
+						'produkt_mwst' => __('Mehrwertsteuer (Schlüssel)', 'wpsg'),
 						'produkt_mwst_value' => __('Mehrwertsteuer (Wert)', 'wpsg'),
-						'produkt_feinheit' => __('FÃŒllmengeneinheit', 'wpsg'),
-						'produkt_fmenge' => __('FÃŒllmenge', 'wpsg'),
+						'produkt_feinheit' => __('Füllmengeneinheit', 'wpsg'),
+						'produkt_fmenge' => __('Füllmenge', 'wpsg'),
 						'produkt_beschreibung' => __('Beschreibung', 'wpsg'),
 						'produkt_weight' => __('Gewicht', 'wpsg'),						 
@@ -596,10 +591,10 @@
 						'kunde_vorname' => __('Vorname', 'wpsg'),
 						'kunde_name' => __('Name', 'wpsg'),
-						'kunde_strasse' => __('StraÃe', 'wpsg'),
+						'kunde_strasse' => __('Straße', 'wpsg'),
 						//'kunde_hausnr' => __('Hausnummer', 'wpsg'),
 						'kunde_ort' => __('Ort', 'wpsg'),
 						'kunde_plz' => __('PLZ', 'wpsg'),
 						'kunde_land' => __('Land (Name)', 'wpsg'),
-						'kunde_land_krzl' => __('Land (KÃŒrzel)', 'wpsg'),
+						'kunde_land_krzl' => __('Land (Kürzel)', 'wpsg'),
 						'kunde_tel' => __('Telefon', 'wpsg'),
 						'kunde_fax' => __('Faxnummer', 'wpsg'),
@@ -755,10 +750,13 @@
 			$field_value = $f['value'];
 			
-			if (array_key_exists($o_id.'_'.$p_id, $this->arCache))
-			{
-				
-				$order = $this->arCache[$o_id.'_'.$p_id]['order'];
-				$produkt = $this->arCache[$o_id.'_'.$p_id]['produkt'];
-				$kunde = $this->arCache[$o_id.'_'.$p_id]['kunde'];				
+			$cache_key = $o_id.'_'.$p_id.'_'.$product_index.'_'.$productkey.'_'.$order_product_id;
+			
+			// Hier werden die Ergebnisse gespeichert
+			if (array_key_exists($cache_key, $this->arCache))
+			{
+				
+				$order = $this->arCache[$cache_key]['order'];
+				$produkt = $this->arCache[$cache_key]['produkt'];
+				$kunde = $this->arCache[$cache_key]['kunde'];				
 				
 			}
@@ -778,12 +776,12 @@
 				");
 				
-				// Anzahl an tatsÃ€chlich bestellten Artikeln
+				// Anzahl an tatsächlich bestellten Artikeln
 				$order['menge'] = $this->db->fetchOne("SELECT SUM(OP.`menge`) FROM `".WPSG_TBL_ORDERPRODUCT."` AS OP WHERE OP.`o_id` = '".wpsg_q($order['id'])."'");
 				
-				// Anzahl an Produkten in der Bestellung (MengenunabhÃ€ngig)
+				// Anzahl an Produkten in der Bestellung (Mengenunabhängig)
 				$order['count'] = $this->db->fetchOne("SELECT COUNT(*) FROM `".WPSG_TBL_ORDERPRODUCT."` WHERE `o_id` = '".wpsg_q($order['id'])."'");
-
-				$order['payment_method'] = wpsg_getStr($this->shop->arPayment[$order['type_payment']]['name'], wpsg_translate(__('Deaktivierte Zahlungsart (#1#)', 'wpsg'), $order['type_payment']));
-				$order['shipping_method'] = wpsg_getStr($this->shop->arShipping[$order['type_shipping']]['name'], wpsg_translate(__('Deaktivierte Versandart (#1#)', 'wpsg'), $order['type_shipping']));
+				
+				$order['payment_method'] = $this->shop->arPayment[$order['type_payment']]['name'];
+				$order['shipping_method'] = $this->shop->arShipping[$order['type_shipping']]['name'];
 				
 				$order['custom_data'] = unserialize($order['custom_data']);
@@ -894,5 +892,5 @@
 					if (wpsg_isSizedInt($order_product_id))
 					{
-						
+						 
 						$produkt = $this->db->fetchRow("
 							SELECT
@@ -908,5 +906,5 @@
 								OP.`id` = '".wpsg_q($order_product_id)."'
 						");
-						
+					 
 					}
 					else
@@ -946,5 +944,5 @@
 				}
 
-				$this->arCache[$o_id.'_'.$p_id] = array(
+				$this->arCache[$cache_key] = array(
 					"order" => $order,
 					"produkt" => $produkt,
@@ -953,5 +951,5 @@
 				
 			}
-			 
+			
 			if (wpsg_isSizedInt($order['land']))
 			{
@@ -966,5 +964,5 @@
 				
 			}
-			
+			  
 			switch ($field_value)
 			{
@@ -1025,11 +1023,11 @@
 				case 'order_firma': $return = $order['shipping_firma']; break;
 				case 'order_status': $return = $this->shop->arStatus[$order['status']]; break;
-				case 'order_bname': $return = wpsg_getStr($order['mod_autodebit_name']); break;
-				case 'order_bblz': $return = wpsg_getStr($order['mod_autodebit_blz']); break;
-				case 'order_binhaber': $return = wpsg_getStr($order['mod_autodebit_inhaber']); break;
+				case 'order_bname': $return = $order['mod_autodebit_name']; break;
+				case 'order_bblz': $return = $order['mod_autodebit_blz']; break;
+				case 'order_binhaber': $return = $order['mod_autodebit_inhaber']; break;
 				case 'order_menge': $return = $order['menge']; break;
-				case 'order_bnr': $return = wpsg_getStr($order['mod_autodebit_knr']); break;
-				case 'order_iban': $return = wpsg_getStr($order['mod_autodebit_iban']); break;
-				case 'order_bic': $return = wpsg_getStr($order['mod_autodebit_bic']); break;
+				case 'order_bnr': $return = $order['mod_autodebit_knr']; break;
+				case 'order_iban': $return = $order['mod_autodebit_iban']; break;
+				case 'order_bic': $return = $order['mod_autodebit_bic']; break;
 				case 'order_weight': $return = $order['weight']; break;
 				case 'order_gutschein': 
@@ -1089,5 +1087,4 @@
 					break;
 				
-
 				case 'produkt_mwst': $return = $produkt['mwst_key']; break;
 				case 'produkt_mwst_value': $return = wpsg_ff($oFrontendCountry->getTax($produkt['mwst_key'])); break;
@@ -1155,5 +1152,5 @@
 						{
 							
-							// AbwÃ€rtskompatibilitÃ€t < 3.5.1 
+							// Abwärtskompatibilität < 3.5.1 
 							if ($produkt['mod_vp_varkey'] != '')
 							{
@@ -1217,5 +1214,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 700: $return = strftime($this->shop->replaceUniversalPlatzhalter(wpsg_getStr($f['userformat']), $order['id'], $kunde['id'], false, $p_id), 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;
 					case 900: $return = '"=""'.$return.'"""'; break;
