Index: ds/wpsg_mod_productgroups.class.php
===================================================================
--- /mods/wpsg_mod_productgroups.class.php	(revision 5989)
+++ 	(revision )
@@ -1,820 +1,0 @@
-<?php
-
-	/**
-	 * Modul fÃŒr die Produktgruppenverwaltung
-	 * @author daniel
-	 */
-	class wpsg_mod_productgroups extends wpsg_mod_basic 
-	{
-		
-		var $lizenz = 1;
-		var $id = 9;
-		var $hilfeURL = 'http://wpshopgermany.de/?p=868';
-		
-		/**
-		 * Costructor
-		 */
-		public function __construct()
-		{
-			
-			parent::__construct();
-			
-			$this->name = __('Produktgruppen', 'wpsg');
-			$this->group = __('Produkte', 'wpsg');
-			$this->desc = __('ErmÃ¶glicht die Zuordnung von Produkten zu Produktgruppen.', 'wpsg');
-									
-		} // public function __construct()
-		 
-		public function install()
-		{
-			
-			require_once(WPSG_PATH_WP.'/wp-admin/includes/upgrade.php');
-					
-			/**
-			 * Produktgruppentabelle anlegen
-			 */ 
-			$sql = "CREATE TABLE ".WPSG_TBL_PRODUCTS_GROUP." (
-		   		id mediumint(9) NOT NULL AUTO_INCREMENT,
-		   		cdate datetime NOT NULL,
-		   		name VARCHAR(255) NOT NULL,
-		   		template_file VARCHAR(255) NOT NULL,
-		   		infopage INT(11) NOT NULL,
-		   		deleted INT(1) NOT NULL,
-		   		rabatt TEXT(255) NOT NULL,
-		   		stock_aktiv VARCHAR(255) NOT NULL,
-		   		stock_value INT(11) NOT NULL,
-				lang TEXT NOT NULL,
-		   		PRIMARY KEY  (id)
-		   	) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
-   	   	 
-   			dbDelta($sql);
-   			
-   			/**
-		   	 * Tabelle fÃŒr die Sticky Produkte
-		   	 */
-		   	$sql = "CREATE TABLE ".WPSG_TBL_PRODUCTS_STICKY." (
-		   		id mediumint(9) NOT NULL AUTO_INCREMENT,
-		   		produkt_id INT(11) NOT NULL,
-		   		von INT NOT NULL,
-		   		bis INT NOT NULL,
-		   		PRIMARY KEY  (id)
-		   	) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
-		   	
-		   	dbDelta($sql);
-			
-		} // public function install()
-		
-		public function init()
-		{
-
-			require_once(WPSG_PATH_MOD.'mod_productgroups/wpsg_productgroup.php');
-			
-			$role_object = get_role('administrator');
-			$role_object->add_cap('wpsg_productgroup');
-			
-		} // public function init()
-		
-		public function settings_edit() 
-		{
-			
-			$pages = get_pages();
-			
-			$arPages = array(
-				'-1' => __('Nicht zugeordnet', 'wpsg')
-			);
-			
-			foreach ($pages as $k => $v)
-			{
-				$arPages[$v->ID] = $v->post_title.' (ID:'.$v->ID.')';
-			}
-			
-			$this->shop->view['pages'] = $arPages;			
-			
-			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/settings_edit.phtml');
-			
-		} // public function settings_edit()
-		
-		public function settings_save() 
-		{
-			
-			$this->shop->update_option('wpsg_productgroups_page', $_REQUEST['wpsg_productgroups_page']);
-			$this->shop->update_option('wpsg_productgroups_order', $_REQUEST['wpsg_productgroups_order']);
-			
-		} // public function settings_save()
-		
-		public function admin_setcapabilities() { 
-			
-			$this->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/admin_setcapabilities.phtml');
-			
-		} // public function admin_setcapabilities()
-		
-		public function wpsg_add_pages()
-		{
-						
-			add_submenu_page('wpsg-Admin', __("Produktgruppen", "wpsg"), __("Produktgruppen", "wpsg"), 'wpsg_productgroup', 'wpsg-Productgroups', array($this, 'dispatch'));
-			
-		} // public function wpsg_add_pages()
-						
-		public function produkt_del($produkt_id) 
-		{ 
-
-			$this->db->Query("DELETE FROM `".WPSG_TBL_PRODUCTS_STICKY."` WHERE `produkt_id` = '".wpsg_q($produkt_id)."'");
-			
-		} // public function produkt_del($produkt_id)
-		
-		public function shortcode($atts)
-		{
-
-			// [wpshopgermany produktgruppe="1" sortierung="id" richtung="asc"]
-			
-			$pg_id = $atts['produktgruppe'];
-			$pg_template = $this->db->fetchOne("SELECT `template_file` FROM `".WPSG_TBL_PRODUCTS_GROUP."` WHERE `id` = '".wpsg_q($pg_id)."'");
-			
-			$arSortierung = Array('id', 'name', 'anr', 'preis');
-			$arDirection = Array('asc', 'desc');
-			
-			$strOrder = 'sticky DESC, ';
-			
-			if (isset($atts['sortierung']) && in_array($atts['sortierung'], $arSortierung))
-			{
-					
-				$strOrder .= 'P.`'.wpsg_q($atts['sortierung']).'`';
-				
-				if (isset($atts['richtung']) && in_array($atts['richtung'], $arDirection))
-				{
-					
-					$strOrder .= ' '.wpsg_q($atts['richtung']);
-					
-				}
-				else
-				{
-					
-					$strOrder .= ' ASC';
-					
-				}
-								
-			}
-			else
-			{
-				
-				$strOrder .= 'P.`id` ASC';
-				
-			}
-			
-			$arProduktIDs = $this->db->fetchAssocField("
-				SELECT 
-					P.`id`,
-					IF (
-						(SELECT PS.`id` FROM `".WPSG_TBL_PRODUCTS_STICKY."` AS PS WHERE PS.`produkt_id` = P.`id` AND  UNIX_TIMESTAMP(NOW()) BETWEEN `von` AND `bis`) > 0,
-						'1',
-						'0'
-					) AS sticky
-				FROM 
-					`".WPSG_TBL_PRODUCTS."` AS P
-				WHERE 
-					P.`pgruppe` = '".wpsg_q($pg_id)."' AND 
-					P.`deleted` != '1' AND 
-					P.`lang_parent` <= 0
-				ORDER BY
-					".$strOrder."
-			");
-						
-			if ($pg_template !== '0' && $pg_template !== '') $template = $pg_template; else $template = false;
-			
-			$strReturn = '';			
-			foreach ((array)$arProduktIDs as $p_id)
-			{
-				
-				//if ($pg_template !== '0' && $pg_template !== '') $template = $pg_template; else $template = $this->db->fetchOne("SELECT `ptemplate_file` FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".wpsg_q($p_id)."'");
-				
-				$strReturn .= $this->shop->renderProdukt($p_id, $template);
-				
-			}
-			
-			return $strReturn;
-			
-		} // public function shortcode($atts)
-
-		/**
-		 * Integriert den Namen der Gruppe in das Produktarray
-		 */
-		public function loadProduktArray(&$arrProdukt)
-		{
-			
-			$arrGrp = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS_GROUP."` WHERE `id` = '".wpsg_q($arrProdukt['pgruppe'])."'");
-			
-			if ($this->shop->isOtherLang())
-			{
-				
-				$lang = @unserialize($arrGrp['lang']);
-				
-				if (is_array($lang) && wpsg_isSizedString($lang[$this->shop->getCurrentLanguage()]['name'])) $arrGrp['name'] = $lang[$this->shop->getCurrentLanguage()]['name'];
-				
-			}
-			
-			$arrProdukt['pgruppe_name'] = $arrGrp['name'];
-			
-			// ?? Scheint zu funktionieren
-			$arrProdukt['rabatt'] = $arrGrp['rabatt'];	
-		
-		}
-		
-		public function produkt_save(&$produkt_id) 
-		{
-				
-			$sticky_id = $this->db->fetchOne("SELECT `id` FROM `".WPSG_TBL_PRODUCTS_STICKY."` WHERE `produkt_id` = '".wpsg_q($produkt_id)."'");
-
-			$data = array(
-				'produkt_id' => wpsg_q($produkt_id),
-				'von' => wpsg_q(strtotime($_REQUEST['wpsg_productgroup_sticky_von'])),
-				'bis' => wpsg_q(strtotime($_REQUEST['wpsg_productgroup_sticky_bis']))
-			);
-			
-			if ($sticky_id > 0)
-			{
-				$this->db->UpdateQuery(WPSG_TBL_PRODUCTS_STICKY, $data, "`id` = '".wpsg_q($sticky_id)."'");
-			}
-			else
-			{
-				$this->db->ImportQuery(WPSG_TBL_PRODUCTS_STICKY, $data);
-			}
-			
-			$data = array(
-				'pgruppe' => wpsg_q($_REQUEST['wpsg_productgroup'])
-			);
-			
-			$this->db->UpdateQuery(WPSG_TBL_PRODUCTS, $data, "`id` = '".wpsg_q($produkt_id)."'");
-			
-		} // public function produkt_save($produkt_id)
-		
-		public function produkt_copy(&$produkt_id, &$copy_id) 
-		{ 
-			
-			$arSticky = $this->db->fetchAssoc("SELECT * FROM `".WPSG_TBL_PRODUCTS_STICKY."` WHERE `produkt_id` = '".wpsg_q($produkt_id)."'");
-			
-			foreach ((array)$arSticky as $s)
-			{
-				
-				unset($s['id']);
-				$s['produkt_id'] = wpsg_q($copy_id);
-				
-				$this->db->ImportQuery(WPSG_TBL_PRODUCTS_STICKY, $s);
-				
-			}
-			
-		} // public function produkt_copy(&$produkt_id, &$copy_id)
-		
-		public function product_addedit_content(&$product_content, &$product_data)
-		{
-		
-			if (wpsg_isSizedInt($product_data['id']))
-			{
-					
-				if (isset($_REQUEST['wpsg_lang'])) return;
-			
-				$this->shop->view['wpsg_mod_productgroups']['produkt_data'] = $product_data;
-				$this->shop->view['wpsg_mod_productgroups']['data'] = array();
-				$this->shop->view['wpsg_mod_productgroups']['data'][0] = __('Nicht zugewiesen.', 'wpsg'); 
-				
-				// Kein Array Merge ! Da indexe gelÃ¶scht werden
-				$groups_db = $this->db->fetchAssocField("
-					SELECT
-						PG.`id`, PG.`name`
-					FROM
-						`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
-					WHERE
-						PG.`deleted` != '1'
-					ORDER BY
-						`id` ASC
-				", "id", "name");
-				$this->shop->view['wpsg_mod_productgroups']['data'] = array_diff_key($this->shop->view['wpsg_mod_productgroups']['data'], $groups_db) + $groups_db;
-				
-				$sticky_data = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS_STICKY."` WHERE `produkt_id` = '".wpsg_q($product_data['id'])."'");
-							
-				if ($sticky_data['von'] > 0) $this->shop->view['wpsg_mod_productgroups']['sticky_von'] = date('d.m.Y', $sticky_data['von']);
-				if ($sticky_data['bis'] > 0) $this->shop->view['wpsg_mod_productgroups']['sticky_bis'] = date('d.m.Y', $sticky_data['bis']);;
-						
-			}
-			
-			$product_content['wpsg_mod_productgroups'] = array(
-				'title' => __('Produktgruppen', 'wpsg'),
-				'content' => $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/produkt_addedit_sidebar.phtml', false)
-			);
-		
-		} // public function produkt_edit_sidebar(&$product_content, &$produkt_data)
-		
-		public function content_filter(&$content) 
-		{
-			
-			if (get_the_id() <= 0 || get_the_id() != $this->shop->get_option('wpsg_productgroups_page')) return;
-
-			if ($_REQUEST['show'] > 0)
-			{
-
-				$arrGrp = $this->db->fetchRow("
-					SELECT
-						*
-					FROM
-						`".WPSG_TBL_PRODUCTS_GROUP."`
-					WHERE
-						`id` = '".wpsg_q($_REQUEST['show'])."' AND
-						`deleted` = '0'
-					ORDER BY
-						`name`			
-				");
-
-				if ($this->shop->isOtherLang())
-				{
-					
-					$lang = @unserialize($arrGrp['lang']);
-					
-					if (is_array($lang) && wpsg_isSizedString($lang[$this->shop->getCurrentLanguage()]['name'])) $arrGrp['name'] = $lang[$this->shop->getCurrentLanguage()]['name']; 
-					
-				}
-	
-				$strOrder = "sticky DESC";
-				if ($this->shop->get_option('wpsg_productgroups_order') != '')
-				{
-							
-					switch ($this->shop->get_option('wpsg_productgroups_order'))
-					{
-									
-						case 'id':
-							$strOrder .= ", P.`id` ASC ";
-							break;
-						case 'alphabetisch':
-							$strOrder .= ", P.`name` ASC ";
-							break;		
-						case 'buyed':
-							$strOrder .= ", `buyed` DESC ";
-							break;	
-						case 'erstellungsdatum':
-							$strOrder .= ", `cdate` DESC ";
-							break;
-						case 'preis':
-							$strOrder .= ", `preis` DESC ";
-							break;			
-									
-					}
-								
-				}
-				 
-				if ($strOrder != "") $strOrder = " ORDER BY ".$strOrder;
-				
-				$arrProdukte = $this->shop->db->fetchAssoc("SELECT 
-						P.`id`,
-						(IF('".time()."' > PS.`von` AND '".time()."' < PS.`bis`, 1, 0)) AS sticky, 
-						(SELECT SUM(`menge`) FROM `".WPSG_TBL_ORDERPRODUCT."` AS OP WHERE OP.`p_id` = P.`id`) AS buyed 
-					FROM 
-						`".WPSG_TBL_PRODUCTS."` AS P
-							LEFT JOIN `".WPSG_TBL_PRODUCTS_STICKY."` AS PS ON (P.`id` = PS.`produkt_id`)
-					WHERE 
-						P.`pgruppe` = '".wpsg_q($arrGrp['id'])."' AND 
-						P.`deleted` = '0' 
-					".$strOrder."
-				");
-
-				// Bilder der Produkte
-				foreach ($arrProdukte as $k => $p)
-				{
-					
-					$arrProdukte[$k] = $this->shop->loadProduktArray($p['id']);
-											
-					$arFiles = array();
-						
-					$dir = $this->shop->callMod('wpsg_mod_produktbilder', 'getPicPath', array($this->shop->getProduktId($p['id'])));
-						
-					//$dir = WP_CONTENT_DIR.'/uploads/produktbilder/'.$p['id']."/";
-						
-					$handle = opendir($dir);
-		 
-					while($filename = readdir($handle))
-			   		{
-			   				
-			   			$file = $dir.$filename; 
-			   			if (is_file($file) && $filename != "." && $filename != "..")
-			   			{
-			   				$arFiles[] = $filename;
-			   			}
-			   				   				   				   				   				
-			   		}
-			   		$arrProdukte[$k]['bilder'] = $arFiles;		   			
-							
-				}
-
-				$this->shop->view['data'] = $arrGrp;
-				$this->shop->view['data']['produkte'] = $arrProdukte;
-								
-				$content = $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/show.phtml', false);
-				
-			}
-			else 
-			{
-				
-				$arrGrp = $this->db->fetchAssoc("
-					SELECT
-						*
-					FROM
-						`".WPSG_TBL_PRODUCTS_GROUP."`
-					WHERE
-						`deleted` = '0'
-					ORDER BY
-						`name`			
-				");
-				
-				foreach ($arrGrp as $k => $pg)
-				{
-					
-					if ($this->shop->isOtherLang())
-					{
-						
-						$lang = @unserialize($pg['lang']);
-						
-						if (is_array($lang) && wpsg_isSizedString($lang[$this->shop->getCurrentLanguage()]['name'])) $pg['name'] = $lang[$this->shop->getCurrentLanguage()]['name'];
-						
-					}
-					
-					$strOrder = "sticky DESC";
-					
-					if ($this->shop->get_option('wpsg_productgroups_order') != '')
-					{
-								
-						switch ($this->shop->get_option('wpsg_productgroups_order'))
-						{
-									
-							case 'id':
-								$strOrder .= ", P.`id` ASC ";
-								break;
-							case 'alphabetisch':
-								$strOrder .= ", P.`name` ASC ";
-								break;		
-							case 'buyed':
-								$strOrder .= ", `buyed` DESC ";
-								break;	
-							case 'erstellungsdatum':
-								$strOrder .= ", `cdate` DESC ";
-								break;
-							case 'preis':
-								$strOrder .= ", `preis` DESC ";
-								break;			
-									
-						}
-								
-					}
-					
-					if ($strOrder != "") $strOrder = " ORDER BY ".$strOrder;
-				 
-					$arrProdukte = array();
-					$arrProdukte = $this->db->fetchAssoc("SELECT 
-															P.`id`, 
-															(IF('".time()."' > PS.`von` AND '".time()."' < PS.`bis`, 1, 0)) AS sticky, 
-															(SELECT SUM(`menge`) FROM `".WPSG_TBL_ORDERPRODUCT."` AS OP WHERE OP.`p_id` = P.`id`) AS buyed 
-														FROM 
-															`".WPSG_TBL_PRODUCTS."` AS P		
-																	LEFT JOIN `".WPSG_TBL_PRODUCTS_STICKY."` AS PS ON (P.`id` = PS.`produkt_id`)					
-														WHERE 
-															P.`pgruppe` = '".wpsg_q($pg['id'])."' AND 
-															P.`deleted` = '0' 
-														".$strOrder."
-													");
-					
-					// Bilder der Produkte
-					foreach ($arrProdukte as $k2 => $p)
-					{
-						
-						$arrProdukte[$k2] = $this->shop->loadProduktArray($p['id']);
-						
-						$arFiles = array();
-						
-						$dir = $this->shop->callMod('wpsg_mod_produktbilder', 'getPicPath', array($this->shop->getProduktId($p['id'])));
-						
-						$handle = opendir($dir);
-		 				
-						while($filename = readdir($handle))
-			   			{
-			   				
-			   				$file = $dir.$filename; 
-			   				if (is_file($file) && $filename != "." && $filename != "..")
-			   				{
-			   					$arFiles[] = $filename;
-			   				}
-			   				   				   				   				   				
-			   			}
-			   			
-			   			$arrProdukte[$k2]['bilder'] = $arFiles;
-					}
-					$this->shop->view['data'][$pg['id']]['produkte'] = $arrProdukte;
-					$this->shop->view['data'][$pg['id']]['pgruppe_name'] = $pg['name'];
-					
-				}
-				
-				$content = $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/list.phtml', false);
-				
-			}
-			
-			return -2;
-			
-		}
-		
-		public function wpsg_mod_export_loadFields(&$arFields) 
-		{ 
-
-			$arFields[20]['fields']['pgruppe_id'] = __('Produktgruppe ID', 'wpsg');
-			$arFields[20]['fields']['pgruppe_name'] = __('Produktgruppe Name', 'wpsg');
-			
-		} // public function wpsg_mod_export_loadFields(&$arFields)
-		
-		public function wpsg_mod_export_getValue(&$return, $field_value, $o_id, $p_id, $productkey, $product_index, $profil_separator) 
-		{ 
- 
-			if (wpsg_isSizedInt($o_id) && !wpsg_isSizedInt($p_id))
-			{
-				
-				$product_db = $this->db->fetchRow("
-					SELECT
-						GROUP_CONCAT(P.`pgruppe`) AS `pgruppe`,
-						GROUP_CONCAT(PG.`name`) AS `pgruppe_name`
-					FROM
-						`".WPSG_TBL_ORDERPRODUCT."` AS OP 
-							LEFT JOIN `".WPSG_TBL_PRODUCTS."` AS P ON (OP.`p_id` = P.`id`)
-							LEFT JOIN `".WPSG_TBL_PRODUCTS_GROUP."` AS PG ON (PG.`id` = P.`pgruppe`)
-					WHERE
-						OP.`o_id` = '".wpsg_q($o_id)."'
-					GROUP BY
-						P.`id`
-				");
-				 				
-			}
-			else if (wpsg_isSizedInt($p_id))
-			{
-				
-				$product_db = $this->shop->cache->loadProduct($p_id);
-				$product_db['pgruppe_name'] = $this->db->fetchOne("SELECT `name` FROM `".WPSG_TBL_PRODUCTS_GROUP."` WHERE `id` = '".wpsg_q($product_db['pgruppe'])."' ");
-				
-			}
-			else
-			{
-				return;
-			}
-			
-			switch ($field_value)
-			{
-				
-				case 'pgruppe_id': $return = $product_db['pgruppe']; break;
-				case 'pgruppe_name': $return = $product_db['pgruppe_name']; break;
-				
-			}
-			
-		} // public function wpsg_mod_export_getValue(&$return, $field_value, $o_id, $p_id, $productkey, $product_index, $profil_separator)
-		
-		/* -- */
-		
-		/**
-		 * Gibt einen Array mit allen Produktgruppen zurÃŒck und beachtet die Ãbersetzung
-		 */
-		public function getAllProductGroups()
-		{
-			
-			$arPG = $this->db->fetchAssocField("
-				SELECT
-					PG.`id`, PG.`name`
-				FROM
-					`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
-				WHERE
-					PG.`deleted` != '1'
-				ORDER BY
-					PG.`name` ASC	
-			", "id", "name");
-			
-			if ($this->shop->isOtherLang())
-			{
-				
-				foreach ($arPG as $k => $pg)
-				{
-					
-					$lang = @unserialize($pg['lang']);
-					
-					if (is_array($lang) && wpsg_isSizedString($lang[$this->shop->getCurrentLanguage()]['name'])) $arPG['name'] = $lang[$this->shop->getCurrentLanguage()]['name'];
-					
-				}
-				
-			}
-						
-			return $arPG;
-			
-		} // public function getAllProductGroups()
-		
-		public function dispatch()
-		{
-			 
-			if (isset($_REQUEST['wpsg_mod_action']) && $_REQUEST['wpsg_mod_action'] == "add")
-			{
-				$this->addAction();	
-			}
-			else if (isset($_REQUEST['wpsg_mod_action']) && $_REQUEST['wpsg_mod_action'] == "edit")
-			{
-				$this->editAction();
-			}
-			else if (isset($_REQUEST['wpsg_mod_action']) && $_REQUEST['wpsg_mod_action'] == "del")
-			{
-				$this->delAction();
-			}
-			else if (isset($_REQUEST['wpsg_mod_action']) && $_REQUEST['wpsg_mod_action'] == "save")
-			{
-				$this->saveAction();
-			}
-			else
-			{	
-				$this->indexAction();				
-			}
-			
-		} // public function dispatch()
-		
-		public function indexAction()
-		{
-
-			$nPerPage = 25;
-			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']['customergroup']['arFilter']))
-			{
-
-				//$this->shop->view['arFilter'] = $_SESSION['wpsg']['backend']['customer']['arFilter'];
-
-			}
-
-			$this->shop->view['countAll'] = wpsg_productgroup::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']['customergroup']['arFilter'] = $this->shop->view['arFilter'];
-
-			$this->shop->view['arData'] = wpsg_productgroup::find($this->shop->view['arFilter']);
-
-			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/index.phtml');
-			
-		} // public function indexAction()
-		
-		public function delAction()
-		{
-			
-			$this->db->Query("DELETE FROM `".WPSG_TBL_PRODUCTS_GROUP."` WHERE `id` = '".wpsg_q($_REQUEST['edit_id'])."'");
-			$this->shop->addBackendMessage(__('Produktgruppe wurde erfolgreich gelÃ¶scht.', 'wpsg'));
-			
-			$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=index');
-			
-		} // public function delAction()
-		
-		public function saveAction()
-		{
-
-			$data = array(
-				'name' => wpsg_q($_REQUEST['wpsg_mod_productgroups_name']),
-				'template_file' => wpsg_q($_REQUEST['wpsg_mod_productgroups_template']),
-				'infopage' => wpsg_q($_REQUEST['wpsg_mod_productgroups_infopage']),
-				'stock_aktiv' => wpsg_q($_REQUEST['wpsg_mod_productgroups']['stock_aktiv']),
-				'stock_value' => wpsg_q($_REQUEST['wpsg_mod_productgroups']['stock_value']),
-				'lang' => wpsg_q(serialize($_REQUEST['lang']))			
-			);
-			
-			if ($_REQUEST['edit_id'] > 0)
-			{
-				
-				$this->db->UpdateQuery(WPSG_TBL_PRODUCTS_GROUP, $data, "`id` = '".wpsg_q($_REQUEST['edit_id'])."'");
-				$this->shop->addBackendMessage(__('Produktgruppe erfolgreich gespeichert.', 'wpsg'));
-				
-			}
-			else
-			{
-				
-				$data['cdate'] = "NOW()";
-				$_REQUEST['edit_id'] = $this->db->ImportQuery(WPSG_TBL_PRODUCTS_GROUP, $data);
-				$this->shop->addBackendMessage(__('Produktgruppe erfolgreich angelegt.', 'wpsg'));
-				
-			}
-						
-			$this->shop->callMods('wpsg_mod_productgroups_save', array($_REQUEST['edit_id']));
-			
-			if (isset($_REQUEST['submit_index'])) $this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=index');
-			else $this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=edit&edit_id='.$_REQUEST['edit_id']);
-			
-		} // public function saveAction()
-		
-		public function editAction()
-		{
-			
-			$this->shop->view['data'] = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS_GROUP."` WHERE `id` = '".wpsg_q($_REQUEST['edit_id'])."'");
-			$this->shop->view['data']['lang'] = @unserialize($this->shop->view['data']['lang']);
-			if (!is_array($this->shop->view['data']['lang'])) $this->shop->view['data']['lang'] = array();
-			$this->shop->view['languages'] = $this->shop->getStoreLanguages();
-			
-			$this->addeditAction();
-			
-			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/add.phtml');
-			
-		} // public function editAction()
-		
-		public function addAction()
-		{
-			
-			$this->addeditAction();
-			$this->shop->view['data'] = array(
-				'name' => '',
-				'template_file' => '',
-				'infopage' => ''
-			);
-
-			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/add.phtml');
-			
-		} // public function addAction()
-		
-		public function addeditAction()
-		{
-			
-			$this->shop->view['templates'] = array();
-			$this->shop->view['templates'][0] = __('Individuelle Produkttemplates', 'wpsg'); 
-			$this->shop->view['templates'] = wpsg_array_merge($this->shop->view['templates'], $this->shop->loadProduktTemplates(true));
-			
-			$pages = get_pages();			
-			$arPages = array(
-				'-1' => __('Nicht zugeordnet', 'wpsg')
-			);			
-			foreach ($pages as $k => $v)
-			{
-				$arPages[$v->ID] = $v->post_title.' (ID:'.$v->ID.')';
-			}			
-			$this->shop->view['pages'] = $arPages;	
-			
-		} // public function addeditAction()
-		 		
-		public function checkPgroupsBestand($produkt, &$menge, &$menge_neu)
-		{
-			
-			if (preg_match('/(vp_)|(\/(.*))/', $produkt['id']))
-			{
-				$pID = preg_replace('/(vp_)|(\/(.*))/', '', $produkt['id']);
-			}
-			else 
-			{
-				$pID = $produkt['id'];
-			}
-			
-			$g_id = intval($this->db->fetchOne("SELECT `pgruppe` FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".$pID."'"));
-			
-			$pgroups_stock = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS_GROUP."` WHERE `id` = '".$g_id."'");
-			
-			if ($pgroups_stock['stock_aktiv'] != '1') { return; }
-			
-			if ($menge_neu >= intval($pgroups_stock['stock_value']))
-			{
-				
-				if ($this->shop->get_option('wpsg_mod_stock_allow') != '1')
-				{
-					$this->shop->addFrontendError(__('Menge ÃŒberschreitet Warenbestand!', 'wpsg'));	
-				}
-				else
-				{
-					$this->shop->addFrontendError(__('Menge wurde korrigiert, da sie den Warenbestand ÃŒberschreitet!', 'wpsg'));
-					$menge = intval($pgroups_stock['stock_value']);
-					return -1;
-				}
-			}
-		}
-				
-		public function wpsg_mod_productgroups_addedit_sidebar(&$productgroupdata) 
-		{
-			
-			$this->shop->view['wpsg_mod_productgroups']['data'] = $productgroupdata;
-
-			if (wpsg_isSizedInt($this->shop->view['wpsg_mod_productgroups']['data']['stock_aktiv'])) { $this->shop->view['wpsg_mod_productgroups']['data']['stock_aktiv'] = true; }
-
-			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/productgroups_addedit_sidebar.phtml');	
-			
-		} // public function wpsg_mod_productgroups_addedit_sidebar(&$productgroupdata)
-		
-	} // class wpsg_mod_productgroups extends wpsg_mod_basic
-
-?>
Index: /system/intern/mods/mod_productgroups/wpsg_productgroup.php
===================================================================
--- /system/intern/mods/mod_productgroups/wpsg_productgroup.php	(revision 5990)
+++ /system/intern/mods/mod_productgroups/wpsg_productgroup.php	(revision 5990)
@@ -0,0 +1,159 @@
+<?php
+
+    /**
+     * Model fÃŒr Zugriff auf die Produktgruppen
+     */
+
+    class wpsg_productgroup extends wpsg_model
+    {
+
+	    /**
+		 * LÃ€dt die Daten der Produktgruppe
+		 */
+		public function load($productgroup_id)
+		{
+
+			parent::load($productgroup_id);
+
+			$this->data = $this->db->fetchRow("
+				SELECT 
+					PG.*,
+					(SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE P.`pgruppe` = PG.`id`) AS `product_count` 
+				FROM
+					`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
+				WHERE
+					PG.`id` = '".wpsg_q($productgroup_id)."' 
+			");
+
+			if ($this->data['id'] != $productgroup_id || !wpsg_isSizedInt($productgroup_id)) return false;
+
+			return true;
+
+		} // public function __construct($customer_group_id)
+
+	    public function countProducts()
+	    {
+		    
+		    return $this->product_count;
+		    
+	    }
+	    
+        /* Statische Funktionen */
+
+	    public static function getProductgroupSelect()
+	    {
+
+		    return $GLOBALS['wpsg_db']->fetchAssocField("
+		        SELECT
+		            PG.`id`, CONCAT(PG.`name`,' (', (
+		            	SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE P.`pgruppe` = PG.`id` 
+		            ), ')') AS `name` ,
+		            (SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE P.`pgruppe` = PG.`id`) AS `product_count`
+		        FROM
+		        	`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
+		        HAVING
+		            `product_count` > 0
+		        ORDER BY
+		            `name` ASC
+		    ", "id", "name");
+
+	    } // public static function getProductgroupSelect()
+
+        /**
+		 * ZÃ€hlt die Bestellungen anhand des Filters
+		 */
+		public static function count($arFilter)
+		{
+
+			list($strQuerySELECT, $strQueryWHERE, $strQueryJOIN, $strQueryHAVING, $strQueryORDER) = self::getQueryParts($arFilter);
+
+			$strQuery = "
+				SELECT
+					COUNT(*)
+				FROM
+					(
+						SELECT
+						  	DISTINCT PG.`id`
+						FROM
+							`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
+							".$strQueryJOIN."
+						WHERE
+							1
+							".$strQueryWHERE." 
+						HAVING
+							1
+							".$strQueryHAVING."											
+					) AS innerSelect
+			";
+
+			return $GLOBALS['wpsg_db']->fetchOne($strQuery);
+
+		} // public static function count($arFilter)
+
+		public static function find($arFilter = array())
+		{
+
+			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
+					PG .`id`
+					".$strQuerySELECT."
+				FROM
+					`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
+				WHERE
+					1
+					".$strQueryWHERE."
+				HAVING
+					1
+					".$strQueryHAVING."
+				ORDER BY
+					".$strQueryORDER."		
+				".$strLimit."
+			";
+
+			$arCustomerID = $GLOBALS['wpsg_db']->fetchAssocField($strQuery);
+			$arReturn = array();
+
+			foreach ($arCustomerID as $customer_id)
+			{
+
+				$arReturn[$customer_id] = self::getInstance($customer_id);
+
+			}
+
+			return $arReturn;
+
+		} // public function find($arQuery = array())
+
+		public static function getQueryParts($arFilter = array())
+		{
+
+			$strQuerySELECT = "";
+			$strQueryWHERE = "";
+			$strQueryJOIN = "";
+			$strQueryHAVING = ""; 
+
+			if (wpsg_isSizedString($arFilter['order'], 'name')) { $strQueryORDER = " PG.`name` "; }
+			else if (wpsg_isSizedString($arFilter['order'], 'template_file')) { $strQueryORDER = " PG.`template_file` "; }
+			else if (wpsg_isSizedString($arFilter['order'], 'product_count')) {
+
+				$strQuerySELECT .= ", (SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE P.`pgruppe` = PG.`id`) AS `product_count`) ";
+				$strQueryORDER = " `product_count` ";
+
+			}
+			else $strQueryORDER = " PG.`id` ";
+
+			// Richtung
+			if (wpsg_isSizedString($arFilter['ascdesc'], "DESC")) $strQueryORDER .= " DESC ";
+			else $strQueryORDER .= " ASC ";
+
+			return array($strQuerySELECT, $strQueryWHERE, $strQueryJOIN, $strQueryHAVING, $strQueryORDER);
+
+		} // public function getQueryParts($arFilter = array())
+
+    }
Index: /system/intern/mods/wpsg_mod_productgroups.class.php
===================================================================
--- /system/intern/mods/wpsg_mod_productgroups.class.php	(revision 5990)
+++ /system/intern/mods/wpsg_mod_productgroups.class.php	(revision 5990)
@@ -0,0 +1,820 @@
+<?php
+
+	/**
+	 * Modul fÃŒr die Produktgruppenverwaltung
+	 * @author daniel
+	 */
+	class wpsg_mod_productgroups extends wpsg_mod_basic 
+	{
+		
+		var $lizenz = 1;
+		var $id = 9;
+		var $hilfeURL = 'http://wpshopgermany.de/?p=868';
+		
+		/**
+		 * Costructor
+		 */
+		public function __construct()
+		{
+			
+			parent::__construct();
+			
+			$this->name = __('Produktgruppen', 'wpsg');
+			$this->group = __('Produkte', 'wpsg');
+			$this->desc = __('ErmÃ¶glicht die Zuordnung von Produkten zu Produktgruppen.', 'wpsg');
+									
+		} // public function __construct()
+		 
+		public function install()
+		{
+			
+			require_once(WPSG_PATH_WP.'/wp-admin/includes/upgrade.php');
+					
+			/**
+			 * Produktgruppentabelle anlegen
+			 */ 
+			$sql = "CREATE TABLE ".WPSG_TBL_PRODUCTS_GROUP." (
+		   		id mediumint(9) NOT NULL AUTO_INCREMENT,
+		   		cdate datetime NOT NULL,
+		   		name VARCHAR(255) NOT NULL,
+		   		template_file VARCHAR(255) NOT NULL,
+		   		infopage INT(11) NOT NULL,
+		   		deleted INT(1) NOT NULL,
+		   		rabatt TEXT(255) NOT NULL,
+		   		stock_aktiv VARCHAR(255) NOT NULL,
+		   		stock_value INT(11) NOT NULL,
+				lang TEXT NOT NULL,
+		   		PRIMARY KEY  (id)
+		   	) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
+   	   	 
+   			dbDelta($sql);
+   			
+   			/**
+		   	 * Tabelle fÃŒr die Sticky Produkte
+		   	 */
+		   	$sql = "CREATE TABLE ".WPSG_TBL_PRODUCTS_STICKY." (
+		   		id mediumint(9) NOT NULL AUTO_INCREMENT,
+		   		produkt_id INT(11) NOT NULL,
+		   		von INT NOT NULL,
+		   		bis INT NOT NULL,
+		   		PRIMARY KEY  (id)
+		   	) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
+		   	
+		   	dbDelta($sql);
+			
+		} // public function install()
+		
+		public function init()
+		{
+
+			require_once(WPSG_PATH_MOD.'mod_productgroups/wpsg_productgroup.php');
+			
+			$role_object = get_role('administrator');
+			$role_object->add_cap('wpsg_productgroup');
+			
+		} // public function init()
+		
+		public function settings_edit() 
+		{
+			
+			$pages = get_pages();
+			
+			$arPages = array(
+				'-1' => __('Nicht zugeordnet', 'wpsg')
+			);
+			
+			foreach ($pages as $k => $v)
+			{
+				$arPages[$v->ID] = $v->post_title.' (ID:'.$v->ID.')';
+			}
+			
+			$this->shop->view['pages'] = $arPages;			
+			
+			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/settings_edit.phtml');
+			
+		} // public function settings_edit()
+		
+		public function settings_save() 
+		{
+			
+			$this->shop->update_option('wpsg_productgroups_page', $_REQUEST['wpsg_productgroups_page']);
+			$this->shop->update_option('wpsg_productgroups_order', $_REQUEST['wpsg_productgroups_order']);
+			
+		} // public function settings_save()
+		
+		public function admin_setcapabilities() { 
+			
+			$this->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/admin_setcapabilities.phtml');
+			
+		} // public function admin_setcapabilities()
+		
+		public function wpsg_add_pages()
+		{
+						
+			add_submenu_page('wpsg-Admin', __("Produktgruppen", "wpsg"), __("Produktgruppen", "wpsg"), 'wpsg_productgroup', 'wpsg-Productgroups', array($this, 'dispatch'));
+			
+		} // public function wpsg_add_pages()
+						
+		public function produkt_del($produkt_id) 
+		{ 
+
+			$this->db->Query("DELETE FROM `".WPSG_TBL_PRODUCTS_STICKY."` WHERE `produkt_id` = '".wpsg_q($produkt_id)."'");
+			
+		} // public function produkt_del($produkt_id)
+		
+		public function shortcode($atts)
+		{
+
+			// [wpshopgermany produktgruppe="1" sortierung="id" richtung="asc"]
+			
+			$pg_id = $atts['produktgruppe'];
+			$pg_template = $this->db->fetchOne("SELECT `template_file` FROM `".WPSG_TBL_PRODUCTS_GROUP."` WHERE `id` = '".wpsg_q($pg_id)."'");
+			
+			$arSortierung = Array('id', 'name', 'anr', 'preis');
+			$arDirection = Array('asc', 'desc');
+			
+			$strOrder = 'sticky DESC, ';
+			
+			if (isset($atts['sortierung']) && in_array($atts['sortierung'], $arSortierung))
+			{
+					
+				$strOrder .= 'P.`'.wpsg_q($atts['sortierung']).'`';
+				
+				if (isset($atts['richtung']) && in_array($atts['richtung'], $arDirection))
+				{
+					
+					$strOrder .= ' '.wpsg_q($atts['richtung']);
+					
+				}
+				else
+				{
+					
+					$strOrder .= ' ASC';
+					
+				}
+								
+			}
+			else
+			{
+				
+				$strOrder .= 'P.`id` ASC';
+				
+			}
+			
+			$arProduktIDs = $this->db->fetchAssocField("
+				SELECT 
+					P.`id`,
+					IF (
+						(SELECT PS.`id` FROM `".WPSG_TBL_PRODUCTS_STICKY."` AS PS WHERE PS.`produkt_id` = P.`id` AND  UNIX_TIMESTAMP(NOW()) BETWEEN `von` AND `bis`) > 0,
+						'1',
+						'0'
+					) AS sticky
+				FROM 
+					`".WPSG_TBL_PRODUCTS."` AS P
+				WHERE 
+					P.`pgruppe` = '".wpsg_q($pg_id)."' AND 
+					P.`deleted` != '1' AND 
+					P.`lang_parent` <= 0
+				ORDER BY
+					".$strOrder."
+			");
+						
+			if ($pg_template !== '0' && $pg_template !== '') $template = $pg_template; else $template = false;
+			
+			$strReturn = '';			
+			foreach ((array)$arProduktIDs as $p_id)
+			{
+				
+				//if ($pg_template !== '0' && $pg_template !== '') $template = $pg_template; else $template = $this->db->fetchOne("SELECT `ptemplate_file` FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".wpsg_q($p_id)."'");
+				
+				$strReturn .= $this->shop->renderProdukt($p_id, $template);
+				
+			}
+			
+			return $strReturn;
+			
+		} // public function shortcode($atts)
+
+		/**
+		 * Integriert den Namen der Gruppe in das Produktarray
+		 */
+		public function loadProduktArray(&$arrProdukt)
+		{
+			
+			$arrGrp = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS_GROUP."` WHERE `id` = '".wpsg_q($arrProdukt['pgruppe'])."'");
+			
+			if ($this->shop->isOtherLang())
+			{
+				
+				$lang = @unserialize($arrGrp['lang']);
+				
+				if (is_array($lang) && wpsg_isSizedString($lang[$this->shop->getCurrentLanguage()]['name'])) $arrGrp['name'] = $lang[$this->shop->getCurrentLanguage()]['name'];
+				
+			}
+			
+			$arrProdukt['pgruppe_name'] = $arrGrp['name'];
+			
+			// ?? Scheint zu funktionieren
+			$arrProdukt['rabatt'] = $arrGrp['rabatt'];	
+		
+		}
+		
+		public function produkt_save(&$produkt_id) 
+		{
+				
+			$sticky_id = $this->db->fetchOne("SELECT `id` FROM `".WPSG_TBL_PRODUCTS_STICKY."` WHERE `produkt_id` = '".wpsg_q($produkt_id)."'");
+
+			$data = array(
+				'produkt_id' => wpsg_q($produkt_id),
+				'von' => wpsg_q(strtotime($_REQUEST['wpsg_productgroup_sticky_von'])),
+				'bis' => wpsg_q(strtotime($_REQUEST['wpsg_productgroup_sticky_bis']))
+			);
+			
+			if ($sticky_id > 0)
+			{
+				$this->db->UpdateQuery(WPSG_TBL_PRODUCTS_STICKY, $data, "`id` = '".wpsg_q($sticky_id)."'");
+			}
+			else
+			{
+				$this->db->ImportQuery(WPSG_TBL_PRODUCTS_STICKY, $data);
+			}
+			
+			$data = array(
+				'pgruppe' => wpsg_q($_REQUEST['wpsg_productgroup'])
+			);
+			
+			$this->db->UpdateQuery(WPSG_TBL_PRODUCTS, $data, "`id` = '".wpsg_q($produkt_id)."'");
+			
+		} // public function produkt_save($produkt_id)
+		
+		public function produkt_copy(&$produkt_id, &$copy_id) 
+		{ 
+			
+			$arSticky = $this->db->fetchAssoc("SELECT * FROM `".WPSG_TBL_PRODUCTS_STICKY."` WHERE `produkt_id` = '".wpsg_q($produkt_id)."'");
+			
+			foreach ((array)$arSticky as $s)
+			{
+				
+				unset($s['id']);
+				$s['produkt_id'] = wpsg_q($copy_id);
+				
+				$this->db->ImportQuery(WPSG_TBL_PRODUCTS_STICKY, $s);
+				
+			}
+			
+		} // public function produkt_copy(&$produkt_id, &$copy_id)
+		
+		public function product_addedit_content(&$product_content, &$product_data)
+		{
+		
+			if (wpsg_isSizedInt($product_data['id']))
+			{
+					
+				if (isset($_REQUEST['wpsg_lang'])) return;
+			
+				$this->shop->view['wpsg_mod_productgroups']['produkt_data'] = $product_data;
+				$this->shop->view['wpsg_mod_productgroups']['data'] = array();
+				$this->shop->view['wpsg_mod_productgroups']['data'][0] = __('Nicht zugewiesen.', 'wpsg'); 
+				
+				// Kein Array Merge ! Da indexe gelÃ¶scht werden
+				$groups_db = $this->db->fetchAssocField("
+					SELECT
+						PG.`id`, PG.`name`
+					FROM
+						`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
+					WHERE
+						PG.`deleted` != '1'
+					ORDER BY
+						`id` ASC
+				", "id", "name");
+				$this->shop->view['wpsg_mod_productgroups']['data'] = array_diff_key($this->shop->view['wpsg_mod_productgroups']['data'], $groups_db) + $groups_db;
+				
+				$sticky_data = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS_STICKY."` WHERE `produkt_id` = '".wpsg_q($product_data['id'])."'");
+							
+				if ($sticky_data['von'] > 0) $this->shop->view['wpsg_mod_productgroups']['sticky_von'] = date('d.m.Y', $sticky_data['von']);
+				if ($sticky_data['bis'] > 0) $this->shop->view['wpsg_mod_productgroups']['sticky_bis'] = date('d.m.Y', $sticky_data['bis']);;
+						
+			}
+			
+			$product_content['wpsg_mod_productgroups'] = array(
+				'title' => __('Produktgruppen', 'wpsg'),
+				'content' => $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/produkt_addedit_sidebar.phtml', false)
+			);
+		
+		} // public function produkt_edit_sidebar(&$product_content, &$produkt_data)
+		
+		public function content_filter(&$content) 
+		{
+			
+			if (get_the_id() <= 0 || get_the_id() != $this->shop->get_option('wpsg_productgroups_page')) return;
+
+			if ($_REQUEST['show'] > 0)
+			{
+
+				$arrGrp = $this->db->fetchRow("
+					SELECT
+						*
+					FROM
+						`".WPSG_TBL_PRODUCTS_GROUP."`
+					WHERE
+						`id` = '".wpsg_q($_REQUEST['show'])."' AND
+						`deleted` = '0'
+					ORDER BY
+						`name`			
+				");
+
+				if ($this->shop->isOtherLang())
+				{
+					
+					$lang = @unserialize($arrGrp['lang']);
+					
+					if (is_array($lang) && wpsg_isSizedString($lang[$this->shop->getCurrentLanguage()]['name'])) $arrGrp['name'] = $lang[$this->shop->getCurrentLanguage()]['name']; 
+					
+				}
+	
+				$strOrder = "sticky DESC";
+				if ($this->shop->get_option('wpsg_productgroups_order') != '')
+				{
+							
+					switch ($this->shop->get_option('wpsg_productgroups_order'))
+					{
+									
+						case 'id':
+							$strOrder .= ", P.`id` ASC ";
+							break;
+						case 'alphabetisch':
+							$strOrder .= ", P.`name` ASC ";
+							break;		
+						case 'buyed':
+							$strOrder .= ", `buyed` DESC ";
+							break;	
+						case 'erstellungsdatum':
+							$strOrder .= ", `cdate` DESC ";
+							break;
+						case 'preis':
+							$strOrder .= ", `preis` DESC ";
+							break;			
+									
+					}
+								
+				}
+				 
+				if ($strOrder != "") $strOrder = " ORDER BY ".$strOrder;
+				
+				$arrProdukte = $this->shop->db->fetchAssoc("SELECT 
+						P.`id`,
+						(IF('".time()."' > PS.`von` AND '".time()."' < PS.`bis`, 1, 0)) AS sticky, 
+						(SELECT SUM(`menge`) FROM `".WPSG_TBL_ORDERPRODUCT."` AS OP WHERE OP.`p_id` = P.`id`) AS buyed 
+					FROM 
+						`".WPSG_TBL_PRODUCTS."` AS P
+							LEFT JOIN `".WPSG_TBL_PRODUCTS_STICKY."` AS PS ON (P.`id` = PS.`produkt_id`)
+					WHERE 
+						P.`pgruppe` = '".wpsg_q($arrGrp['id'])."' AND 
+						P.`deleted` = '0' 
+					".$strOrder."
+				");
+
+				// Bilder der Produkte
+				foreach ($arrProdukte as $k => $p)
+				{
+					
+					$arrProdukte[$k] = $this->shop->loadProduktArray($p['id']);
+											
+					$arFiles = array();
+						
+					$dir = $this->shop->callMod('wpsg_mod_produktbilder', 'getPicPath', array($this->shop->getProduktId($p['id'])));
+						
+					//$dir = WP_CONTENT_DIR.'/uploads/produktbilder/'.$p['id']."/";
+						
+					$handle = opendir($dir);
+		 
+					while($filename = readdir($handle))
+			   		{
+			   				
+			   			$file = $dir.$filename; 
+			   			if (is_file($file) && $filename != "." && $filename != "..")
+			   			{
+			   				$arFiles[] = $filename;
+			   			}
+			   				   				   				   				   				
+			   		}
+			   		$arrProdukte[$k]['bilder'] = $arFiles;		   			
+							
+				}
+
+				$this->shop->view['data'] = $arrGrp;
+				$this->shop->view['data']['produkte'] = $arrProdukte;
+								
+				$content = $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/show.phtml', false);
+				
+			}
+			else 
+			{
+				
+				$arrGrp = $this->db->fetchAssoc("
+					SELECT
+						*
+					FROM
+						`".WPSG_TBL_PRODUCTS_GROUP."`
+					WHERE
+						`deleted` = '0'
+					ORDER BY
+						`name`			
+				");
+				
+				foreach ($arrGrp as $k => $pg)
+				{
+					
+					if ($this->shop->isOtherLang())
+					{
+						
+						$lang = @unserialize($pg['lang']);
+						
+						if (is_array($lang) && wpsg_isSizedString($lang[$this->shop->getCurrentLanguage()]['name'])) $pg['name'] = $lang[$this->shop->getCurrentLanguage()]['name'];
+						
+					}
+					
+					$strOrder = "sticky DESC";
+					
+					if ($this->shop->get_option('wpsg_productgroups_order') != '')
+					{
+								
+						switch ($this->shop->get_option('wpsg_productgroups_order'))
+						{
+									
+							case 'id':
+								$strOrder .= ", P.`id` ASC ";
+								break;
+							case 'alphabetisch':
+								$strOrder .= ", P.`name` ASC ";
+								break;		
+							case 'buyed':
+								$strOrder .= ", `buyed` DESC ";
+								break;	
+							case 'erstellungsdatum':
+								$strOrder .= ", `cdate` DESC ";
+								break;
+							case 'preis':
+								$strOrder .= ", `preis` DESC ";
+								break;			
+									
+						}
+								
+					}
+					
+					if ($strOrder != "") $strOrder = " ORDER BY ".$strOrder;
+				 
+					$arrProdukte = array();
+					$arrProdukte = $this->db->fetchAssoc("SELECT 
+															P.`id`, 
+															(IF('".time()."' > PS.`von` AND '".time()."' < PS.`bis`, 1, 0)) AS sticky, 
+															(SELECT SUM(`menge`) FROM `".WPSG_TBL_ORDERPRODUCT."` AS OP WHERE OP.`p_id` = P.`id`) AS buyed 
+														FROM 
+															`".WPSG_TBL_PRODUCTS."` AS P		
+																	LEFT JOIN `".WPSG_TBL_PRODUCTS_STICKY."` AS PS ON (P.`id` = PS.`produkt_id`)					
+														WHERE 
+															P.`pgruppe` = '".wpsg_q($pg['id'])."' AND 
+															P.`deleted` = '0' 
+														".$strOrder."
+													");
+					
+					// Bilder der Produkte
+					foreach ($arrProdukte as $k2 => $p)
+					{
+						
+						$arrProdukte[$k2] = $this->shop->loadProduktArray($p['id']);
+						
+						$arFiles = array();
+						
+						$dir = $this->shop->callMod('wpsg_mod_produktbilder', 'getPicPath', array($this->shop->getProduktId($p['id'])));
+						
+						$handle = opendir($dir);
+		 				
+						while($filename = readdir($handle))
+			   			{
+			   				
+			   				$file = $dir.$filename; 
+			   				if (is_file($file) && $filename != "." && $filename != "..")
+			   				{
+			   					$arFiles[] = $filename;
+			   				}
+			   				   				   				   				   				
+			   			}
+			   			
+			   			$arrProdukte[$k2]['bilder'] = $arFiles;
+					}
+					$this->shop->view['data'][$pg['id']]['produkte'] = $arrProdukte;
+					$this->shop->view['data'][$pg['id']]['pgruppe_name'] = $pg['name'];
+					
+				}
+				
+				$content = $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/list.phtml', false);
+				
+			}
+			
+			return -2;
+			
+		}
+		
+		public function wpsg_mod_export_loadFields(&$arFields) 
+		{ 
+
+			$arFields[20]['fields']['pgruppe_id'] = __('Produktgruppe ID', 'wpsg');
+			$arFields[20]['fields']['pgruppe_name'] = __('Produktgruppe Name', 'wpsg');
+			
+		} // public function wpsg_mod_export_loadFields(&$arFields)
+		
+		public function wpsg_mod_export_getValue(&$return, $field_value, $o_id, $p_id, $productkey, $product_index, $profil_separator) 
+		{ 
+ 
+			if (wpsg_isSizedInt($o_id) && !wpsg_isSizedInt($p_id))
+			{
+				
+				$product_db = $this->db->fetchRow("
+					SELECT
+						GROUP_CONCAT(P.`pgruppe`) AS `pgruppe`,
+						GROUP_CONCAT(PG.`name`) AS `pgruppe_name`
+					FROM
+						`".WPSG_TBL_ORDERPRODUCT."` AS OP 
+							LEFT JOIN `".WPSG_TBL_PRODUCTS."` AS P ON (OP.`p_id` = P.`id`)
+							LEFT JOIN `".WPSG_TBL_PRODUCTS_GROUP."` AS PG ON (PG.`id` = P.`pgruppe`)
+					WHERE
+						OP.`o_id` = '".wpsg_q($o_id)."'
+					GROUP BY
+						P.`id`
+				");
+				 				
+			}
+			else if (wpsg_isSizedInt($p_id))
+			{
+				
+				$product_db = $this->shop->cache->loadProduct($p_id);
+				$product_db['pgruppe_name'] = $this->db->fetchOne("SELECT `name` FROM `".WPSG_TBL_PRODUCTS_GROUP."` WHERE `id` = '".wpsg_q($product_db['pgruppe'])."' ");
+				
+			}
+			else
+			{
+				return;
+			}
+			
+			switch ($field_value)
+			{
+				
+				case 'pgruppe_id': $return = $product_db['pgruppe']; break;
+				case 'pgruppe_name': $return = $product_db['pgruppe_name']; break;
+				
+			}
+			
+		} // public function wpsg_mod_export_getValue(&$return, $field_value, $o_id, $p_id, $productkey, $product_index, $profil_separator)
+		
+		/* -- */
+		
+		/**
+		 * Gibt einen Array mit allen Produktgruppen zurÃŒck und beachtet die Ãbersetzung
+		 */
+		public function getAllProductGroups()
+		{
+			
+			$arPG = $this->db->fetchAssocField("
+				SELECT
+					PG.`id`, PG.`name`
+				FROM
+					`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
+				WHERE
+					PG.`deleted` != '1'
+				ORDER BY
+					PG.`name` ASC	
+			", "id", "name");
+			
+			if ($this->shop->isOtherLang())
+			{
+				
+				foreach ($arPG as $k => $pg)
+				{
+					
+					$lang = @unserialize($pg['lang']);
+					
+					if (is_array($lang) && wpsg_isSizedString($lang[$this->shop->getCurrentLanguage()]['name'])) $arPG['name'] = $lang[$this->shop->getCurrentLanguage()]['name'];
+					
+				}
+				
+			}
+						
+			return $arPG;
+			
+		} // public function getAllProductGroups()
+		
+		public function dispatch()
+		{
+			 
+			if (isset($_REQUEST['wpsg_mod_action']) && $_REQUEST['wpsg_mod_action'] == "add")
+			{
+				$this->addAction();	
+			}
+			else if (isset($_REQUEST['wpsg_mod_action']) && $_REQUEST['wpsg_mod_action'] == "edit")
+			{
+				$this->editAction();
+			}
+			else if (isset($_REQUEST['wpsg_mod_action']) && $_REQUEST['wpsg_mod_action'] == "del")
+			{
+				$this->delAction();
+			}
+			else if (isset($_REQUEST['wpsg_mod_action']) && $_REQUEST['wpsg_mod_action'] == "save")
+			{
+				$this->saveAction();
+			}
+			else
+			{	
+				$this->indexAction();				
+			}
+			
+		} // public function dispatch()
+		
+		public function indexAction()
+		{
+
+			$nPerPage = 25;
+			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']['customergroup']['arFilter']))
+			{
+
+				//$this->shop->view['arFilter'] = $_SESSION['wpsg']['backend']['customer']['arFilter'];
+
+			}
+
+			$this->shop->view['countAll'] = wpsg_productgroup::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']['customergroup']['arFilter'] = $this->shop->view['arFilter'];
+
+			$this->shop->view['arData'] = wpsg_productgroup::find($this->shop->view['arFilter']);
+
+			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/index.phtml');
+			
+		} // public function indexAction()
+		
+		public function delAction()
+		{
+			
+			$this->db->Query("DELETE FROM `".WPSG_TBL_PRODUCTS_GROUP."` WHERE `id` = '".wpsg_q($_REQUEST['edit_id'])."'");
+			$this->shop->addBackendMessage(__('Produktgruppe wurde erfolgreich gelÃ¶scht.', 'wpsg'));
+			
+			$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=index');
+			
+		} // public function delAction()
+		
+		public function saveAction()
+		{
+
+			$data = array(
+				'name' => wpsg_q($_REQUEST['wpsg_mod_productgroups_name']),
+				'template_file' => wpsg_q($_REQUEST['wpsg_mod_productgroups_template']),
+				'infopage' => wpsg_q($_REQUEST['wpsg_mod_productgroups_infopage']),
+				'stock_aktiv' => wpsg_q($_REQUEST['wpsg_mod_productgroups']['stock_aktiv']),
+				'stock_value' => wpsg_q($_REQUEST['wpsg_mod_productgroups']['stock_value']),
+				'lang' => wpsg_q(serialize($_REQUEST['lang']))			
+			);
+			
+			if ($_REQUEST['edit_id'] > 0)
+			{
+				
+				$this->db->UpdateQuery(WPSG_TBL_PRODUCTS_GROUP, $data, "`id` = '".wpsg_q($_REQUEST['edit_id'])."'");
+				$this->shop->addBackendMessage(__('Produktgruppe erfolgreich gespeichert.', 'wpsg'));
+				
+			}
+			else
+			{
+				
+				$data['cdate'] = "NOW()";
+				$_REQUEST['edit_id'] = $this->db->ImportQuery(WPSG_TBL_PRODUCTS_GROUP, $data);
+				$this->shop->addBackendMessage(__('Produktgruppe erfolgreich angelegt.', 'wpsg'));
+				
+			}
+						
+			$this->shop->callMods('wpsg_mod_productgroups_save', array($_REQUEST['edit_id']));
+			
+			if (isset($_REQUEST['submit_index'])) $this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=index');
+			else $this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=edit&edit_id='.$_REQUEST['edit_id']);
+			
+		} // public function saveAction()
+		
+		public function editAction()
+		{
+			
+			$this->shop->view['data'] = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS_GROUP."` WHERE `id` = '".wpsg_q($_REQUEST['edit_id'])."'");
+			$this->shop->view['data']['lang'] = @unserialize($this->shop->view['data']['lang']);
+			if (!is_array($this->shop->view['data']['lang'])) $this->shop->view['data']['lang'] = array();
+			$this->shop->view['languages'] = $this->shop->getStoreLanguages();
+			
+			$this->addeditAction();
+			
+			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/add.phtml');
+			
+		} // public function editAction()
+		
+		public function addAction()
+		{
+			
+			$this->addeditAction();
+			$this->shop->view['data'] = array(
+				'name' => '',
+				'template_file' => '',
+				'infopage' => ''
+			);
+
+			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/add.phtml');
+			
+		} // public function addAction()
+		
+		public function addeditAction()
+		{
+			
+			$this->shop->view['templates'] = array();
+			$this->shop->view['templates'][0] = __('Individuelle Produkttemplates', 'wpsg'); 
+			$this->shop->view['templates'] = wpsg_array_merge($this->shop->view['templates'], $this->shop->loadProduktTemplates(true));
+			
+			$pages = get_pages();			
+			$arPages = array(
+				'-1' => __('Nicht zugeordnet', 'wpsg')
+			);			
+			foreach ($pages as $k => $v)
+			{
+				$arPages[$v->ID] = $v->post_title.' (ID:'.$v->ID.')';
+			}			
+			$this->shop->view['pages'] = $arPages;	
+			
+		} // public function addeditAction()
+		 		
+		public function checkPgroupsBestand($produkt, &$menge, &$menge_neu)
+		{
+			
+			if (preg_match('/(vp_)|(\/(.*))/', $produkt['id']))
+			{
+				$pID = preg_replace('/(vp_)|(\/(.*))/', '', $produkt['id']);
+			}
+			else 
+			{
+				$pID = $produkt['id'];
+			}
+			
+			$g_id = intval($this->db->fetchOne("SELECT `pgruppe` FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".$pID."'"));
+			
+			$pgroups_stock = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS_GROUP."` WHERE `id` = '".$g_id."'");
+			
+			if ($pgroups_stock['stock_aktiv'] != '1') { return; }
+			
+			if ($menge_neu >= intval($pgroups_stock['stock_value']))
+			{
+				
+				if ($this->shop->get_option('wpsg_mod_stock_allow') != '1')
+				{
+					$this->shop->addFrontendError(__('Menge ÃŒberschreitet Warenbestand!', 'wpsg'));	
+				}
+				else
+				{
+					$this->shop->addFrontendError(__('Menge wurde korrigiert, da sie den Warenbestand ÃŒberschreitet!', 'wpsg'));
+					$menge = intval($pgroups_stock['stock_value']);
+					return -1;
+				}
+			}
+		}
+				
+		public function wpsg_mod_productgroups_addedit_sidebar(&$productgroupdata) 
+		{
+			
+			$this->shop->view['wpsg_mod_productgroups']['data'] = $productgroupdata;
+
+			if (wpsg_isSizedInt($this->shop->view['wpsg_mod_productgroups']['data']['stock_aktiv'])) { $this->shop->view['wpsg_mod_productgroups']['data']['stock_aktiv'] = true; }
+
+			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_productgroups/productgroups_addedit_sidebar.phtml');	
+			
+		} // public function wpsg_mod_productgroups_addedit_sidebar(&$productgroupdata)
+		
+	} // class wpsg_mod_productgroups extends wpsg_mod_basic
+
+?>
Index: /system/intern/views/mod_productgroups/add.phtml
===================================================================
--- /system/intern/views/mod_productgroups/add.phtml	(revision 5990)
+++ /system/intern/views/mod_productgroups/add.phtml	(revision 5990)
@@ -0,0 +1,79 @@
+<?php
+
+	/**
+	 * Template fÃŒr das Anlegen/Bearbeiten einer Produktgruppe
+	 */
+
+?>
+
+<div class="wpsg_productgroups" id="wpsg-bs">
+
+    <nav class="navbar navbar-default">
+
+		<div class="container-fluid">
+			<div class="navbar-header">
+				<a class="navbar-brand" href="#"><?php echo __('wpShopGermany', 'wpsg'); ?></a>
+			</div>
+			<div class="collapse navbar-collapse" id="bs-customer-navbar-collapse-1">
+				<ul class="nav navbar-nav">
+					<li role="presentation" class="wpsg-customer-tab-a active"><a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=index"><?php echo __("Produktgruppenverwaltung", "wpsg"); ?></a></li>
+                    <li role="presentation" class="active"><a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=add"><span class="glyphicon glyphicon-plus"></span><?php echo __("Produktgruppe anlegen/bearbeiten", "wpsg"); ?></a></li>
+				</ul>
+				<ul class="nav navbar-nav navbar-right">
+				</ul>
+			</div>
+		</div>
+
+    </nav>
+
+    <div class="wpsg_clear"></div>
+
+	<?php echo $this->writeBackendMessage(); ?>
+
+    <form method="POST" action="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=save&noheader=1" enctype="multipart/form-data">
+        <div class="content form-horizontal">
+
+            <div class="row">
+                <div class="col-md-8 col-lg-8">
+
+                    <?php echo wpsg_drawForm_AdminboxStart(__('Allgemein', 'wpsg')); ?>
+
+                        <?php echo wpsg_drawForm_Input('wpsg_mod_productgroups_name', __('Name', 'wpsg'), $this->view['data']['name']); ?>
+
+                        <?php if (wpsg_isSizedArray($this->view['languages'])) { ?>
+                            <?php foreach ($this->view['languages'] as $l) { if ($l['locale'] != $this->getDefaultLanguage()) { ?>
+
+                                <?php echo wpsg_drawForm_Input(
+                                    'lang['.$l['locale'].'][name]',
+                                    __('Name', 'wpsg').'&nbsp;('.$l['name'].'&nbsp;<img src="'.$this->getFlagURL().$l['flag'].'" alt="'.$l['Name'].'" />)',
+                                    $this->view['data']['lang'][$l['locale']]['name']
+                                ); ?>
+
+                            <?php } } ?>
+                        <?php } ?>
+
+                        <?php echo wpsg_drawForm_Select('wpsg_mod_productgroups_template', __('Template', 'wpsg'), $this->view['templates'], $this->view['data']['template_file']); ?>
+                        <?php echo wpsg_drawForm_Select('wpsg_mod_productgroups_infopage', __('Info Seite', 'wpsg'), $this->view['pages'], $this->view['data']['infopage']); ?>
+
+                    <?php echo wpsg_drawForm_AdminboxEnd(); ?>
+
+                </div>
+                <div class="col-md-4 col-lg-4">
+
+                    <?php $this->callMods('wpsg_mod_productgroups_addedit_sidebar', array(&$this->view['data'])); ?>
+
+                </div>
+            </div>
+
+            <input type="submit" value="<?php echo __('Produktgruppe speichern', 'wpsg'); ?>" class="button-primary" id="submit" name="submit" />
+	        <input type="submit" value="<?php echo __('Produktgruppe speichern und zur Ãbersicht', 'wpsg'); ?>" class="button-primary" id="submit_index" name="submit_index" />
+
+        </div>
+
+        <?php if (isset($this->view['data']['id']) && $this->view['data']['id'] > 0) { ?>
+		<input type="hidden" name="edit_id" value="<?php echo $this->view['data']['id']; ?>" />
+		<?php } ?>
+
+    </form>
+
+</div>
Index: /system/intern/views/mod_productgroups/admin_setcapabilities.phtml
===================================================================
--- /system/intern/views/mod_productgroups/admin_setcapabilities.phtml	(revision 5990)
+++ /system/intern/views/mod_productgroups/admin_setcapabilities.phtml	(revision 5990)
@@ -0,0 +1,19 @@
+<?php
+	
+	/**
+	 * Template fÃŒr die Integration in die Verwaltung der Berechtigungen
+	 */
+
+	global $wpdb; $arRoles = get_option($wpdb->prefix."user_roles");
+
+?>
+<tr>
+	<td class="wpsg_col_capname"><?php echo __('Produktgruppen', 'wpsg'); ?></td>
+	<?php foreach ($arRoles as $role_key => $r) { ?>
+	<td class="wpsg_col_cap">
+		<input type="hidden" name="wpsg_cap[<?php echo $role_key; ?>][wpsg_productgroup]" value="0" />
+		<input type="checkbox" <?php echo ((isset($r['capabilities']['wpsg_productgroup']) && $r['capabilities']['wpsg_productgroup'] == "1")?'checked="checked"':''); ?> name="wpsg_cap[<?php echo $role_key; ?>][wpsg_productgroup]" value="1" /> 
+	</td>
+	<?php } ?>
+	<td></td>
+</tr>	
Index: /system/intern/views/mod_productgroups/index.phtml
===================================================================
--- /system/intern/views/mod_productgroups/index.phtml	(revision 5990)
+++ /system/intern/views/mod_productgroups/index.phtml	(revision 5990)
@@ -0,0 +1,151 @@
+<?php
+
+	/**
+	 * Template fÃŒr die ProduktgruppenÃŒbersicht
+	 */
+
+?>
+
+<div class="wpsg_productgroups" id="wpsg-bs">
+
+    <nav class="navbar navbar-default">
+
+		<div class="container-fluid">
+			<div class="navbar-header">
+				<a class="navbar-brand" href="#"><?php echo __('wpShopGermany', 'wpsg'); ?></a>
+			</div>
+			<div class="collapse navbar-collapse" id="bs-customer-navbar-collapse-1">
+				<ul class="nav navbar-nav">
+					<li role="presentation" class="wpsg-customer-tab-a active"><a href="#" onclick="return false;"><?php echo __("Produktgruppenverwaltung", "wpsg"); ?></a></li>
+                    <li role="presentation" class="wpsg-customer-tab-a wpsg_showhide_filter" id="wpsg-customer-tab-0"><a href="#" onclick="return false;"><span class="glyphicon glyphicon-search"></span><?php echo __("Suche", "wpsg"); ?></a></li>
+                    <li role="presentation" class="<?php echo ((wpsg_isSizedString($_REQUEST['action'], 'add'))?'active':''); ?>"><a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=add"><span class="glyphicon glyphicon-plus"></span><?php echo __("HinzufÃŒgen", "wpsg"); ?></a></li>
+				</ul>
+				<ul class="nav navbar-nav navbar-right">
+				</ul>
+			</div>
+		</div>
+
+        <div class="wpsg-filter wpsg-customer-tab wpsg-customer-tab-0 container-fluid form-horizontal" style="display:<?php echo (($this->view['hasFilter'] === true)?'block':'none'); ?>;">
+            <div class="row">
+                <div class="col-lg-4">
+                    <form method="post" id="filter_form">
+
+                        <input id="wpsg_seite" type="hidden" name="filter[page]" value="<?php echo @$this->view['page']; ?>" class="current-page" />
+
+                        <input id="wpsg_order" type="hidden" name="filter[order]" value="<?php echo @$this->view['arFilter']['order']; ?>" />
+                        <input id="wpsg_ascdesc" type="hidden" name="filter[ascdesc]" value="<?php echo @$this->view['arFilter']['ascdesc']; ?>" />
+
+                        <?php echo wpsg_drawForm_Input('filter[s]', __('Suchfeld', 'wpsg'), wpsg_getStr($this->view['arFilter']['s'])); ?>
+
+                        <?php echo wpsg_drawForm_SubmitButton(__('Produktgruppen suchen')); ?><br />
+
+                    </form>
+                </div>
+            </div>
+        </div>
+
+    </nav>
+
+    <?php if ($this->view['pages'] > 1) { ?>
+        <nav class="pagination_wrap">
+            <ul class="pagination">
+                <?php if ($this->view['arFilter']['page'] > 1) { ?>
+                    <li><a onclick="return goPage(<?php echo $this->view['arFilter']['page'] - 1; ?>);" href="#" aria-label="<?php echo __('Vorherige Seite'); ?>"><span aria-hidden="true">&laquo;</span></a></li>
+                <?php } ?>
+                <?php for ($i = 1; $i <= $this->view['pages']; $i ++) { ?>
+                    <li class="<?php echo (($i == $this->view['arFilter']['page'])?'active':''); ?>"><a onclick="return goPage(<?php echo $i; ?>);" href="#"><?php echo $i; ?></a></li>
+                <?php } ?>
+                <?php if ($this->view['arFilter']['page'] + 1 <= $this->view['pages']) { ?>
+                    <li><a onclick="return goPage(<?php echo $this->view['arFilter']['page'] + 1; ?>);" href="#" aria-label="<?php echo __('NÃ€chste Seite'); ?>"><span aria-hidden="true">&raquo;</span></a></li>
+                <?php } ?>
+            </ul>
+        </nav>
+	<?php } ?>
+
+    <div class="wpsg_clear"></div>
+
+	<?php echo $this->writeBackendMessage(); ?>
+
+	<div class="content">
+
+        <?php if (is_array($this->view['arData']) && sizeof($this->view['arData']) > 0) { ?>
+
+            <table class="table wpsg-table-order table-bordered table-hover table-striped wpsg-table-customer">
+                <thead>
+                    <tr>
+                        <th class="wpsg_order col_name" data-order="nr"><?php echo __("Name", 'wpsg'); ?></th>
+                        <th class="wpsg_order col_template" data-order="template"><?php echo __("Template", 'wpsg'); ?></th>
+                        <th class="wpsg_order col_products" data-order="products"><?php echo __("Produkte", 'wpsg'); ?></th>
+                    </tr>
+                </thead>
+                <tbody>
+                    <?php foreach ($this->view['arData'] as $pg) { ?>
+                    <tr>
+                        <td class="col_name">
+                            <strong><a title="<?php echo __("Diese Produktgruppe bearbeiten", "wpsg"); ?>" href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=edit&edit_id=<?php echo $pg->id; ?>" class="row-title"><?php echo $pg->name; ?></a></strong>
+					        <div class="row-actions">
+                                <span class="edit"><a title="<?php echo __("Diese Produktgruppe bearbeiten", "wpsg"); ?>" href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=edit&edit_id=<?php echo $pg->id; ?>"><?php echo __("Bearbeiten", "wpsg"); ?></a>
+                                |
+                                <span class="del"><a onclick="if (!confirm('<?php echo __("Sind Sie sich sicher?", "wpsg"); ?>')) return false;" title="<?php echo __("Diese Produktgruppe lÃ¶schen", "wpsg"); ?>" href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=del&noheader=1&edit_id=<?php echo $pg->id; ?>"><?php echo __("LÃ¶schen", "wpsg"); ?></a>
+                                <?php if ($pg->countProducts() > 0) { ?>
+                                |
+                                <span class="edit"><a title="<?php echo __("Zur Produktliste", "wpsg"); ?>" href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt&search[pgruppe]=<?php echo $pg->id; ?>"><?php echo __("Zur Produktliste", "wpsg"); ?></a>
+                                <?php } ?>
+                            </div>
+                        </td>
+                        <td class="col_template">
+                            <?php echo (($pg->template_file == "0")?'Individuelle Produkttemplates':$pg->template_file); ?>
+                        </td>
+                        <td class="col_products">
+                            <?php echo $pg->countProducts(); ?>
+                        </td>
+                    </tr>
+                    <?php } ?>
+                </tbody>
+            </table>
+
+            <?php if ($this->view['pages'] > 1) { ?>
+                <nav class="pagination_wrap pagination_wrap_bottom">
+                    <ul class="pagination">
+                        <?php if ($this->view['arFilter']['page'] > 1) { ?>
+                            <li><a onclick="return goPage(<?php echo $this->view['arFilter']['page'] - 1; ?>);" href="#" aria-label="<?php echo __('Vorherige Seite'); ?>"><span aria-hidden="true">&laquo;</span></a></li>
+                        <?php } ?>
+                        <?php for ($i = 1; $i <= $this->view['pages']; $i ++) { ?>
+                            <li class="<?php echo (($i == $this->view['arFilter']['page'])?'active':''); ?>"><a onclick="return goPage(<?php echo $i; ?>);" href="#"><?php echo $i; ?></a></li>
+                        <?php } ?>
+                        <?php if ($this->view['arFilter']['page'] + 1 <= $this->view['pages']) { ?>
+                            <li><a onclick="return goPage(<?php echo $this->view['arFilter']['page'] + 1; ?>);" href="#" aria-label="<?php echo __('NÃ€chste Seite'); ?>"><span aria-hidden="true">&raquo;</span></a></li>
+                        <?php } ?>
+                    </ul>
+                </nav>
+            <?php } ?>
+
+        <?php } else { ?>
+
+            <?php echo wpsg_drawForm_AdminboxStart(); ?>
+    		<?php echo __('Keine Produktgruppen in der Datenbank.', 'wpsg'); ?>
+            <?php echo wpsg_drawForm_AdminboxEnd(); ?>
+
+        <?php } ?>
+
+</div>
+
+<script type="text/javascript">/* <![CDATA[ */
+
+    <?php if (wpsg_isSizedString($this->view['arFilter']['order']) && wpsg_isSizedString($this->view['arFilter']['ascdesc'])) { ?>
+    jQuery('th[data-order="<?php echo $this->view['arFilter']['order']; ?>"]').addClass('wpsg_order_<?php echo strtolower($this->view['arFilter']['ascdesc']); ?>');
+    <?php } ?>
+
+	function goPage(page)
+	{
+
+		if (page <= 0 || page == <?php echo $this->view['arFilter']['page']; ?> || page > <?php echo $this->view['pages']; ?>) return;
+
+		jQuery('#wpsg_seite').val(page);
+		jQuery('#filter_form').submit();
+
+		return false;
+
+	} // function goPage(page)
+
+/* ]]> */</script>
Index: /system/intern/views/mod_productgroups/list.phtml
===================================================================
--- /system/intern/views/mod_productgroups/list.phtml	(revision 5990)
+++ /system/intern/views/mod_productgroups/list.phtml	(revision 5990)
@@ -0,0 +1,45 @@
+<?php
+	
+	/*
+	 * 
+	 * Template fÃŒr die Produktgruppenansicht im Frontend
+	 * 
+	 */ 
+
+	// Produkte die neben dem Namen angezeigt werden sollen
+	$showP = 4;
+	
+	if (!$this->hasMod("wpsg_mod_produktbilder")) die(__("Dieses Template erfordert das Modul mod_produktbilder.", "wpsg"));
+	
+	// Dimension der Bilder
+	$picW = 150;
+	$picH = 100;	
+	$picMode = 's';
+
+?>
+<?php //wpsg_debug($this->view['data']) ?>
+<?php $c = 0; foreach ((array)$this->view['data'] as $k => $g) { ?>
+<?php //wpsg_debug($g) ?>
+<div class="wpsg_pgruppen_list_row">
+	<div class="wpsg_pgruppen_list_titel">
+		<a href="<?php echo WPSG_URL_WP ?>?page_id=<?php echo get_the_ID(); ?>&show=<?php echo $k ?>">
+			<?php echo $g['pgruppe_name'] ?>
+		</a>
+	</div>
+	<div class="wpsg_pgruppen_list_produkte">	
+		<?php for ($i = 0; $i < $showP && $i < sizeof($g['produkte']); $i ++) { ?>
+			<?php $image = array_rand($g['produkte'][$i]['bilder']); ?>
+			<?php if ($image >= 0 && is_int($image)) { ?>
+			<div class="wpsg_pgruppen_list_image">
+				<?php $image_path = $this->callMod('wpsg_mod_produktbilder', 'makeTn', array($g['produkte'][$i]['id'], $g['produkte'][$i]['bilder'][$image], $picW, $picH, $picMode)) ?>
+				<a href="<?php echo $g['produkte'][$i]['url'] ?>">
+					<img src="<?php echo $image_path; ?>" alt="<?php echo $g['produkte'][$i]['name']; ?>"/>
+				</a>
+			</div>
+			<?php } ?>
+		<?php } ?>
+		<div style="clear:both;"></div>			
+	</div>
+</div>
+<?php $c++ ?>
+<?php } ?>
Index: /system/intern/views/mod_productgroups/productgroups_addedit_sidebar.phtml
===================================================================
--- /system/intern/views/mod_productgroups/productgroups_addedit_sidebar.phtml	(revision 5990)
+++ /system/intern/views/mod_productgroups/productgroups_addedit_sidebar.phtml	(revision 5990)
@@ -0,0 +1,14 @@
+<?php
+
+	/**
+	 * Template fÃŒr die Lagerverwaltung innerhalb der Einstellungen der Produktgruppe
+	 */
+
+?>
+
+<?php echo wpsg_drawForm_AdminboxStart(__('Produktgruppen Lagerbestand'));  ?>
+
+	<?php echo wpsg_drawForm_Input('wpsg_mod_productgroups[stock_value]', __('Bestand', 'wpsg'), wpsg_hspc(@$this->view['wpsg_mod_productgroups']['data']['stock_value']), array()); ?>
+    <?php echo wpsg_drawForm_Checkbox('wpsg_mod_productgroups[stock_aktiv]', __('Lagerbestand zÃ€hlen', 'wpsg'), @$this->view['wpsg_mod_productgroups']['data']['stock_aktiv'], array()); ?>
+
+<?php echo wpsg_drawForm_AdminboxEnd(); ?>
Index: /system/intern/views/mod_productgroups/produkt_addedit_sidebar.phtml
===================================================================
--- /system/intern/views/mod_productgroups/produkt_addedit_sidebar.phtml	(revision 5990)
+++ /system/intern/views/mod_productgroups/produkt_addedit_sidebar.phtml	(revision 5990)
@@ -0,0 +1,28 @@
+<?php
+
+	/**
+	 * Template fÃŒr die Konfiguration der Produktvariablen innerhalb der Produktverwaltung
+	 */
+ 
+?>
+<div class="panel panel-default">
+	<div class="panel-heading clearfix">
+		<h3 class="panel-title">
+			<?php echo __('Produktgruppen', 'wpsg'); ?> 
+		</h3>
+	</div>
+	<div class="panel-body">
+		
+		<?php if (!wpsg_isSizedArray($this->view['wpsg_mod_productgroups']['data'])) { ?>
+		<p><?php echo __('Bisher wurden keine Produktgruppen angelegt.', 'wpsg'); ?></p>
+		<?php } else { ?>
+		<?php echo wpsg_drawForm_Select('wpsg_productgroup', __('Produktgruppe', 'wpsg'), @$this->view['wpsg_mod_productgroups']['data'], @$this->view['wpsg_mod_productgroups']['produkt_data']['pgruppe']); ?>
+		<?php echo wpsg_drawForm_Input('wpsg_productgroup_sticky_von', __('Sticky von', 'wpsg'), @$this->view['wpsg_mod_productgroups']['sticky_von']); ?>
+		<?php echo wpsg_drawForm_Input('wpsg_productgroup_sticky_bis', __('Sticky bis', 'wpsg'), @$this->view['wpsg_mod_productgroups']['sticky_bis']); ?>
+		<?php } ?>
+		 
+		<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&amp;page=wpsg-Productgroups"><span class="wpsg-glyphicon glyphicon glyphicon-book"></span><?php echo __('Produktgruppenverwaltung', 'wpsg'); ?></a><br />
+		<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_productgroups"><span class="wpsg-glyphicon glyphicon glyphicon-wrench"></span><?php echo __('Zur Konfiguration der Produktgruppe', 'wpsg'); ?></a>
+		
+	</div>
+</div>
Index: /system/intern/views/mod_productgroups/settings_edit.phtml
===================================================================
--- /system/intern/views/mod_productgroups/settings_edit.phtml	(revision 5990)
+++ /system/intern/views/mod_productgroups/settings_edit.phtml	(revision 5990)
@@ -0,0 +1,15 @@
+<?php
+
+	/**
+	 * Template fÃŒr die Einstellungsseite der Produktgruppen
+	 */
+
+?>
+<?php echo wpsg_drawForm_Select('wpsg_productgroups_page', __('ProduktgruppenÃŒbersichtsseite', 'wpsg'), $this->view['pages'], $this->get_option('wpsg_productgroups_page'), array('help' => 'wpsg_mod_productgroups_page')); ?>
+<?php echo wpsg_drawForm_Select('wpsg_productgroups_order', __('Sortierung innerhalb der Gruppe', 'wpsg'), array(
+	'id' => __('Nach ID', 'wpsg'),
+	'alphabetisch' => __('Alphabetisch', 'wpsg'),
+	'buyed' => __('Anzahl VerkÃ€ufe', 'wpsg'),
+	'erstellungsdatum' => __('Erstellungsdatum', 'wpsg'),
+	'preis' => __('Preis', 'wpsg')
+), $this->get_option('wpsg_productgroups_order'), array('help' => 'wpsg_mod_productgroups_order')); ?>
Index: /system/intern/views/mod_productgroups/show.phtml
===================================================================
--- /system/intern/views/mod_productgroups/show.phtml	(revision 5990)
+++ /system/intern/views/mod_productgroups/show.phtml	(revision 5990)
@@ -0,0 +1,48 @@
+<?php 
+ 
+	/*
+	 * 
+	 * Template fÃŒr die Ansicht einer einzelnen Produktgruppe
+	 * 
+	 */
+
+	if (!$this->hasMod("wpsg_mod_produktbilder")) die(__("Dieses Template erfordert das Modul mod_produktbilder.", "wpsg"));
+		
+	// Dimension der Bilder
+	$picW = 200;
+	$picH = 200;	
+	$picMode = 'c';
+
+	//$p['produktattribute'][$index]['name'];		Der Name des Attributs
+	//$p['produktattribute'][$index]['value'];		Der Wert des Attributs
+	//$index ist die Nummer des Produktattributs
+	
+	//AusgabemÃ¶glichkeit bei aktiviertem Debug Modus
+	//wpsg_debug($this->view['data']);	
+	
+?>
+<div class="wpsg_pgruppen_single">
+	<div class="wpsg_pgruppen_single_produkte_wrap">
+		<div class="wpsg_pgruppen_single_produkte">
+		<?php foreach ((array)$this->view['data']['produkte'] as $p) { ?>
+		<?php //wpsg_debug($p) ?>
+			<?php if (sizeof($p['bilder']) > 0) { ?>
+			<?php $image = array_rand($p['bilder']); ?>			
+			<div class="wpsg_pgruppen_single_list_image">
+				<?php $image_path = $this->callMod('wpsg_mod_produktbilder', 'makeTn', array($p['id'], $p['bilder'][$image], $picW, $picH, $picMode)) ?>				
+				<a href="<?php echo $p['url'] ?>">
+					<img src="<?php echo $image_path; ?>" alt="<?php echo $p['name']; ?>"/>
+				</a>
+			</div>
+			<?php } ?>
+		<?php } ?>
+		</div>
+	</div>
+	<div style="clear:both;"></div>
+	<div class="wpsg_pgruppen_single_titel"><?php echo $this->view['data']['name']; ?></div>
+	<?php if ($this->view['data']['infopage'] > 0) { ?>	
+	<div class="wpsg_pgruppen_single_link">
+		<a href="<?php echo get_permalink($this->view['data']['infopage']); ?>"><?php echo __("Mehr zur Produktgruppe", "wpsg"); ?></a>
+	</div>
+	<?php } ?>	
+</div>
