<?php

namespace DataView;

class Payout {
  
  

  
  

    // --- Statische Methoden ---
  
  public static function renderScript() { 
    
    
    // --- BLOCK: main ---
    
								\FOP\I18n::ensureIsLoaded();
								?>
								<script type="text/javascript">
									
									
									function updateNumberpayout(col) {
										//var checklist = window.DataViewChecked['payout'][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['payout'] && window.DataViewChecked['payout'][col].ranges.length > 0) {
											$('.payout__mass-action').css('visibility', 'visible');
											$('.payout__action').css('visibility', 'hidden');
										} else {
											$('.payout__mass-action').css('visibility', 'hidden');
											$('.payout__action').css('visibility', 'visible');
										}
										$('.payout__checkbox').each(function (idx, x) {
											for (var cssclass of x.classList) {
												if (cssclass.startsWith('payout__checkbox-'+col+'-')) {
													var my_id = cssclass.substr(('payout__checkbox-'+col+'-').length);
													if (window.DataViewChecked) {
														x.MaterialCheckbox[checklist.has(my_id) ? 'check' : 'uncheck']();
													}
												}
											}
										});
									}
									function reloadpayout (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/Payout/" + 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 (true) { ?>
											delete nq['action'];
											querystr = "DataView/Payout/renderTabSepa?" + Object.keys(nq).map(function(k){ return k + "=" +  encodeURIComponent(nq[k]); }).join("&");
											// per Ajax laden
											if(!$("#payout-sepa")?.parent()?.parent()?.hasClass('fop-form-feature-collapsed') || $("#payout-sepa")?.parent()?.parent()?.hasClass('fop-form-feature-mode-area')) {
											$.get(querystr, function(data){
												var tab = $("#payout-sepa");
												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
												updateNumberpayout('ID');
											});
											} else {
												// gesamten Tab ersetzen
												var tab = $("#payout-sepa");
												tab.children().remove();
												el = tab.html('<div class="fop-lazy-reload" onclick="reloadpayout()"></div>');
											}
											<?php } ?>
											
											
											<?php if (true) { ?>
											delete nq['action'];
											querystr = "DataView/Payout/renderTabTable?" + Object.keys(nq).map(function(k){ return k + "=" +  encodeURIComponent(nq[k]); }).join("&");
											// per Ajax laden
											if(!$("#payout-table")?.parent()?.parent()?.hasClass('fop-form-feature-collapsed') || $("#payout-table")?.parent()?.parent()?.hasClass('fop-form-feature-mode-area')) {
											$.get(querystr, function(data){
												var tab = $("#payout-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
												updateNumberpayout('ID');
											});
											} else {
												// gesamten Tab ersetzen
												var tab = $("#payout-table");
												tab.children().remove();
												el = tab.html('<div class="fop-lazy-reload" onclick="reloadpayout()"></div>');
											}
											<?php } ?>
											
										}
									}
									function checkpayout (id, col, checked) {
										// ID-Liste aufbauen
										if (!window.DataViewChecked) window.DataViewChecked = {};
										if (!window.DataViewChecked['payout']) window.DataViewChecked['payout'] = {};
										if (!window.DataViewChecked['payout'][col]) window.DataViewChecked['payout'][col] = new IDList();

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

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

    
  }

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

	</script>
	<?php
	
    
  }

  public static function renderTabSepaAction() { 
    
    
    // --- 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='betrag' title='<?php echo(_('Betrag')); ?>'>
		<div class='fop-dv-aggregate-caption' style='text-align: right'><?php echo(_('Betrag')); ?></div>
		<div class='fop-dv-aggregate-value'>-...-</div>
	</div>
	<?php } ?><?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="payout-dynamic-filter" value='<?php echo date(_('dateformat_php')); ?>'>
		<script type='text/javascript'>
			$(function () {
				$('#payout-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_payout'] = 0;
					} else {
						// filter a certain time
						query['dynamic_payout'] = e.date.unix();
					}
					delete query['page_payout'];
					reloadpayout();
				});
			});
		</script>
	</span>
	<?php } ?></div><?php ?>
<?php
$konten = \Types\Fop_fints_konto::getItems([]);
if (count($konten) == 1) {
	?><a href="<?php echo \TablesRouter\Fop_fints_konto::createURL(); ?>" class='mdl-button mdl-js-button mdl-button--raised mdl-button--colored' target='_blank'><?php printf(_('create %s'),_('Bankkonto')); ?></a><?php
}
foreach ($konten AS $konto) if ($konto['ID']) {
	?><p><a class='mdl-button mdl-js-button mdl-button--raised mdl-button--colored' href="#" onclick="reloadpayout({action: 'sepaFile', 'konto': <?php echo intval($konto['ID']); ?>}); return false;"><?php echo(_('sepa-file')); ?>: <?php echo htmlentities($konto['description']); ?></a></p><?php
} ?>
<?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='betrag' title='<?php echo(_('Betrag')); ?>'>
		<div class='fop-dv-aggregate-caption' style='text-align: right'><?php echo(_('Betrag')); ?></div>
		<div class='fop-dv-aggregate-value'>-...-</div>
	</div>
	<?php } ?><?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="payout-dynamic-filter" value='<?php echo date(_('dateformat_php')); ?>'>
		<script type='text/javascript'>
			$(function () {
				$('#payout-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_payout'] = 0;
					} else {
						// filter a certain time
						query['dynamic_payout'] = e.date.unix();
					}
					delete query['page_payout'];
					reloadpayout();
				});
			});
		</script>
	</span>
	<?php } ?></div><?php 
								\FOP\User::getIsGuest();
								$itemheight = 32;
								$itemsperpage = ceil(1080 / $itemheight * 0.8);
								$page = (isset($_GET['page_payout']) ? intval($_GET['page_payout']) : 0);
								$addlines = (isset($_GET['addlines_payout']) ? intval($_GET['addlines_payout']) : 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' => 'betrag',
												'desc' => _('Betrag'),
												'order' => ++$order,
												'width' => 120, // default value
												'collapsed' => 0

											];
											$columns['betrag'] = $col;
										}
									
										if(true){
											$col = [
												'id' => 'title',
												'desc' => _('Betreff'),
												'order' => ++$order,
												'width' => 180, // default value
												'collapsed' => 0

											];
											$columns['title'] = $col;
										}
									
										if(true){
											$col = [
												'id' => 'xname',
												'desc' => _('Mitglied'),
												'order' => ++$order,
												'width' => 180, // default value
												'collapsed' => 0

											];
											$columns['xname'] = $col;
										}
									
										if(true){
											$col = [
												'id' => 'iban',
												'desc' => _('IBAN'),
												'order' => ++$order,
												'width' => 180, // default value
												'collapsed' => 0

											];
											$columns['iban'] = $col;
										}
									
										if(true){
											$col = [
												'id' => 'bic',
												'desc' => _('BIC'),
												'order' => ++$order,
												'width' => 180, // default value
												'collapsed' => 0

											];
											$columns['bic'] = $col;
										}
									
										if(true){
											$col = [
												'id' => 'sepaDate',
												'desc' => _('Datum Lastschrift'),
												'order' => ++$order,
												'width' => 100, // default value
												'collapsed' => 0

											];
											$columns['sepaDate'] = $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('payout'))->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='betrag'
												data-order='<?php echo intval($columns['betrag']['order']); ?>'
												data-width='<?php echo intval($columns['betrag']['width']); ?>'
												data-collapsed='<?php echo intval($columns['betrag']['collapsed']); ?>'
												style='width: <?php echo intval($columns['betrag']['width']); ?>px; <?php if ($columns['betrag']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadpayout(); 
		}});
		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_payout_betrag']).on('change keyup paste', function () { query['range_min_payout_betrag'] = von.val(); delete query['page_payout']; changed = true; }))
.append('<div>' + window.i18n_bis + '</div>').append(bis = $('<input type=\'number\' step=\'any\'>').val(query['range_max_payout_betrag']).on('change keyup paste', function () { query['range_max_payout_betrag'] = bis.val(); delete query['page_payout']; 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_payout'] == 'betrag ASC') {
			query['sort_payout'] = 'betrag DESC';
		 } else if (query['sort_payout'] == 'betrag DESC') {
		 	delete query['sort_payout'];
		 } else {
			query['sort_payout'] = 'betrag ASC';
		 }
		 reloadpayout();
		 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(_('Betrag')); ?>'><?php echo(_('Betrag')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_payout']) && $_GET['sort_payout'] == 'betrag ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_payout']) && $_GET['sort_payout'] == 'betrag DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_payout_betrag']) || isset($_GET['range_max_payout_betrag']) || isset($_GET['deps_payout_betrag']) || isset($_GET['fullsearch_payout_betrag']) || isset($_GET['dynamic_payout_betrag']) || isset($_GET['search_payout_betrag']) || isset($_GET['searchnot_payout_betrag']) || isset($_GET['filter_payout_betrag'])) {
															// 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['betrag']['header'] = ob_get_contents(); ob_end_clean();
											$columns['betrag']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['betrag']['width']); ?>px; <?php if ($columns['betrag']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='betrag'><span style="white-space: nowrap; width: 100%; display: inline-block; text-align: right;"><?php echo htmlentities(\Types\Euro::print($item['betrag'])); ?><?php echo '&nbsp;' .  htmlentities('€'); ?>
	</span></div><?php
											};
											$columns['betrag']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='betrag'
													data-order='<?php echo intval($columns['betrag']['order']); ?>'
													data-width='<?php echo intval($columns['betrag']['width']); ?>'
													data-collapsed='<?php echo intval($columns['betrag']['collapsed']); ?>'
													style='width: <?php echo intval($columns['betrag']['width']); ?>px; <?php if ($columns['betrag']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													<b><span style="white-space: nowrap; width: 100%; display: inline-block; text-align: right;"><?php echo htmlentities(\Types\Euro::print($item['betrag'])); ?><?php echo '&nbsp;' .  htmlentities('€'); ?>
	</span></b></div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='title'
												data-order='<?php echo intval($columns['title']['order']); ?>'
												data-width='<?php echo intval($columns['title']['width']); ?>'
												data-collapsed='<?php echo intval($columns['title']['collapsed']); ?>'
												style='width: <?php echo intval($columns['title']['width']); ?>px; <?php if ($columns['title']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadpayout(); 
		}});
		
		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_payout_title'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_payout_title'] = text.val(); } else { delete query['search_payout_title']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_payout').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_payout_title'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_payout_title'] = text2.val(); } else { delete query['searchnot_payout_title']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_payout').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_payout'] == 'title ASC') {
			query['sort_payout'] = 'title DESC';
		 } else if (query['sort_payout'] == 'title DESC') {
		 	delete query['sort_payout'];
		 } else {
			query['sort_payout'] = 'title ASC';
		 }
		 reloadpayout();
		 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(_('Betreff')); ?>'><?php echo(_('Betreff')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_payout']) && $_GET['sort_payout'] == 'title ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_payout']) && $_GET['sort_payout'] == 'title DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_payout_title']) || isset($_GET['range_max_payout_title']) || isset($_GET['deps_payout_title']) || isset($_GET['fullsearch_payout_title']) || isset($_GET['dynamic_payout_title']) || isset($_GET['search_payout_title']) || isset($_GET['searchnot_payout_title']) || isset($_GET['filter_payout_title'])) {
															// 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['title']['header'] = ob_get_contents(); ob_end_clean();
											$columns['title']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['title']['width']); ?>px; <?php if ($columns['title']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='title'><span class='overflow-text' title="<?php echo htmlentities($item['title']); ?>"><?php echo htmlentities($item['title']); ?></span></div><?php
											};
											$columns['title']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='title'
													data-order='<?php echo intval($columns['title']['order']); ?>'
													data-width='<?php echo intval($columns['title']['width']); ?>'
													data-collapsed='<?php echo intval($columns['title']['collapsed']); ?>'
													style='width: <?php echo intval($columns['title']['width']); ?>px; <?php if ($columns['title']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='xname'
												data-order='<?php echo intval($columns['xname']['order']); ?>'
												data-width='<?php echo intval($columns['xname']['width']); ?>'
												data-collapsed='<?php echo intval($columns['xname']['collapsed']); ?>'
												style='width: <?php echo intval($columns['xname']['width']); ?>px; <?php if ($columns['xname']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadpayout(); 
		}});
		
		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_payout_xname'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_payout_xname'] = text.val(); } else { delete query['search_payout_xname']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_payout').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_payout_xname'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_payout_xname'] = text2.val(); } else { delete query['searchnot_payout_xname']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_payout').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_payout'] == 'xname ASC') {
			query['sort_payout'] = 'xname DESC';
		 } else if (query['sort_payout'] == 'xname DESC') {
		 	delete query['sort_payout'];
		 } else {
			query['sort_payout'] = 'xname ASC';
		 }
		 reloadpayout();
		 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(_('Mitglied')); ?>'><?php echo(_('Mitglied')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_payout']) && $_GET['sort_payout'] == 'xname ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_payout']) && $_GET['sort_payout'] == 'xname DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_payout_xname']) || isset($_GET['range_max_payout_xname']) || isset($_GET['deps_payout_xname']) || isset($_GET['fullsearch_payout_xname']) || isset($_GET['dynamic_payout_xname']) || isset($_GET['search_payout_xname']) || isset($_GET['searchnot_payout_xname']) || isset($_GET['filter_payout_xname'])) {
															// 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['xname']['header'] = ob_get_contents(); ob_end_clean();
											$columns['xname']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['xname']['width']); ?>px; <?php if ($columns['xname']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='xname'><span class='overflow-text' title="<?php echo htmlentities($item['xname']); ?>"><?php echo htmlentities($item['xname']); ?></span></div><?php
											};
											$columns['xname']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='xname'
													data-order='<?php echo intval($columns['xname']['order']); ?>'
													data-width='<?php echo intval($columns['xname']['width']); ?>'
													data-collapsed='<?php echo intval($columns['xname']['collapsed']); ?>'
													style='width: <?php echo intval($columns['xname']['width']); ?>px; <?php if ($columns['xname']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='iban'
												data-order='<?php echo intval($columns['iban']['order']); ?>'
												data-width='<?php echo intval($columns['iban']['width']); ?>'
												data-collapsed='<?php echo intval($columns['iban']['collapsed']); ?>'
												style='width: <?php echo intval($columns['iban']['width']); ?>px; <?php if ($columns['iban']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadpayout(); 
		}});
		
		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_payout_iban'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_payout_iban'] = text.val(); } else { delete query['search_payout_iban']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_payout').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_payout_iban'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_payout_iban'] = text2.val(); } else { delete query['searchnot_payout_iban']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_payout').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_payout'] == 'iban ASC') {
			query['sort_payout'] = 'iban DESC';
		 } else if (query['sort_payout'] == 'iban DESC') {
		 	delete query['sort_payout'];
		 } else {
			query['sort_payout'] = 'iban ASC';
		 }
		 reloadpayout();
		 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(_('IBAN')); ?>'><?php echo(_('IBAN')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_payout']) && $_GET['sort_payout'] == 'iban ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_payout']) && $_GET['sort_payout'] == 'iban DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_payout_iban']) || isset($_GET['range_max_payout_iban']) || isset($_GET['deps_payout_iban']) || isset($_GET['fullsearch_payout_iban']) || isset($_GET['dynamic_payout_iban']) || isset($_GET['search_payout_iban']) || isset($_GET['searchnot_payout_iban']) || isset($_GET['filter_payout_iban'])) {
															// 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['iban']['header'] = ob_get_contents(); ob_end_clean();
											$columns['iban']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['iban']['width']); ?>px; <?php if ($columns['iban']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='iban'><span class='overflow-text' title="<?php echo htmlentities($item['iban']); ?>"><?php echo htmlentities($item['iban']); ?></span></div><?php
											};
											$columns['iban']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='iban'
													data-order='<?php echo intval($columns['iban']['order']); ?>'
													data-width='<?php echo intval($columns['iban']['width']); ?>'
													data-collapsed='<?php echo intval($columns['iban']['collapsed']); ?>'
													style='width: <?php echo intval($columns['iban']['width']); ?>px; <?php if ($columns['iban']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='bic'
												data-order='<?php echo intval($columns['bic']['order']); ?>'
												data-width='<?php echo intval($columns['bic']['width']); ?>'
												data-collapsed='<?php echo intval($columns['bic']['collapsed']); ?>'
												style='width: <?php echo intval($columns['bic']['width']); ?>px; <?php if ($columns['bic']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadpayout(); 
		}});
		
		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_payout_bic'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_payout_bic'] = text.val(); } else { delete query['search_payout_bic']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_payout').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_payout_bic'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_payout_bic'] = text2.val(); } else { delete query['searchnot_payout_bic']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_payout').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_payout'] == 'bic ASC') {
			query['sort_payout'] = 'bic DESC';
		 } else if (query['sort_payout'] == 'bic DESC') {
		 	delete query['sort_payout'];
		 } else {
			query['sort_payout'] = 'bic ASC';
		 }
		 reloadpayout();
		 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(_('BIC')); ?>'><?php echo(_('BIC')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_payout']) && $_GET['sort_payout'] == 'bic ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_payout']) && $_GET['sort_payout'] == 'bic DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_payout_bic']) || isset($_GET['range_max_payout_bic']) || isset($_GET['deps_payout_bic']) || isset($_GET['fullsearch_payout_bic']) || isset($_GET['dynamic_payout_bic']) || isset($_GET['search_payout_bic']) || isset($_GET['searchnot_payout_bic']) || isset($_GET['filter_payout_bic'])) {
															// 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['bic']['header'] = ob_get_contents(); ob_end_clean();
											$columns['bic']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['bic']['width']); ?>px; <?php if ($columns['bic']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='bic'><span class='overflow-text' title="<?php echo htmlentities($item['bic']); ?>"><?php echo htmlentities($item['bic']); ?></span></div><?php
											};
											$columns['bic']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='bic'
													data-order='<?php echo intval($columns['bic']['order']); ?>'
													data-width='<?php echo intval($columns['bic']['width']); ?>'
													data-collapsed='<?php echo intval($columns['bic']['collapsed']); ?>'
													style='width: <?php echo intval($columns['bic']['width']); ?>px; <?php if ($columns['bic']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='sepaDate'
												data-order='<?php echo intval($columns['sepaDate']['order']); ?>'
												data-width='<?php echo intval($columns['sepaDate']['width']); ?>'
												data-collapsed='<?php echo intval($columns['sepaDate']['collapsed']); ?>'
												style='width: <?php echo intval($columns['sepaDate']['width']); ?>px; <?php if ($columns['sepaDate']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadpayout(); 
		}}, 600);
		date_filter(win, 'payout', 'sepaDate', <?php echo htmlentities(json_encode(_('period'))); ?>, <?php echo htmlentities(json_encode(\FOP\I18n::getShortLocale())); ?>, <?php echo htmlentities(json_encode(_('dateformat_moment'))); ?>, function() { reloadpayout();  reloadpayout(); });
	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_payout'] == 'sepaDate ASC') {
			query['sort_payout'] = 'sepaDate DESC';
		 } else if (query['sort_payout'] == 'sepaDate DESC') {
		 	delete query['sort_payout'];
		 } else {
			query['sort_payout'] = 'sepaDate ASC';
		 }
		 reloadpayout();
		 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(_('Datum Lastschrift')); ?>'><?php echo(_('Datum Lastschrift')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_payout']) && $_GET['sort_payout'] == 'sepaDate ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_payout']) && $_GET['sort_payout'] == 'sepaDate DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_payout_sepaDate']) || isset($_GET['range_max_payout_sepaDate']) || isset($_GET['deps_payout_sepaDate']) || isset($_GET['fullsearch_payout_sepaDate']) || isset($_GET['dynamic_payout_sepaDate']) || isset($_GET['search_payout_sepaDate']) || isset($_GET['searchnot_payout_sepaDate']) || isset($_GET['filter_payout_sepaDate'])) {
															// 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['sepaDate']['header'] = ob_get_contents(); ob_end_clean();
											$columns['sepaDate']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['sepaDate']['width']); ?>px; <?php if ($columns['sepaDate']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='sepaDate'><span class='overflow-text' title="<?php echo htmlentities(($item['sepaDate']) ? strftime(_('dateformat_php2'), intval($item['sepaDate'])) : ''); ?>"><?php echo htmlentities(($item['sepaDate']) ? strftime(_('dateformat_php2'), intval($item['sepaDate'])) : ''); ?></span></div><?php
											};
											$columns['sepaDate']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='sepaDate'
													data-order='<?php echo intval($columns['sepaDate']['order']); ?>'
													data-width='<?php echo intval($columns['sepaDate']['width']); ?>'
													data-collapsed='<?php echo intval($columns['sepaDate']['collapsed']); ?>'
													style='width: <?php echo intval($columns['sepaDate']['width']); ?>px; <?php if ($columns['sepaDate']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									

									// sort by order
									uasort($columns, function ($a, $b) {
										return $a['order'] - $b['order'];
									});
									?>
									<style type='text/css'>
										#payout-table .fop-table-header {
											height: <?php echo 32; ?>px;
										}
										#payout-table .fop-table-header .fop-table-column .title,
										#payout-table .fop-column-handle,
										#payout-table .fop-table-row,
										#payout-table .fop-table-row .fop-table-column,
										#payout-table .fop-table-column-multicontrol,
										#payout-table .fop-filter-button {
											height: 32px;
											line-height: 32px;
										}
										</style>
											<div class="fop-table" data-table-id="payout">
											<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="payout__all-checkbox">
														<input class="mdl-checkbox__input" id="payout__all-checkbox" type="checkbox" onchange="checkpayout('all', 'ID', this.checked);">
														</label>
														<button type="button" class="mdl-button mdl-js-button mdl-button--icon payout__mass-action" style='visibility: hidden;' onclick="$.get('DataView/Payout/permissions?id=' + checkpayout(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_payout_') == 0 || key.indexOf('range_max_payout_') == 0 || key.indexOf('deps_payout_') == 0 || key.indexOf('fullsearch_payout_') == 0 || key.indexOf('dynamic_payout_') == 0 || key.indexOf('search_payout_') == 0 || key.indexOf('searchnot_payout_') == 0 || key.indexOf('filter_payout_') == 0) delete query[key]; reloadpayout(); $(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_payout_ID'] = checkpayout(null, 'ID'); delete query['page_payout']; reloadpayout(); $(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(checkpayout(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;
			}
			checkpayout(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::getCampaign()) && (\FOP\User::getCampaign()))) { ?>
			<span class="mdl-list__item mdl-button">
				<span class="mdl-list__item mdl-button" data-interaction-name="campaignTargetAdd" style="margin-right:auto; text-align:left;"
					onclick="location.href = 'Tables/CampaignTarget/multiadd?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&column_target=' + escape(checkpayout(null, 'ID')); $(this).closest('.overlay').click(); return false;">
					<span style="float:left;"><i class="material-icons">add</i></span><span class="fop-menu-caption" title="<?php echo(sprintf(_('Zu %s hinzufügen'), _('Aktion'))); ?>"><?php echo(sprintf(_('Zu %s hinzufügen'), _('Aktion'))); ?> (<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="gruppeItemAdd" style="margin-right:auto; text-align:left;"
					onclick="location.href = 'Tables/GruppeItem/multiadd?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&column_item=' + escape(checkpayout(null, 'ID')); $(this).closest('.overlay').click(); return false;">
					<span style="float:left;"><i class="material-icons">add</i></span><span class="fop-menu-caption" title="<?php echo(sprintf(_('Zu %s hinzufügen'), _('Gruppe'))); ?>"><?php echo(sprintf(_('Zu %s hinzufügen'), _('Gruppe'))); ?> (<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/Mitglied/lifecycleEnd?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&id=' + escape(checkpayout(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'), _('Austrittsdatum'))); ?>"><?php echo(sprintf(_('%s setzen'), _('Austrittsdatum'))); ?> (<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/Mitglied/delete?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&id=' + escape(checkpayout(null, 'ID'))).then(function () { reloadpayout(); }, 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('payout', <?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: 'payout', 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_payout" <?php \EasyEditor\Navigation::printScroll('dv.Payout', '/* 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_payout\'] || 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_payout\'] = wantedPage;
														reloadpayout(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="<?php echo 'background: ' .htmlentities((function ($item) {return $item['betrag'] && $item['title'] && $item['xname'] && $item['iban'] ? 'none' : '#f002';})($item)).'!important;'; ?> " data-mitglied-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(reloadpayout({action: \'open\', fop_table: \'mitglied\', 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 payout__checkbox payout__checkbox payout__checkbox-ID-<?php echo htmlentities($item['ID']); ?>" style="width: auto;" for="payout__<?php echo htmlentities($itempos); ?>-checkbox">
													<input class="mdl-checkbox__input" id="payout__<?php echo htmlentities($itempos); ?>-checkbox" type="checkbox" onchange="<?php if (isset($item['ID'])) echo 'checkpayout(' . htmlentities(json_encode($item['ID'])) . ', \'ID\', this.checked); ' ?>">
													</label><button type="button" class="mdl-button mdl-js-button mdl-button--icon payout__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-payout-action-<?php echo $item['ID'] ?? 0; ?>">
														<?php
		if(isset($item['ID']) && (!\FOP\User::getIsGuest())) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="view" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Mitglied::viewURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick=" if (!event.ctrlKey) { open_url(reloadpayout({action: 'open', fop_table: 'mitglied', 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']) && (!\FOP\User::getIsGuest()) && ((\FOP\User::getGruppe()))) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="edit" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Mitglied::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::getCampaign()) && (\FOP\User::getCampaign()))) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="campaignTargetAdd" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\CampaignTarget::multiaddURL2(['column_target' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">add</i></span><span class="fop-menu-caption" title="<?php echo(sprintf(_('Zu %s hinzufügen'), _('Aktion'))); ?>"><?php echo(sprintf(_('Zu %s hinzufügen'), _('Aktion'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((\FOP\User::getGruppe())) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\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_ansprechpartner_mitglied" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Ansprechpartner::createURL2(['column_mitglied' => $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'), _('Kontaktperson'))); ?>"><?php echo(sprintf(_('create %s'), _('Kontaktperson'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\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_campaignTarget_target" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\CampaignTarget::createURL2(['column_target' => $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'), _('Empfänger'))); ?>"><?php echo(sprintf(_('create %s'), _('Empfänger'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((\FOP\User::getDokument())) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\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-mitglied" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Doc::createURL2(['column_to-mitglied' => $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())) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="create_gruppeItem_item" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\GruppeItem::createURL2(['column_item' => $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::getBuchhaltung()) && (\FOP\User::getGruppe())) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\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_mitgliedBuchung_mitglied" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\MitgliedBuchung::createURL2(['column_mitglied' => $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'), _('Beitrag'))); ?>"><?php echo(sprintf(_('create %s'), _('Beitrag'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((false))) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="create_mitgliedDynamicMonthyear_dynamic:parent" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\MitgliedDynamicMonthyear::createURL2(['column_dynamic:parent' => $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'), sprintf(_('versions of %s'), _('Mitglied')))); ?>"><?php echo(sprintf(_('create %s'), sprintf(_('versions of %s'), _('Mitglied')))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((\FOP\User::getGruppe())) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\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_mitgliedPassnummer_mitglied" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\MitgliedPassnummer::createURL2(['column_mitglied' => $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'), _('Passnummer'))); ?>"><?php echo(sprintf(_('create %s'), _('Passnummer'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((\FOP\User::getSammlung()) && (\FOP\User::getSammlung())) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="create_sammlungMitglied_mitglied" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\SammlungMitglied::createURL2(['column_mitglied' => $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'), _('Sammlungs-Mitglied'))); ?>"><?php echo(sprintf(_('create %s'), _('Sammlungs-Mitglied'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((\FOP\User::getGruppe()))) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="gruppeItemAdd" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\GruppeItem::multiaddURL2(['column_item' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">add</i></span><span class="fop-menu-caption" title="<?php echo(sprintf(_('Zu %s hinzufügen'), _('Gruppe'))); ?>"><?php echo(sprintf(_('Zu %s hinzufügen'), _('Gruppe'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && (!\FOP\User::getIsGuest()) && ((\FOP\User::getGruppe()))) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="lifecycleEnd" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Mitglied::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'), _('Austrittsdatum'))); ?>"><?php echo(sprintf(_('%s setzen'), _('Austrittsdatum'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((\FOP\User::getGruppe()))) { ?>
			<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/Mitglied/delete?ajax&id=<?php echo htmlentities($item['ID']);?>&from=<?php echo htmlentities(\FOP\Util::getBackUrl());?>').then(function () { reloadpayout(); }, 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']) && (!\FOP\User::getIsGuest())) {
			?><a class="mdl-button mdl-js-button mdl-button--icon tbl-link" data-tbl="mitglied" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="view" href="<?php echo htmlentities(\TablesRouter\Mitglied::viewURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();  if (!event.ctrlKey) { open_url(reloadpayout({action: 'open', fop_table: 'mitglied', fop_id: <?php echo htmlentities(json_encode($item['ID'])); ?>, fop_from: location.href}, true), true); return false; }  reloadpayout();
					$(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 } ?><?php
		if(isset($item['ID']) && (!\FOP\User::getIsGuest()) && ((\FOP\User::getGruppe()))) {
			?><a class="mdl-button mdl-js-button mdl-button--icon tbl-link" data-tbl="mitglied" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="edit" href="<?php echo htmlentities(\TablesRouter\Mitglied::editURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();    reloadpayout();
					$(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 } ?>
													</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 getSQL($params) { 
    
    
    // --- 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 */ `t`.`ID` AS '.qi('ID').',
									/* betrag */ - ('.qi('t').'.'.qi('forderungen').') AS '.qi('betrag').',
									/* bic */ `bic` AS '.qi('bic').',
									/* iban */ `iban` AS '.qi('iban').',
									/* name */ '.qi('name').' AS '.qi('name').',
									/* sepaDate */ `sepaDate` AS '.qi('sepaDate').',
									/* title */ \'Mitgliedsbeitraege\' AS '.qi('title').',
									/* vorname */ '.qi('vorname').' AS '.qi('vorname').',
									/* xname */ CONCAT(`vorname`, \' \', `name`) AS '.qi('xname').',
									1
								FROM '.qi('mitglied').' '.qi('t').'
								WHERE ((('.qi('t').'.'.qi('forderungen').') < (0)) AND ('.qi('t').'.'.qi('sepa').'))) AS t
								WHERE ' . (isset($params['range_min_payout_betrag']) ? ($params['range_min_payout_betrag'] !== '' && is_numeric($params['range_min_payout_betrag']) ? 't.'.qi('betrag').' >= ' . \FOP\Database::quote($params['range_min_payout_betrag']) . ' AND ' : '') : '') . 
								(isset($params['range_min_payout_sepaDate']) ? ($params['range_min_payout_sepaDate'] !== '' && is_numeric($params['range_min_payout_sepaDate']) ? 't.'.qi('sepaDate').' >= ' . \FOP\Database::quote($params['range_min_payout_sepaDate']) . ' AND ' : '') : '') . 
								(isset($params['range_max_payout_betrag']) ? ($params['range_max_payout_betrag'] !== '' && is_numeric($params['range_max_payout_betrag']) ? 't.'.qi('betrag').' <= ' . \FOP\Database::quote($params['range_max_payout_betrag']) . ' AND ' : '') : '') . 
								(isset($params['range_max_payout_sepaDate']) ? ($params['range_max_payout_sepaDate'] !== '' && is_numeric($params['range_max_payout_sepaDate']) ? 't.'.qi('sepaDate').' <= ' . \FOP\Database::quote($params['range_max_payout_sepaDate']) . ' AND ' : '') : '') . 
								(isset($params['filter_payout_betrag']) ? ($params['filter_payout_betrag'] !== '' ? ('(' . (new \FOP\IDList($params['filter_payout_betrag']))->toSQL('t.'.qi('betrag').'') . ') AND ') : '') : '') . 
								(isset($params['filter_payout_title']) ? ($params['filter_payout_title'] !== '' ? ('(' . (new \FOP\IDList($params['filter_payout_title']))->toSQL('t.'.qi('title').'') . ') AND ') : '') : '') . 
								(isset($params['filter_payout_xname']) ? ($params['filter_payout_xname'] !== '' ? ('(' . (new \FOP\IDList($params['filter_payout_xname']))->toSQL('t.'.qi('xname').'') . ') AND ') : '') : '') . 
								(isset($params['filter_payout_iban']) ? ($params['filter_payout_iban'] !== '' ? ('(' . (new \FOP\IDList($params['filter_payout_iban']))->toSQL('t.'.qi('iban').'') . ') AND ') : '') : '') . 
								(isset($params['filter_payout_bic']) ? ($params['filter_payout_bic'] !== '' ? ('(' . (new \FOP\IDList($params['filter_payout_bic']))->toSQL('t.'.qi('bic').'') . ') AND ') : '') : '') . 
								(isset($params['filter_payout_sepaDate']) ? ($params['filter_payout_sepaDate'] !== '' ? ('(' . (new \FOP\IDList($params['filter_payout_sepaDate']))->toSQL('t.'.qi('sepaDate').'') . ') AND ') : '') : '') . 
								(isset($params['filter_payout_ID']) ? ($params['filter_payout_ID'] !== '' ? ('(' . (new \FOP\IDList($params['filter_payout_ID']))->toSQL('t.'.qi('ID').'') . ') AND ') : '') : '') . 
								(isset($params['search_payout_title']) ? 't.'.qi('title').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_payout_title'] . '%') . ' AND ' : '') . 
								(isset($params['search_payout_xname']) ? 't.'.qi('xname').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_payout_xname'] . '%') . ' AND ' : '') . 
								(isset($params['search_payout_iban']) ? 't.'.qi('iban').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_payout_iban'] . '%') . ' AND ' : '') . 
								(isset($params['search_payout_bic']) ? 't.'.qi('bic').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_payout_bic'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_payout_title']) ? 'NOT t.'.qi('title').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_payout_title'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_payout_xname']) ? 'NOT t.'.qi('xname').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_payout_xname'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_payout_iban']) ? 'NOT t.'.qi('iban').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_payout_iban'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_payout_bic']) ? 'NOT t.'.qi('bic').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_payout_bic'] . '%') . ' AND ' : '') . 
								(isset($params['search_payout']) ? '(' . 't.'.qi('title').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_payout'] . '%') . ' OR ' . 't.'.qi('xname').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_payout'] . '%') . ' OR ' . 't.'.qi('iban').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_payout'] . '%') . ' OR ' . 't.'.qi('bic').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_payout'] . '%') . ') AND ' : '') . 
								'
								(' . (isset($params['dynamic_payout']) ? ($params['dynamic_payout'] == 0 ? '1' : '(t.'.qi('eintritt').' IS NULL OR t.'.qi('eintritt').' <= ' . intval($params['dynamic_payout']) . ') AND (t.'.qi('austrittsdatum').' IS NULL OR t.'.qi('austrittsdatum').' >= ' . intval($params['dynamic_payout']) . ')') : '(t.'.qi('eintritt').' IS NULL OR t.'.qi('eintritt').' <= UNIX_TIMESTAMP()) AND (t.'.qi('austrittsdatum').' IS NULL OR t.'.qi('austrittsdatum').' >= UNIX_TIMESTAMP())') . ') AND  TRUE ';
								return $sql;
	
    
  }

  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::getGruppe()).' THEN TRUE ELSE NOT (('.qi('mitglied').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) AND (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('mitglied').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('mitglied').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) AND (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('mitglied').'.'.qi('superadmin').') END)) AND ((CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('mitglied').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('mitglied').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) AND ('.\FOP\Database::quote(\FOP\User::getGruppe()).') AND (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('mitglied').'.'.qi('superadmin').') END)) 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 NOT ((('.qi('mitglied').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('mitglied').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) AND ('.\FOP\Database::quote(\FOP\User::getGruppe()).') AND (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('mitglied').'.'.qi('superadmin').') END)) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('delete').', SUM(CASE (TRUE) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('campaignTargetAdd').', SUM(CASE (TRUE) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('gruppeItemAdd').' FROM '.qi('mitglied').' WHERE ' . $ids->toSQL(qi('ID')))->fetch(\PDO::FETCH_ASSOC);
		
		return $perms;
	
    
  }

  public static function sepaFileAction($konto) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
		// Datei erzeugen und zu TAN-Menü weiterleiten
		\FOP\Database::beginTransaction();
		$konto = \Tables\Fop_fints_konto::view($konto);
		if (!$konto) {
			throw new AccessDeniedException('Kein Zugriff auf dieses Konto');
		}
		$bank = \Tables\Fop_fints_bank::view($konto['bank']);
		$data = \Tables\Fop_fints_file::getDefaults();
		$data['konto'] = $konto['ID'];
		ob_start(); // SEPA-Datei recorden
		$stammdaten = \Configuration\Stammdaten::getStammdaten(null);
		self::sepaXML($stammdaten['firmenname'], $konto['iban'], $bank['bic'], $konto['glaeubigerid']);
		$xml = ob_get_contents();
		ob_end_clean();
		$data['file'] = \FOP\Files::uploadFromString($xml, 'sepa.xml');
		\Tables\Fop_fints_file::sanitizeDefaults($data, false);
		$id = \Tables\Fop_fints_file::create($data);

		// Erledigt markieren
		$items = self::getData('', $_GET)['items'];
		
		foreach ($items AS $item) {
			if ($item['betrag'] && $item['title'] && $item['xname'] && $item['iban']) {
				
				
			}
		}

		if (\FOP\Database::commitTransaction()) {
			// User zur SEPA-Datei schicken, damit dieser sie ausführen oder jemandem übergeben kann
			header('Location: ' . \TablesRouter\Fop_fints_file::viewURL($id));
		} else throw new \FOP\AccessDeniedException('SQL transaction error');
		die();
	
    
  }

  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_payout']))
                \FOP\Database::setTime($params['dynamic_payout']);
        
    // --- BLOCK: main ---
    
								$sql = self::getSQL($params);

								$order = (\FOP\Util::array_value(array(
									'title ASC' => 'ORDER BY t.'.qi('title').' ASC',
									'xname ASC' => 'ORDER BY t.'.qi('xname').' ASC',
									'bic ASC' => 'ORDER BY t.'.qi('bic').' ASC',
									'iban ASC' => 'ORDER BY t.'.qi('iban').' ASC',
									'betrag ASC' => 'ORDER BY t.'.qi('betrag').' ASC',
									'sepaDate ASC' => 'ORDER BY t.'.qi('sepaDate').' ASC',
									'title DESC' => 'ORDER BY t.'.qi('title').' DESC',
									'xname DESC' => 'ORDER BY t.'.qi('xname').' DESC',
									'bic DESC' => 'ORDER BY t.'.qi('bic').' DESC',
									'iban DESC' => 'ORDER BY t.'.qi('iban').' DESC',
									'betrag DESC' => 'ORDER BY t.'.qi('betrag').' DESC',
									'sepaDate DESC' => 'ORDER BY t.'.qi('sepaDate').' DESC',
									'' => ''), isset($params['sort_payout']) ? $params['sort_payout'] : '') ?: 'ORDER BY '.qi('t').'.'.qi('name').' , '.qi('t').'.'.qi('vorname').' ');
								// 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['betrag'] = \Types\Euro::unpack($item['betrag']);
											$item['iban'] = \FOP\Sanitizers::a_text($item['iban']);
											$item['sepaDate'] = intval($item['sepaDate']);
											
											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['betrag'] = \Types\Euro::unpack($item['betrag']);
										$item['iban'] = \FOP\Sanitizers::a_text($item['iban']);
										$item['sepaDate'] = intval($item['sepaDate']);
										
									}
									unset($item);

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

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

								return $result;
	
    // --- BLOCK: main-DynamicTime ---
    
// ggf. dynamische Zeit zurücksetzen
        if (isset($params['dynamic_payout']))
                \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_payout_betrag']) && isset($params['range_max_payout_betrag'])) {
		array_push($filters, _('Betrag') . ': ' . (\Types\Euro::print($params['range_min_payout_betrag']) .  ' €'
	) . ' ' . _('filters_between') . ' ' . (\Types\Euro::print($params['range_max_payout_betrag']) .  ' €'
	));
	} else if (isset($params['range_min_payout_betrag'])) {
		array_push($filters, _('Betrag') . ': ' . _('filters_from') . ' ' . (\Types\Euro::print($params['range_min_payout_betrag']) .  ' €'
	));
	} else if (isset($params['range_max_payout_betrag'])) {
		array_push($filters, _('Betrag') . ': ' . _('filters_to') . ' ' . (\Types\Euro::print($params['range_max_payout_betrag']) .  ' €'
	));
	}
	
	if ( // Corner Case: Monat
		isset($params['range_min_payout_sepaDate'])
		&& isset($params['range_max_payout_sepaDate'])
		&& (date('d', $params['range_min_payout_sepaDate']) == '01') //check first day of month
		&& (date('d', $params['range_max_payout_sepaDate']) == date('t', $params['range_max_payout_sepaDate'])) //check last day of month
		&& (date('Y-m', $params['range_min_payout_sepaDate']) == date('Y-m', $params['range_max_payout_sepaDate'])) //check if same year and month
	) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_payout_sepaDate&apos;] = &apos;'.strtotime('first day of last month', $params['range_min_payout_sepaDate']).'&apos;;
				query[&apos;range_max_payout_sepaDate&apos;] = &apos;'.strtotime('last day of last month', $params['range_min_payout_sepaDate']).'&apos;;
				reloadpayout(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_payout_sepaDate&apos;] = &apos;'.strtotime('first day of next month', $params['range_min_payout_sepaDate']).'&apos;;
				query[&apos;range_max_payout_sepaDate&apos;] = &apos;'.strtotime('last day of next month', $params['range_min_payout_sepaDate']).'&apos;;
				reloadpayout(); ">add_circle_outline</i>' : ''),
			htmlentities(_('Datum Lastschrift') . ': ' . strftime('%B', $params['range_min_payout_sepaDate']) . ' ' . date('Y', $params['range_min_payout_sepaDate']))
		]);
	} else if ( // Corner Case: Tag
		isset($params['range_min_payout_sepaDate'])
		&& isset($params['range_max_payout_sepaDate'])
		&& (date('Y-m-d', $params['range_min_payout_sepaDate']) == (date('Y-m-d', $params['range_max_payout_sepaDate'])))
	) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_payout_sepaDate&apos;] = &apos;'.strtotime('last day', $params['range_min_payout_sepaDate']).'&apos;;
				query[&apos;range_max_payout_sepaDate&apos;] = &apos;'.strtotime('last day', $params['range_min_payout_sepaDate']).'&apos;;
				reloadpayout(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_payout_sepaDate&apos;] = &apos;'.strtotime('next day', $params['range_min_payout_sepaDate']).'&apos;;
				query[&apos;range_max_payout_sepaDate&apos;] = &apos;'.strtotime('next day', $params['range_min_payout_sepaDate']).'&apos;;
				reloadpayout(); ">add_circle_outline</i>' : ''),
			htmlentities(_('Datum Lastschrift') . ': ' . date('d.m.Y', $params['range_min_payout_sepaDate']))
		]);
	} else if ( // Corner Case: Jahr
		isset($params['range_min_payout_sepaDate'])
		&& isset($params['range_max_payout_sepaDate'])
		&& (date('Y', $params['range_min_payout_sepaDate']) == (date('Y', $params['range_max_payout_sepaDate'])))
		&& ((date('m-d', $params['range_min_payout_sepaDate']) == '01-01'))
		&& ((date('m-d', $params['range_max_payout_sepaDate']) == '12-31'))
	) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_payout_sepaDate&apos;] = &apos;'.strtotime('first day of January last year', $params['range_min_payout_sepaDate']).'&apos;;
				query[&apos;range_max_payout_sepaDate&apos;] = &apos;'.strtotime('last day of December last year', $params['range_min_payout_sepaDate']).'&apos;;
				reloadpayout(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_payout_sepaDate&apos;] = &apos;'.strtotime('first day of January next year', $params['range_min_payout_sepaDate']).'&apos;;
				query[&apos;range_max_payout_sepaDate&apos;] = &apos;'.strtotime('last day of December next year', $params['range_min_payout_sepaDate']).'&apos;;
				reloadpayout(); ">add_circle_outline</i>' : ''),
			htmlentities(_('Datum Lastschrift') . ': ' . date('Y', $params['range_min_payout_sepaDate']))
		]);
	} else if ( // Corner Case: Quartal
		isset($params['range_min_payout_sepaDate'])
		&& isset($params['range_max_payout_sepaDate'])
		&& ( (
		 ((date('m-d', $params['range_min_payout_sepaDate']) == '01-01'))
		&& ((date('m-d', $params['range_max_payout_sepaDate']) == '03-31')) )
		|| (
		 ((date('m-d', $params['range_min_payout_sepaDate']) == '04-01'))
		&& ((date('m-d', $params['range_max_payout_sepaDate']) == '06-30')) )
		|| (
		 ((date('m-d', $params['range_min_payout_sepaDate']) == '07-01'))
		&& ((date('m-d', $params['range_max_payout_sepaDate']) == '09-30')) )
		|| (
		 ((date('m-d', $params['range_min_payout_sepaDate']) == '10-01'))
		&& ((date('m-d', $params['range_max_payout_sepaDate']) == '12-31')) )
	) ) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
					query[&apos;range_min_payout_sepaDate&apos;] = &apos;'.strtotime('first day of -3 months', $params['range_min_payout_sepaDate']).'&apos;;
					query[&apos;range_max_payout_sepaDate&apos;] = &apos;'.strtotime('last day of -3 months', $params['range_max_payout_sepaDate']).'&apos;;
					reloadpayout(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_payout_sepaDate&apos;] = &apos;'.strtotime('first day of +3 months', $params['range_min_payout_sepaDate']).'&apos;;
				query[&apos;range_max_payout_sepaDate&apos;] = &apos;'.strtotime('last day of +3 months', $params['range_max_payout_sepaDate']).'&apos;;
				reloadpayout(); ">add_circle_outline</i>' : ''),	
			htmlentities(_('Datum Lastschrift') . ': Q' . (ceil((date('m', $params['range_min_payout_sepaDate']))/3)) . ' (' . date('d.m.', $params['range_min_payout_sepaDate']) . ' - ' . date('d.m.Y', $params['range_max_payout_sepaDate']) . ')')
		]);
	}
	else if (isset($params['range_min_payout_sepaDate']) && isset($params['range_max_payout_sepaDate'])) {
		array_push($filters, _('Datum Lastschrift') . ': ' . (($params['range_min_payout_sepaDate']) ? strftime(_('dateformat_php2'), intval($params['range_min_payout_sepaDate'])) : '') . ' ' . _('filters_between') . ' ' . (($params['range_max_payout_sepaDate']) ? strftime(_('dateformat_php2'), intval($params['range_max_payout_sepaDate'])) : ''));
	} else if (isset($params['range_min_payout_sepaDate'])) {
		array_push($filters, _('Datum Lastschrift') . ': ' . _('filters_from') . ' ' . (($params['range_min_payout_sepaDate']) ? strftime(_('dateformat_php2'), intval($params['range_min_payout_sepaDate'])) : ''));
	} else if (isset($params['range_max_payout_sepaDate'])) {
		array_push($filters, _('Datum Lastschrift') . ': ' . _('filters_to') . ' ' . (($params['range_max_payout_sepaDate']) ? strftime(_('dateformat_php2'), intval($params['range_max_payout_sepaDate'])) : ''));
	}if (isset($params['filter_payout_betrag'])) {
		if ($params['filter_payout_betrag'] == '_null') {
			array_push($filters, _('Betrag') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_payout_betrag']))->all() AS $val) {
				$value = \Types\Euro::print($val) .  ' €'
	;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Betrag') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_payout_title'])) {
		if ($params['filter_payout_title'] == '_null') {
			array_push($filters, _('Betreff') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_payout_title']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Betreff') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_payout_xname'])) {
		if ($params['filter_payout_xname'] == '_null') {
			array_push($filters, _('Mitglied') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_payout_xname']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Mitglied') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_payout_iban'])) {
		if ($params['filter_payout_iban'] == '_null') {
			array_push($filters, _('IBAN') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_payout_iban']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('IBAN') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_payout_bic'])) {
		if ($params['filter_payout_bic'] == '_null') {
			array_push($filters, _('BIC') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_payout_bic']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('BIC') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_payout_sepaDate'])) {
		if ($params['filter_payout_sepaDate'] == '_null') {
			array_push($filters, _('Datum Lastschrift') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_payout_sepaDate']))->all() AS $val) {
				$value = ($val) ? strftime(_('dateformat_php2'), intval($val)) : '';
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Datum Lastschrift') . ': ' . implode(', ', $values));
		}
	}if (isset($params['search_payout_title'])) {
		array_push($filters, _('title') . ' ' . _('filter_contains') . ' ' . $params['search_payout_title']);
	}if (isset($params['search_payout_xname'])) {
		array_push($filters, _('xname') . ' ' . _('filter_contains') . ' ' . $params['search_payout_xname']);
	}if (isset($params['search_payout_iban'])) {
		array_push($filters, _('iban') . ' ' . _('filter_contains') . ' ' . $params['search_payout_iban']);
	}if (isset($params['search_payout_bic'])) {
		array_push($filters, _('bic') . ' ' . _('filter_contains') . ' ' . $params['search_payout_bic']);
	}if (isset($params['searchnot_payout_title'])) {
		array_push($filters, _('title') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_payout_title']);
	}if (isset($params['searchnot_payout_xname'])) {
		array_push($filters, _('xname') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_payout_xname']);
	}if (isset($params['searchnot_payout_iban'])) {
		array_push($filters, _('iban') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_payout_iban']);
	}if (isset($params['searchnot_payout_bic'])) {
		array_push($filters, _('bic') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_payout_bic']);
	}
		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(\'_payout_\')) delete query[q];} reloadpayout(); ">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 == 'mitglied') {
	\FOP\Session::setPayload('dv-mitglied', [
		'id' => 'payout',
		'tbl' => 'mitglied',
		'idcol' => 'ID',
		'prev' => \DataViewRouter\Payout::stepURL('mitglied', 'XXX', -1),
		'next' => \DataViewRouter\Payout::stepURL('mitglied', '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\Mitglied::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();

    
  }

  public static function sepaXML($name, $iban, $bic, $glaeubigerid) { 
    
    
    // --- BLOCK: main ---
    
$stammdaten = \Configuration\Stammdaten::getStammdaten();
$data = self::getData('', $_GET);

$result = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02 pain.008.001.02.xsd"/>');
$content = $result->addChild('CstmrDrctDbtInitn');

$header = $content->addChild('GrpHdr');
$ids = '';
$num = 0;
$sum = 0;
$pmt = $content->addChild('PmtInf');
foreach($data['items'] AS $item) {
	if ($item['betrag'] && $item['title'] && $item['xname'] && $item['iban']) {
		$ids .= $item['ID'] . ';';
		$num++;
		$sum += round($item['betrag'], 2);
	}
}
// Header
$header->addChild('MsgId', substr(hash('sha256', $ids), 0, 32));
$header->addChild('CreDtTm', date('Y-m-d\TH:i:s\Z'));
$header->addChild('NbOfTxs', $num);
$header->addChild('CtrlSum', number_format($sum, 2, '.', ''));
$header->addChild('InitgPty')->addChild('Nm', \FOP\Util::escapeSEPA($name, 70));

$pmt->addChild('PmtInfId', substr(hash('sha256', $ids), 0, 32));
$pmt->addChild('PmtMtd', 'DD');
$pmt->addChild('BtchBookg', 'false');
$pmt->addChild('NbOfTxs', $num);
$pmt->addChild('CtrlSum', number_format($sum, 2, '.', ''));
$tp = $pmt->addChild('PmtTpInf');
$tp->addChild('SvcLvl')->addChild('Cd', 'SEPA');

$tp->addChild('LclInstrm')->addChild('Cd', 'CORE'); // momentan nur Basislastschrift
$tp->addChild('SeqTp', 'RCUR'); // TODO: Unterscheidung: RCUR, FRST, OOFF, FNAL für Folgel., Erstl., Einmall.

$pmt->addChild('ReqdColltnDt', date('Y-m-d'));
$pmt->addChild('Cdtr')->addChild('Nm', \FOP\Util::escapeSEPA($name, 70));
$pmt->addChild('CdtrAcct')->addChild('Id')->addChild('IBAN',  str_replace(' ', '', $iban));
$pmt->addChild('CdtrAgt')->addChild('FinInstnId')->addChild('BIC', str_replace(' ', '', $bic));

$pmt->addChild('ChrgBr', 'SLEV');

$glaeubiger_id = $pmt->addChild('CdtrSchmeId')->addChild('Id')->addChild('PrvtId')->addChild('Othr');
$glaeubiger_id->addChild('Id', $glaeubigerid);
$glaeubiger_id->addChild('SchmeNm')->addChild('Prtry', 'SEPA');


// IntrBkSttlmDt -> Fälligkeitsdatum

// Body
foreach($data['items'] AS $dataset) {
	if ($dataset['betrag'] && $dataset['title'] && $dataset['xname'] && $dataset['iban']) {
		$item = $pmt->addChild('DrctDbtTxInf');
		$item->addChild('PmtId')->addChild('EndToEndId', $dataset['ID']);
	
		$item->addChild('InstdAmt', number_format($dataset['betrag'], 2, '.', ''))->addAttribute('Ccy', 'EUR');
		$mandat = $item->addChild('DrctDbtTx')->addChild('MndtRltdInf');
		$mandat->addChild('MndtId', $dataset['ID']);
		$mandat->addChild('DtOfSgntr', date('Y-m-d', $dataset['sepaDate']));
		$mandat->addChild('AmdmntInd', 'false');
		$item->addChild('DbtrAgt')->addChild('FinInstnId')->addChild('BIC', str_replace(' ', '', $dataset['bic']));
		$item->addChild('Dbtr')->addChild('Nm', \FOP\Util::escapeSEPA($dataset['xname'], 70));
		$item->addChild('DbtrAcct')->addChild('Id')->addChild('IBAN', str_replace(' ', '', $dataset['iban']));
	

		$item->addChild('Purp')->addChild('Cd', \FOP\Util::escapeSEPA('GDSV'));
		$item->addChild('RmtInf')->addChild('Ustrd', \FOP\Util::escapeSEPA($dataset['title']));
	}
}
echo $result->asXML();

    
  }


  
  

  
  
}



