<?php

namespace DataView;

class Gruppe {
  
  

  
  

    // --- Statische Methoden ---
  
  public static function renderScript() { 
    
    
    // --- BLOCK: main ---
    
								\FOP\I18n::ensureIsLoaded();
								?>
								<script type="text/javascript">
									
									
									function updateNumbergruppe(col) {
										//var checklist = window.DataViewChecked['gruppe'][col];
										//if (checklist.id) {
											// checklist is online
											// TODO: check if cache is alive, otherwise reload from ajax, delay execution and return now
											//checklist.ranges = [[1,10000000]]; // mostly we use indirect idlists to tick all marks; so this is an approximation
										//}
										// checkboxes aktualisieren
										if (window.DataViewChecked && window.DataViewChecked['gruppe'] && window.DataViewChecked['gruppe'][col].ranges.length > 0) {
											$('.gruppe__mass-action').css('visibility', 'visible');
											$('.gruppe__action').css('visibility', 'hidden');
										} else {
											$('.gruppe__mass-action').css('visibility', 'hidden');
											$('.gruppe__action').css('visibility', 'visible');
										}
										$('.gruppe__checkbox').each(function (idx, x) {
											for (var cssclass of x.classList) {
												if (cssclass.startsWith('gruppe__checkbox-'+col+'-')) {
													var my_id = cssclass.substr(('gruppe__checkbox-'+col+'-').length);
													if (window.DataViewChecked) {
														x.MaterialCheckbox[checklist.has(my_id) ? 'check' : 'uncheck']();
													}
												}
											}
										});
									}
									function reloadgruppe (params, returnUrl, onlyScroll, addPadding = 0) {
										// copy query
										let nq = JSON.parse(JSON.stringify(query));
										nq['parent_request'] = <?php echo json_encode(strtok(\FOP\Util::getBackUrl(), '?')); ?>;
										<?php if (isset($_GET['select'])) { ?>nq['select'] = 'select';<?php } ?>
										
										if (params) {
											for (var i in params) nq[i] = params[i];
											var action = nq['action'];
											delete nq['action'];
											let querystr = "DataView/Gruppe/" + action + "?" + Object.keys(nq).map(function(k){ return k + "=" +  encodeURIComponent(nq[k]); }).join("&");
											// direkt aufrufen (ist wohl ein Download oder so)
											if (returnUrl) return querystr;
											window.location.href = querystr;
										} else {
											let querystr;
											
											
											<?php if ((!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?>
											delete nq['action'];
											querystr = "DataView/Gruppe/renderTabTable?" + Object.keys(nq).map(function(k){ return k + "=" +  encodeURIComponent(nq[k]); }).join("&");
											// per Ajax laden
											if(!$("#gruppe-table")?.parent()?.parent()?.hasClass('fop-form-feature-collapsed') || $("#gruppe-table")?.parent()?.parent()?.hasClass('fop-form-feature-mode-area')) {
											$.get(querystr, function(data){
												var tab = $("#gruppe-table");
												var top = tab.find('.fop-table-body-inner');
												var el;
												if (onlyScroll && (el = $('<div class="tabcontent">' + data + '</div>').find('.fop-table-body-inner'))) {
													// nur Scroll-Bereich ersetzen
													var paddingTop = parseInt(el.css('paddingTop') || '0px', 10);
													var minHeight = parseInt(el.css('minHeight'), 10)
													paddingTop += addPadding;
													minHeight += addPadding;
													top.css({paddingTop: paddingTop.toString()+'px', minHeight: minHeight.toString()+'px'}); // Offset
													el = el.children();
													top.empty();
													top.append(el);
													el = top; // top-upgrade doppelt machen, dadurch vermeiden wir das Array-upgrade => Performance
												} else {
													// gesamten Tab ersetzen
													tab.children().remove();
													el = tab.html('<div class="tabcontent">' + data + '</div>');
												}
												try {
													for (var i = 0; i < el.length; i++) upgradeDOM(el[i]);
												} catch (e) {
													console.log(e);
												}
												upgradeTable(el.find('.fop-table .fop-table-header')); // Falls es Tabellen-Layout ist: Spalten-Order anpassen
												flushURL(); // Neue URL in Titelleiste eintragen

												// Checkbox-Auswahl ankreuzen
												updateNumbergruppe('ID');
											});
											} else {
												// gesamten Tab ersetzen
												var tab = $("#gruppe-table");
												tab.children().remove();
												el = tab.html('<div class="fop-lazy-reload" onclick="reloadgruppe()"></div>');
											}
											<?php } ?>
											
										}
									}
									function checkgruppe (id, col, checked) {
										// ID-Liste aufbauen
										if (!window.DataViewChecked) window.DataViewChecked = {};
										if (!window.DataViewChecked['gruppe']) window.DataViewChecked['gruppe'] = {};
										if (!window.DataViewChecked['gruppe'][col]) window.DataViewChecked['gruppe'][col] = new IDList();

										// Abfrage aller gecheckten IDs für eine Tabelle
										if (!id) {
											return window.DataViewChecked['gruppe'][col].toString();
										}

										// check all, check id
										if (id == 'all') {
											// TODO: umbauen #1289: 'all' auch nur auf ne idlist reduzieren
											if (checked) {
												$.get(reloadgruppe({action: 'getids', col: col}, true), function (ids) {
													window.DataViewChecked['gruppe'][col] = new IDList(ids);
													updateNumbergruppe(col);
												});
											} else {
												window.DataViewChecked['gruppe'][col] = new IDList();
												updateNumbergruppe(col);
											}
										} else {
											var ids = new IDList(id);
											var allcb = $('#gruppe__all-checkbox');
											if (allcb[0]) {
												allcb[0].parentElement.MaterialCheckbox.uncheck(); // TODO: prüfen, ob Gruppen-CBs voll werden
											}
											if (checked == 'set') {
												window.DataViewChecked['gruppe'][col] = ids;
											} else for (id of ids.all()) {
												if (checked) {
													window.DataViewChecked['gruppe'][col].push(id);
												} else {
													window.DataViewChecked['gruppe'][col].remove(id);
												}
											}
											updateNumbergruppe(col);
										}
									}
								</script><?php

    
  }

  public static function renderSpecialFilters() { 
    
    
    // --- BLOCK: main ---
    ?>
	
	<script type"text/javascript">
		function updateSpecialFilter(param, val) {
			query[param] = val.toString();reloadgruppe();
			
		}

	</script>
	<?php
	
    
  }

  public static function renderTabTableAction() { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
     ?><div class='fop-dv-buttonbar'><?php if((!\FOP\User::getIsGuest())) { ?>
	<?php if ((true) && (true)) { ?>
	<div class='fop-dv-aggregate' data-column='anzahl' title='<?php echo(_('Mitglieder')); ?>'>
		<div class='fop-dv-aggregate-caption' style='text-align: right'><?php echo(_('Mitglieder')); ?></div>
		<div class='fop-dv-aggregate-value'>-...-</div>
	</div>
	<?php } ?><?php }if(((\FOP\User::getGruppe()))) { ?><a class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored" onclick="
		var self = this;
		event.preventDefault();
		$.get(reloadgruppe({action: 'open', fop_table: 'gruppe', fop_id: '_', fop_from: location.href}, true))
		.then(function () {
			window.open_url(self.href, true);
		});" href="<?php echo htmlentities(\TablesRouter\Gruppe::createURL2(['from' => $_GET['from'] ?? null, 'popup' => $_GET['popup'] ?? null])); ?>"><i class="material-icons">add</i> <?php echo(sprintf(_('create %s'), _('Gruppe'))); ?></a><?php }if((!\FOP\User::getIsGuest())) { ?>
	<span style ="margin-left: 20px">
		<?php echo htmlentities(_('Betrachtungszeitpunkt'));?>:
		<input type='text' class="mdl-textfield__input" style="width: 160px; display: inline-block; " id="gruppe-dynamic-filter" value='<?php echo date(_('dateformat_php')); ?>'>
		<script type='text/javascript'>
			$(function () {
				$('#gruppe-dynamic-filter')
				.datetimepicker({locale: <?php echo (json_encode(\FOP\I18n::getShortLocale())); ?>, format: <?php echo (json_encode(_('datetimeformat_moment'))); ?>})
				.on('dp.change', function (e) {
					if (!e.date) {
						// filter all times
						query['dynamic_gruppe'] = 0;
					} else {
						// filter a certain time
						query['dynamic_gruppe'] = e.date.unix();
					}
					delete query['page_gruppe'];
					reloadgruppe();
				});
			});
		</script>
	</span>
	<?php } ?></div><?php 
								\FOP\User::getIsGuest();
								$itemheight = 32;
								$itemsperpage = ceil(1080 / $itemheight * 0.8);
								$page = (isset($_GET['page_gruppe']) ? intval($_GET['page_gruppe']) : 0);
								$addlines = (isset($_GET['addlines_gruppe']) ? intval($_GET['addlines_gruppe']) : 0);
								$firstitem = $page * $itemsperpage;
								$sqladdon = ' LIMIT ' . ($itemsperpage * 2) . ' OFFSET ' . ($firstitem);
								$data = self::getData($sqladdon, $_GET);
								$arr = $data["items"];
								$itemcount = $data["itemcount"];
								$lastPage = ceil($itemcount/$itemsperpage-1);
								// calculate width of first column: 67px + 32px for each shortcut
								$firstColumnWidth = 66 + 34 + 34;
								$additionalLines = 0;
								$renderAggregateRow = function ($item) use (&$columns, $firstColumnWidth) {
										if (!(true)) {
											return; // no access
										}
										?><div class="fop-table-row fop-table-row-aggregate">
											<div class="fop-table-column noprint" style="width: <?php echo json_encode($firstColumnWidth); ?>px;"><?php echo $item['::cnt']; ?> x</div><?php
											foreach ($columns AS $col) {
												$col['renderSum']($item);
											} ?>
										</div><?php
								};
								$checkAggregates = function ($last, $current) use ($data, $renderAggregateRow) {
									
								};

									// Spaltenliste zuerst aufbauen, damit sie noch umsortiert werden kann
									$order = 1000;
									$columns = [];
									
										if(true){
											$col = [
												'id' => 'name',
												'desc' => _('Bezeichnung'),
												'order' => ++$order,
												'width' => 180, // default value
												'collapsed' => 0

											];
											$columns['name'] = $col;
										}
									
										if((false)){
											$col = [
												'id' => 'items',
												'desc' => _('Gruppenmitglieder'),
												'order' => ++$order,
												'width' => 60, // default value
												'collapsed' => 0

											];
											$columns['items'] = $col;
										}
									
										if(true){
											$col = [
												'id' => 'anzahl',
												'desc' => _('Mitglieder'),
												'order' => ++$order,
												'width' => 60, // default value
												'collapsed' => 0

											];
											$columns['anzahl'] = $col;
										}
									
										if(true){
											$col = [
												'id' => 'public',
												'desc' => _('in Gruppenliste aufgelistet'),
												'order' => ++$order,
												'width' => 40, // default value
												'collapsed' => 0

											];
											$columns['public'] = $col;
										}
									
										if(true){
											$col = [
												'id' => 'memberVisibility',
												'desc' => _('Mitglieder sehen sich gegenseitig'),
												'order' => ++$order,
												'width' => 40, // default value
												'collapsed' => 0

											];
											$columns['memberVisibility'] = $col;
										}
									
										if(true){
											$col = [
												'id' => 'start',
												'desc' => _('Gründungsdatum'),
												'order' => ++$order,
												'width' => 100, // default value
												'collapsed' => 0

											];
											$columns['start'] = $col;
										}
									
										if(true){
											$col = [
												'id' => 'ende',
												'desc' => _('Auflösungsdatum'),
												'order' => ++$order,
												'width' => 100, // default value
												'collapsed' => 0

											];
											$columns['ende'] = $col;
										}
									

									// gespeicherte Spaltenanordnung
									foreach (\FOP\Database::query('SELECT * FROM fop_dataview WHERE '.qi('user').' = ' . \FOP\Database::quote(\FOP\User::getID()) . ' AND dataview = ' . \FOP\Database::quote('gruppe'))->fetchAll(\PDO::FETCH_ASSOC) AS $column => $c) {
										if (isset($columns[$c['column']])) {
											$columns[$c['column']]['order'] = $c['order']; // order, width, collapsed
											$columns[$c['column']]['width'] = $c['width']; // order, width, collapsed
											$columns[$c['column']]['collapsed'] = $c['collapsed']; // order, width, collapsed
										}
									}

									// DOM vor-rendern
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='name'
												data-order='<?php echo intval($columns['name']['order']); ?>'
												data-width='<?php echo intval($columns['name']['width']); ?>'
												data-collapsed='<?php echo intval($columns['name']['collapsed']); ?>'
												style='width: <?php echo intval($columns['name']['width']); ?>px; <?php if ($columns['name']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadgruppe(); 
		}});
		
		var el = $('<div class=\'mdl-textfield mdl-js-textfield mdl-textfield--floating-label fop-floatsorter\' style=\'width: calc(100% - 42px);\'><input class=\'mdl-textfield__input\' style=\'display: inline-block;\' type=\'text\'><label class=\'mdl-textfield__input\'><?php echo(_('search')); ?></label></div>');
		win.append(el);
		var text = el.find('input');
		text.val(query['search_gruppe_name'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_gruppe_name'] = text.val(); } else { delete query['search_gruppe_name']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_gruppe').find('.fop-table-row:first').click();} if (event.key === 'Escape') { win.close(); }});

		var el2 = $('<div class=\'mdl-textfield mdl-js-textfield mdl-textfield--floating-label\'><input class=\'mdl-textfield__input\' style=\'display: inline-block;\' type=\'text\'><label class=\'mdl-textfield__input\'><?php echo(htmlentities(htmlentities(_('filter_contains_not')))); ?></label></div>');
		win.append(el2);
		var text2 = el2.find('input');
		text2.val(query['searchnot_gruppe_name'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_gruppe_name'] = text2.val(); } else { delete query['searchnot_gruppe_name']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_gruppe').find('.fop-table-row:first').click();} if (event.key === 'Escape') { win.close(); }});
	
	var icon, sortbtn	= $('<a class=\'mdl-button mdl-js-button mdl-button--icon mdl-button--colored\' style=\'display: inline-block;\'></a>')
		.append(icon = $('<i class=\'material-icons\'></i>').text('unfold_more'))
		.click(function() {
		 if (query['sort_gruppe'] == 'name ASC') {
			query['sort_gruppe'] = 'name DESC';
		 } else if (query['sort_gruppe'] == 'name DESC') {
		 	delete query['sort_gruppe'];
		 } else {
			query['sort_gruppe'] = 'name ASC';
		 }
		 reloadgruppe();
		 return false;
	});
	if (win.children().first().hasClass('fop-floatsorter')) {
		// floating layout
		win.prepend(sortbtn.css({float: 'right', margin: '0px'}));
	} else {
		// append to the end
		win.append(sortbtn);
	}
		return false;
	">
													<span class='title-title' title='<?php echo(_('Bezeichnung')); ?>'><?php echo(_('Bezeichnung')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'name ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'name DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_gruppe_name']) || isset($_GET['range_max_gruppe_name']) || isset($_GET['deps_gruppe_name']) || isset($_GET['fullsearch_gruppe_name']) || isset($_GET['dynamic_gruppe_name']) || isset($_GET['search_gruppe_name']) || isset($_GET['searchnot_gruppe_name']) || isset($_GET['filter_gruppe_name'])) {
															// filter indicator
															?><i class='material-icons fop-small'>filter_list</i><?php
														}
														// search indicator
														?><i class='material-icons fop-small'>search</i>
													</span>
												<div class='fop-column-handle'></div>
											</div><?php
											$columns['name']['header'] = ob_get_contents(); ob_end_clean();
											$columns['name']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['name']['width']); ?>px; <?php if ($columns['name']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='name'><span class='overflow-text' title="<?php echo htmlentities($item['name']); ?>"><?php echo htmlentities($item['name']); ?></span></div><?php
											};
											$columns['name']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='name'
													data-order='<?php echo intval($columns['name']['order']); ?>'
													data-width='<?php echo intval($columns['name']['width']); ?>'
													data-collapsed='<?php echo intval($columns['name']['collapsed']); ?>'
													style='width: <?php echo intval($columns['name']['width']); ?>px; <?php if ($columns['name']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if((false)){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='items'
												data-order='<?php echo intval($columns['items']['order']); ?>'
												data-width='<?php echo intval($columns['items']['width']); ?>'
												data-collapsed='<?php echo intval($columns['items']['collapsed']); ?>'
												style='width: <?php echo intval($columns['items']['width']); ?>px; <?php if ($columns['items']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadgruppe(); 
		}});
		var von, bis; win.append('<div class=\'fop-floatsorter\'>' + window.i18n_von + '</div>').append(von = $('<input type=\'number\' step=\'any\'><br>').val(query['range_min_gruppe_items']).on('change keyup paste', function () { query['range_min_gruppe_items'] = von.val(); delete query['page_gruppe']; changed = true; }))
.append('<div>' + window.i18n_bis + '</div>').append(bis = $('<input type=\'number\' step=\'any\'>').val(query['range_max_gruppe_items']).on('change keyup paste', function () { query['range_max_gruppe_items'] = bis.val(); delete query['page_gruppe']; changed = true; }))
; von.focus(); von.select();
	var icon, sortbtn	= $('<a class=\'mdl-button mdl-js-button mdl-button--icon mdl-button--colored\' style=\'display: inline-block;\'></a>')
		.append(icon = $('<i class=\'material-icons\'></i>').text('unfold_more'))
		.click(function() {
		 if (query['sort_gruppe'] == 'items ASC') {
			query['sort_gruppe'] = 'items DESC';
		 } else if (query['sort_gruppe'] == 'items DESC') {
		 	delete query['sort_gruppe'];
		 } else {
			query['sort_gruppe'] = 'items ASC';
		 }
		 reloadgruppe();
		 return false;
	});
	if (win.children().first().hasClass('fop-floatsorter')) {
		// floating layout
		win.prepend(sortbtn.css({float: 'right', margin: '0px'}));
	} else {
		// append to the end
		win.append(sortbtn);
	}
		return false;
	" style='text-align: right;'>
													<span class='title-title' title='<?php echo(_('Gruppenmitglieder')); ?>'><?php echo(_('Gruppenmitglieder')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'items ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'items DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_gruppe_items']) || isset($_GET['range_max_gruppe_items']) || isset($_GET['deps_gruppe_items']) || isset($_GET['fullsearch_gruppe_items']) || isset($_GET['dynamic_gruppe_items']) || isset($_GET['search_gruppe_items']) || isset($_GET['searchnot_gruppe_items']) || isset($_GET['filter_gruppe_items'])) {
															// filter indicator
															?><i class='material-icons fop-small'>filter_list</i><?php
														}
														// search indicator
														?><i class='material-icons fop-small'>search</i>
													</span>
												<div class='fop-column-handle'></div>
											</div><?php
											$columns['items']['header'] = ob_get_contents(); ob_end_clean();
											$columns['items']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['items']['width']); ?>px; <?php if ($columns['items']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='items'><span style="white-space: nowrap; width: 100%; display: inline-block; text-align: right;"><?php echo htmlentities(\Types\Integer::print($item['items'])); ?>
	</span></div><?php
											};
											$columns['items']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='items'
													data-order='<?php echo intval($columns['items']['order']); ?>'
													data-width='<?php echo intval($columns['items']['width']); ?>'
													data-collapsed='<?php echo intval($columns['items']['collapsed']); ?>'
													style='width: <?php echo intval($columns['items']['width']); ?>px; <?php if ($columns['items']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='anzahl'
												data-order='<?php echo intval($columns['anzahl']['order']); ?>'
												data-width='<?php echo intval($columns['anzahl']['width']); ?>'
												data-collapsed='<?php echo intval($columns['anzahl']['collapsed']); ?>'
												style='width: <?php echo intval($columns['anzahl']['width']); ?>px; <?php if ($columns['anzahl']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadgruppe(); 
		}});
		var von, bis; win.append('<div class=\'fop-floatsorter\'>' + window.i18n_von + '</div>').append(von = $('<input type=\'number\' step=\'any\'><br>').val(query['range_min_gruppe_anzahl']).on('change keyup paste', function () { query['range_min_gruppe_anzahl'] = von.val(); delete query['page_gruppe']; changed = true; }))
.append('<div>' + window.i18n_bis + '</div>').append(bis = $('<input type=\'number\' step=\'any\'>').val(query['range_max_gruppe_anzahl']).on('change keyup paste', function () { query['range_max_gruppe_anzahl'] = bis.val(); delete query['page_gruppe']; changed = true; }))
; von.focus(); von.select();
	var icon, sortbtn	= $('<a class=\'mdl-button mdl-js-button mdl-button--icon mdl-button--colored\' style=\'display: inline-block;\'></a>')
		.append(icon = $('<i class=\'material-icons\'></i>').text('unfold_more'))
		.click(function() {
		 if (query['sort_gruppe'] == 'anzahl ASC') {
			query['sort_gruppe'] = 'anzahl DESC';
		 } else if (query['sort_gruppe'] == 'anzahl DESC') {
		 	delete query['sort_gruppe'];
		 } else {
			query['sort_gruppe'] = 'anzahl ASC';
		 }
		 reloadgruppe();
		 return false;
	});
	if (win.children().first().hasClass('fop-floatsorter')) {
		// floating layout
		win.prepend(sortbtn.css({float: 'right', margin: '0px'}));
	} else {
		// append to the end
		win.append(sortbtn);
	}
		return false;
	" style='text-align: right;'>
													<span class='title-title' title='<?php echo(_('Mitglieder')); ?>'><?php echo(_('Mitglieder')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'anzahl ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'anzahl DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_gruppe_anzahl']) || isset($_GET['range_max_gruppe_anzahl']) || isset($_GET['deps_gruppe_anzahl']) || isset($_GET['fullsearch_gruppe_anzahl']) || isset($_GET['dynamic_gruppe_anzahl']) || isset($_GET['search_gruppe_anzahl']) || isset($_GET['searchnot_gruppe_anzahl']) || isset($_GET['filter_gruppe_anzahl'])) {
															// filter indicator
															?><i class='material-icons fop-small'>filter_list</i><?php
														}
														// search indicator
														?><i class='material-icons fop-small'>search</i>
													</span>
												<div class='fop-column-handle'></div>
											</div><?php
											$columns['anzahl']['header'] = ob_get_contents(); ob_end_clean();
											$columns['anzahl']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['anzahl']['width']); ?>px; <?php if ($columns['anzahl']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='anzahl'><span style="white-space: nowrap; width: 100%; display: inline-block; text-align: right;"><?php echo htmlentities(\Types\Integer::print($item['anzahl'])); ?>
	</span></div><?php
											};
											$columns['anzahl']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='anzahl'
													data-order='<?php echo intval($columns['anzahl']['order']); ?>'
													data-width='<?php echo intval($columns['anzahl']['width']); ?>'
													data-collapsed='<?php echo intval($columns['anzahl']['collapsed']); ?>'
													style='width: <?php echo intval($columns['anzahl']['width']); ?>px; <?php if ($columns['anzahl']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													<b><span style="white-space: nowrap; width: 100%; display: inline-block; text-align: right;"><?php echo htmlentities(\Types\Integer::print($item['anzahl'])); ?>
	</span></b></div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='public'
												data-order='<?php echo intval($columns['public']['order']); ?>'
												data-width='<?php echo intval($columns['public']['width']); ?>'
												data-collapsed='<?php echo intval($columns['public']['collapsed']); ?>'
												style='width: <?php echo intval($columns['public']['width']); ?>px; <?php if ($columns['public']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadgruppe(); 
		}});
		win
	.append($('<input type=\'checkbox\'' + (querySet('filter_gruppe_public', '0') ? ' checked>': '>')).change(function (){querySet('filter_gruppe_public', '0', $(this).prop('checked')); delete query['page_gruppe']; changed=true;})).append(' <?php echo(_('off')); ?><br/>')
	.append($('<input type=\'checkbox\'' + (querySet('filter_gruppe_public', '1') ? ' checked>': '>')).change(function (){querySet('filter_gruppe_public', '1', $(this).prop('checked')); delete query['page_gruppe']; changed=true;})).append(' <?php echo(_('on')); ?><br/>')
;
		return false;
	">
													<span class='title-title' title='<?php echo(_('in Gruppenliste aufgelistet')); ?>'><?php echo(_('in Gruppenliste aufgelistet')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'public ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'public DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_gruppe_public']) || isset($_GET['range_max_gruppe_public']) || isset($_GET['deps_gruppe_public']) || isset($_GET['fullsearch_gruppe_public']) || isset($_GET['dynamic_gruppe_public']) || isset($_GET['search_gruppe_public']) || isset($_GET['searchnot_gruppe_public']) || isset($_GET['filter_gruppe_public'])) {
															// filter indicator
															?><i class='material-icons fop-small'>filter_list</i><?php
														}
														// search indicator
														?><i class='material-icons fop-small'>search</i>
													</span>
												<div class='fop-column-handle'></div>
											</div><?php
											$columns['public']['header'] = ob_get_contents(); ob_end_clean();
											$columns['public']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['public']['width']); ?>px; <?php if ($columns['public']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='public'><?php if($item['public'] == 1){ ?>✓<?php }else{ ?><?php }?></div><?php
											};
											$columns['public']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='public'
													data-order='<?php echo intval($columns['public']['order']); ?>'
													data-width='<?php echo intval($columns['public']['width']); ?>'
													data-collapsed='<?php echo intval($columns['public']['collapsed']); ?>'
													style='width: <?php echo intval($columns['public']['width']); ?>px; <?php if ($columns['public']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='memberVisibility'
												data-order='<?php echo intval($columns['memberVisibility']['order']); ?>'
												data-width='<?php echo intval($columns['memberVisibility']['width']); ?>'
												data-collapsed='<?php echo intval($columns['memberVisibility']['collapsed']); ?>'
												style='width: <?php echo intval($columns['memberVisibility']['width']); ?>px; <?php if ($columns['memberVisibility']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadgruppe(); 
		}});
		win
	.append($('<input type=\'checkbox\'' + (querySet('filter_gruppe_memberVisibility', '0') ? ' checked>': '>')).change(function (){querySet('filter_gruppe_memberVisibility', '0', $(this).prop('checked')); delete query['page_gruppe']; changed=true;})).append(' <?php echo(_('off')); ?><br/>')
	.append($('<input type=\'checkbox\'' + (querySet('filter_gruppe_memberVisibility', '1') ? ' checked>': '>')).change(function (){querySet('filter_gruppe_memberVisibility', '1', $(this).prop('checked')); delete query['page_gruppe']; changed=true;})).append(' <?php echo(_('on')); ?><br/>')
;
		return false;
	">
													<span class='title-title' title='<?php echo(_('Mitglieder sehen sich gegenseitig')); ?>'><?php echo(_('Mitglieder sehen sich gegenseitig')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'memberVisibility ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'memberVisibility DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_gruppe_memberVisibility']) || isset($_GET['range_max_gruppe_memberVisibility']) || isset($_GET['deps_gruppe_memberVisibility']) || isset($_GET['fullsearch_gruppe_memberVisibility']) || isset($_GET['dynamic_gruppe_memberVisibility']) || isset($_GET['search_gruppe_memberVisibility']) || isset($_GET['searchnot_gruppe_memberVisibility']) || isset($_GET['filter_gruppe_memberVisibility'])) {
															// filter indicator
															?><i class='material-icons fop-small'>filter_list</i><?php
														}
														// search indicator
														?><i class='material-icons fop-small'>search</i>
													</span>
												<div class='fop-column-handle'></div>
											</div><?php
											$columns['memberVisibility']['header'] = ob_get_contents(); ob_end_clean();
											$columns['memberVisibility']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['memberVisibility']['width']); ?>px; <?php if ($columns['memberVisibility']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='memberVisibility'><?php if($item['memberVisibility'] == 1){ ?>✓<?php }else{ ?><?php }?></div><?php
											};
											$columns['memberVisibility']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='memberVisibility'
													data-order='<?php echo intval($columns['memberVisibility']['order']); ?>'
													data-width='<?php echo intval($columns['memberVisibility']['width']); ?>'
													data-collapsed='<?php echo intval($columns['memberVisibility']['collapsed']); ?>'
													style='width: <?php echo intval($columns['memberVisibility']['width']); ?>px; <?php if ($columns['memberVisibility']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='start'
												data-order='<?php echo intval($columns['start']['order']); ?>'
												data-width='<?php echo intval($columns['start']['width']); ?>'
												data-collapsed='<?php echo intval($columns['start']['collapsed']); ?>'
												style='width: <?php echo intval($columns['start']['width']); ?>px; <?php if ($columns['start']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadgruppe(); 
		}}, 600);
		date_filter(win, 'gruppe', 'start', <?php echo htmlentities(json_encode(_('period'))); ?>, <?php echo htmlentities(json_encode(\FOP\I18n::getShortLocale())); ?>, <?php echo htmlentities(json_encode(_('dateformat_moment'))); ?>, function() { reloadgruppe();  reloadgruppe(); });
	var icon, sortbtn	= $('<a class=\'mdl-button mdl-js-button mdl-button--icon mdl-button--colored\' style=\'display: inline-block;\'></a>')
		.append(icon = $('<i class=\'material-icons\'></i>').text('unfold_more'))
		.click(function() {
		 if (query['sort_gruppe'] == 'start ASC') {
			query['sort_gruppe'] = 'start DESC';
		 } else if (query['sort_gruppe'] == 'start DESC') {
		 	delete query['sort_gruppe'];
		 } else {
			query['sort_gruppe'] = 'start ASC';
		 }
		 reloadgruppe();
		 return false;
	});
	if (win.children().first().hasClass('fop-floatsorter')) {
		// floating layout
		win.prepend(sortbtn.css({float: 'right', margin: '0px'}));
	} else {
		// append to the end
		win.append(sortbtn);
	}
		return false;
	">
													<span class='title-title' title='<?php echo(_('Gründungsdatum')); ?>'><?php echo(_('Gründungsdatum')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'start ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'start DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_gruppe_start']) || isset($_GET['range_max_gruppe_start']) || isset($_GET['deps_gruppe_start']) || isset($_GET['fullsearch_gruppe_start']) || isset($_GET['dynamic_gruppe_start']) || isset($_GET['search_gruppe_start']) || isset($_GET['searchnot_gruppe_start']) || isset($_GET['filter_gruppe_start'])) {
															// filter indicator
															?><i class='material-icons fop-small'>filter_list</i><?php
														}
														// search indicator
														?><i class='material-icons fop-small'>search</i>
													</span>
												<div class='fop-column-handle'></div>
											</div><?php
											$columns['start']['header'] = ob_get_contents(); ob_end_clean();
											$columns['start']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['start']['width']); ?>px; <?php if ($columns['start']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='start'><span class='overflow-text' title="<?php echo htmlentities(($item['start']) ? strftime(_('dateformat_php2'), intval($item['start'])) : ''); ?>"><?php echo htmlentities(($item['start']) ? strftime(_('dateformat_php2'), intval($item['start'])) : ''); ?></span></div><?php
											};
											$columns['start']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='start'
													data-order='<?php echo intval($columns['start']['order']); ?>'
													data-width='<?php echo intval($columns['start']['width']); ?>'
													data-collapsed='<?php echo intval($columns['start']['collapsed']); ?>'
													style='width: <?php echo intval($columns['start']['width']); ?>px; <?php if ($columns['start']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='ende'
												data-order='<?php echo intval($columns['ende']['order']); ?>'
												data-width='<?php echo intval($columns['ende']['width']); ?>'
												data-collapsed='<?php echo intval($columns['ende']['collapsed']); ?>'
												style='width: <?php echo intval($columns['ende']['width']); ?>px; <?php if ($columns['ende']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadgruppe(); 
		}}, 600);
		date_filter(win, 'gruppe', 'ende', <?php echo htmlentities(json_encode(_('period'))); ?>, <?php echo htmlentities(json_encode(\FOP\I18n::getShortLocale())); ?>, <?php echo htmlentities(json_encode(_('dateformat_moment'))); ?>, function() { reloadgruppe();  reloadgruppe(); });
	var icon, sortbtn	= $('<a class=\'mdl-button mdl-js-button mdl-button--icon mdl-button--colored\' style=\'display: inline-block;\'></a>')
		.append(icon = $('<i class=\'material-icons\'></i>').text('unfold_more'))
		.click(function() {
		 if (query['sort_gruppe'] == 'ende ASC') {
			query['sort_gruppe'] = 'ende DESC';
		 } else if (query['sort_gruppe'] == 'ende DESC') {
		 	delete query['sort_gruppe'];
		 } else {
			query['sort_gruppe'] = 'ende ASC';
		 }
		 reloadgruppe();
		 return false;
	});
	if (win.children().first().hasClass('fop-floatsorter')) {
		// floating layout
		win.prepend(sortbtn.css({float: 'right', margin: '0px'}));
	} else {
		// append to the end
		win.append(sortbtn);
	}
		return false;
	">
													<span class='title-title' title='<?php echo(_('Auflösungsdatum')); ?>'><?php echo(_('Auflösungsdatum')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'ende ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_gruppe']) && $_GET['sort_gruppe'] == 'ende DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_gruppe_ende']) || isset($_GET['range_max_gruppe_ende']) || isset($_GET['deps_gruppe_ende']) || isset($_GET['fullsearch_gruppe_ende']) || isset($_GET['dynamic_gruppe_ende']) || isset($_GET['search_gruppe_ende']) || isset($_GET['searchnot_gruppe_ende']) || isset($_GET['filter_gruppe_ende'])) {
															// filter indicator
															?><i class='material-icons fop-small'>filter_list</i><?php
														}
														// search indicator
														?><i class='material-icons fop-small'>search</i>
													</span>
												<div class='fop-column-handle'></div>
											</div><?php
											$columns['ende']['header'] = ob_get_contents(); ob_end_clean();
											$columns['ende']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['ende']['width']); ?>px; <?php if ($columns['ende']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='ende'><span class='overflow-text' title="<?php echo htmlentities(($item['ende']) ? strftime(_('dateformat_php2'), intval($item['ende'])) : ''); ?>"><?php echo htmlentities(($item['ende']) ? strftime(_('dateformat_php2'), intval($item['ende'])) : ''); ?></span></div><?php
											};
											$columns['ende']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='ende'
													data-order='<?php echo intval($columns['ende']['order']); ?>'
													data-width='<?php echo intval($columns['ende']['width']); ?>'
													data-collapsed='<?php echo intval($columns['ende']['collapsed']); ?>'
													style='width: <?php echo intval($columns['ende']['width']); ?>px; <?php if ($columns['ende']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									

									// sort by order
									uasort($columns, function ($a, $b) {
										return $a['order'] - $b['order'];
									});
									?>
									<style type='text/css'>
										#gruppe-table .fop-table-header {
											height: <?php echo 32; ?>px;
										}
										#gruppe-table .fop-table-header .fop-table-column .title,
										#gruppe-table .fop-column-handle,
										#gruppe-table .fop-table-row,
										#gruppe-table .fop-table-row .fop-table-column,
										#gruppe-table .fop-table-column-multicontrol,
										#gruppe-table .fop-filter-button {
											height: 32px;
											line-height: 32px;
										}
										</style>
											<div class="fop-table" data-table-id="gruppe">
											<div class="fop-legend"></div>
											<div class="fop-filter-string-wrapper"><div class="fop-filter-string"><label>Filter:</label> <span><?php echo self::getFilterHTML($_GET); ?></span></div></div>
											
											<?php if (isset($_GET['select'])) { echo '<br>'; } ?>
											<div class="fop-table-header">
											<?php if (!isset($_GET['select'])) { ?>
												<div class="fop-table-column noprint" style="width: <?php echo json_encode($firstColumnWidth); ?>px;">
													
													<div class="fop-table-column-multicontrol">
													<label class="mdl-checkbox mdl-js-checkbox"  style='width: auto;' for="gruppe__all-checkbox">
														<input class="mdl-checkbox__input" id="gruppe__all-checkbox" type="checkbox" onchange="checkgruppe('all', 'ID', this.checked);">
														</label>
														<button type="button" class="mdl-button mdl-js-button mdl-button--icon gruppe__mass-action" style='visibility: hidden;' onclick="$.get('DataView/Gruppe/permissions?id=' + checkgruppe(null, 'ID'), function (data) { for (var method in data) if (method != '__cnt') { var btn = $('[data-interaction-name=&quot;' + method + '&quot;]'); if (data[method] >= 1) btn.show(); else btn.hide(); btn.find('.cnt').text(data[method]); }; }); dropDownFixPosition($(this), $(this).next())">
															<i class="material-icons">more_vert</i>
														</button>
														<ul class="mdl-list mdl-card mdl-shadow--4dp fop-scroll-menu">
															<?php
		if(true) { ?>
			<span class="mdl-list__item mdl-button">
				<span class="mdl-list__item mdl-button" data-interaction-name="filterall" style="margin-right:auto; text-align:left;"
					onclick="for (key in query) if (key.indexOf('range_min_gruppe_') == 0 || key.indexOf('range_max_gruppe_') == 0 || key.indexOf('deps_gruppe_') == 0 || key.indexOf('fullsearch_gruppe_') == 0 || key.indexOf('dynamic_gruppe_') == 0 || key.indexOf('search_gruppe_') == 0 || key.indexOf('searchnot_gruppe_') == 0 || key.indexOf('filter_gruppe_') == 0) delete query[key]; reloadgruppe(); $(this).closest('.overlay').click(); return false;">
					<span style="float:left;"><i class="material-icons">list</i></span><span class="fop-menu-caption" title="<?php echo(_('view all elements')); ?>"><?php echo(_('view all elements')); ?> 
					</span>
				</span>
			</span>
		<?php } ?><?php
		if(true) { ?>
			<span class="mdl-list__item mdl-button">
				<span class="mdl-list__item mdl-button" data-interaction-name="filteronly" style="margin-right:auto; text-align:left;"
					onclick="query['filter_gruppe_ID'] = checkgruppe(null, 'ID'); delete query['page_gruppe']; reloadgruppe(); $(this).closest('.overlay').click(); return false;">
					<span style="float:left;"><i class="material-icons">arrow_forward</i></span><span class="fop-menu-caption" title="<?php echo(_('view only these elements')); ?>"><?php echo(_('view only these elements')); ?> (<span class='cnt'></span>)
					</span>
				</span>
			</span>
		<?php } ?><?php
		if(true) { ?>
			<span class="mdl-list__item mdl-button">
				<span class="mdl-list__item mdl-button" data-interaction-name="filterrange" style="margin-right:auto; text-align:left;"
					onclick="
		var ticks = new IDList(checkgruppe(null, 'ID'));
		var range = prompt('Bitte geben Sie den Bereich ein', '1-' + ticks.count());
		var newticks = new IDList();
		if (range) {
			range = range.split('-');
			if (range.length == 1) {
				range.push(range[0]);
			}
			var skip = (range[0] || 1) - 1;
			var take = (range[1] || Infinity) - skip;
			for (var item of ticks.all()) {
				if (skip > 0) {
					skip--;
				} else if (take > 0) {
					newticks.push(item);
					take--;
				} else break;
			}
			checkgruppe(newticks, 'ID', 'set');
		} $(this).closest('.overlay').click(); return false;">
					<span style="float:left;"><i class="material-icons">colorize</i></span><span class="fop-menu-caption" title="<?php echo(_('limit range')); ?>"><?php echo(_('limit range')); ?> (<span class='cnt'></span>)
					</span>
				</span>
			</span>
		<?php } ?><?php
		if(true && (!\FOP\User::getIsGuest()) && ((\FOP\User::getGruppe()))) { ?>
			<span class="mdl-list__item mdl-button">
				<span class="mdl-list__item mdl-button" data-interaction-name="lifecycleEnd" style="margin-right:auto; text-align:left;"
					onclick="location.href = 'Tables/Gruppe/lifecycleEnd?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&id=' + escape(checkgruppe(null, 'ID')); $(this).closest('.overlay').click(); return false;">
					<span style="float:left;"><i class="material-icons">stop</i></span><span class="fop-menu-caption" title="<?php echo(sprintf(_('%s setzen'), _('Auflösungsdatum'))); ?>"><?php echo(sprintf(_('%s setzen'), _('Auflösungsdatum'))); ?> (<span class='cnt'></span>)
					</span>
				</span>
			</span>
		<?php } ?><?php
		if(true && ((\FOP\User::getGruppe()))) { ?>
			<span class="mdl-list__item mdl-button">
				<span class="mdl-list__item mdl-button" data-interaction-name="delete" style="margin-right:auto; text-align:left;"
					onclick="if(!confirm(<?php echo htmlentities(json_encode(_('confirmdelete'))); ?>)) return;$.get('Tables/Gruppe/delete?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&id=' + escape(checkgruppe(null, 'ID'))).then(function () { reloadgruppe(); }, function (err) { if (err.responseText.startsWith('http')) { window.location.href = err.responseText; } else {alert(err.responseText); }}); $(this).closest('.overlay').click(); return false;">
					<span style="float:left;"><i class="material-icons">delete</i></span><span class="fop-menu-caption" title="<?php echo(_('delete')); ?>"><?php echo(_('delete')); ?> (<span class='cnt'></span>)
					</span>
				</span>
			</span>
		<?php } ?>
														</ul>
														<!-- column hide -->
														<button type="button" class="mdl-button mdl-js-button mdl-button--icon" onclick="dropDownFixPosition($(this), $(this).next())">
															<i class="material-icons">visibility</i>
														</button>
														<ul class="mdl-list mdl-card mdl-shadow--4dp fop-scroll-menu">
															<?php foreach ($columns AS $col) { ?>
																<li class="mdl-list__item mdl-button" onclick="
																	var isVisible = this.firstElementChild.innerText !== 'clear';
																	this.firstElementChild.innerText = isVisible ? 'clear' : 'visibility'; // switch icon
																	tableColumnVisibility('gruppe', <?php echo htmlentities(json_encode($col['id'])); ?>, !isVisible); // the rest is up to a helper function in layout/tables.fop
																	">
																	<i class="material-icons"><?php if ($col['collapsed']) { echo 'clear'; } else { echo 'visibility'; }?></i>
																	<?php echo htmlentities($col['desc']); ?>
																</li>
															<?php } ?>
															<li class="mdl-list__item mdl-button" onclick="
																$.get('FOP/Index/dataview?data='+encodeURIComponent(JSON.stringify({dataview: 'gruppe', reset: true}))).then(function () { location.reload(); });
																">
																<i class="material-icons">refresh</i>
																<?php echo _('reset all'); ?>
															</li>
														</ul>
													</div>
												</div><?php }
												
												foreach ($columns AS $col) {
													// Spalten-Überschrift rendern
													echo $col['header'];
												} ?>
											 </div>
											
											<div class="fop-table-body" id="table_gruppe" <?php \EasyEditor\Navigation::printScroll('dv.Gruppe', '/* scroll horiz */ this.nextElementSibling.firstElementChild.style.marginLeft = this.previousElementSibling.firstElementChild.style.marginLeft = \'-\' + this.scrollLeft + \'px\';
												/* scroll verti */
												var self = this;
												if (window.DataViewScrollReloadTimeout) clearTimeout(window.DataViewScrollReloadTimeout);
												window.DataViewScrollReloadTimeout = setTimeout(function () {
													var currentPage = parseInt(query[\'page_gruppe\'] || 0);
													var paddingTop = parseInt( self.lastElementChild.style.paddingTop, 10);
													var wantedPage = Math.max(0, currentPage + Math.floor((self.scrollTop - paddingTop) / ' . ($itemheight * $itemsperpage) . '));
													if (wantedPage != currentPage) {
														query[\'page_gruppe\'] = wantedPage;
														reloadgruppe(undefined, undefined, true);
													}
												}, 50);
											'); ?>>
												<div class="fop-table-body-inner" style="min-height: <?php echo 12 + $itemheight * ($itemcount + $additionalLines); ?>px; padding-top: <?php echo $itemheight * $itemsperpage * $page; ?>px;">
												<?php foreach($arr as $itempos => $item) {
													
													if ($itempos != 0) $checkAggregates(null, $item);?>
													<div class="fop-table-row" style="" data-gruppe-id="<?php echo htmlentities($item['ID']); ?>"<?php if (isset($item['ID'])){
														if (isset($_GET['select']) && isset($_GET['from'])) {
															echo 'onclick="event.preventDefault(); if (!window.getSelection().toString()) window.location.href=' . htmlentities(json_encode($_GET['from'] . '&colvalue=' . urlencode($item['ID']))) . ';" ';
														} else {
															echo 'onclick="event.preventDefault(); if (!window.getSelection().toString()) open_url(reloadgruppe({action: \'open\', fop_table: \'gruppe\', fop_id: ' .  htmlentities(json_encode($item['ID'])) . ', fop_from: location.href}, true), true);"';
														}
													}?> >

													<?php if (!isset($_GET['select'])) { ?>
													<div class='fop-table-column noprint' style="width: <?php echo json_encode($firstColumnWidth); ?>px;" onclick="$(this).find('input[type=checkbox]').first().click(); event.stopPropagation();">
													<label onclick="event.stopPropagation();" class="mdl-checkbox mdl-js-checkbox gruppe__checkbox gruppe__checkbox gruppe__checkbox-ID-<?php echo htmlentities($item['ID']); ?>" style="width: auto;" for="gruppe__<?php echo htmlentities($itempos); ?>-checkbox">
													<input class="mdl-checkbox__input" id="gruppe__<?php echo htmlentities($itempos); ?>-checkbox" type="checkbox" onchange="<?php if (isset($item['ID'])) echo 'checkgruppe(' . htmlentities(json_encode($item['ID'])) . ', \'ID\', this.checked); ' ?>">
													</label><button type="button" class="mdl-button mdl-js-button mdl-button--icon gruppe__action" onclick="
														event.stopPropagation();
														dropDownFixPosition($(this), $(this).next());
														">
														<i class="material-icons">more_vert</i>
													</button><ul class="mdl-list mdl-card mdl-shadow--4dp fop-scroll-menu" id="fop-scroll-menu-gruppe-action-<?php echo $item['ID'] ?? 0; ?>">
														<?php
		if(isset($item['ID']) && $item['operation::view']) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="view" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Gruppe::viewURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick=" if (!event.ctrlKey) { open_url(reloadgruppe({action: 'open', fop_table: 'gruppe', fop_id: <?php echo htmlentities(json_encode($item['ID'])); ?>, fop_from: location.href}, true), true); return false; } $(this).closest('.overlay').click(); return false;  
					open_url(this.href, true);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">find_in_page</i></span><span class="fop-menu-caption" title="<?php echo(_('open')); ?>"><?php echo(_('open')); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && $item['operation::view'] && $item['operation::edit']) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="edit" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Gruppe::editURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, true);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">edit</i></span><span class="fop-menu-caption" title="<?php echo(_('edit')); ?>"><?php echo(_('edit')); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((\FOP\User::getDokument())) && $item['operation::2d116d15dc29336bb749526a5539896a8de1dc6711cc39a36c9deafb330a7d11'] && $item['operation::bcwXCW1H'] && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="create_doc_to-gruppe" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Doc::createURL2(['column_to-gruppe' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, true);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">create</i></span><span class="fop-menu-caption" title="<?php echo(sprintf(_('create %s'), _('Dokument'))); ?>"><?php echo(sprintf(_('create %s'), _('Dokument'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((\FOP\User::getGruppe())) && $item['operation::2c7eef2a4b491903463d0ce1ed0ec3d6319a1099957d1344bf29e389097ca9ae'] && $item['operation::770b66fd32023ffe61686523acdd27c2397c0396a642efe0bfe5f5ff6e454bd7'] && $item['operation::OrtqOgf3'] && $item['operation::t0aG1aFV'] && (!\FOP\User::getIsGuest())) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="create_gruppeItem_list" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\GruppeItem::createURL2(['column_list' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">create</i></span><span class="fop-menu-caption" title="<?php echo(sprintf(_('create %s'), _('Gruppenmitglied'))); ?>"><?php echo(sprintf(_('create %s'), _('Gruppenmitglied'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((\FOP\User::getGruppe()) && (\FOP\User::getGruppe())) && $item['operation::e78c0756f011f71fc72c7fd98ca3008070a04e8a37f2c26ef0343632a5aeca76'] && $item['operation::187359c749ff52d493bfa3fa84f3ae48f981dd0701bcc3cfc7ae94374f6cdbcf'] && $item['operation::OrtqOgf3'] && $item['operation::t0aG1aFV']) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="create_gruppeVerantwortlich_gruppe" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\GruppeVerantwortlich::createURL2(['column_gruppe' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">create</i></span><span class="fop-menu-caption" title="<?php echo(sprintf(_('create %s'), _('Gruppenverantwortlicher'))); ?>"><?php echo(sprintf(_('create %s'), _('Gruppenverantwortlicher'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && $item['operation::view'] && $item['operation::edit']) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="lifecycleEnd" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Gruppe::lifecycleEndURL2(['id' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">stop</i></span><span class="fop-menu-caption" title="<?php echo(sprintf(_('%s setzen'), _('Auflösungsdatum'))); ?>"><?php echo(sprintf(_('%s setzen'), _('Auflösungsdatum'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && $item['operation::delete']) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="delete" style="margin-right:auto; text-align:left;" href="#"
				onclick="if(!confirm(<?php echo htmlentities(json_encode(_('confirmdelete'))); ?>)) return false;   $.get('Tables/Gruppe/delete?ajax&id=<?php echo htmlentities($item['ID']);?>&from=<?php echo htmlentities(\FOP\Util::getBackUrl());?>').then(function () { reloadgruppe(); }, function (err) { if (err.responseText.startsWith('http')) { window.location.href = err.responseText; } else {alert(err.responseText); }}); $(this).closest('.overlay').click(); return false;
					open_url(this.href, true);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">delete</i></span><span class="fop-menu-caption" title="<?php echo(_('delete')); ?>"><?php echo(_('delete')); ?></span>
			</a>
		<?php } ?>
													</ul><?php
		if(isset($item['ID']) && $item['operation::view'] && $item['operation::edit']) {
			?><a class="mdl-button mdl-js-button mdl-button--icon tbl-link" data-tbl="gruppe" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="edit" href="<?php echo htmlentities(\TablesRouter\Gruppe::editURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();    reloadgruppe();
					$(this).closest('.overlay').click();
					if (this.href != '#') {
						open_url(this.href, true);
					}
					event.preventDefault();"
				title="<?php echo(_('edit')); ?>">
				<i class="material-icons">edit</i>
			</a><?php } ?><?php
		if(isset($item['ID']) && $item['operation::view']) {
			?><a class="mdl-button mdl-js-button mdl-button--icon tbl-link" data-tbl="gruppe" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="view" href="<?php echo htmlentities(\TablesRouter\Gruppe::viewURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();  if (!event.ctrlKey) { open_url(reloadgruppe({action: 'open', fop_table: 'gruppe', fop_id: <?php echo htmlentities(json_encode($item['ID'])); ?>, fop_from: location.href}, true), true); return false; }  reloadgruppe();
					$(this).closest('.overlay').click();
					if (this.href != '#') {
						open_url(this.href, true);
					}
					event.preventDefault();"
				title="<?php echo(_('open')); ?>">
				<i class="material-icons">find_in_page</i>
			</a><?php } ?>
													</div><?php } ?><?php
													
													foreach ($columns AS $col) {
														$col['render']($item);
													}
													?></div>
												 <?php }
												$checkAggregates(null, null);?>

													</div>
												</div>
												<?php
												// allerletzte Zeile
												$renderAggregateRow($data['aggregate']);
												?>

												
												
												</div><?php
												
	
    
  }

  public static function getidsAction($col) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
			$q = \FOP\Database::query('SELECT t.'.qi($col).' '.self::getSQL($_GET));
			$result = new \FOP\IDList();
			while ($item = $q->fetchColumn()) {
				$result->push($item);
			}
			die($result->toString());

    
  }

  public static function permissionsAction($id) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
		$ids = new \FOP\IDList($id);
		header('Content-Type: application/json');
		
		$perms = \FOP\Database::query('SELECT COUNT(*) AS __cnt, SUM(CASE ((CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('gruppe').'.'.qi('public').'))) END)) AND ((CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('Wk3yjwJT').' WHERE '.qi('Wk3yjwJT').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('Wk3yjwJT').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1) END) AND ('.\FOP\Database::quote(\FOP\User::getGruppe()).')) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('lifecycleEnd').', SUM(CASE (TRUE) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('filteronly').', SUM(CASE (TRUE) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('filterrange').', SUM(CASE (TRUE) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('filterall').', SUM(CASE ((CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('Wk3yjwJT').' WHERE '.qi('Wk3yjwJT').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('Wk3yjwJT').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1) END) AND ('.\FOP\Database::quote(\FOP\User::getGruppe()).')) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('delete').' FROM '.qi('gruppe').' WHERE ' . $ids->toSQL(qi('ID')))->fetch(\PDO::FETCH_ASSOC);
		
		return $perms;
	
    
  }

  public static function getSQL($params) { 
    
    
    // --- BLOCK: dependency-gruppe ---
    
		if (isset($params['select']) && $params['select'] == 'gruppe') {
			$deps = [];
		}
	
    // --- BLOCK: dependency-gruppeNullDMS ---
    
		if (isset($params['select']) && $params['select'] == 'gruppeNullDMS') {
			$deps = [];
		}
	
    // --- BLOCK: main ---
    
								// returns a sql snippet 'FROM (...) AS t WHERE' where you can prepend your select clauses and append your ORDER LIMIT
								$sql = 'FROM (SELECT /* ID */ '.qi('ID').' AS '.qi('ID').',
									/* anzahl */ (SELECT COUNT(1) FROM '.qi('gruppeItem').' '.qi('KUVJWuZi').' WHERE '.qi('KUVJWuZi').'.'.qi('list').' = '.qi('gruppe').'.'.qi('ID').' AND ((('.qi('KUVJWuZi').'.'.qi('eintritt').') <= (' . \FOP\Database::sessionVarSQL('time') . ')) AND ((COALESCE('.qi('KUVJWuZi').'.'.qi('austritt').', ' . \FOP\Database::sessionVarSQL('time') . ')) >= (' . \FOP\Database::sessionVarSQL('time') . '))) LIMIT 1) AS '.qi('anzahl').',
									/* ende */ '.qi('ende').' AS '.qi('ende').',
									/* items */ (SELECT COUNT(1) FROM '.qi('gruppeItem').' '.qi('kH54lx3D').' WHERE '.qi('kH54lx3D').'.'.qi('list').' = '.qi('gruppe').'.'.qi('ID').' LIMIT 1) AS '.qi('items').',
									/* memberVisibility */ '.qi('memberVisibility').' AS '.qi('memberVisibility').',
									/* name */ '.qi('name').' AS '.qi('name').',
									/* operation::2c7eef2a4b491903463d0ce1ed0ec3d6319a1099957d1344bf29e389097ca9ae */ CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('Wk3yjwJT').' WHERE '.qi('Wk3yjwJT').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('Wk3yjwJT').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1) END AS '.qi('operation::2c7eef2a4b491903463d0ce1ed0ec3d6319a1099957d1344bf29e389097ca9ae').',
									/* operation::2d116d15dc29336bb749526a5539896a8de1dc6711cc39a36c9deafb330a7d11 */ CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('gruppe').'.'.qi('public').'))) END AS '.qi('operation::2d116d15dc29336bb749526a5539896a8de1dc6711cc39a36c9deafb330a7d11').',
									/* operation::770b66fd32023ffe61686523acdd27c2397c0396a642efe0bfe5f5ff6e454bd7 */ '.\FOP\Database::quote(\FOP\User::getGruppe()).' AS '.qi('operation::770b66fd32023ffe61686523acdd27c2397c0396a642efe0bfe5f5ff6e454bd7').',
									/* operation::187359c749ff52d493bfa3fa84f3ae48f981dd0701bcc3cfc7ae94374f6cdbcf */ '.\FOP\Database::quote(\FOP\User::getGruppe()).' AS '.qi('operation::187359c749ff52d493bfa3fa84f3ae48f981dd0701bcc3cfc7ae94374f6cdbcf').',
									/* operation::OrtqOgf3 */ (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('Wk3yjwJT').' WHERE '.qi('Wk3yjwJT').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('Wk3yjwJT').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1) END) AS '.qi('operation::OrtqOgf3').',
									/* operation::bcwXCW1H */ (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('gruppe').'.'.qi('public').'))) END) AS '.qi('operation::bcwXCW1H').',
									/* operation::create */ (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('Wk3yjwJT').' WHERE '.qi('Wk3yjwJT').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('Wk3yjwJT').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1) END) AND ('.\FOP\Database::quote(\FOP\User::getGruppe()).') AS '.qi('operation::create').',
									/* operation::delete */ (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('Wk3yjwJT').' WHERE '.qi('Wk3yjwJT').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('Wk3yjwJT').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1) END) AND ('.\FOP\Database::quote(\FOP\User::getGruppe()).') AS '.qi('operation::delete').',
									/* operation::e78c0756f011f71fc72c7fd98ca3008070a04e8a37f2c26ef0343632a5aeca76 */ CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('Wk3yjwJT').' WHERE '.qi('Wk3yjwJT').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('Wk3yjwJT').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1) END AS '.qi('operation::e78c0756f011f71fc72c7fd98ca3008070a04e8a37f2c26ef0343632a5aeca76').',
									/* operation::edit */ (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('Wk3yjwJT').' WHERE '.qi('Wk3yjwJT').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('Wk3yjwJT').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1) END) AND ('.\FOP\Database::quote(\FOP\User::getGruppe()).') AS '.qi('operation::edit').',
									/* operation::index */ ' . (!\FOP\User::getIsGuest() ? 1 : 0) . ' AS '.qi('operation::index').',
									/* operation::t0aG1aFV */ ('.\FOP\Database::quote(\FOP\User::getGruppe()).') AS '.qi('operation::t0aG1aFV').',
									/* operation::view */ (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('gruppe').'.'.qi('public').'))) END) AS '.qi('operation::view').',
									/* public */ '.qi('public').' AS '.qi('public').',
									/* start */ '.qi('start').' AS '.qi('start').',
									1
								FROM '.qi('gruppe').' '.qi('gruppe').'
								WHERE (((CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('gruppe').'.'.qi('public').'))) END)))
									AND (' . (isset($_GET['select']) && $_GET['select'] == 'gruppe' ? 'TRUE' : 'TRUE') . ')
									AND (' . (isset($_GET['select']) && $_GET['select'] == 'gruppeNullDMS' ? 'TRUE' : 'TRUE') . ')) AS t
								WHERE ' . (isset($params['range_min_gruppe_anzahl']) ? ($params['range_min_gruppe_anzahl'] !== '' && is_numeric($params['range_min_gruppe_anzahl']) ? 't.'.qi('anzahl').' >= ' . \FOP\Database::quote($params['range_min_gruppe_anzahl']) . ' AND ' : '') : '') . 
								(isset($params['range_min_gruppe_items']) ? ($params['range_min_gruppe_items'] !== '' && is_numeric($params['range_min_gruppe_items']) ? 't.'.qi('items').' >= ' . \FOP\Database::quote($params['range_min_gruppe_items']) . ' AND ' : '') : '') . 
								(isset($params['range_min_gruppe_start']) ? ($params['range_min_gruppe_start'] !== '' && is_numeric($params['range_min_gruppe_start']) ? 't.'.qi('start').' >= ' . \FOP\Database::quote($params['range_min_gruppe_start']) . ' AND ' : '') : '') . 
								(isset($params['range_min_gruppe_ende']) ? ($params['range_min_gruppe_ende'] !== '' && is_numeric($params['range_min_gruppe_ende']) ? 't.'.qi('ende').' >= ' . \FOP\Database::quote($params['range_min_gruppe_ende']) . ' AND ' : '') : '') . 
								(isset($params['range_max_gruppe_anzahl']) ? ($params['range_max_gruppe_anzahl'] !== '' && is_numeric($params['range_max_gruppe_anzahl']) ? 't.'.qi('anzahl').' <= ' . \FOP\Database::quote($params['range_max_gruppe_anzahl']) . ' AND ' : '') : '') . 
								(isset($params['range_max_gruppe_items']) ? ($params['range_max_gruppe_items'] !== '' && is_numeric($params['range_max_gruppe_items']) ? 't.'.qi('items').' <= ' . \FOP\Database::quote($params['range_max_gruppe_items']) . ' AND ' : '') : '') . 
								(isset($params['range_max_gruppe_start']) ? ($params['range_max_gruppe_start'] !== '' && is_numeric($params['range_max_gruppe_start']) ? 't.'.qi('start').' <= ' . \FOP\Database::quote($params['range_max_gruppe_start']) . ' AND ' : '') : '') . 
								(isset($params['range_max_gruppe_ende']) ? ($params['range_max_gruppe_ende'] !== '' && is_numeric($params['range_max_gruppe_ende']) ? 't.'.qi('ende').' <= ' . \FOP\Database::quote($params['range_max_gruppe_ende']) . ' AND ' : '') : '') . 
								(isset($params['filter_gruppe_anzahl']) ? ($params['filter_gruppe_anzahl'] !== '' ? ('(' . (new \FOP\IDList($params['filter_gruppe_anzahl']))->toSQL('t.'.qi('anzahl').'') . ') AND ') : '') : '') . 
								(isset($params['filter_gruppe_public']) ? ($params['filter_gruppe_public'] !== '' ? ('(' . (new \FOP\IDList($params['filter_gruppe_public']))->toSQL('t.'.qi('public').'') . ') AND ') : '') : '') . 
								(isset($params['filter_gruppe_memberVisibility']) ? ($params['filter_gruppe_memberVisibility'] !== '' ? ('(' . (new \FOP\IDList($params['filter_gruppe_memberVisibility']))->toSQL('t.'.qi('memberVisibility').'') . ') AND ') : '') : '') . 
								(isset($params['filter_gruppe_start']) ? ($params['filter_gruppe_start'] !== '' ? ('(' . (new \FOP\IDList($params['filter_gruppe_start']))->toSQL('t.'.qi('start').'') . ') AND ') : '') : '') . 
								(isset($params['filter_gruppe_ende']) ? ($params['filter_gruppe_ende'] !== '' ? ('(' . (new \FOP\IDList($params['filter_gruppe_ende']))->toSQL('t.'.qi('ende').'') . ') AND ') : '') : '') . 
								(isset($params['filter_gruppe_name']) ? ($params['filter_gruppe_name'] !== '' ? ('(' . (new \FOP\IDList($params['filter_gruppe_name']))->toSQL('t.'.qi('name').'') . ') AND ') : '') : '') . 
								(isset($params['filter_gruppe_items']) ? ($params['filter_gruppe_items'] !== '' ? ('(' . (new \FOP\IDList($params['filter_gruppe_items']))->toSQL('t.'.qi('items').'') . ') AND ') : '') : '') . 
								(isset($params['filter_gruppe_ID']) ? ($params['filter_gruppe_ID'] !== '' ? ('(' . (new \FOP\IDList($params['filter_gruppe_ID']))->toSQL('t.'.qi('ID').'') . ') AND ') : '') : '') . 
								(isset($params['search_gruppe_name']) ? 't.'.qi('name').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_gruppe_name'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_gruppe_name']) ? 'NOT t.'.qi('name').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_gruppe_name'] . '%') . ' AND ' : '') . 
								(isset($params['search_gruppe']) ? '(' . 't.'.qi('name').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_gruppe'] . '%') . ') AND ' : '') . 
								'
								(' . (isset($params['dynamic_gruppe']) ? ($params['dynamic_gruppe'] == 0 ? '1' : '(t.'.qi('start').' IS NULL OR t.'.qi('start').' <= ' . intval($params['dynamic_gruppe']) . ') AND (t.'.qi('ende').' IS NULL OR t.'.qi('ende').' >= ' . intval($params['dynamic_gruppe']) . ')') : '(t.'.qi('start').' IS NULL OR t.'.qi('start').' <= UNIX_TIMESTAMP()) AND (t.'.qi('ende').' IS NULL OR t.'.qi('ende').' >= UNIX_TIMESTAMP())') . ') AND  TRUE ';
								return $sql;
	
    
  }

  public static function getData($sqladdon, $params, $stream = false ) { 
    
    
    // --- BLOCK: before-DynamicTime ---
    
// dynamische Zeit für Datenbankaufrufe setzen, wenn eine übergeben wurde
        if (isset($params['dynamic_gruppe']))
                \FOP\Database::setTime($params['dynamic_gruppe']);
        
    // --- BLOCK: main ---
    
								$sql = self::getSQL($params);

								$order = (\FOP\Util::array_value(array(
									'name ASC' => 'ORDER BY t.'.qi('name').' ASC',
									'anzahl ASC' => 'ORDER BY t.'.qi('anzahl').' ASC',
									'items ASC' => 'ORDER BY t.'.qi('items').' ASC',
									'start ASC' => 'ORDER BY t.'.qi('start').' ASC',
									'ende ASC' => 'ORDER BY t.'.qi('ende').' ASC',
									'name DESC' => 'ORDER BY t.'.qi('name').' DESC',
									'anzahl DESC' => 'ORDER BY t.'.qi('anzahl').' DESC',
									'items DESC' => 'ORDER BY t.'.qi('items').' DESC',
									'start DESC' => 'ORDER BY t.'.qi('start').' DESC',
									'ende DESC' => 'ORDER BY t.'.qi('ende').' DESC',
									'' => ''), isset($params['sort_gruppe']) ? $params['sort_gruppe'] : '') ?: '');
								// wenn sqladdon bereits ein ORDER enthält, kein order aufbauen
								if (strpos($sqladdon, 'ORDER') !== false) {
									$order = '';
								}
								if ($stream) {
									// als Stream (währenddessen darf keine weitere SQL-Query laufen) für große Datenmengen und Statistiken
									$result = (function () use ($sql, $order, $sqladdon) {
										$stream = \FOP\Database::query('SELECT t.* ' . $sql . $order . $sqladdon);
										while ($item = $stream->fetch(\PDO::FETCH_ASSOC)) {
											$item['anzahl'] = \Types\Integer::unpack($item['anzahl']);
											$item['public'] = \FOP\Util::BoolSanitizer($item['public']);
											$item['memberVisibility'] = \FOP\Util::BoolSanitizer($item['memberVisibility']);
											$item['start'] = intval($item['start']);
											$item['ende'] = intval($item['ende']);
											$item['items'] = \Types\Integer::unpack($item['items']);
											
											yield $item;
										}
									})();
								} else {
									// als RAM-Array
									$result = \FOP\Database::query('SELECT t.* ' . $sql . $order . $sqladdon);
									$arr = $result->fetchAll(\PDO::FETCH_ASSOC);
									$itemcount = count($arr);

									foreach($arr as $i => &$item){
										$item['anzahl'] = \Types\Integer::unpack($item['anzahl']);
										$item['public'] = \FOP\Util::BoolSanitizer($item['public']);
										$item['memberVisibility'] = \FOP\Util::BoolSanitizer($item['memberVisibility']);
										$item['start'] = intval($item['start']);
										$item['ende'] = intval($item['ende']);
										$item['items'] = \Types\Integer::unpack($item['items']);
										
									}
									unset($item);

									$result = ["items" => $arr, "itemcount" => $itemcount];

									
										$result['aggregate'] = \FOP\Database::query('SELECT COUNT(*) AS '.qi('::cnt').', SUM(t.'.qi('anzahl').') AS '.qi('anzahl').' ' . $sql)->fetch(\PDO::FETCH_ASSOC);
										$result['aggregate']['anzahl'] = \Types\Integer::unpack($result['aggregate']['anzahl']);
										
									
								}

								return $result;
	
    // --- BLOCK: main-DynamicTime ---
    
// ggf. dynamische Zeit zurücksetzen
        if (isset($params['dynamic_gruppe']))
                \FOP\Database::setTime(time());
        
    
  }

  public static function getFilterHTML($params, $delimiter = ', ' , $showButton = true ) { 
    
    
    // --- BLOCK: main ---
    
		// Contract: ist showButton == false, sollten keine HTML-Tags im Output enthalten sein (Verwendung in Dateinamen!!)
		$filters = [];
		
	if (isset($params['range_min_gruppe_anzahl']) && isset($params['range_max_gruppe_anzahl'])) {
		array_push($filters, _('Mitglieder') . ': ' . (\Types\Integer::print($params['range_min_gruppe_anzahl'])
	) . ' ' . _('filters_between') . ' ' . (\Types\Integer::print($params['range_max_gruppe_anzahl'])
	));
	} else if (isset($params['range_min_gruppe_anzahl'])) {
		array_push($filters, _('Mitglieder') . ': ' . _('filters_from') . ' ' . (\Types\Integer::print($params['range_min_gruppe_anzahl'])
	));
	} else if (isset($params['range_max_gruppe_anzahl'])) {
		array_push($filters, _('Mitglieder') . ': ' . _('filters_to') . ' ' . (\Types\Integer::print($params['range_max_gruppe_anzahl'])
	));
	}
	if (isset($params['range_min_gruppe_items']) && isset($params['range_max_gruppe_items'])) {
		array_push($filters, _('Gruppenmitglieder') . ': ' . (\Types\Integer::print($params['range_min_gruppe_items'])
	) . ' ' . _('filters_between') . ' ' . (\Types\Integer::print($params['range_max_gruppe_items'])
	));
	} else if (isset($params['range_min_gruppe_items'])) {
		array_push($filters, _('Gruppenmitglieder') . ': ' . _('filters_from') . ' ' . (\Types\Integer::print($params['range_min_gruppe_items'])
	));
	} else if (isset($params['range_max_gruppe_items'])) {
		array_push($filters, _('Gruppenmitglieder') . ': ' . _('filters_to') . ' ' . (\Types\Integer::print($params['range_max_gruppe_items'])
	));
	}
	
	if ( // Corner Case: Monat
		isset($params['range_min_gruppe_start'])
		&& isset($params['range_max_gruppe_start'])
		&& (date('d', $params['range_min_gruppe_start']) == '01') //check first day of month
		&& (date('d', $params['range_max_gruppe_start']) == date('t', $params['range_max_gruppe_start'])) //check last day of month
		&& (date('Y-m', $params['range_min_gruppe_start']) == date('Y-m', $params['range_max_gruppe_start'])) //check if same year and month
	) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_start&apos;] = &apos;'.strtotime('first day of last month', $params['range_min_gruppe_start']).'&apos;;
				query[&apos;range_max_gruppe_start&apos;] = &apos;'.strtotime('last day of last month', $params['range_min_gruppe_start']).'&apos;;
				reloadgruppe(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_start&apos;] = &apos;'.strtotime('first day of next month', $params['range_min_gruppe_start']).'&apos;;
				query[&apos;range_max_gruppe_start&apos;] = &apos;'.strtotime('last day of next month', $params['range_min_gruppe_start']).'&apos;;
				reloadgruppe(); ">add_circle_outline</i>' : ''),
			htmlentities(_('Gründungsdatum') . ': ' . strftime('%B', $params['range_min_gruppe_start']) . ' ' . date('Y', $params['range_min_gruppe_start']))
		]);
	} else if ( // Corner Case: Tag
		isset($params['range_min_gruppe_start'])
		&& isset($params['range_max_gruppe_start'])
		&& (date('Y-m-d', $params['range_min_gruppe_start']) == (date('Y-m-d', $params['range_max_gruppe_start'])))
	) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_start&apos;] = &apos;'.strtotime('last day', $params['range_min_gruppe_start']).'&apos;;
				query[&apos;range_max_gruppe_start&apos;] = &apos;'.strtotime('last day', $params['range_min_gruppe_start']).'&apos;;
				reloadgruppe(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_start&apos;] = &apos;'.strtotime('next day', $params['range_min_gruppe_start']).'&apos;;
				query[&apos;range_max_gruppe_start&apos;] = &apos;'.strtotime('next day', $params['range_min_gruppe_start']).'&apos;;
				reloadgruppe(); ">add_circle_outline</i>' : ''),
			htmlentities(_('Gründungsdatum') . ': ' . date('d.m.Y', $params['range_min_gruppe_start']))
		]);
	} else if ( // Corner Case: Jahr
		isset($params['range_min_gruppe_start'])
		&& isset($params['range_max_gruppe_start'])
		&& (date('Y', $params['range_min_gruppe_start']) == (date('Y', $params['range_max_gruppe_start'])))
		&& ((date('m-d', $params['range_min_gruppe_start']) == '01-01'))
		&& ((date('m-d', $params['range_max_gruppe_start']) == '12-31'))
	) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_start&apos;] = &apos;'.strtotime('first day of January last year', $params['range_min_gruppe_start']).'&apos;;
				query[&apos;range_max_gruppe_start&apos;] = &apos;'.strtotime('last day of December last year', $params['range_min_gruppe_start']).'&apos;;
				reloadgruppe(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_start&apos;] = &apos;'.strtotime('first day of January next year', $params['range_min_gruppe_start']).'&apos;;
				query[&apos;range_max_gruppe_start&apos;] = &apos;'.strtotime('last day of December next year', $params['range_min_gruppe_start']).'&apos;;
				reloadgruppe(); ">add_circle_outline</i>' : ''),
			htmlentities(_('Gründungsdatum') . ': ' . date('Y', $params['range_min_gruppe_start']))
		]);
	} else if ( // Corner Case: Quartal
		isset($params['range_min_gruppe_start'])
		&& isset($params['range_max_gruppe_start'])
		&& ( (
		 ((date('m-d', $params['range_min_gruppe_start']) == '01-01'))
		&& ((date('m-d', $params['range_max_gruppe_start']) == '03-31')) )
		|| (
		 ((date('m-d', $params['range_min_gruppe_start']) == '04-01'))
		&& ((date('m-d', $params['range_max_gruppe_start']) == '06-30')) )
		|| (
		 ((date('m-d', $params['range_min_gruppe_start']) == '07-01'))
		&& ((date('m-d', $params['range_max_gruppe_start']) == '09-30')) )
		|| (
		 ((date('m-d', $params['range_min_gruppe_start']) == '10-01'))
		&& ((date('m-d', $params['range_max_gruppe_start']) == '12-31')) )
	) ) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
					query[&apos;range_min_gruppe_start&apos;] = &apos;'.strtotime('first day of -3 months', $params['range_min_gruppe_start']).'&apos;;
					query[&apos;range_max_gruppe_start&apos;] = &apos;'.strtotime('last day of -3 months', $params['range_max_gruppe_start']).'&apos;;
					reloadgruppe(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_start&apos;] = &apos;'.strtotime('first day of +3 months', $params['range_min_gruppe_start']).'&apos;;
				query[&apos;range_max_gruppe_start&apos;] = &apos;'.strtotime('last day of +3 months', $params['range_max_gruppe_start']).'&apos;;
				reloadgruppe(); ">add_circle_outline</i>' : ''),	
			htmlentities(_('Gründungsdatum') . ': Q' . (ceil((date('m', $params['range_min_gruppe_start']))/3)) . ' (' . date('d.m.', $params['range_min_gruppe_start']) . ' - ' . date('d.m.Y', $params['range_max_gruppe_start']) . ')')
		]);
	}
	else if (isset($params['range_min_gruppe_start']) && isset($params['range_max_gruppe_start'])) {
		array_push($filters, _('Gründungsdatum') . ': ' . (($params['range_min_gruppe_start']) ? strftime(_('dateformat_php2'), intval($params['range_min_gruppe_start'])) : '') . ' ' . _('filters_between') . ' ' . (($params['range_max_gruppe_start']) ? strftime(_('dateformat_php2'), intval($params['range_max_gruppe_start'])) : ''));
	} else if (isset($params['range_min_gruppe_start'])) {
		array_push($filters, _('Gründungsdatum') . ': ' . _('filters_from') . ' ' . (($params['range_min_gruppe_start']) ? strftime(_('dateformat_php2'), intval($params['range_min_gruppe_start'])) : ''));
	} else if (isset($params['range_max_gruppe_start'])) {
		array_push($filters, _('Gründungsdatum') . ': ' . _('filters_to') . ' ' . (($params['range_max_gruppe_start']) ? strftime(_('dateformat_php2'), intval($params['range_max_gruppe_start'])) : ''));
	}
	
	if ( // Corner Case: Monat
		isset($params['range_min_gruppe_ende'])
		&& isset($params['range_max_gruppe_ende'])
		&& (date('d', $params['range_min_gruppe_ende']) == '01') //check first day of month
		&& (date('d', $params['range_max_gruppe_ende']) == date('t', $params['range_max_gruppe_ende'])) //check last day of month
		&& (date('Y-m', $params['range_min_gruppe_ende']) == date('Y-m', $params['range_max_gruppe_ende'])) //check if same year and month
	) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_ende&apos;] = &apos;'.strtotime('first day of last month', $params['range_min_gruppe_ende']).'&apos;;
				query[&apos;range_max_gruppe_ende&apos;] = &apos;'.strtotime('last day of last month', $params['range_min_gruppe_ende']).'&apos;;
				reloadgruppe(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_ende&apos;] = &apos;'.strtotime('first day of next month', $params['range_min_gruppe_ende']).'&apos;;
				query[&apos;range_max_gruppe_ende&apos;] = &apos;'.strtotime('last day of next month', $params['range_min_gruppe_ende']).'&apos;;
				reloadgruppe(); ">add_circle_outline</i>' : ''),
			htmlentities(_('Auflösungsdatum') . ': ' . strftime('%B', $params['range_min_gruppe_ende']) . ' ' . date('Y', $params['range_min_gruppe_ende']))
		]);
	} else if ( // Corner Case: Tag
		isset($params['range_min_gruppe_ende'])
		&& isset($params['range_max_gruppe_ende'])
		&& (date('Y-m-d', $params['range_min_gruppe_ende']) == (date('Y-m-d', $params['range_max_gruppe_ende'])))
	) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_ende&apos;] = &apos;'.strtotime('last day', $params['range_min_gruppe_ende']).'&apos;;
				query[&apos;range_max_gruppe_ende&apos;] = &apos;'.strtotime('last day', $params['range_min_gruppe_ende']).'&apos;;
				reloadgruppe(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_ende&apos;] = &apos;'.strtotime('next day', $params['range_min_gruppe_ende']).'&apos;;
				query[&apos;range_max_gruppe_ende&apos;] = &apos;'.strtotime('next day', $params['range_min_gruppe_ende']).'&apos;;
				reloadgruppe(); ">add_circle_outline</i>' : ''),
			htmlentities(_('Auflösungsdatum') . ': ' . date('d.m.Y', $params['range_min_gruppe_ende']))
		]);
	} else if ( // Corner Case: Jahr
		isset($params['range_min_gruppe_ende'])
		&& isset($params['range_max_gruppe_ende'])
		&& (date('Y', $params['range_min_gruppe_ende']) == (date('Y', $params['range_max_gruppe_ende'])))
		&& ((date('m-d', $params['range_min_gruppe_ende']) == '01-01'))
		&& ((date('m-d', $params['range_max_gruppe_ende']) == '12-31'))
	) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_ende&apos;] = &apos;'.strtotime('first day of January last year', $params['range_min_gruppe_ende']).'&apos;;
				query[&apos;range_max_gruppe_ende&apos;] = &apos;'.strtotime('last day of December last year', $params['range_min_gruppe_ende']).'&apos;;
				reloadgruppe(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_ende&apos;] = &apos;'.strtotime('first day of January next year', $params['range_min_gruppe_ende']).'&apos;;
				query[&apos;range_max_gruppe_ende&apos;] = &apos;'.strtotime('last day of December next year', $params['range_min_gruppe_ende']).'&apos;;
				reloadgruppe(); ">add_circle_outline</i>' : ''),
			htmlentities(_('Auflösungsdatum') . ': ' . date('Y', $params['range_min_gruppe_ende']))
		]);
	} else if ( // Corner Case: Quartal
		isset($params['range_min_gruppe_ende'])
		&& isset($params['range_max_gruppe_ende'])
		&& ( (
		 ((date('m-d', $params['range_min_gruppe_ende']) == '01-01'))
		&& ((date('m-d', $params['range_max_gruppe_ende']) == '03-31')) )
		|| (
		 ((date('m-d', $params['range_min_gruppe_ende']) == '04-01'))
		&& ((date('m-d', $params['range_max_gruppe_ende']) == '06-30')) )
		|| (
		 ((date('m-d', $params['range_min_gruppe_ende']) == '07-01'))
		&& ((date('m-d', $params['range_max_gruppe_ende']) == '09-30')) )
		|| (
		 ((date('m-d', $params['range_min_gruppe_ende']) == '10-01'))
		&& ((date('m-d', $params['range_max_gruppe_ende']) == '12-31')) )
	) ) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
					query[&apos;range_min_gruppe_ende&apos;] = &apos;'.strtotime('first day of -3 months', $params['range_min_gruppe_ende']).'&apos;;
					query[&apos;range_max_gruppe_ende&apos;] = &apos;'.strtotime('last day of -3 months', $params['range_max_gruppe_ende']).'&apos;;
					reloadgruppe(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_gruppe_ende&apos;] = &apos;'.strtotime('first day of +3 months', $params['range_min_gruppe_ende']).'&apos;;
				query[&apos;range_max_gruppe_ende&apos;] = &apos;'.strtotime('last day of +3 months', $params['range_max_gruppe_ende']).'&apos;;
				reloadgruppe(); ">add_circle_outline</i>' : ''),	
			htmlentities(_('Auflösungsdatum') . ': Q' . (ceil((date('m', $params['range_min_gruppe_ende']))/3)) . ' (' . date('d.m.', $params['range_min_gruppe_ende']) . ' - ' . date('d.m.Y', $params['range_max_gruppe_ende']) . ')')
		]);
	}
	else if (isset($params['range_min_gruppe_ende']) && isset($params['range_max_gruppe_ende'])) {
		array_push($filters, _('Auflösungsdatum') . ': ' . (($params['range_min_gruppe_ende']) ? strftime(_('dateformat_php2'), intval($params['range_min_gruppe_ende'])) : '') . ' ' . _('filters_between') . ' ' . (($params['range_max_gruppe_ende']) ? strftime(_('dateformat_php2'), intval($params['range_max_gruppe_ende'])) : ''));
	} else if (isset($params['range_min_gruppe_ende'])) {
		array_push($filters, _('Auflösungsdatum') . ': ' . _('filters_from') . ' ' . (($params['range_min_gruppe_ende']) ? strftime(_('dateformat_php2'), intval($params['range_min_gruppe_ende'])) : ''));
	} else if (isset($params['range_max_gruppe_ende'])) {
		array_push($filters, _('Auflösungsdatum') . ': ' . _('filters_to') . ' ' . (($params['range_max_gruppe_ende']) ? strftime(_('dateformat_php2'), intval($params['range_max_gruppe_ende'])) : ''));
	}if (isset($params['filter_gruppe_anzahl'])) {
		if ($params['filter_gruppe_anzahl'] == '_null') {
			array_push($filters, _('Mitglieder') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_gruppe_anzahl']))->all() AS $val) {
				$value = \Types\Integer::print($val)
	;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Mitglieder') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_gruppe_public'])) {
		if ($params['filter_gruppe_public'] == '_null') {
			array_push($filters, _('in Gruppenliste aufgelistet') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_gruppe_public']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('in Gruppenliste aufgelistet') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_gruppe_memberVisibility'])) {
		if ($params['filter_gruppe_memberVisibility'] == '_null') {
			array_push($filters, _('Mitglieder sehen sich gegenseitig') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_gruppe_memberVisibility']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Mitglieder sehen sich gegenseitig') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_gruppe_start'])) {
		if ($params['filter_gruppe_start'] == '_null') {
			array_push($filters, _('Gründungsdatum') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_gruppe_start']))->all() AS $val) {
				$value = ($val) ? strftime(_('dateformat_php2'), intval($val)) : '';
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Gründungsdatum') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_gruppe_ende'])) {
		if ($params['filter_gruppe_ende'] == '_null') {
			array_push($filters, _('Auflösungsdatum') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_gruppe_ende']))->all() AS $val) {
				$value = ($val) ? strftime(_('dateformat_php2'), intval($val)) : '';
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Auflösungsdatum') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_gruppe_name'])) {
		if ($params['filter_gruppe_name'] == '_null') {
			array_push($filters, _('Bezeichnung') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_gruppe_name']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Bezeichnung') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_gruppe_items'])) {
		if ($params['filter_gruppe_items'] == '_null') {
			array_push($filters, _('Gruppenmitglieder') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_gruppe_items']))->all() AS $val) {
				$value = \Types\Integer::print($val)
	;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Gruppenmitglieder') . ': ' . implode(', ', $values));
		}
	}if (isset($params['search_gruppe_name'])) {
		array_push($filters, _('name') . ' ' . _('filter_contains') . ' ' . $params['search_gruppe_name']);
	}if (isset($params['searchnot_gruppe_name'])) {
		array_push($filters, _('name') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_gruppe_name']);
	}
		if (count($filters)) {
			$result = implode($delimiter, array_map(function ($filter) {
				if (is_array($filter)) {
					return implode('', $filter);
				}
				return htmlentities($filter);
			}, $filters))
			// Button, um Filter zu entfernen
			. ($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="for (var q in query) {if (q.includes(\'_gruppe_\')) delete query[q];} reloadgruppe(); ">clear</i>' : '');
		} else {
			$result = _('no_filter');
		}
		return $result;
	
    
  }

  public static function openAction($fop_table, $fop_id, $fop_from) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    

if ($fop_table == 'gruppe') {
	\FOP\Session::setPayload('dv-gruppe', [
		'id' => 'gruppe',
		'tbl' => 'gruppe',
		'idcol' => 'ID',
		'prev' => \DataViewRouter\Gruppe::stepURL('gruppe', 'XXX', -1),
		'next' => \DataViewRouter\Gruppe::stepURL('gruppe', 'XXX',  1),
		'from' => $fop_from
	]);
	
	if ($fop_id == '_') return; // nur Rückreferenz setzen, nicht öffnen
	$params = [];
	if (isset($_GET['popup'])) $params['popup'] = true;
	if (isset($_GET['from'])) $params['from'] = $_GET['from'];
	$params['id'] = $fop_id;
	
	$url = \TablesRouter\Gruppe::viewURL2($params);
	header('Location: ' . $url);
}

die();
    
  }

  public static function stepAction($tbl, $id, $step) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	$dv = \FOP\Session::getPayload('dv-'.$tbl);
	$url = $dv['from'];
	$parts = parse_url($url);
	parse_str($parts['query'], $query);
	$data = self::getData('', $query);
	$col = $dv['idcol'];
	$ids = array_map(function ($x) use ($col) {return $x[$col];}, $data['items']);
	if (!count($ids)) {
		header('Location: ' . \FOP\Util::getCurrentBaseurl() . 'Tables/' . preg_replace('/[^a-zA-Z0-9_]/', '_', ucfirst($dv['tbl'])));
		die();
	}
	$idx = array_search($id, $ids);
	$idx += count($ids) + $step;
	$idx = $idx % count($ids);
	header('Location: ' . \FOP\Util::getCurrentBaseurl() . 'Tables/' . preg_replace('/[^a-zA-Z0-9_]/', '_', ucfirst($dv['tbl'])) . '/view?id=' . urlencode($ids[$idx]));
	die();

    
  }


  
  

  
  
}



