Index: /mods/mod_anschreiben/wpsg_anschreiben.class.php
===================================================================
--- /mods/mod_anschreiben/wpsg_anschreiben.class.php	(revision 7256)
+++ /mods/mod_anschreiben/wpsg_anschreiben.class.php	(revision 7256)
@@ -0,0 +1,172 @@
+<?php
+
+/**
+ * Klasse fÃŒr einen Anschreiben
+ * @author Daschmi
+ *
+ */
+class wpsg_anschreiben extends wpsg_model
+{
+    
+    /**
+     * LÃ€dt die Daten des Anschreiben
+     * @see wpsg_model::load()
+     */
+    public function load($anschreiben_id)
+    {
+        
+        parent::load($anschreiben_id);
+        
+        $this->data = $this->db->fetchRow("SELECT DN.* FROM `".WPSG_TBL_anschreiben."` AS DN WHERE DN.`id` = '".wpsg_q($anschreiben_id)."' ");
+        
+        if ($this->data['id'] != $anschreiben_id) throw new \wpsg\Exception(__('Konnte Anschreiben nicht laden, ungÃŒltige ID ÃŒbergeben', 'wpsg'));
+        
+        return true;
+        
+    } // public function load($anschreiben_id)
+    
+    /**
+     * Gibt true zurÃŒck wenn der Anschreiben fÃŒr ungÃŒltig erklÃ€rt wurde
+     * @return boolean
+     */
+    public function isCanceled()
+    {
+        
+        if ($this->cancel == '1') return true;
+        else return false;
+        
+    } // public function isCanceled()
+    
+    /**
+     * Gibt das Datum der Lieferung als Timestamp zurÃŒck
+     */
+    public function getDeliveryTimestamp()
+    {
+        
+        return strtotime($this->delivery_date);
+        
+    } // public function getDeliveryTimestamp()
+    
+    /**
+     * Gibt die Produkte dieses Anschreiben zurÃŒck
+     */
+    public function getProducts()
+    {
+        
+        return $this->db->fetchAssoc("
+				SELECT
+					P.`id`, OP.`productkey`, P.`name`
+				FROM
+					`".WPSG_TBL_ORDERPRODUCT."` AS OP
+						LEFT JOIN `".WPSG_TBL_PRODUCTS."` AS P ON (OP.`p_id` = P.`id`)
+				WHERE
+					OP.`o_id` = '".wpsg_q($this->order_id)."' AND
+					OP.`product_index` IN (".wpsg_q($this->product_indexes).")
+			", "productkey");
+        
+    } // public function getProducts()
+    
+    /**
+     * PrÃŒft ob ein Anschreiben fÃŒr das Produkt erstellt werden kann
+     */
+    public static function checkProductKey($product_indexes, $order_id)
+    {
+        
+        $nExists = $GLOBALS['wpsg_db']->fetchOne("
+				SELECT
+					COUNT(*)
+				FROM
+					`".WPSG_TBL_anschreiben."`
+				WHERE
+					`order_id` = '".wpsg_q($order_id)."' AND
+					FIND_IN_SET('".wpsg_q($product_indexes)."', `product_indexes`) AND
+					`cancel` != '1'
+			");
+        
+        if ($nExists > 0) return false;
+        else return true;
+        
+    } // public static function checkProductKey($product_indexes, $order_id)
+    
+    /**
+     * zeigt das Formular zum Drucken in der Bestellverwaltung
+     */
+    public function order_view($order_id, &$arSidebarArray)
+    {
+        
+        $path = $this->shop->getRessourcePath();
+        
+        $this->shop->view['arTemplates'] = array();
+        
+        $arrFiles = scandir($path);
+        
+        foreach ($arrFiles as $file)
+        {
+            
+            if (is_file($path.$file) && preg_match('/(.*)\.phtml/', $file) && !preg_match('/(.*)_html\.phtml/', $file))
+            {
+                
+                $template_name = str_replace('.phtml', '', $file);
+                
+                $this->shop->view['arTemplates'][$file]['filename'] = $file;
+                $this->shop->view['arTemplates'][$file]['name'] = ucfirst($template_name);
+                
+            }
+            
+        }
+        
+        $arSidebarArray[$this->id] = array(
+            'title' => $this->name,
+            'content' => $this->shop->render(WPSG_PATH_VIEW.'mods/mod_anschreiben/order_view.phtml', false)
+        );
+        
+    } // public function order_view_content($order_id)
+    
+    /**
+     * Gibt einen Array von Anschreibenen zurÃŒck, die auf den ÃŒbergebenen Filter passen
+     * @param array $arFilter
+     */
+    public static function find($arFilter = array())
+    {
+        
+        $strQueryWHERE = "";
+        $strQueryORDER = " DN.`cdate` ";
+        $strQueryORDER_DIRECTION = " DESC ";
+        
+        if (wpsg_isSizedInt($arFilter['order_id'])) $strQueryWHERE .= " AND DN.`order_id` = '".wpsg_q($arFilter['order_id'])."' ";
+        if (isset($arFilter['cancel'])) $strQueryWHERE .= " AND DN.`cancel` = '".wpsg_q($arFilter['cancel'])."' ";
+        if (isset($arFilter['order'])) $strQueryORDER = wpsg_q($arFilter['order']);
+        if (isset($arFilter['order_direction'])) $strQueryORDER_DIRECTION = wpsg_q($arFilter['order_direction']);
+        if (wpsg_isSizedInt($arFilter['product_index'])) $strQueryWHERE .= " AND FIND_IN_SET('".wpsg_q($arFilter['product_index'])."', DN.`product_indexes`) ";
+        
+        $strQuery = "
+				SELECT
+					DN.`id`
+				FROM
+					`".WPSG_TBL_anschreiben."` AS DN
+				WHERE
+					1
+					".$strQueryWHERE."
+				GROUP BY
+					DN.`id`
+				ORDER BY
+					".$strQueryORDER." ".$strQueryORDER_DIRECTION."
+			";
+        
+        $arDNID = $GLOBALS['wpsg_db']->fetchAssocField($strQuery);
+        $arReturn = array();
+        
+        foreach ($arDNID as $dn_id)
+        {
+            
+            $arReturn[] = wpsg_anschreiben::getInstance($dn_id);
+            
+        }
+        
+        return $arReturn;
+        
+    } // public static function find($arFilter = array())
+    
+} // class wpsg_anschreiben extends wpsg_model
+
+?>
Index: /mods/wpsg_mod_anschreiben.class.php
===================================================================
--- /mods/wpsg_mod_anschreiben.class.php	(revision 7256)
+++ /mods/wpsg_mod_anschreiben.class.php	(revision 7256)
@@ -0,0 +1,618 @@
+<?php
+
+	/**
+	 * Modul zur Generierung von Anschreibenen
+	 * @author Daschmi
+	 */
+	class wpsg_mod_anschreiben extends wpsg_mod_basic
+	{
+		
+		var $lizenz = 0;
+		var $id = 2200;
+		var $hilfeURL = 'http://wpshopgermany.maennchen1.de/?p=3667';
+
+		
+		public function __construct()
+		{
+			
+			parent::__construct();
+				
+			$this->name = __('Anschreiben', 'wpsg');
+			$this->group = __('Bestellung', 'wpsg');
+			$this->desc = __('ErmÃ¶glicht die Erstellung von Anschreibenen.', 'wpsg');
+						
+		} // public function __construct()
+		
+		public function init()
+		{
+			
+			require_once(dirname(__FILE__).'/mod_anschreiben/wpsg_anschreiben.class.php');
+			
+			$this->fields = array(
+				'firma' => __('Firmenname', 'wpsg'),
+				'name' => __('Name', 'wpsg'),
+				'strasse' => __('StraÃe', 'wpsg'),
+				'plzort' => __('PLZ/Ort', 'wpsg'),
+				'land' => __('Land', 'wpsg'),
+				'tel' => __('Tel', 'wpsg'),
+				'fax' => __('Fax', 'wpsg'),
+				'mail' => __('E-Mail', 'wpsg'),
+				'web' => __('Web', 'wpsg'),
+				'strnr' => __('Steuer-Nr', 'wpsg'),
+				'ustidnr' => __('UStIdNr.', 'wpsg'),
+				'knr' => __('Kontonummer', 'wpsg'),
+				'blz' => __('BLZ', 'wpsg'),
+				'bank' => __('Bank', 'wpsg'),
+				'user1' => __('Benutzer 1', 'wpsg'),
+				'user2' => __('Benutzer 2', 'wpsg'),
+				'user3' => __('Benutzer 3', 'wpsg'),
+				'user4' => __('Benutzer 4', 'wpsg'),
+				'user5' => __('Benutzer 5', 'wpsg')
+			);
+			
+		} // public function init()
+		 
+		public function install()
+		{
+			
+			require_once(WPSG_PATH_WP.'/wp-admin/includes/upgrade.php');
+				
+			/**
+			 * Tabelle fÃŒr die Lieferanten
+			*/
+			$sql = "CREATE TABLE ".WPSG_TBL_anschreiben." (
+				id int(25) NOT NULL AUTO_INCREMENT,
+				order_id int(25) NOT NULL ,
+				cdate DATETIME NOT NULL ,
+				lnr VARCHAR(255) NOT NULL ,
+				delivery_date DATETIME NOT NULL ,
+				note TEXT NOT NULL,
+				cancel int(1) NOT NULL,		
+				product_indexes TEXT NOT NULL,
+				PRIMARY KEY  (id) 
+			) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
+							
+			// FrÃŒher gab es "product_keys" welches aber nicht eindeutig war, da es aktuell mehrmals den gleichen SchlÃŒssel im Warenkorb geben kann
+			
+			dbDelta($sql); 
+
+						
+			if ($this->shop->get_option('wpsg_mod_anschreiben_texte') === false) $this->resetAction();				
+			
+		} // public function install()
+
+		public function settings_edit()
+		{
+
+			$this->shop->view['wpsg_mod_anschreiben']['fields'] = $this->fields;
+			$this->shop->view['wpsg_mod_anschreiben']['arTexte'] = $this->shop->get_option('wpsg_mod_anschreiben_texte');
+			if (!is_array($this->shop->view['wpsg_mod_anschreiben']['arTexte'])) $this->shop->view['wpsg_mod_anschreiben']['arTexte'] = array();
+
+			if (file_exists($this->getFilePath('').'wpsg_anschreiben_bp.jpg'))
+			{
+				$this->shop->view['wpsg_mod_anschreiben']['bp'] = $this->getFilePath('', true).'wpsg_anschreiben_bp.jpg';
+			}
+			else if (file_exists($this->getFilePath('').'wpsg_anschreiben_bp.pdf'))
+			{
+				$this->shop->view['wpsg_mod_anschreiben']['bp'] = $this->getFilePath('', true).'wpsg_anschreiben_bp.pdf';
+			}
+			else
+			{
+				$this->shop->view['wpsg_mod_anschreiben']['bp'] = false;
+			}
+
+			if (file_exists($this->getFilePath('').'wpsg_anschreiben_logo.jpg'))
+			{
+				$this->shop->view['wpsg_mod_anschreiben']['logo'] = $this->getFilePath('', true).'wpsg_anschreiben_logo.jpg';
+			}
+			else
+			{
+				$this->shop->view['wpsg_mod_anschreiben']['logo'] = false;
+			}
+
+			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_anschreiben/settings_edit.phtml');
+
+		} // public function settings_edit()
+		
+		/**
+		 * zeigt das Formular zum Drucken in der Bestellverwaltung
+		 */
+		public function order_view($order_id, &$arSidebarArray)
+		{
+			
+			$arSidebarArray[$this->id] = array(
+				'title' => $this->name,
+				'content' => $this->shop->render(WPSG_PATH_VIEW.'mods/mod_anschreiben/order_view.phtml', false)
+			);
+			
+		} // public function order_view_content($order_id)
+
+		public function settings_save()
+		{
+
+			$this->shop->update_option("wpsg_mod_anschreiben_texte", $_REQUEST['text']);
+			$this->shop->update_option('wpsg_mod_anschreiben_adressrow', $_REQUEST['wpsg_mod_anschreiben_adressrow']);
+
+
+
+			if (file_exists($_FILES['wpsg_mod_anschreiben_bp']['tmp_name']))
+			{
+
+				$ending = strtolower(preg_replace("/(.*)\./", "", $_FILES['wpsg_mod_anschreiben_bp']['name']));
+
+				if ($ending != "jpg" && $ending != "jpeg" && $ending != "pdf")
+				{
+					$this->shop->addBackendError(__("UngÃŒltiger Dateityp (Briefpapier) ! Es sind nur JPG und PDF Dateien erlaubt!", "wpsg"));
+				}
+				else if ($ending == "jpg" || $ending == "jpeg")
+				{
+					move_uploaded_file($_FILES['wpsg_mod_anschreiben_bp']['tmp_name'], $this->getFilePath('').'wpsg_anschreiben_bp.jpg');
+				}
+				else if ($ending == "pdf")
+				{
+					move_uploaded_file($_FILES['wpsg_mod_anschreiben_bp']['tmp_name'], $this->getFilePath('').'wpsg_anschreiben_bp.pdf');
+				}
+
+			}
+			else if ((array_key_exists('wpsg_mod_anschreiben_bp_del', $_REQUEST)) && ($_REQUEST['wpsg_mod_anschreiben_bp_del'] == "1"))
+			{
+
+				@unlink($this->getFilePath('').'wpsg_anschreiben_bp.jpg');
+				@unlink($this->getFilePath('').'wpsg_anschreiben_bp.pdf');
+
+				$this->shop->addBackendMessage(__('Briefpapier wurde erfolgreich gelÃ¶scht.', 'wpsg'));
+
+			}
+
+
+			if (array_key_exists('wpsg_mod_anschreiben_logo_position_left', $_REQUEST) && strpos($_REQUEST['wpsg_mod_anschreiben_logo_position_left'], 'selected') !== false)
+				$wpsg_mod_anschreiben_logo_position = "left";
+
+			if (array_key_exists('wpsg_mod_anschreiben_logo_position_center', $_REQUEST) && strpos($_REQUEST['wpsg_mod_anschreiben_logo_position_center'], 'selected') !== false)
+				$wpsg_mod_anschreiben_logo_position = "center";
+
+			if (array_key_exists('wpsg_mod_anschreiben_logo_position_right', $_REQUEST) && strpos($_REQUEST['wpsg_mod_anschreiben_logo_position_right'], 'selected') !== false)
+				$wpsg_mod_anschreiben_logo_position = "right";
+
+
+			if (file_exists($_FILES['wpsg_mod_anschreiben_logo']['tmp_name']))
+			{
+
+				$ending = strtolower(preg_replace("/(.*)\./", "", $_FILES['wpsg_mod_anschreiben_logo']['name']));
+
+				if ($ending != "jpg" && $ending != "jpeg")
+				{
+					$this->shop->addBackendError(__("UngÃŒltiger Dateityp (Logo) ! Es sind nur JPG und PDF Dateien erlaubt!", "wpsg"));
+				}
+				else if ($ending == "jpg" || $ending == "jpeg")
+				{
+					move_uploaded_file($_FILES['wpsg_mod_anschreiben_logo']['tmp_name'], $this->getFilePath('').'wpsg_anschreiben_logo.jpg');
+				}
+
+			}
+			else if ((array_key_exists('wpsg_mod_anschreiben_logo_del', $_REQUEST)) && ($_REQUEST['wpsg_mod_anschreiben_logo_del'] == "1"))
+			{
+
+				@unlink($this->getFilePath('').'wpsg_anschreiben_logo.jpg');
+
+				$this->shop->addBackendMessage(__('Logo wurde erfolgreich gelÃ¶scht.', 'wpsg'));
+
+			}
+
+			$this->shop->update_option("wpsg_mod_anschreiben_logo_position", $wpsg_mod_anschreiben_logo_position ? $wpsg_mod_anschreiben_logo_position : null);
+			$this->shop->update_option("wpsg_mod_anschreiben_logo_transparency", $_REQUEST['wpsg_mod_anschreiben_logo_transparency']);
+
+		} // public function settings_save()
+
+		public function admin_presentation() 
+		{
+			
+			echo wpsg_drawForm_Checkbox('wpsg_mod_anschreiben_pdf_beschreibung', __('Produktbeschreibung auf Anschreiben anzeigen', 'wpsg'), $this->shop->get_option('wpsg_mod_anschreiben_pdf_beschreibung'));
+			if ($this->shop->hasMod('wpsg_mod_productvariants')) echo wpsg_drawForm_Checkbox('wpsg_mod_anschreiben_pdf_varianten', __('Varianten auf Anschreiben anzeigen', 'wpsg'), $this->shop->get_option('wpsg_mod_anschreiben_pdf_varianten'));
+			
+		} // public function admin_presentation()
+		
+		public function admin_presentation_submit() 
+		{ 
+			
+			$this->shop->update_option('wpsg_mod_anschreiben_pdf_beschreibung', $_REQUEST['wpsg_mod_anschreiben_pdf_beschreibung']);
+			
+		} // public function admin_presentation_submit()
+		
+		public function order_ajax()
+		{
+
+			if (isset($_REQUEST['wpsg_anschreiben_preview']))
+			{
+
+				// Vorschau eines Anschreibenes aus der Bestellverwaltung
+				$this->writeanschreiben(
+					$_REQUEST['edit_id'],
+					explode(',', $_REQUEST['wpsg_mod_anschreiben_productindexes']),
+					strtotime($_REQUEST['wpsg_mod_anschreiben_date']),
+					true
+				);
+			
+				die();
+			
+			}
+			else if (wpsg_getStr($_REQUEST['do']) == 'get')
+			{
+				
+				$dn = new wpsg_anschreiben();
+				$dn->load($_REQUEST['dn_id']);
+				
+				if ($dn->order_id != $_REQUEST['edit_id']) throw new \wpsg\Exception(__('Es wurde versucht ein Anschreiben von einer anderen Bestellung anzuzeigen', 'wpsg'));
+				
+				$filename = 'anschreiben_'.$dn->id.'.pdf';
+				$file = $this->getFilePath($_REQUEST['edit_id']).$filename;
+				
+				wpsg_header::PDFPlugin($file);
+				
+			}
+			else if (isset($_REQUEST['wpsg_mod_anschreiben_write']))
+			{
+				
+				if ($_REQUEST['edit_id'] <= 0) throw new \wpsg\Exception(__('Beim Erstellen des Anschreibendokumentes wurde keine BestellID ÃŒbergeben', 'wpsg'));
+				
+				$lnr = $this->buildLnr($_REQUEST['edit_id']);
+				
+				$arProductIndexes = explode(',', $_REQUEST['wpsg_mod_anschreiben_productindexes']);
+				
+				foreach ($arProductIndexes as $product_key)
+				{
+			 
+					if (!wpsg_anschreiben::checkProductKey($product_key, $_REQUEST['edit_id'])) throw new \wpsg\Exception(__('Ein Anschreiben wurde fÃŒr ein Produkt bereits erstellt', 'wpsg'));
+					
+				} 
+				
+				// In Datenbank eintragen
+				$dn_id = $this->db->ImportQuery(WPSG_TBL_anschreiben, array(
+					'order_id' => wpsg_q($_REQUEST['edit_id']),
+					'cdate' => "NOW()",
+					'delivery_date' => date('Y-m-d', strtotime($_REQUEST['wpsg_mod_anschreiben_date'])),
+					'lnr' => wpsg_q($lnr),
+					'cancel' => '0',
+					'product_indexes' => wpsg_q($_REQUEST['wpsg_mod_anschreiben_productindexes'])
+				));
+				
+				$filename = 'anschreiben_'.$dn_id.'.pdf';
+								
+				// Anschreiben erstellen
+				$bOK = $this->writeanschreiben(
+					$_REQUEST['edit_id'], 
+					explode(',', $_REQUEST['wpsg_mod_anschreiben_productindexes']), 
+					strtotime($_REQUEST['wpsg_mod_anschreiben_date']),
+					false,
+					$lnr,
+					$filename
+				);
+				
+				if ($bOK === true)
+				{
+				
+					$file = $this->getFilePath($_REQUEST['edit_id']).'/'.$filename;
+					 
+					if (!file_exists($file) || !is_file($file))
+					{
+						
+						$this->db->Query("DELETE FROM `".WPSG_TBL_anschreiben."` WHERE `id` = '".wpsg_q($dn_id)."'");
+						throw new \wpsg\Exception(__('Das Anschreibendokument wurde nicht wie vorgesehen angelegt', 'wpsg'));
+						
+					}
+					 										
+					wpsg_header::PDFPlugin($file);					
+										
+				}
+				else
+				{
+					
+					$this->db->Query("DELETE FROM `".WPSG_TBL_anschreiben."` WHERE `id` = '".wpsg_q($dn_id)."'");
+					throw new \wpsg\Exception(__('Beim Erstellen des Anschreibendokumentes ist ein Fehler aufgetreten', 'wpsg'));
+					
+				}
+				
+			}
+			
+		} // public function order_ajax()
+		
+
+		public function delOrder(&$order_id)
+		{
+				
+			// Anschreibene in der Datenbank lÃ¶schen
+			$this->db->Query("DELETE FROM `".WPSG_TBL_anschreiben."` WHERE `order_id` = '".wpsg_q($order_id)."'");
+				
+			// Anschreibene im Dateisystem lÃ¶schen
+			$path = $this->getFilePath($order_id); wpsg_rrmdir($path);
+				
+		} // public function delOrder(&$order_id)
+		
+			
+		public function be_ajax()
+		{
+				
+			if ($_REQUEST['do'] == 'reset')
+			{
+			
+				$this->resetAction();
+				$this->shop->addBackendMessage(__('Grundeinstellungen wieder hergestellt', 'wpsg'));
+			
+				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&modul='.$_REQUEST['modul']); 
+			
+			}
+			else if ($_REQUEST['do'] == 'orderAjax')
+			{
+
+				$this->order_ajax();
+
+			}
+			
+			
+		} // public function be_ajax()
+		
+		
+
+		/**
+		 * Generiert das Anschreiben fÃŒr eine Bestellung
+		 */
+		public function writeanschreiben($order_id, $arProductIndexes, $preview = false, $lnr = false, $filename = false)
+		{
+
+			if($preview && is_null($order_id)) $order_id = 1;
+
+			$this->shop->view['order'] = $this->shop->cache->loadOrder($order_id);
+			$this->shop->view['customer'] = $this->shop->cache->loadKunden($this->shop->view['order']['k_id']);
+			$this->shop->view['data'] = array();
+
+			// Wurde die Bestellung in einer anderen Sprache gemacht
+			if (trim($this->shop->view['order']['language']) != '') $this->shop->setTempLocale($this->shop->view['order']['language']);
+			
+			$oOrder = wpsg_order::getInstance($order_id);
+			
+			// Rechnungsadresse		
+			$this->shop->view['data']['id'] = $this->shop->view['customer']['id'];
+			$this->shop->view['data']['firma'] = $this->shop->view['customer']['firma'];
+			$this->shop->view['data']['vname'] = $this->shop->view['customer']['vname'];
+			$this->shop->view['data']['name'] = $this->shop->view['customer']['name'];
+			$this->shop->view['data']['strasse'] = $this->shop->view['customer']['strasse'];
+			$this->shop->view['data']['hausnr'] = $this->shop->view['customer']['nr'];
+			$this->shop->view['data']['plz'] = $this->shop->view['customer']['plz'];
+			$this->shop->view['data']['ort'] = $this->shop->view['customer']['ort'];
+			$this->shop->view['data']['land'] = $this->shop->view['customer']['land'];
+			$this->shop->view['data']['land'] = strtoupper($oOrder->getInvoiceCountryName());
+
+			// Lieferadresse?
+			if ($this->shop->hasMod('wpsg_mod_shippingadress'))
+			{
+				
+				if ($this->shop->callMod('wpsg_mod_shippingadress', 'check_different_shippingadress', array($this->shop->view['order']['k_id'], $order_id)))
+				{
+					
+					$adata = $this->db->fetchRow("SELECT A.* FROM `".WPSG_TBL_ADRESS."` AS A WHERE A.`id` = '".wpsg_q($this->shop->view['order']['shipping_adress_id'])."'");
+						
+					
+					$this->shop->view['data']['firma'] = $adata['firma'];
+					$this->shop->view['data']['vname'] = $adata['vname'];
+					$this->shop->view['data']['name'] = $adata['name'];
+					$this->shop->view['data']['strasse'] = $adata['strasse'];
+					$this->shop->view['data']['hausnr'] = $adata['nr'];
+					$this->shop->view['data']['plz'] = $adata['plz'];
+					$this->shop->view['data']['ort'] = $adata['ort'];
+					$this->shop->view['data']['land'] = $adata['land'];
+					$this->shop->view['data']['land'] = strtoupper($oOrder->getShippingCountryName());
+					
+				}
+								
+			}
+			 
+			if (wpsg_isSizedInt($this->shop->view['data']['land']))
+			{
+				
+				$this->shop->view['data']['land'] = $this->db->fetchRow("SELECT L.* FROM `".WPSG_TBL_LAND."` AS L WHERE L.`id` = '".wpsg_q($this->shop->view['data']['land'])."'");
+				
+			}
+			
+			$this->shop->view['preview'] = $preview;
+						
+			if ($liefer_datum === false) $this->shop->view['lDatum'] = time();
+			else $this->shop->view['lDatum'] = $liefer_datum;
+			
+			$this->shop->view['data']['products'] = array();
+			
+			foreach ($arProductIndexes as $product_index)
+			{
+				
+				$product_data = $this->db->fetchRow("
+					SELECT
+						OP.*,
+						P.`name`
+					FROM
+						`".WPSG_TBL_ORDERPRODUCT."` AS OP
+							LEFT JOIN `".WPSG_TBL_PRODUCTS."` AS P ON (OP.`p_id` = P.`id`)
+					WHERE
+						OP.`product_index` = '".wpsg_q($product_index)."' AND
+						OP.`o_id` = '".wpsg_q($order_id)."'
+				");
+				 
+				if ($this->shop->isOtherLang())
+				{
+				
+					$produkt_trans = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `lang_parent` = '".wpsg_q($product_data['p_id'])."' AND `lang_code` = '".wpsg_q($this->shop->getCurrentLanguageCode())."'");
+				 
+					if ($produkt_trans['id'] > 0)
+					{
+							
+						$product_data['name'] = $produkt_trans['name']; 
+				
+					}
+				
+				}
+				
+				$this->shop->view['data']['products'][$product_index] = $product_data;
+				
+			}
+			
+			if ($preview === true)
+			{
+				
+				$this->shop->view['filename'] = __('AnschreibenVorschau.pdf', 'wpsg');
+				$this->shop->view['title'] = __('Anschreiben Vorschau', 'wpsg');
+				$this->shop->view['lnr'] = $this->buildLnr($order_id);
+								
+			}
+			else
+			{
+				
+				$this->shop->view['filename'] = $filename;
+				$this->shop->view['title'] = __('Anschreiben', 'wpsg');
+				$this->shop->view['lnr'] = $lnr;
+				
+			}
+
+			$this->shop->view['oOrder'] = $this->shop->cache->loadOrderObject($order_id);
+			
+			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_anschreiben/anschreiben_pdf.phtml');
+
+			$this->shop->restoreTempLocale();
+			
+			return true;
+			
+		} // public function writeanschreiben($order_id, $preview = false)
+		
+		
+		/**
+		 * LÃ€dt die Anschreibene einer Bestellung
+		 * @param int $order_id ID der Bestellung
+		 */
+		public function loadanschreibensFromOrder($order_id)
+		{
+			
+			$anschreiben_ids = $this->db->fetchAssocField("SELECT DN.`id` FROM `".WPSG_TBL_anschreiben."` AS DN WHERE `order_id` = '".wpsg_q($order_id)."' ");
+			
+			$arReturn = array();
+			
+			foreach ($anschreiben_ids as $anschreiben_id)
+			{
+				
+				$anschreiben = new wpsg_anschreiben();
+				$anschreiben->load($anschreiben_id);
+				
+				$arReturn[$anschreiben_id] = $anschreiben;
+				
+			}
+			
+			return $arReturn;
+			
+		} // public function loadanschreibensFromOrder($order_id)
+
+		
+		/**
+		 * Gibt die Texte fÃŒr das PDF in der korrekten Sprache und mit ÃŒbersetzen Platzhaltern zurÃŒck
+		 */
+		public function getTexte($order_id)
+		{
+				
+			$arTexte = $this->shop->get_option("wpsg_mod_anschreiben_texte");
+				
+			foreach ($arTexte as $k => $v)
+			{
+		
+				$arTexte[$k]['text'] = $this->shop->replaceUniversalPlatzhalter(__($arTexte[$k]['text'], 'wpsg'), $order_id);
+		
+			}
+				
+			return $arTexte;
+				
+		} // public function getTexte($order_id)
+		
+		/**
+		 * LÃ€dt die vordefinierten Textfelder
+		 */
+		public function resetAction()
+		{
+			
+			$arData = array(
+				"firma" => array("aktiv" => "1", "x" => "24", "y" => "10", "fontsize" => 8, "text" => "%shopinfo_name%", "color" => "#000000"),
+				"name" => array("aktiv" => "1", "x" => "24", "y" => "13", "fontsize" => 8, "text" => "Inh. %shopinfo_owner%", "color" => "#000000"),
+				"strasse" => array("aktiv" => "1", "x" => "24", "y" => "16", "fontsize" => 8, "text" => "%shopinfo_street%", "color" => "#000000"),
+				"plzort" => array("aktiv" => "1", "x" => "24", "y" => "19", "fontsize" => 8, "text" => "%shopinfo_zip% %shopinfo_city%", "color" => "#000000"),
+				"land" => array("aktiv" => "1", "x" => "24", "y" => "22", "fontsize" => 8, "text" => "DEUTSCHLAND", "color" => "#000000"),
+				"tel" => array("aktiv" => "1", "x" => "75", "y" => "10", "fontsize" => 8, "text" => "Tel. %shopinfo_tel%", "color" => "#000000"),
+				"fax" => array("aktiv" => "1", "x" => "75", "y" => "13", "fontsize" => 8, "text" => "Fax. %shopinfo_fax%", "color" => "#000000"),
+				"mail" => array("aktiv" => "1", "x" => "75", "y" => "16", "fontsize" => 8, "text" => "Mail: %shopinfo_email%", "color" => "#000000"),
+				"web" => array("aktiv" => "1", "x" => "75", "y" => "19", "fontsize" => 8, "text" => "Web: ".site_url(), "color" => "#000000"),
+				"strnr" => array("aktiv" => "1", "x" => "24", "y" => "270", "fontsize" => 8, "text" => "Steuer-Nr.: %shopinfo_taxnr%", "color" => "#000000"),
+				"ustidnr" => array("aktiv" => "1", "x" => "24", "y" => "273", "fontsize" => 8, "text" => "USt-IdNr.: %shopinfo_ustidnr%", "color" => "#000000"),
+				"knr" => array("aktiv" => "1", "x" => "24", "y" => "276", "fontsize" => 8, "text" => "IBAN: %shopinfo_iban%", "color" => "#000000"),
+				"blz" => array("aktiv" => "1", "x" => "24", "y" => "279", "fontsize" => 8, "text" => "BIC: %shopinfo_bic%", "color" => "#000000"),
+				"bank" => array("aktiv" => "1", "x" => "24", "y" => "282", "fontsize" => 8, "text" => "Bank: %shopinfo_bankname%", "color" => "#000000"),
+			);
+			 
+			$this->shop->update_option("wpsg_mod_anschreiben_adressrow", "Absender: %shopinfo_name% %shopinfo_street% %shopinfo_zip% %shopinfo_city%");
+			$this->shop->update_option("wpsg_mod_anschreiben_texte", $arData);
+			
+		} // public function resetAction()
+		
+		/**
+		 * Gibt den Absoluten Pfad zurÃŒck wo die Anschreibene gespeichert sind
+		 */
+		public function getFilePath($order_id, $url = false) {
+		
+			if ($order_id == '') {
+			    
+			    // Briefpapier/Logo
+				if ($this->shop->isMultiBlog()) {
+					
+					$path = WPSG_PATH_CONTENT.'/'.WPSG_MB_UPLOADS.'/wpsg/wpsg_anschreiben/'.$order_id.'/';
+					$url_content = WPSG_URL_CONTENT.WPSG_MB_UPLOADS.'/wpsg/wpsg_anschreiben/';
+					
+					if ($url) $strReturn = $url_content.$order_id.'/';
+					else $strReturn = $path;
+					
+				} else {
+					
+					$path = WPSG_PATH_CONTENT.'uploads/wpsg/wpsg_anschreiben/'.$order_id.'/';
+					
+					if ($url) $strReturn = WPSG_URL_CONTENT.'uploads/wpsg/wpsg_anschreiben/'.$order_id.'/';
+					else $strReturn = $path.'/';
+					
+				}
+				
+			} else {
+			    
+			    // Anschreiben aus Bestellung
+				$anschreiben = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_anschreiben."` AS DN WHERE `order_id` = '".wpsg_q($order_id)."' ");
+				$datum = $anschreiben['cdate'];
+				$ym = date('Y/m/', strtotime($datum));
+				
+				if ($this->shop->isMultiBlog()) {
+					
+					$path = WPSG_PATH_CONTENT.'/'.WPSG_MB_UPLOADS.'/wpsg/wpsg_anschreiben/'.$ym.$order_id.'/';
+					$url_content = WPSG_URL_CONTENT.WPSG_MB_UPLOADS.'/wpsg/wpsg_anschreiben/'.$ym;
+					
+					if ($url) $strReturn = $url_content.$order_id.'/';
+					else $strReturn = $path;
+					
+				} else {
+					
+					$path = WPSG_PATH_CONTENT.'uploads/wpsg/wpsg_anschreiben/'.$ym.$order_id.'/';
+					
+					if ($url) $strReturn = WPSG_URL_CONTENT.'uploads/wpsg/wpsg_anschreiben/'.$ym.$order_id.'/';
+					else $strReturn = $path.'/';
+					
+				}
+				
+			} // if ($order_id == '')
+			
+			$this->shop->protectDirectory($path, [
+                'wpsg_anschreiben_logo.jpg', 'wpsg_anschreiben_bp.jpg', 'wpsg_anschreiben_bp.pdf'
+            ] );	
+            				
+			return $strReturn;
+		
+		} // private function getFilePath($produkt_id, $url = false)
+		 
+	} // class wpsg_mod_anschreiben extends wpsg_mod_basic
+
+?>
Index: /mods/wpsg_mod_basic.class.php
===================================================================
--- /mods/wpsg_mod_basic.class.php	(revision 7255)
+++ /mods/wpsg_mod_basic.class.php	(revision 7256)
@@ -78,4 +78,6 @@
 			2050    => 'wpsg_mod_funding', // Crowdfunding 
 			2100	=> 'wpsg_mod_productpackage', // Produktpaket
+			2150    => 'wpsg_mod_sms', // SMS-Versand
+			2200    => 'wpsg_mod_anschreiben', // Anschreiben
 			3000 	=> 'wpsg_mod_spconditions',
 			3050	=> 'wpsg_mod_giropay', /* Giropay*/
Index: /views/css/admin.css
===================================================================
--- /views/css/admin.css	(revision 7255)
+++ /views/css/admin.css	(revision 7256)
@@ -117,4 +117,9 @@
 .wpsg_kundenkontakt_textarea { width:100%; float:right; height:150px; }
 
+/* SMS-Versand */
+.wpsg_sms_template,
+.wpsg_sms_newnumber { width:70%; float:right; margin-bottom:20px; }
+.wpsg_sms_textarea { width:100%; float:right; height:150px; }
+
 /* LÃ€nderverwaltung */
 .wpsg_table_country { margin-bottom:0px; }
Index: /views/mods/mod_anschreiben/anschreiben_pdf.phtml
===================================================================
--- /views/mods/mod_anschreiben/anschreiben_pdf.phtml	(revision 7256)
+++ /views/mods/mod_anschreiben/anschreiben_pdf.phtml	(revision 7256)
@@ -0,0 +1,199 @@
+<?php
+
+	/**
+	 * FPDF Template fÃŒr die Generierung des Lieferscheins
+	 */
+
+	require_once WPSG_PATH_LIB.'fpdf/fpdf.php';
+	require_once WPSG_PATH_LIB.'fpdf/fpdi.php';
+	require_once WPSG_PATH_LIB.'wpsg_fpdf.class.php';
+	
+	global $absender_left, $absender_top, $adress_left, $adress_top, $dndata_left, $dndata_top;
+			
+	if (!function_exists('AddanschreibenPage'))
+	{
+	
+		function AddanschreibenPage($shop, $pdf)
+		{
+	
+			global $absender_left, $absender_top, $adress_left, $adress_top, $dndata_left, $dndata_top;
+							
+			$rdata_left = 0;
+			$pdf->AddPage();
+			
+			if (file_exists($shop->callMod('wpsg_mod_anschreiben', 'getFilePath', array(''))."wpsg_anschreiben_bp.pdf"))
+			{
+				
+				$pagecount = $pdf->setSourceFile($shop->callMod('wpsg_mod_anschreiben', 'getFilePath', array(''))."wpsg_anschreiben_bp.pdf");
+				$tplidx = $pdf->importPage(1, '/MediaBox');
+				$pdf->useTemplate($tplidx, 0, 0, 210);
+			
+			}
+			else if (file_exists($shop->callMod('wpsg_mod_anschreiben', 'getFilePath', array(''))."wpsg_anschreiben_bp.jpg"))
+			{
+				
+				$pdf->image($shop->callMod('wpsg_mod_anschreiben', 'getFilePath', array(''))."wpsg_anschreiben_bp.jpg", 0, 0, 210, 297, 'jpg');
+				
+			}
+
+
+			if (file_exists($shop->callMod('wpsg_mod_anschreiben', 'getFilePath', array(''))."wpsg_anschreiben_logo.jpg"))
+			{
+
+				list($width, $height, $type, $attr) = getimagesize($shop->callMod('wpsg_mod_anschreiben', 'getFilePath', array(''))."wpsg_anschreiben_logo.jpg");
+
+				// Umrechnung von Inch zu Pixel
+				$wPix = (25.4 * $width) / 96;
+				$hPix = (25.4 * $height) / 96;
+
+				$leftPos = 110 - $wPix;
+				$midPos = $wPix * 2.6 - $width / 2;
+				$rightPos = 210 - $wPix;
+
+				$abscissa = $rightPos;
+				$ordinate = 0;
+
+				$transparency = str_replace("%", "", $shop->get_option('wpsg_mod_anschreiben_logo_transparency'));
+				if($transparency !== "100") $transparency = str_replace(array("0", "00"), "", $transparency);
+
+				$alpha = 1;
+				if(!is_null($transparency) && $transparency !== "100") $alpha = "0.$transparency";
+				if(!is_null($transparency) && $transparency === "100") $alpha = $transparency;
+
+				$logo_pos = $shop->get_option('wpsg_mod_anschreiben_logo_position');
+
+				if(isset($logo_pos) && $logo_pos === "left") { $abscissa = $leftPos; $ordinate = 20; }
+				if(isset($logo_pos) && $logo_pos === "center") { $abscissa = $midPos; $ordinate = 20; }
+				if(isset($logo_pos) && $logo_pos === "right") { $abscissa = $rightPos; }
+
+				$pdf->SetAlpha($alpha);
+				$pdf->image($shop->callMod('wpsg_mod_anschreiben', 'getFilePath', array(''))."wpsg_anschreiben_logo.jpg", $abscissa, $ordinate, $wPix, $hPix);
+				$pdf->SetAlpha(1);
+
+			}
+				
+			// Absenderadresszeile (Wird in der Konfiguration hinterlegt)
+			$pdf->SetFont('Arial', '', 6);
+			$pdf->Text($absender_left, $absender_top, $shop->replaceUniversalPlatzhalter($shop->get_option("wpsg_mod_anschreiben_adressrow"), $shop->view['order']['id']));
+			
+			if (wpsg_getStr($shop->view['kunde']['kuerzel']) != "") $shop->view['kunde']['kuerzel'] = $shop->view['kunde']['kuerzel'].'-';
+				
+			// Adresse des Kunden
+			$pdf->SetFont('Arial', '', 12);
+			$pdf->Text($adress_left, $adress_top, $shop->view['data']['firma']);
+			$pdf->Text($adress_left, $adress_top + 5, $shop->view['data']['vname'].' '.$shop->view['data']['name']);
+			$pdf->Text($adress_left, $adress_top + 10, $shop->view['data']['strasse'].' '.$shop->view['data']['hausnr']);
+			$pdf->Text($adress_left, $adress_top + 15, $shop->view['data']['plz'].' '.$shop->view['data']['ort']);
+			//if ($shop->get_option('wpsg_mod_anschreiben_hideCountry') != '1') $pdf->Text($adress_left, $adress_top + 20, strtoupper($shop->view['oOrder']->getShippingCountryName()));
+			if ($shop->get_option('wpsg_mod_anschreiben_hideCountry') != '1') $pdf->Text($adress_left, $adress_top + 20, $shop->view['data']['land']);
+			
+			// Daten
+			$pdf->SetFont('Arial', 'B', 16);
+			$pdf->Text($dndata_left, $dndata_top, $shop->view['title']);
+			$pdf->SetFont('Arial', 'B', 9);
+			$pdf->Text($dndata_left, $dndata_top + 6, $shop->view['lnr']);
+			$pdf->SetFont('Arial', '', 9);
+			
+			$pdf->Text($rdata_left + 100, $dndata_top, __("Kunden-Nr", "wpsg"));
+			$pdf->Text($rdata_left + 100, $dndata_top + 6, (($shop->view['customer']['knr'] != '')?$shop->view['customer']['knr']:$shop->view['customer']['id']));
+				
+			$pdf->Text($rdata_left + 125, $dndata_top, __("Best. Nr.", "wpsg"));
+			$pdf->Text($rdata_left + 125, $dndata_top + 6, ((trim($shop->view['order']['onr']) != '')?$shop->view['order']['onr']:$shop->view['order']['id']));
+			
+			$pdf->Text($rdata_left + 145, $dndata_top, __("Bestelldatum", "wpsg"));
+			$pdf->Text($rdata_left + 145, $dndata_top + 6, wpsg_formatTimestamp(strtotime($shop->view['order']['cdate']), true));
+				
+			$pdf->Text($rdata_left + 170, $dndata_top, __("Lieferdatum", "wpsg"));
+			$pdf->Text($rdata_left + 170, $dndata_top + 6, wpsg_formatTimestamp($shop->view['lDatum'], true));
+			
+			if ($shop->view['oOrder']->isInnerEu())
+			{
+
+            	$pdf->SetFont('Arial', '', 9);
+                $pdf->Text($adress_left, $rdata_top + 11.5, __("Innergemeinschaftliche Lieferung.", "wpsg"));
+
+            } else if (!$shop->view['oOrder']->isInnerEu() && $shop->view['oOrder']->getShippingCountryID() != $shop->getDefaultCountry(true)) {
+
+			// Nicht InnerEU und Nicht Inland
+
+             	$pdf->SetFont('Arial', '', 9);
+                $pdf->Text($adress_left, $rdata_top + 11.5, __("Steuerfreie Ausfuhrlieferung.", "wpsg"));
+
+			}
+			
+			
+			// Benutzerdefinierte Felder
+			$arTexte = $shop->callMod('wpsg_mod_anschreiben', 'getTexte', array($shop->view['data']['id'])); 
+			
+			foreach ((array)$arTexte as $text)
+			{
+			
+				if (isset($text['aktiv']) && $text['aktiv'] == 1)
+				{
+						
+					$pdf->SetFont('Arial', 'B', ((intval($text['fontsize']) > 0)?intval($text['fontsize']):10));
+					$pdf->wpsg_SetTextColor($text['color']);
+					$pdf->wpsg_MultiCell($text['x'], $text['y'], 5, $text['text']);
+					$pdf->wpsg_SetTextColor("#000000");
+						
+				}
+			
+			}
+			
+		}
+		
+	}
+	
+	// Positionierung der Absenderadresszeile
+	$absender_left				= 25;
+	$absender_top				= 50;
+	
+	// Positionierung der Zieladress
+	$adress_left 				= 25;
+	$adress_top					= 55;
+	
+	// Positionierund des Lieferscheinkopfes
+	$dndata_left				= 25;
+	$dndata_top					= 90;
+	
+	// Positionierung der Produktdaten
+	$prod_left					= 25;
+	$prod_top					= 105;
+	
+	// Anzahl an Produkten pro Seite
+	$prod_break					= 10;
+	
+	$pdf = new wpsg_fpdf();
+	$pdf->SetAutoPageBreak(true, 5);
+	AddanschreibenPage($this, $pdf);
+
+	$filename = $this->view['filename'].".pdf";
+	
+	
+	$offset += 5;
+	
+	if ($this->view['fussText'] != "")
+	{
+	
+		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, $this->view['fussText']);
+		$pdf->SetFont('Arial', 'B', 9);
+		$offset += 10;
+	
+	}
+
+    ob_end_clean();
+	
+	if ($this->view['preview'])
+	{
+		$pdf->Output($this->view['filename'], 'I');
+	}
+	else
+	{
+	
+		$pdf->Output($this->callMod('wpsg_mod_anschreiben', 'getFilePath', array($this->view['order']['id'])).$this->view['filename'], 'F');
+	
+		if ($this->view['output'] === true) $pdf->Output($filename, 'I');
+			
+	}
+	
+?>
Index: /views/mods/mod_anschreiben/order_view.phtml
===================================================================
--- /views/mods/mod_anschreiben/order_view.phtml	(revision 7256)
+++ /views/mods/mod_anschreiben/order_view.phtml	(revision 7256)
@@ -0,0 +1,113 @@
+<script type="text/javascript">
+				
+	/**
+	 *
+	 */
+	function anschreiben_sendMail()
+	{
+		
+		if (jQuery('#anschreiben_text').val() == '')
+		{
+
+			alert("<?php echo __('Bitte einen Text angeben!', 'wpsg'); ?>");
+			return;
+			
+		}
+
+		var text = "";
+
+		text = tinyMCE.get('anschreiben_html').getContent();
+		
+		jQuery.ajax( {
+			url: "<?php echo WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_anschreiben&edit_id='.$this->view['data']['id'].'&noheader=1&do=anschreiben_sendMail' ?>",
+			method: 'post',
+			success: function(data) {
+				
+				if (data != '1')
+				{
+
+					alert("<?php echo __("Anschreiben konnte nicht gespeichert/gedruckt werden es, weil ein Fehler aufgetreten ist!", "wpsg"); ?>");
+
+				}
+				else
+				{
+
+					tinyMCE.get('_html').setContent('');
+					alert("<?php echo __('Mail wurde erfolgreich an den Kunden gesendet.', 'wpsg'); ?>");
+
+					location.reload();
+					
+				}
+				
+			}
+			
+		} );	
+		
+	}
+	
+	
+</script>
+<?php //wpsg_debug($this->view) ?>
+<?php echo wpsg_drawForm_AdminboxStart(__('Anschreiben', 'wpsg'));?>
+
+	<?php if (sizeof($this->view['mod_anschreiben']['aranschreiben']) == 0 ) { ?>
+	   
+	   <p><?php echo __('Bisher kein Anschreiben geschrieben.', 'wpsg'); ?></p>
+	   
+	   <?php } else { ?>
+	   	<table>
+	        <?php foreach ($this->view['mod_anschreiben']['aranschreiben_gesamt'] as $a) { ?>
+	            <tr>
+	                <td>#<?php echo ($a['anr'] != ''); ?>
+						
+						<?php if ($a['anr'] != "") { ?>
+	                    	<?php echo wpsg_translate(__('Anschreiben gespeichert am #1#', 'wpsg'), date("d.m.Y", $a['ts_datum'])); ?>
+	                    <?php } ?>
+	
+	                </td>
+	                <td style="text-align:right;">
+	
+	                    <?php if ($a['anr'] != "") {
+
+	                    	$rfile = $this->callMod('wpsg_mod_anschreiben', 'getFilePath', array($this->view['data']['id'], true)).'A'.$r['anr'].'.pdf';
+	                        
+	                    } ?>
+
+	            	</td>
+	        	</tr>
+	    	<?php } ?>
+	 	</table>
+	 <?php } ?>
+	
+	<br>
+	
+	<div class="wpsg_clear"></div>
+	
+	<hr>
+	
+	<div class="inside">						
+		<div style="padding:5px;">
+			
+			<form method="post" action="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_anschreiben&edit_id=<?php echo $this->view['data']['id']; ?>&noheader=1">	
+
+				<?php /* Auswahl Adresse (Zweitstelle/Hauptstelle */ ?>
+
+				<?php /* Anredeauswahl */ ?>
+
+				<?php echo __('Text fÃŒr das Anschreiben', 'wpsg'); ?>:<br /><br />			
+				<?php wp_editor('', 'anschreiben_html'); ?>
+							
+				<div class="wpsg_clear"></div>
+						
+				<br />
+				
+				<input type="button" class="button" onclick="anschreiben_sendMail(); return false;" value="<?php echo __("Speichern & Drucken", "wpsg"); ?>" style="float:right;" />
+				
+				<div class="wpsg_clear"></div>
+				
+			</form>
+			
+		</div>
+	</div>
+
+<?php echo wpsg_drawForm_AdminboxEnd(); ?>
Index: /views/mods/mod_anschreiben/settings_edit.phtml
===================================================================
--- /views/mods/mod_anschreiben/settings_edit.phtml	(revision 7256)
+++ /views/mods/mod_anschreiben/settings_edit.phtml	(revision 7256)
@@ -0,0 +1,212 @@
+<?php
+
+/**
+ * Template fÃŒr die Einstellungen des "Anschreiben" Moduls
+ */
+
+?>
+
+<div>
+	<ul class="nav nav-tabs" role="tablist">
+		<li role="presentation" class="active"><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab"><?php echo __('Vordefinierte Textfelder', 'wpsg'); ?></a></li>
+	</ul>
+	<div class="tab-content">
+		<div role="tabpanel" class="tab-pane active" id="tab1">
+		
+			<?php echo wpsg_drawForm_TextStart(); ?>
+			<div style="position:relative;">
+				<?php if ($this->view['wpsg_mod_anschreiben']['bp'] === false) { ?>
+					<p><?php echo __('Es wurde bisher kein Briefpapier hochgeladen', 'wpsg'); ?></p>
+				<?php } else { ?>
+					<a href="<?php echo $this->view['wpsg_mod_anschreiben']['bp']; ?>" target="_blank"><?php echo __('Derzeitiges Briefpapier', 'wpsg'); ?></a>
+				<?php } ?>
+				<a class="wpsg_glyphicon_right glyphicon glyphicon-question-sign form-control-feedback" href="?page=wpsg-Admin&subaction=loadHelp&noheader=1&field=mod_anschreiben_bp" data-wpsg-tip="mod_anschreiben_bp" rel="?page=wpsg-Admin&subaction=loadHelp&noheader=1&field=mod_anschreiben_bp"></a>
+				<input type="file" name="wpsg_mod_anschreiben_bp">
+				<?php $strSuffix = ''; if ($this->view['wpsg_mod_anschreiben']['bp'] !== false) { $strSuffix = '
+                    <label>
+						<input type="checkbox" name="wpsg_mod_anschreiben_bp_del" value="1" />&nbsp;'.__('LÃ¶schen', 'wpsg').'
+					</label>';
+					echo __($strSuffix);
+				} ?>
+			</div>
+			<?php echo wpsg_drawForm_TextEnd(__('Briefpapier (PDF/JPG)', 'wpsg'), array('noP' => true, 'helps' => 'wpsg_mod_anschreiben_bp')); ?>
+
+			<hr>
+			
+			<?php echo wpsg_drawForm_TextStart(); ?>
+			<div style="position:relative;">
+				<?php if ($this->view['wpsg_mod_anschreiben']['logo'] === false) { ?>
+					<p><?php echo __('Es wurde bisher kein Logo hochgeladen', 'wpsg'); ?></p>
+				<?php } else { ?>
+					<a href="<?php echo stripslashes($this->view['wpsg_mod_anschreiben']['logo']); ?>" target="_blank"><?php echo __('Derzeitiges Logo', 'wpsg'); ?></a>
+				<?php } ?>
+				<a class="wpsg_glyphicon_right glyphicon glyphicon-question-sign form-control-feedback" href="?page=wpsg-Admin&subaction=loadHelp&noheader=1&field=mod_anschreiben_logo" data-wpsg-tip="mod_anschreiben_logo" rel="?page=wpsg-Admin&subaction=loadHelp&noheader=1&field=mod_anschreiben_logo"></a>
+				<input type="file" name="wpsg_mod_anschreiben_logo">
+				<?php $logo_pos = $this->get_option("wpsg_mod_anschreiben_logo_position"); ?>
+				<?php $defaultAlign = !isset($logo_pos) || empty($logo_pos) ? "align-buttons-active" : ""; ?>
+
+				<?php $alignLeft = $logo_pos === 'left' ? "align-buttons-active" : ""; ?>
+				<?php $alignCenter = $logo_pos === 'center' ? "align-buttons-active" : ""; ?>
+				<?php $alignRight = $logo_pos === 'right' ? "align-buttons-active" : ""; ?>
+
+				<?php $logo_transparency = $this->get_option("wpsg_mod_anschreiben_logo_transparency") ?: "0%"; ?>
+
+				<?php $strSuffix = ''; if ($this->view['logo'] !== false) { $strSuffix = '
+					<div class="row">
+						<div class="col-md-4">
+							<div class="align-buttons">
+								<input type="input" data-toggle="tooltip" class="logo-align-button logo-align-button-left '.$alignLeft.'" name="wpsg_mod_anschreiben_logo_position_left" value="&#xf036" onclick="handleLogoAlignClick($(this))" onkeydown="return false;" onfocus="return false;" autocomplete="off" title="'.__("Logo linksbÃŒndig ausrichten").'">
+								<input type="input" data-toggle="tooltip" class="logo-align-button logo-align-button-center '.$alignCenter.'" name="wpsg_mod_anschreiben_logo_position_center" value="&#xf037" onclick="handleLogoAlignClick($(this))" onkeydown="return false;" onfocus="return false;" autocomplete="off" title="'.__("Logo zentrieren").'">
+								<input type="input" data-toggle="tooltip" class="logo-align-button logo-align-button-right '.$alignRight.' '.$defaultAlign.'" name="wpsg_mod_anschreiben_logo_position_right" value="&#xf038" onclick="handleLogoAlignClick($(this))" onkeydown="return false;" onfocus="return false;" autocomplete="off" title="'.__("Logo rechtsbÃŒndig ausrichten").'">
+							</div>
+						</div>
+						<div class="col-md-8 logo-transparency">
+							<label>
+								<input type="text" name="wpsg_mod_anschreiben_logo_transparency" value="'.$logo_transparency.'" />&nbsp;'.__('Logodeckkraft', 'wpsg').'
+							</label>		
+						</div>
+						<div class="col-md-12">
+							<label>
+								<input type="checkbox" name="wpsg_mod_anschreiben_logo_del" value="1" />&nbsp;'.__('LÃ¶schen', 'wpsg').'
+							</label>	
+						</div>
+					</div>';
+					echo __($strSuffix);
+				} ?>
+						
+					
+				<button class="button wpsg_anschreiben_preview" style="float:right; margin-right:10px;" name="wpsg_anschreiben_preview" type="button">
+					<?php echo __("Vorschau", "wpsg"); ?>
+				</button>
+
+			</div>
+			<?php echo wpsg_drawForm_TextEnd(__('Logo (JPG)', 'wpsg'), array('noP' => true, 'helps' => 'wpsg_mod_anschreiben_logo')); ?>
+
+			<hr> <br />
+
+			<table class="table table-body-striped wpsg_mod_anschreiben_fieldtable">
+				<thead>
+				<tr>
+					<th class="col_bezeichnung"><?php echo __('Bezeichnung', 'wpsg'); ?></th>
+					<th class="col_freitext"><?php echo __('Freitext', 'wpsg'); ?></th>
+					<th class="col_x"><?php echo __('X', 'wpsg'); ?></th>
+					<th class="col_y"><?php echo __('Y', 'wpsg'); ?></th>
+					<th class="col_color"><?php echo __('Farbe', 'wpsg'); ?></th>
+					<th class="col_groesse"><?php echo __('GrÃ¶Ãe', 'wpsg'); ?></th>
+					<th class="col_action"></th>
+				</tr>
+				</thead>
+				<tbody>
+				<?php foreach ($this->view['wpsg_mod_anschreiben']['fields'] as $f => $field_name) { ?>
+					<tr>
+						<td><?php echo wpsg_hspc($field_name); ?></td>
+						<td>
+							<input type="text" style="width:100%;" name="text[<?php echo $f; ?>][text]" value="<?php echo wpsg_getStr($this->view['wpsg_mod_anschreiben']['arTexte'][$f]['text']); ?>" />
+						</td>
+						<td>
+							<input type="text" style="width:100%;" name="text[<?php echo $f; ?>][x]" value="<?php echo wpsg_getStr($this->view['wpsg_mod_anschreiben']['arTexte'][$f]['x']); ?>" />
+						</td>
+						<td>
+							<input type="text" style="width:100%;" name="text[<?php echo $f; ?>][y]" value="<?php echo wpsg_getStr($this->view['wpsg_mod_anschreiben']['arTexte'][$f]['y']); ?>" />
+						</td>
+						<td>
+							<input type="text" style="width:100%;" name="text[<?php echo $f; ?>][color]" value="<?php echo wpsg_getStr($this->view['wpsg_mod_anschreiben']['arTexte'][$f]['color']); ?>" />
+						</td>
+						<td>
+							<select name="text[<?php echo $f; ?>][fontsize]" style="width:100%;">
+								<option <?php echo ((wpsg_getStr($this->view['wpsg_mod_anschreiben']['arTexte'][$f]['fontsize']) == "8")?'selected="selected"':''); ?> value="8">8</option>
+								<option <?php echo ((wpsg_getStr($this->view['wpsg_mod_anschreiben']['arTexte'][$f]['fontsize']) == "9")?'selected="selected"':''); ?> value="9">9</option>
+								<option <?php echo ((wpsg_getStr($this->view['wpsg_mod_anschreiben']['arTexte'][$f]['fontsize']) == "10")?'selected="selected"':''); ?> value="10">10</option>
+								<option <?php echo ((wpsg_getStr($this->view['wpsg_mod_anschreiben']['arTexte'][$f]['fontsize']) == "11")?'selected="selected"':''); ?> value="11">11</option>
+								<option <?php echo ((wpsg_getStr($this->view['wpsg_mod_anschreiben']['arTexte'][$f]['fontsize']) == "12")?'selected="selected"':''); ?> value="12">12</option>
+								<option <?php echo ((wpsg_getStr($this->view['wpsg_mod_anschreiben']['arTexte'][$f]['fontsize']) == "13")?'selected="selected"':''); ?> value="13">13</option>
+								<option <?php echo ((wpsg_getStr($this->view['wpsg_mod_anschreiben']['arTexte'][$f]['fontsize']) == "14")?'selected="selected"':''); ?> value="14">14</option>
+							</select>
+						</td>
+						<td>
+							<input type="checkbox" title="<?php echo __('Diese Checkbox aktivieren, damit die Textzeile verwendet wird.', 'wpsg'); ?>" value="1" name="text[<?php echo $f; ?>][aktiv]" <?php echo ((wpsg_isSizedInt($this->view['wpsg_mod_anschreiben']['arTexte'][$f]['aktiv']))?'checked="checked"':''); ?> />
+						</td>
+					</tr>
+				<?php } ?>
+				</tbody>
+			</table>
+
+			<input class="button" onclick="if (!confirm('<?php echo __('Sind Sie sich sicher? Ihre bisherigen Einstellungen gehen verloren!', 'wpsg'); ?>')) return false; else location.href = '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&amp;action=module&amp;modul=<?php echo $_REQUEST['modul']; ?>&amp;do=reset&amp;noheader=1';" type="button" value="<?php echo __('Standardeinstellungen laden', 'wpsg'); ?>" />
+
+			<br /><br />
+
+			<div class="info">
+				<p>
+					<?php echo __('Die Angaben fÃŒr X (Abstand von Links) und Y (Abstand von Oben) werden in mm eingetragen.', 'wpsg'); ?><br />
+					<?php echo __('Die Farbe wird im Hexadezimalformat angegeben (#FFFFFF fÃŒr weiÃ, #000000 fÃŒr schwarz).', 'wpsg'); ?>
+				</p>
+			</div>
+
+			<br />
+
+		</div>
+	</div>
+</div>
+
+<script type="text/javascript">/* <![CDATA[ */
+
+	/**
+	 * Stellt sicher, dass immer nur ein Button der align-buttons die highlight Klasse hat
+	 */
+	function handleLogoAlignClick(pressedEl)
+	{
+
+		if(pressedEl.hasClass("align-buttons-active")) return;
+		else
+		{
+
+			pressedEl.addClass("align-buttons-active");
+			pressedEl[0].value = pressedEl[0].value + " selected";
+
+			jQuery.each($(".logo-align-button"), function(index, element) {
+				if(element.classList.contains("align-buttons-active") && element !== pressedEl[0]){
+
+					var values = element.value.split(" ");
+					element.value = values[0];
+
+					element.classList.remove("align-buttons-active");
+
+					return false;
+
+				}
+			});
+
+		}
+
+	} // function handleLogoAlignClick()
+
+	/**
+	 * Wird beim Klicken auf den Vorschau Button ausgelÃ¶st
+	 */
+	function wpsg_anschreiben_preview()
+	{
+
+		var url = "<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_anschreiben&do=orderAjax&noheader=1&wpsg_anschreiben_preview=1";
+
+		window.open(url, '_blank');
+
+		return false;
+
+	} // function wpsg_anschreiben_preview()
+
+
+
+	jQuery(document).ready(function() {
+
+		jQuery('#wpsg_tab').wpsg_tab( {
+			'cookiename': 'wpsg_mod_anschreiben_tab',
+			'tab2': function() {
+				jQuery('.tablink').show();
+			}
+		} );
+
+		jQuery(".wpsg_anschreiben_preview").click(function(){ wpsg_anschreiben_preview(); });
+
+	} );
+
+	/* ]]> */</script>
