Index: /lib/filter_functions.inc.php
===================================================================
--- /lib/filter_functions.inc.php	(revision 7806)
+++ /lib/filter_functions.inc.php	(revision 7807)
@@ -436,5 +436,6 @@
         $api_return_json = json_decode($api_return, true);
 
-        //wpsg_debug_console($api_return_json);
+        //
+        //g4/wp-admindie($api_return);
 
         if (wpsg_isSizedArray($api_return_json)) {
Index: /lib/functions.inc.php
===================================================================
--- /lib/functions.inc.php	(revision 7806)
+++ /lib/functions.inc.php	(revision 7807)
@@ -1533,14 +1533,13 @@
 	 * ZusÃ€tzlich wird der String noch durch Htmlspecialchars gejagt
 	 */
-	function wpsg_translate($string)
-	{
+	function wpsg_translate($string) {
 		
 		$arg = array(); 
 			
-	  	for($i = 1 ; $i < func_num_args(); $i++)
-	  	{
+	  	for($i = 1 ; $i < func_num_args(); $i++) {
 	  		
 	  		$arg = func_get_arg($i);
-	  		$string = preg_replace("/#".$i."#/", $arg, $string);  	
+	  		$string = preg_replace("/#".$i."#/", $arg, $string);
+	  		
 	  	}
 	   
Index: /lib/helper_functions.inc.php
===================================================================
--- /lib/helper_functions.inc.php	(revision 7806)
+++ /lib/helper_functions.inc.php	(revision 7807)
@@ -461,7 +461,6 @@
 	} // function wpsg_drawForm_TextEnd($field_label)
 	
-	function wpsg_drawForm_Text($field_label, $field_value, $field_id = false, $conf = array())
-	{
-		
+	function wpsg_drawForm_Text($field_label, $field_value, $field_id = false, $conf = array()) {
+	 
 		$TC = new wpsg_SystemController();
 		
Index: /mods/mod_abo/wpsg_abo.php
===================================================================
--- /mods/mod_abo/wpsg_abo.php	(revision 7807)
+++ /mods/mod_abo/wpsg_abo.php	(revision 7807)
@@ -0,0 +1,287 @@
+<?php
+
+    /**
+     * User: Daschmi (daschmi@daschmi.de)
+     * Date: 16.11.2020
+     * Time: 08:32
+     */
+
+    class wpsg_abo extends wpsg_model {
+
+        static $_tableName = 'WPSG_TBL_ABO';
+        public static $arState = [];
+        
+        const STATE_RUNNING = 1;
+        const STATE_INEXTENSION = 2;
+        const STATE_EXTEND = 3;
+
+        /**
+         * LÃ€dt die Daten der Bestellung
+         */
+        public function load($abo_id) {
+
+            parent::load($abo_id);
+
+            $this->data = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_ABO."` WHERE `id` = '".intval($abo_id)."' ");
+            
+        }
+
+        public function getExpirationTime() {
+            
+            return strtotime($this->__get('expiration'));
+            
+        }
+
+        /**
+         * Gibt den Wert des Status zurÃŒck
+         * @return int
+         */
+        public function getState() {
+
+            $expiration_time = $this->getExpirationTime();
+            $time = wpsg_time();
+
+            if ($expiration_time < $time) {
+
+                return self::STATE_EXTEND;
+
+            } else {
+
+                $wpsg_mod_abo_autoexpire_informationtime = intval($this->shop->get_option('wpsg_mod_abo_autoexpire_informationtime'));
+
+                if ($wpsg_mod_abo_autoexpire_informationtime > 0) {
+
+                    $t_inform = strtotime('-'.$wpsg_mod_abo_autoexpire_informationtime.' day', $expiration_time);
+
+                    if ($time > $t_inform) {
+
+                        return self::STATE_INEXTENSION;
+
+                    } else {
+
+                        return self::STATE_RUNNING;
+
+                    }
+
+                } else return self::STATE_RUNNING;
+
+            }
+                        
+        }
+        
+        /**
+         * Gibt den aktuellen Status anhand der Laufzeit zurÃŒck
+         */
+        public function getStateLabel() {
+
+            return self::$arState[$this->getState()];
+            
+        }
+        
+        /**
+         * Gibt die Hauptbestellung zurÃŒck, mit der das Abo gestartet wurde
+         * @return wpsg_order
+         */
+        public function getOrder() {
+            
+            return wpsg_order::getInstance(intval($this->data['order_id']));
+            
+        }
+        
+        public function getNr() {
+            
+            return $this->getOrder()->getNr();
+            
+        }
+        
+        public static function getFromOrderAndProductKey($order_id, $product_key) {
+ 
+            $abo_id = intval(
+                wpsg_ShopController::getShop()->db->fetchOne("SELECT `id` FROM `".WPSG_TBL_ABO."` WHERE `order_id` = '".wpsg_q($order_id)."' AND `product_key` = '".wpsg_q($product_key)."' ")
+            );
+
+            if ($abo_id <= 0) throw new \wpsg\Exception(__('Kein Abo zu dieser Bestellung und Produkt gefunden.'));
+
+            return wpsg_abo::getInstance($abo_id);
+            
+        }
+
+        public static function getFromOrderAndProduct($order_id, $order_product_id) {
+            
+            $oOrderProduct = wpsg_order_product::getInstance($order_product_id);
+            
+            return self::getFromOrderAndProductKey($order_id, $oOrderProduct->getProductKey());
+                        
+        }
+        
+        public static function find($arFilter = array(), $load = true) {
+
+            list($strQuerySELECT, $strQueryWHERE, $strQueryJOIN, $strQueryHAVING, $strQueryORDER) = self::getQueryParts($arFilter);
+
+            $strLimit = "";
+
+            if (wpsg_isSizedArray($arFilter['limit'])) $strLimit = "LIMIT ".wpsg_q($arFilter['limit'][0]).", ".wpsg_q($arFilter['limit'][1]);
+
+            $strQuery = "
+				SELECT
+					A.`id`
+					".$strQuerySELECT."
+				FROM
+					`".WPSG_TBL_ABO."` AS A
+					".$strQueryJOIN."
+				WHERE
+					1
+					".$strQueryWHERE."
+				GROUP BY 
+					A.`id`
+				HAVING
+					1
+					".$strQueryHAVING."
+				ORDER BY
+					".$strQueryORDER."
+				".$strLimit."
+			";
+
+            $arAboID = wpsg_ShopController::getShop()->db->fetchAssocField($strQuery, "id", "id");
+
+            if ($load !== true) return $arAboID;
+
+            $arReturn = array();
+
+            foreach ($arAboID as $abo_id) {
+
+                $oAbo = wpsg_abo::getInstance($abo_id);
+                $arReturn[] = $oAbo;
+
+            }
+
+            return $arReturn;
+
+        }
+
+        public static function count($arFilter) {
+
+            list($strQuerySELECT, $strQueryWHERE, $strQueryJOIN, $strQueryHAVING, $strQueryORDER) = self::getQueryParts($arFilter);
+
+            $strQuery = "
+				SELECT
+					COUNT(*)
+				FROM
+					(
+						SELECT
+						  	DISTINCT A.`id`
+						FROM
+							`".WPSG_TBL_ABO."` AS A
+							".$strQueryJOIN."
+						WHERE
+							1
+							".$strQueryWHERE." 
+						HAVING
+							1
+							".$strQueryHAVING."											
+					) AS innerSelect
+			";
+            
+            return wpsg_ShopController::getShop()->db->fetchOne($strQuery);
+
+        } // public static function count($arFilter)
+        
+        public static function getQueryParts($arFilter = array()) {
+
+            $strQuerySELECT = "";
+            $strQueryWHERE = "";
+            $strQueryJOIN = ""; $strQueryJOINSuffix = "";
+            $strQueryHAVING = "";
+            
+            $bJoinOrder = false;
+            
+            if (wpsg_isSizedString($arFilter['s'])) {
+                
+                $bJoinOrder = true;
+
+                list($strQuerySELECTOrder, $strQueryWHEREOrder, $strQueryJOINOrder, $strQueryHAVINGOrder, $strQueryORDEROrder) = wpsg_order::getQueryParts(['s' => $arFilter['s']]);
+ 
+                $strQueryWHERE .= $strQueryWHEREOrder;
+                $strQueryJOINSuffix .= $strQueryJOINOrder;
+                
+            }
+
+            if (wpsg_isSizedInt($arFilter['k_id'])) {
+
+                $bJoinOrder = true;
+
+                list($strQuerySELECTOrder, $strQueryWHEREOrder, $strQueryJOINOrder, $strQueryHAVINGOrder, $strQueryORDEROrder) = wpsg_order::getQueryParts(['k_id' => $arFilter['k_id']]);
+
+                $strQueryWHERE .= $strQueryWHEREOrder;
+                $strQueryJOINSuffix .= $strQueryJOINOrder;
+
+            }
+            
+            if (wpsg_isSizedInt($arFilter['cdate_m'])) $strQueryWHERE .= " AND MONTH(A.`cdate`) = '".wpsg_q($arFilter['cdate_m'])."' ";
+            if (wpsg_isSizedInt($arFilter['cdate_y'])) $strQueryWHERE .= " AND YEAR(A.`cdate`) = '".wpsg_q($arFilter['cdate_y'])."' ";
+
+            if (wpsg_isSizedInt($arFilter['enddate_m'])) $strQueryWHERE .= " AND MONTH(A.`expiration`) = '".wpsg_q($arFilter['enddate_m'])."' ";
+            if (wpsg_isSizedInt($arFilter['enddate_y'])) $strQueryWHERE .= " AND YEAR(A.`expiration`) = '".wpsg_q($arFilter['enddate_y'])."' ";
+            
+            if (wpsg_isSizedInt($arFilter['state'])) {
+                
+                $state = intval($arFilter['state']);
+                $wpsg_mod_abo_autoexpire_informationtime = intval(wpsg_ShopController::getShop()->get_option('wpsg_mod_abo_autoexpire_informationtime'));
+                
+                if ($state === self::STATE_RUNNING) {
+                    
+                    if ($wpsg_mod_abo_autoexpire_informationtime <= 0) $strQueryWHERE .= " AND A.`expiration` >= NOW() ";
+                    else {
+ 
+                        $strQueryWHERE .= " AND (
+                            NOW() < DATE_SUB(A.`expiration`, INTERVAL ".wpsg_q($wpsg_mod_abo_autoexpire_informationtime)." DAY)                             
+                        ) ";
+                        
+                    }
+                    
+                } else if ($state === self::STATE_EXTEND) {
+                    
+                    $strQueryWHERE .= " AND A.`expiration` < NOW() ";
+                    
+                } else if ($state === self::STATE_INEXTENSION) {
+
+                    if ($wpsg_mod_abo_autoexpire_informationtime <= 0) $strQueryWHERE .= " AND 0 ";
+                    else {
+                    
+                        $strQueryWHERE .= " AND ( 
+                            NOW() > DATE_SUB(A.`expiration`, INTERVAL ".wpsg_q($wpsg_mod_abo_autoexpire_informationtime)." DAY) AND 
+                            NOW() < A.`expiration`    
+                        ) ";
+                        
+                    }
+                                        
+                }
+                
+            }
+
+            if ($bJoinOrder) {
+                
+                $strQueryJOIN .= " LEFT JOIN `".WPSG_TBL_ORDER."` AS O ON (O.`id` = A.`order_id`) ";
+                
+            }
+            
+            // Sortierung
+            $strQueryORDER = " A.`id` ";
+ 
+            return array($strQuerySELECT, $strQueryWHERE, $strQueryJOIN.$strQueryJOINSuffix, $strQueryHAVING, $strQueryORDER);
+
+        }
+        
+        public static function init() {
+         
+            self::$arState = [
+                self::STATE_RUNNING => __('laufend', 'wpsg'),
+                self::STATE_INEXTENSION => __('in VerlÃ€ngerung', 'wpsg'),
+                self::STATE_EXTEND => __('abgelaufen', 'wpsg')
+            ];
+            
+        }
+        
+    }
+
+    wpsg_abo::init();
Index: /mods/wpsg_mod_abo.class.php
===================================================================
--- /mods/wpsg_mod_abo.class.php	(revision 7806)
+++ /mods/wpsg_mod_abo.class.php	(revision 7807)
@@ -40,4 +40,6 @@
             if ($this->shop->get_option('wpsg_mod_abo_expiremode') === false) $this->shop->update_option('wpsg_mod_abo_expiremode', self::EXPIRE_MAIL);
                         
+            require_once WPSG_PATH_MOD.'/mod_abo/wpsg_abo.php';
+            
         } // public function init()
         
@@ -119,63 +121,5 @@
             
         } // public function delOrder(&$order_id)
-        
-		/**
-		 * Ãbersicht ÃŒber die Kunden im Backend
-		 */
-		private function be_indexActionxxxx()
-		{
-		
-			if (isset($_REQUEST['wpsg_do']) && $_REQUEST['wpsg_do'] !== '-1')
-			{
-		
-				if ($_REQUEST['wpsg_do'] === 'setAccount') return $this->be_index_setAccount();
-		
-			}
-		
-			$nPerPage = $this->shop->get_option('wpsg_mod_abo_perpage');
-			if ($nPerPage <= 0) $nPerPage = 10;
-		
-			$this->shop->view['hasFilter'] = false;
-			$this->shop->view['arFilter'] = array(
-					'order' => 'cdate',
-					'ascdesc' => 'ASC',
-					'status' => '0',
-					'page' => '1'
-			);
-			$this->shop->view['arData'] = array();
-			$this->shop->view['pages'] = 1;
-		
-			if (wpsg_isSizedArray($_REQUEST['filter']))
-			{
-
-				$this->shop->view['arFilter'] = $_REQUEST['filter'];
-				$this->shop->view['hasFilter'] = true;
-		
-			}
-			else if (wpsg_isSizedArray($_SESSION['wpsg']['backend']['customer']['arFilter']))
-			{
-		
-				$this->shop->view['arFilter'] = $_SESSION['wpsg']['backend']['customer']['arFilter'];
-		
-			}
-		
-			$this->shop->view['countAll'] = wpsg_customer::count($this->shop->view['arFilter']);
-		
-			if (wpsg_isSizedInt($_REQUEST['seite'])) $this->shop->view['arFilter']['page'] = $_REQUEST['seite'];
-		
-			$this->shop->view['pages'] = ceil($this->shop->view['countAll'] / $nPerPage);
-			if ($this->shop->view['arFilter']['page'] <= 0 || $this->shop->view['arFilter']['page'] > $this->shop->view['pages']) $this->shop->view['arFilter']['page'] = 1;
-		
-			$this->shop->view['arFilter']['limit'] = array(($this->shop->view['arFilter']['page'] - 1) * $nPerPage, $nPerPage);
-		
-			// Filter speichern
-			$_SESSION['wpsg']['backend']['customer']['arFilter'] = $this->shop->view['arFilter'];
-		
-			$this->shop->view['arData'] = wpsg_customer::find($this->shop->view['arFilter']);
-		
-			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_abo/index.phtml');
-			 
-		} // private function be_indexAction()
-		
+         
 		/**
 		 * Ãbersicht ÃŒber die Kunden im Backend
@@ -189,75 +133,46 @@
 			
 			$this->shop->view['hasFilter'] = false;
-			$this->shop->view['pages'] = 0;
-			$this->shop->view['arStatus'] = array();
+			$this->shop->view['pages'] = 0; 
+			$this->shop->view['arState'] = [];
 			$this->shop->view['arFilter'] = array(
-					'order' => 'cdate',
-					'ascdesc' => 'DESC',
-					'status' => '0',
-					'page' => '1'
+                'order' => 'cdate',
+                'ascdesc' => 'DESC', 
+                'page' => '1'
 			);
-			
-			$this->shop->view['tabs'] = array('left' => array(), 'right' => array());
-			
-			$this->shop->callMods('order_index_tab', array(&$this->shop->view['tabs']));
-			
-			if (wpsg_isSizedArray($_REQUEST['filter']))
-			{
-
-				$_REQUEST['filter']['s'] = wpsg_sinput("text_field", $_REQUEST['filter']['s']);
-				$_REQUEST['filter']['k_id'] = wpsg_sinput("text_field", $_REQUEST['filter']['k_id']);
-				$_REQUEST['filter']['status'] = wpsg_sinput("key", $_REQUEST['filter']['status']);
-				$_REQUEST['filter']['cdate_m'] = wpsg_sinput("key", $_REQUEST['filter']['cdate_m']);
-				$_REQUEST['filter']['cdate_y'] = wpsg_sinput("key", $_REQUEST['filter']['cdate_y']);
-				$_REQUEST['filter']['enddate_m'] = wpsg_sinput("key", $_REQUEST['filter']['enddate_m']);
-				$_REQUEST['filter']['enddate_y'] = wpsg_sinput("key", $_REQUEST['filter']['enddate_y']);
-
-				$this->shop->view['arFilter'] = $_REQUEST['filter'];
-				
-			}
-			else if (wpsg_isSizedArray($_SESSION['wpsg']['backend']['order']['arFilter']))
-			{
-				
-				$this->shop->view['arFilter'] = $_SESSION['wpsg']['backend']['order']['arFilter'];
-				
-			}
-			
-			if (!isset($this->shop->view['arFilter']['status'])) $this->shop->view['arFilter']['status'] = '0';
-			if (($this->shop->view['arFilter']['status'] >= '0') && ($this->shop->view['arFilter']['status'] < wpsg_ShopController::STATUS_AKTIVABO)) $this->shop->view['arFilter']['status'] = wpsg_ShopController::STATUS_AKTIVABO;
-			
-			// Filter gesetzt?
-			foreach (Array('s', 'k_id', 'cdate_m', 'cdate_y', 'enddate_m', 'enddate_y') as $field)
-			{
-				
-				if (wpsg_isSizedString($this->shop->view['arFilter'][$field]) && $this->shop->view['arFilter'][$field] != '-1') { $this->shop->view['hasFilter'] = true; break; }
-				
-			}
-			
-			foreach ($this->shop->arStatus as $status_key => $status_label)
-			{
-				
-				//if ($this->shop->get_option('wpsg_showincompleteorder') != '1' && $status_key == wpsg_ShopController::STATUS_UNVOLLSTAENDIG) continue;
-				
-				$arFilterState = $this->shop->view['arFilter'];
-				$arFilterState['status'] = $status_key;
-				
-				if ($status_key == wpsg_ShopController::STATUS_AKTIVABO) {
-				    
-					$count = wpsg_order::countAbo($arFilterState);
-				
-					if (wpsg_isSizedInt($count)) $this->shop->view['arStatus'][$status_key] = array('label' => $status_label, 'count' => $count);
-				
-				}
-				
-			}
-			
-			$arFilterState = $this->shop->view['arFilter']; unset($arFilterState['status']);
-			$arFilterState['NOTstatus'] = wpsg_ShopController::STATUS_UNVOLLSTAENDIG;
-			
-			$this->shop->view['arStatus'] = wpsg_array_merge(array('-1' => array('label' => __('Alle', 'wpsg'), 'count' => wpsg_Order::countAbo($arFilterState))), $this->shop->view['arStatus']);
-			
-			if ($this->shop->view['arFilter']['status'] == '-1') $this->shop->view['arFilter']['NOTstatus'] = wpsg_ShopController::STATUS_UNVOLLSTAENDIG;
-			
-			$this->shop->view['countAll'] = wpsg_order::countAbo($this->shop->view['arFilter']);
+			  
+			if (isset($_REQUEST['filter']['s'])) $this->shop->view['arFilter']['s'] = sanitize_text_field($_REQUEST['filter']['s']);
+            if (isset($_REQUEST['filter']['k_id'])) $this->shop->view['arFilter']['k_id'] = sanitize_text_field($_REQUEST['filter']['k_id']);
+            if (isset($_REQUEST['filter']['cdate_m'])) $this->shop->view['arFilter']['cdate_m'] = intval($_REQUEST['filter']['cdate_m']);
+            if (isset($_REQUEST['filter']['cdate_y'])) $this->shop->view['arFilter']['cdate_y'] = intval($_REQUEST['filter']['cdate_y']);
+            if (isset($_REQUEST['filter']['enddate_m'])) $this->shop->view['arFilter']['enddate_m'] = intval($_REQUEST['filter']['enddate_m']);
+            if (isset($_REQUEST['filter']['enddate_y'])) $this->shop->view['arFilter']['enddate_y'] = intval($_REQUEST['filter']['enddate_y']);
+            if (wpsg_isSizedInt($_REQUEST['filter']['status'])) $this->shop->view['arFilter']['state'] = intval($_REQUEST['filter']['status']);
+
+            $filter_state = $this->shop->view['arFilter'];
+            unset($filter_state['state']);
+            
+            $this->shop->view['arState'][0] = [
+                'label' => __('Alle', 'wpsg'),
+                'count' => wpsg_abo::count($filter_state)
+            ];
+            
+			foreach (wpsg_abo::$arState as $state_key => $state_label) {
+			    
+			    $filter_state = $this->shop->view['arFilter'];
+			    $filter_state['state'] = $state_key;
+			    $count = wpsg_abo::count($filter_state);
+			    
+			    if ($count > 0) {
+			    
+			        $this->shop->view['arState'][$state_key] = [
+                        'label' => $state_label,
+                        'count' => wpsg_abo::count($filter_state)
+                    ];
+			        
+                }
+			    
+            }
+			
+			$this->shop->view['countAll'] = wpsg_abo::count($this->shop->view['arFilter']);
 			
 			if (wpsg_isSizedInt($_REQUEST['seite'])) $this->shop->view['arFilter']['page'] = $_REQUEST['seite'];
@@ -271,11 +186,9 @@
 			$_SESSION['wpsg']['backend']['order']['arFilter'] = $this->shop->view['arFilter'];
 			
-			$this->shop->view['arData'] = wpsg_order::findAbo($this->shop->view['arFilter']);
+			$this->shop->view['arData'] = wpsg_abo::find($this->shop->view['arFilter']);
 			
 			$this->shop->view['cdate_years'] = $this->db->fetchAssocField("SELECT DISTINCT DATE_FORMAT(`cdate`, '%Y') FROM `".WPSG_TBL_ORDER."` ORDER BY `cdate` ASC ");
-			//if ($this->shop->hasMod('wpsg_mod_rechnungen')) $this->shop->view['invoicedate_years'] = $this->db->fetchAssocField("SELECT DISTINCT DATE_FORMAT(`datum`, '%Y') FROM `".WPSG_TBL_RECHNUNGEN."` WHERE `storno` = '0000-00-00' AND `gnr` = '' ORDER BY `datum` ASC ");
 			
 			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_abo/index.phtml');
-			
 			
 		} // private function be_indexAction()
@@ -560,6 +473,5 @@
 		}
 		
-		public function cron()
-		{
+		public function cron() {
  
 			$arAboExpiration = $this->db->fetchAssoc("
@@ -574,6 +486,5 @@
 			");
   
-			foreach ($arAboExpiration as $a)
-			{
+			foreach ($arAboExpiration as $a) {
 
 				$product_id = $this->shop->getProduktID($a['product_key']);
@@ -592,12 +503,9 @@
 				}
 
-                if ($this->shop->get_option('wpsg_mod_abo_expiremode') == self::EXPIRE_AUTO)
-                {
+                if ($this->shop->get_option('wpsg_mod_abo_expiremode') == self::EXPIRE_AUTO) {
                     
                     $this->autoExtendOrder($a['order_id'], $a['product_key']);
                     
-                }
-                else
-                {
+                } else {
                 
 				    // Mail mit Benachrichtigung senden
@@ -1106,5 +1014,11 @@
             ], " `order_id` = '".wpsg_q($order_id)."' AND `product_key` = '".wpsg_q($product_key)."' ");
 
-            echo wpsg_formatTimestamp($tDate);
+            $oAbo = wpsg_abo::getFromOrderAndProductKey($order_id, $product_key);
+            
+            wpsg_header::JSONData([
+                'state' => $oAbo->getState(),
+                'time' => wpsg_formatTimestamp($tDate)
+            ]);
+            
             exit;
             
@@ -1592,6 +1506,5 @@
 		 * @return boolean
 		 */
-		public function sendAboExpirationMail($order_id, $product_key)
-		{
+		public function sendAboExpirationMail($order_id, $product_key) {
 
 			if ($this->shop->get_option('wpsg_mod_abo_wpsgmodaboexpiration') != '1') return;
Index: /mods/wpsg_mod_ordercondition.class.php
===================================================================
--- /mods/wpsg_mod_ordercondition.class.php	(revision 7806)
+++ /mods/wpsg_mod_ordercondition.class.php	(revision 7807)
@@ -347,5 +347,5 @@
 				$produkt_db = $this->shop->cache->loadProduct($produkt_id);
 				
-				$arOC_products = wpsg_array_merge($arOC_products, explode(",", $produkt_db['wpsg_mod_ordercondition']));
+				$arOC_products = wpsg_array_merge($arOC_products, explode(",", wpsg_getStr($produkt_db['wpsg_mod_ordercondition'])));
 				
 			}
Index: /mods/wpsg_mod_versandarten.class.php
===================================================================
--- /mods/wpsg_mod_versandarten.class.php	(revision 7806)
+++ /mods/wpsg_mod_versandarten.class.php	(revision 7807)
@@ -602,5 +602,5 @@
 				foreach ($arPLZ_flatten as $plz => $value) {
 
-					if (strpos($arBasket['checkout']['plz'], (string)$plz) === 0) {
+					if (strpos(wpsg_getStr($arBasket['checkout']['plz']), (string)$plz) === 0) {
 
 						$va['kosten'] = $kosten_plz[$value];				
Index: /views/admin/form/text.phtml
===================================================================
--- /views/admin/form/text.phtml	(revision 7806)
+++ /views/admin/form/text.phtml	(revision 7807)
@@ -1,4 +1,4 @@
 <div class="form-group form-group-text form-group-sm <?php echo ((wpsg_isSizedString($this->view['field_config']['help']))?'has-feedback':''); ?> <?php echo wpsg_getStr($this->view['field_config']['class_wrap']); ?>">
-
+    
 	<label class="col-sm-6 control-label" for=""><?php echo $this->view['field_label']; ?></label>
 	
Index: /views/css/admin.css
===================================================================
--- /views/css/admin.css	(revision 7806)
+++ /views/css/admin.css	(revision 7807)
@@ -350,4 +350,7 @@
 .wpsg_mod_abo_expired { color:red; }
 .wpsg_mod_abo_future_expire { color:green; }
+.wpsg_abo_state_class_1 { color:green; }
+.wpsg_abo_state_class_2 { color:orange; }
+.wpsg_abo_state_class_3 { color:red; }
 
 /* Modul Produktbilder (wpsg_mod_produktbilder) */
Index: /views/mailtemplates/html/status.phtml
===================================================================
--- /views/mailtemplates/html/status.phtml	(revision 7806)
+++ /views/mailtemplates/html/status.phtml	(revision 7807)
@@ -21,6 +21,5 @@
 	$this->view['order']['onr'], 
 	__($this->view['status_alt'], 'wpsg'), 
-	__($this->view['status_neu'], 'wpsg'),
-	__($this->view['state_new_id'], 'wpsg')); ?></p> 
+	__($this->view['status_neu'], 'wpsg')); ?></p> 
    
 <?php $this->callMods('mail_status', array(&$this->view['order'], &$this->view['kunde'])); ?>
Index: /views/mailtemplates/status.phtml
===================================================================
--- /views/mailtemplates/status.phtml	(revision 7806)
+++ /views/mailtemplates/status.phtml	(revision 7807)
@@ -31,5 +31,5 @@
 	
 <?php echo wpsg_translate(	
-	__('Der Status Ihrer Bestellung mit der Bestellnummer #1# hat sich von "#2#" auf "#3#" "#4#"geÃ€ndert.', 'wpsg'), 
+	__('Der Status Ihrer Bestellung mit der Bestellnummer #1# hat sich von "#2#" auf "#3#" geÃ€ndert.', 'wpsg'), 
 	$this->view['order']['onr'], 
 	__($this->view['status_alt'], 'wpsg'), 
Index: /views/mods/mod_abo/index.phtml
===================================================================
--- /views/mods/mod_abo/index.phtml	(revision 7806)
+++ /views/mods/mod_abo/index.phtml	(revision 7807)
@@ -37,5 +37,11 @@
 						<?php echo wpsg_drawForm_Input('filter[s]', __('Suchfeld', 'wpsg'), wpsg_getStr($this->view['arFilter']['s'])); ?>
                         <?php echo wpsg_drawForm_Input('filter[k_id]', __('Kunde (ID)', 'wpsg'), wpsg_getStr($this->view['arFilter']['k_id'])); ?>
-						<?php echo wpsg_drawForm_Select('filter[status]', __('Abostatus', 'wpsg'), wpsg_array_merge(array('-1' => __('Alle', 'wpsg')), $this->arStatus), @$this->view['arFilter']['status']); ?>
+						
+						<?php
+							
+							$arStateSelect = [];
+							foreach ($this->view['arState'] as $state_key => $state_data) $arStateSelect[$state_key] = $state_data['label'];
+							
+							echo wpsg_drawForm_Select('filter[status]', __('Abostatus', 'wpsg'), wpsg_array_merge(array('-1' => __('Alle', 'wpsg')), $arStateSelect), @$this->view['arFilter']['state']); ?>
 
                         <?php echo wpsg_drawForm_TextStart(); ?>
@@ -97,6 +103,6 @@
 
 		<ul class="pagination">
-			<?php foreach ($this->view['arStatus'] as $status_key => $status_info) { ?>
-			<li class="<?php echo ((wpsg_getStr($this->view['arFilter']['status']) == $status_key)?'active':''); ?>"><a href="#" onclick="return wpsg_setFilterStatus('<?php echo $status_key; ?>');"><?php echo wpsg_translate(__('#1# <span>(#2#)<span>', 'wpsg'), $status_info['label'], $status_info['count']); ?></a></li>
+			<?php foreach ($this->view['arState'] as $status_key => $status_info) { ?>
+			<li class="<?php echo ((wpsg_getStr($this->view['arFilter']['state']) == $status_key)?'active':''); ?>"><a href="#" onclick="return wpsg_setFilterStatus('<?php echo $status_key; ?>');"><?php echo wpsg_translate(__('#1# <span>(#2#)<span>', 'wpsg'), $status_info['label'], $status_info['count']); ?></a></li>
 			<?php } ?>
 		</ul>
@@ -123,20 +129,22 @@
                         <th class="col_products wpsg_order" data-order="products"><?php echo __('Abonnement', 'wpsg'); ?></th>                       
                         <th class="col_sum wpsg_order" data-order="amount"><?php echo __('Bestellwert', 'wpsg'); ?></th>
-                        <th class="col_state wpsg_order" data-order="time"><?php echo __('Laufzeit', 'wpsg'); ?></th>
+                        <th class="col_time wpsg_order" data-order="time"><?php echo __('Laufzeit', 'wpsg'); ?></th>
+						<th class="col_state wpsg_order" data-order="time"><?php echo __('Status', 'wpsg'); ?></th>
                     </tr>
                 </thead>
                 <tbody>
-                    <?php foreach ($this->view['arData'] as $oOrder) { ?>
+                    <?php foreach ($this->view['arData'] as $oAbo) { $oOrder = $oAbo->getOrder(); ?>
                     <tr>
                         <td class="col_checkbox">
 
-                            <input class="col_set_checkbox" name="wpsg_multido[<?php echo $oOrder->id; ?>]" type="checkbox" />
+                            <input class="col_set_checkbox" name="wpsg_multido[<?php echo $oAbo->id; ?>]" type="checkbox" />
 
                         </td>
                         <td class="col_nr">
 
-                            <?php echo $oOrder->getNr(); ?> <span class="wpsg_grey"><?php echo wpsg_formatTimestamp(strtotime($oOrder->cdate), false); ?></span><br />
+                            <?php echo $oAbo->getNr(); ?> <span class="wpsg_grey"><?php echo wpsg_formatTimestamp(strtotime($oAbo->__get('cdate')), false); ?></span><br />
 
                             <div class="actions">
+								
                                 <span class="view"><a title="<?php echo __("Dieses Abonnement ansehen", "wpsg"); ?>" href="<?php 
 									
@@ -145,12 +153,4 @@
 								?>"><?php echo __("Ansehen", "wpsg"); ?></a></span>
                                 |
-                                <?php if ($this->view['arFilter']['status'] != wpsg_ShopController::STATUS_GEKUENDIGTEABOS) { ?>
-                                <?php /*<span class="storno"><a onclick="return confirm('<?php echo __('Sind Sie sich sicher, dass Sie dieses Abonnement kÃŒndigen mÃ¶chten?', 'wpsg'); ?>');" title="<?php echo __("Dieses Abonnement kÃŒndigen", "wpsg"); ?>" href="<?php 
-										
-									echo wpsg_admin_url('Order', 'resign', ['edit_id' => $oOrder->id], ['noheader' => '1']);
-										
-								?>"><?php echo __("KÃŒndigen", "wpsg"); ?></a></span> 
-                                | */ ?>
-                                <?php } ?>
                                 <span class="delete"><a onclick="return confirm('<?php echo __('Sind Sie sich sicher, dass Sie dieses Abonnement lÃ¶schen mÃ¶chten?', 'wpsg'); ?>');" title="<?php echo __('Dieses Abonnement lÃ¶schen', 'wpsg'); ?>" href="<?php 
 									
@@ -158,27 +158,24 @@
 																			
 								?>"><?php echo __('LÃ¶schen', 'wpsg'); ?></a></span>
-                            </div>
-							
-                            <?php if (trim($oOrder->admincomment) != "") { ?>
-                            <a title="<?php echo __("Kommentar (Admin): ", "wpsg").htmlspecialchars($oOrder->admincomment); ?>" onclick="return false;" class="glyphicon glyphicon-question-sign admincomment" href="#"></a>
-                            <?php } ?>
-
-                            <?php if (trim($oOrder->comment) != "") { ?>
-                            <a title="<?php echo __("Kommentar (Kunde): ", "wpsg").htmlspecialchars($oOrder->comment); ?>" onclick="return false;" class="glyphicon glyphicon-question-sign customercomment" href="#"></a>
-                            <?php } ?>
-														
-                            <?php if ($oOrder->hasShippingAdress()) { ?>
-                            <a title="<?php echo __("Lieferadresse beachten", "wpsg"); ?>" onclick="return false;" class="glyphicon glyphicon-map-marker shippingadress" href="#"></a>
-                            <?php } ?>
+							
+                            </div>
+							
+                            <?php if (trim($oAbo->getOrder()->admincomment) != "") { ?>
+                            <a title="<?php echo __("Kommentar (Admin): ", "wpsg").htmlspecialchars($oAbo->getOrder()->admincomment); ?>" onclick="return false;" class="glyphicon glyphicon-question-sign admincomment" href="#"></a>
+                            <?php } ?>
+
+                            <?php if (trim($oAbo->getOrder()->comment) != "") { ?>
+                            <a title="<?php echo __("Kommentar (Kunde): ", "wpsg").htmlspecialchars($oAbo->getOrder()->comment); ?>" onclick="return false;" class="glyphicon glyphicon-question-sign customercomment" href="#"></a>
+                            <?php } ?> 
 
                         </td>
                         <td class="col_customer">
-                            <?php $firma = $oOrder->getInvoiceCompany(); if (wpsg_isSizedString($firma)) { ?>
+                            <?php $firma = $oAbo->getOrder()->getInvoiceCompany(); if (wpsg_isSizedString($firma)) { ?>
                             <?php echo $firma; ?><br />
                             <?php } ?>
-                            <?php echo $oOrder->getInvoiceTitle(); ?> <?php echo $oOrder->getInvoiceFirstname(); ?> <?php echo $oOrder->getInvoiceName(); ?>
+                            <?php echo $oAbo->getOrder()->getInvoiceTitle(); ?> <?php echo $oOrder->getInvoiceFirstname(); ?> <?php echo $oAbo->getOrder()->getInvoiceName(); ?>
                             <br />
-                            <span class="wpsg_grey"><?php echo $oOrder->getInvoiceStreet(); ?><br />
-                            <?php echo ltrim($oOrder->getInvoiceZip().' '.$oOrder->getInvoiceCity()); ?> <?php echo $oOrder->getInvoiceCountryKuerzel(); ?>
+                            <span class="wpsg_grey"><?php echo $oAbo->getOrder()->getInvoiceStreet(); ?><br />
+                            <?php echo ltrim($oAbo->getOrder()->getInvoiceZip().' '.$oAbo->getOrder()->getInvoiceCity()); ?> <?php echo $oAbo->getOrder()->getInvoiceCountryKuerzel(); ?>
                             </span>
                         </td>
@@ -256,4 +253,14 @@
                             
                        </td>
+						
+						<td class="col_state">
+							
+							<?php $state = $oAbo->getState(); ?>
+							
+							<?php if ($state === wpsg_abo::STATE_INEXTENSION) { ?><span style="color:orange;"><?php echo $oAbo->getStateLabel(); ?></span> 
+							<?php } else if ($state === wpsg_abo::STATE_RUNNING) { ?><span style="color:green;"><?php echo $oAbo->getStateLabel(); ?></span>
+							<?php } else if ($state === wpsg_abo::STATE_EXTEND) { ?><span style="color:red;"><?php echo $oAbo->getStateLabel(); ?></span><?php } ?>
+															
+						</td>
                        
                     </tr>
Index: /views/mods/mod_abo/order_view.phtml
===================================================================
--- /views/mods/mod_abo/order_view.phtml	(revision 7806)
+++ /views/mods/mod_abo/order_view.phtml	(revision 7807)
@@ -9,10 +9,14 @@
 ?>
        
-<?php foreach ($this->view['arOrderedAboProducts'] as $oOrderProduct) { ?>
+<?php foreach ($this->view['arOrderedAboProducts'] as $oOrderProduct) {
+
+    $oAbo = wpsg_abo::getFromOrderAndProduct($view['oOrder']->getId(), $oOrderProduct->getId());
+	
+	?>
 
     <?php echo wpsg_drawForm_AdminboxStart($oOrderProduct->getProduct()->getProductName()); ?>
 
         <?php $tExpire = strtotime($this->callMod('wpsg_mod_abo', 'getOrderAboExpiration', Array($_REQUEST['edit_id'], $oOrderProduct->getProductKey()))); ?>
-		<?php echo wpsg_drawForm_Text(__('Laufzeit', 'wpsg'), wpsg_formatTimestamp($tExpire), 'wpsg_mod_abo_duration', Array('class_content_wrap' => (($tExpire > time())?'wpsg_mod_abo_future_expire':'wpsg_mod_abo_expired'))); ?>
+		<?php echo wpsg_drawForm_Text(__('Laufzeit', 'wpsg'), wpsg_formatTimestamp($tExpire), 'wpsg_mod_abo_duration', Array('class_content_wrap' => 'wpsg_abo_state wpsg_abo_state_class_'.$oAbo->getState())); ?>
 	
 		<script>
@@ -22,4 +26,9 @@
             jQuery('#wpsg_mod_abo_duration').editable({
 				type: 'combodate',
+                display: function(value) {
+				    
+                    jQuery(this).html(value.format('DD.MM.YYYY HH:mm:ss'));
+				    
+				},
                 success: function(response, newValue) {
 				    
@@ -33,5 +42,7 @@
                         },
 						success: function(response) {
-                             
+ 
+                            jQuery('.wpsg_abo_state').attr("class", "col-sm-6 wpsg_abo_state_class_" + response.state)
+                                                        
 						}
 					})
@@ -51,4 +62,12 @@
 
         <?php echo wpsg_drawForm_Text(wpsg_translate(__('Preis (#1# Tage):', 'wpsg'), $oOrderProduct->getProduct()->wpsg_mod_abo_durration), wpsg_ff($oOrderProduct->getProduct()->wpsg_mod_abo_price, $this->get_option('wpsg_currency'))); ?>
+		<?php
+	
+			$strURL = $this->callMod('wpsg_mod_abo', 'getRebuyLink', [$view['oOrder']->getId(), $oOrderProduct->getProductKey()]);
+			$strURL = '<a href="'.$strURL.'">'.$strURL.'</a>';
+	
+			echo wpsg_drawForm_Text(__('URL fÃŒr den Kauf einer VerlÃ€ngerung', 'wpsg'), $strURL); 
+			
+		?>
     
         <?php echo wpsg_drawForm_TextStart(); ?>
