<?php

namespace DataView;

class Ansprechpartner {
  
  

  
  

    // --- Statische Methoden ---
  
  public static function exportCSVAction($attachTo = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: before-header ---
    
		$data = self::getData('', $_GET);
	
    // --- BLOCK: before-header-filename ---
    
	$filename = preg_replace('/[~"#%&\*:<>\?\/\\\{|\}]/', '_', _('Kontaktpersonen') . ' ' . self::getFilterHTML($_GET, ', ', false) . '.csv'); // sanitize
    // --- BLOCK: before-main ---
    
	if (!$attachTo) {
		header('Content-Type: ' . 'text/csv');
		header('Content-Disposition: attachment; filename="'.$filename.'"');
	} else if ($attachTo === 'string') {
		
	ob_start();
	} else if ($attachTo === 'file') {
		
		$ob_tmp = tempnam(sys_get_temp_dir(), 'fop-file');
		$ob_tmp_handle = fopen($ob_tmp, 'w');
		ob_start(function ($data) use ($ob_tmp_handle) {
			fwrite($ob_tmp_handle, $data);
			return '';
		}, 1024*1024);
	} else if ($attachTo instanceof \PHPMailer\PHPMailer\PHPMailer) {
		
		ob_start();
	} else if ($attachTo instanceof \ZipArchive) {
		
		ob_start();
	} else {
		throw new \FOP\AccessDeniedException('unknown attachment object');
	}
    // --- BLOCK: main ---
    
		?>"von Mitglied";"von Mitglied-Link";"Vorname";"Nachname";"Beziehung zum Mitglied";"Telefon";"Telefon 2";"E-Mail"<?php
		echo "\n";
		$sums = [];
		foreach ($data['items'] AS $item) {
			$val = $item['mitglied'];
			$val = 
  \FOP\Database::query('SELECT CONCAT('.qi('mitglied').'.'.qi('vorname').', \' \', '.qi('mitglied').'.'.qi('name').') AS description FROM '.qi('mitglied').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($val))->fetchColumn() ?: _('')
;
			if (is_numeric($val)) {
				echo $val;
			} else {
				echo '"' . str_replace("\n", "\\n", str_replace('"', '""', $val)) . '"';
			}
			$val = $item['mitglied'];
			echo ';' . '"' . str_replace("\n", "\\n", str_replace('"', '""', (\TablesRouter\Mitglied::viewURL($val)))) . '"';
			echo ';';
			$val = $item['vorname'];
			$val = $val;
			if (is_numeric($val)) {
				echo $val;
			} else {
				echo '"' . str_replace("\n", "\\n", str_replace('"', '""', $val)) . '"';
			}
			echo ';';
			$val = $item['name'];
			$val = $val;
			if (is_numeric($val)) {
				echo $val;
			} else {
				echo '"' . str_replace("\n", "\\n", str_replace('"', '""', $val)) . '"';
			}
			echo ';';
			$val = $item['stellung'];
			$val = $val;
			if (is_numeric($val)) {
				echo $val;
			} else {
				echo '"' . str_replace("\n", "\\n", str_replace('"', '""', $val)) . '"';
			}
			echo ';';
			$val = $item['tel'];
			$val = $val;
			if (is_numeric($val)) {
				echo $val;
			} else {
				echo '"' . str_replace("\n", "\\n", str_replace('"', '""', $val)) . '"';
			}
			echo ';';
			$val = $item['tel2'];
			$val = $val;
			if (is_numeric($val)) {
				echo $val;
			} else {
				echo '"' . str_replace("\n", "\\n", str_replace('"', '""', $val)) . '"';
			}
			echo ';';
			$val = $item['email'];
			$val = $val;
			if (is_numeric($val)) {
				echo $val;
			} else {
				echo '"' . str_replace("\n", "\\n", str_replace('"', '""', $val)) . '"';
			}
			
			echo "\n";
		}
		
	
    // --- BLOCK: main-~method ---
    
	if (!$attachTo) { ;
	} else if ($attachTo === 'string') {
		
	$content = ob_get_clean();
	return $content;
	} else if ($attachTo === 'file') {
		
		ob_end_flush();
		fclose($ob_tmp_handle);
		return \FOP\Files::uploadFromFile($ob_tmp, $filename);
	} else if ($attachTo instanceof \PHPMailer\PHPMailer\PHPMailer) {
		
		$content = ob_get_clean();
		$attachTo->AddStringAttachment($content, $filename);

	} else if ($attachTo instanceof \ZipArchive) {
		
		$content = ob_get_clean();
		$attachTo->addFromString($filename, $content);
	
	}
    
  }

  public static function renderScript() { 
    
    
    // --- BLOCK: main ---
    
								\FOP\I18n::ensureIsLoaded();
								?>
								<script type="text/javascript">
									
    function changefilter_ansprechpartner_mitgliedListMultiFilter(val, cb) {
		  if (val) {
			  querySet('filter_ansprechpartner_mitglied', val, cb.checked);
		  } else {
			  delete query['filter_ansprechpartner_mitglied'];
		  }reloadansprechpartner();
        
    }

		var i03da5d7142c4e11a8c7e0ecf50b8e16ed26a7554a568088b7f471f5fd14d9d16timeout = null;
		function changefilter_ansprechpartner_mitgliedSearchFilter(val, callback) {
			if(i03da5d7142c4e11a8c7e0ecf50b8e16ed26a7554a568088b7f471f5fd14d9d16timeout) clearTimeout(i03da5d7142c4e11a8c7e0ecf50b8e16ed26a7554a568088b7f471f5fd14d9d16timeout);

			i03da5d7142c4e11a8c7e0ecf50b8e16ed26a7554a568088b7f471f5fd14d9d16timeout = setTimeout(function() {
				$.getJSON(reloadansprechpartner({action: 'getfilter_ansprechpartner_mitgliedItemsByString', 'fstr': val}, true), function(r) {
					callback(r);
					query['filter_ansprechpartner_mitglied_orig'] = val;
				});
			}, 300);
		}

	function getfilter_ansprechpartner_mitgliedListMultiFilter() {
		var gui = $("<div class='fop-floatsorter'></div>");
		// TODO: usability #1866 auf ajax warten bevor ENTER behandelt wird
		var fstr = <?php echo(isset($_GET['filter_ansprechpartner_mitglied_orig']) ? json_encode($_GET['filter_ansprechpartner_mitglied_orig']) : '""') ?>;
		var search = $('<div class="mdl-textfield mdl-js-textfield">' + 
			'<input value="" class="mdl-textfield__input" id="03da5d7142c4e11a8c7e0ecf50b8e16ed26a7554a568088b7f471f5fd14d9d16" type="text">' +
			'<label class="mdl-textfield__label" for="03da5d7142c4e11a8c7e0ecf50b8e16ed26a7554a568088b7f471f5fd14d9d16">Filter...</label>' +
			'</div>');
		search.find('input').val(fstr).keyup(function (event) {
			var self = this;
			if ((event.keyCode || e.which) == 13) {
				var hasChecked = false;
				if (this.value) {
					// search value + tick all search results
					checkboxes.find('input').each(function (i, inp) {
						if (!inp.checked && $(inp).data('value')) {
							inp.checked = true;
							querySet('filter_ansprechpartner_mitglied', $(inp).data('value'), true);
							hasChecked = true;
						}
					});
				} else {
					// untick all
					search.find('input').val('');
					query['filter_ansprechpartner_mitglied_orig'] = '';
					delete query['filter_ansprechpartner_mitglied'];
					reload('', items);
					hasChecked = true;
				}
				if (hasChecked) {reloadansprechpartner();
					
				} else {
					$('#table_ansprechpartner').find('.fop-table-row:first').click();
				}
			} else {
				changefilter_ansprechpartner_mitgliedSearchFilter(this.value, function (result) {
					reload(self.value, result);
				});
			}
		});
		gui.append(search);

		var checkboxes = $("<div></div>").css({maxHeight: '200px', overflow: 'auto'});
		var items = <?php
			// TODO: deps-Variable füllen mit DV-Parametern vom DataView id
			echo json_encode(\DataView\Ansprechpartner::getfilter_ansprechpartner_mitgliedItemsByStringAction(''));
		?>;

		function reload(fstr, items) {
			// rerender checkbox list
			checkboxes.empty();
			checkboxes.append($('<i style="cursor: pointer;"><?php echo _('show all'); ?></i>').click(function () {
				search.find('input').val('');
				query['filter_ansprechpartner_mitglied_orig'] = '';
				delete query['filter_ansprechpartner_mitglied'];
				reload('', items);reloadansprechpartner();
				
			})).append('<br/>');
			// NULL-Wert auch suchbar #2057 (kommt als ID=0 an, muss für die idlist in _null geändert werden)
			for (var i = 0; i < items.length; i++) {
				let value = (items[i].ID === '0' ? '_null' : items[i].ID);
				let descr = items[i].description;
				let checked = querySet('filter_ansprechpartner_mitglied', value);
				if (!fstr || checked || descr.toLowerCase().includes(fstr.toLowerCase())) {
					checkboxes.append($('<input type=\'checkbox\'  onclick=\'changefilter_ansprechpartner_mitgliedListMultiFilter("' + value + '", this)\' ' + (checked ? ' checked>': '> ')).data('value', value)).append($('<span></span>').text(descr).prepend('&nbsp;')).append('<br/>');
				}
			 }
		}
		reload(fstr, items);
		gui.append(checkboxes);

		return gui;
	}
									
    function changefilter_ansprechpartner_mitgliedListMultiFilter(val, cb) {
		  if (val) {
			  querySet('filter_ansprechpartner_mitglied', val, cb.checked);
		  } else {
			  delete query['filter_ansprechpartner_mitglied'];
		  }reloadansprechpartner();
        
    }

		var i03da5d7142c4e11a8c7e0ecf50b8e16ed26a7554a568088b7f471f5fd14d9d16timeout = null;
		function changefilter_ansprechpartner_mitgliedSearchFilter(val, callback) {
			if(i03da5d7142c4e11a8c7e0ecf50b8e16ed26a7554a568088b7f471f5fd14d9d16timeout) clearTimeout(i03da5d7142c4e11a8c7e0ecf50b8e16ed26a7554a568088b7f471f5fd14d9d16timeout);

			i03da5d7142c4e11a8c7e0ecf50b8e16ed26a7554a568088b7f471f5fd14d9d16timeout = setTimeout(function() {
				$.getJSON(reloadansprechpartner({action: 'getfilter_ansprechpartner_mitgliedItemsByString', 'fstr': val}, true), function(r) {
					callback(r);
					query['filter_ansprechpartner_mitglied_orig'] = val;
				});
			}, 300);
		}

	function getfilter_ansprechpartner_mitgliedListMultiFilter() {
		var gui = $("<div class='fop-floatsorter'></div>");
		// TODO: usability #1866 auf ajax warten bevor ENTER behandelt wird
		var fstr = <?php echo(isset($_GET['filter_ansprechpartner_mitglied_orig']) ? json_encode($_GET['filter_ansprechpartner_mitglied_orig']) : '""') ?>;
		var search = $('<div class="mdl-textfield mdl-js-textfield">' + 
			'<input value="" class="mdl-textfield__input" id="03da5d7142c4e11a8c7e0ecf50b8e16ed26a7554a568088b7f471f5fd14d9d16" type="text">' +
			'<label class="mdl-textfield__label" for="03da5d7142c4e11a8c7e0ecf50b8e16ed26a7554a568088b7f471f5fd14d9d16">Filter...</label>' +
			'</div>');
		search.find('input').val(fstr).keyup(function (event) {
			var self = this;
			if ((event.keyCode || e.which) == 13) {
				var hasChecked = false;
				if (this.value) {
					// search value + tick all search results
					checkboxes.find('input').each(function (i, inp) {
						if (!inp.checked && $(inp).data('value')) {
							inp.checked = true;
							querySet('filter_ansprechpartner_mitglied', $(inp).data('value'), true);
							hasChecked = true;
						}
					});
				} else {
					// untick all
					search.find('input').val('');
					query['filter_ansprechpartner_mitglied_orig'] = '';
					delete query['filter_ansprechpartner_mitglied'];
					reload('', items);
					hasChecked = true;
				}
				if (hasChecked) {reloadansprechpartner();
					
				} else {
					$('#table_ansprechpartner').find('.fop-table-row:first').click();
				}
			} else {
				changefilter_ansprechpartner_mitgliedSearchFilter(this.value, function (result) {
					reload(self.value, result);
				});
			}
		});
		gui.append(search);

		var checkboxes = $("<div></div>").css({maxHeight: '200px', overflow: 'auto'});
		var items = <?php
			// TODO: deps-Variable füllen mit DV-Parametern vom DataView id
			echo json_encode(\DataView\Ansprechpartner::getfilter_ansprechpartner_mitgliedItemsByStringAction(''));
		?>;

		function reload(fstr, items) {
			// rerender checkbox list
			checkboxes.empty();
			checkboxes.append($('<i style="cursor: pointer;"><?php echo _('show all'); ?></i>').click(function () {
				search.find('input').val('');
				query['filter_ansprechpartner_mitglied_orig'] = '';
				delete query['filter_ansprechpartner_mitglied'];
				reload('', items);reloadansprechpartner();
				
			})).append('<br/>');
			// NULL-Wert auch suchbar #2057 (kommt als ID=0 an, muss für die idlist in _null geändert werden)
			for (var i = 0; i < items.length; i++) {
				let value = (items[i].ID === '0' ? '_null' : items[i].ID);
				let descr = items[i].description;
				let checked = querySet('filter_ansprechpartner_mitglied', value);
				if (!fstr || checked || descr.toLowerCase().includes(fstr.toLowerCase())) {
					checkboxes.append($('<input type=\'checkbox\'  onclick=\'changefilter_ansprechpartner_mitgliedListMultiFilter("' + value + '", this)\' ' + (checked ? ' checked>': '> ')).data('value', value)).append($('<span></span>').text(descr).prepend('&nbsp;')).append('<br/>');
				}
			 }
		}
		reload(fstr, items);
		gui.append(checkboxes);

		return gui;
	}
									function updateNumberansprechpartner(col) {
										//var checklist = window.DataViewChecked['ansprechpartner'][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['ansprechpartner'] && window.DataViewChecked['ansprechpartner'][col].ranges.length > 0) {
											$('.ansprechpartner__mass-action').css('visibility', 'visible');
											$('.ansprechpartner__action').css('visibility', 'hidden');
										} else {
											$('.ansprechpartner__mass-action').css('visibility', 'hidden');
											$('.ansprechpartner__action').css('visibility', 'visible');
										}
										$('.ansprechpartner__checkbox').each(function (idx, x) {
											for (var cssclass of x.classList) {
												if (cssclass.startsWith('ansprechpartner__checkbox-'+col+'-')) {
													var my_id = cssclass.substr(('ansprechpartner__checkbox-'+col+'-').length);
													if (window.DataViewChecked) {
														x.MaterialCheckbox[checklist.has(my_id) ? 'check' : 'uncheck']();
													}
												}
											}
										});
									}
									function reloadansprechpartner (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/Ansprechpartner/" + action + "?" + Object.keys(nq).map(function(k){ return k + "=" +  encodeURIComponent(nq[k]); }).join("&");
											// direkt aufrufen (ist wohl ein Download oder so)
											if (returnUrl) return querystr;
											window.location.href = querystr;
										} else {
											let querystr;
											
											
											<?php if ((!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?>
											delete nq['action'];
											querystr = "DataView/Ansprechpartner/renderTabTable?" + Object.keys(nq).map(function(k){ return k + "=" +  encodeURIComponent(nq[k]); }).join("&");
											// per Ajax laden
											if(!$("#ansprechpartner-table")?.parent()?.parent()?.hasClass('fop-form-feature-collapsed') || $("#ansprechpartner-table")?.parent()?.parent()?.hasClass('fop-form-feature-mode-area')) {
											$.get(querystr, function(data){
												var tab = $("#ansprechpartner-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
												updateNumberansprechpartner('ID');
											});
											} else {
												// gesamten Tab ersetzen
												var tab = $("#ansprechpartner-table");
												tab.children().remove();
												el = tab.html('<div class="fop-lazy-reload" onclick="reloadansprechpartner()"></div>');
											}
											<?php } ?>
											
										}
									}
									function checkansprechpartner (id, col, checked) {
										// ID-Liste aufbauen
										if (!window.DataViewChecked) window.DataViewChecked = {};
										if (!window.DataViewChecked['ansprechpartner']) window.DataViewChecked['ansprechpartner'] = {};
										if (!window.DataViewChecked['ansprechpartner'][col]) window.DataViewChecked['ansprechpartner'][col] = new IDList();

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

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

    
  }

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

	</script>
	<?php
	
    
  }

  public static function renderTabTableAction() { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
     ?><div class='fop-dv-buttonbar'><?php if(((\FOP\User::getGruppe())) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?><a class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored" onclick="
		var self = this;
		event.preventDefault();
		$.get(reloadansprechpartner({action: 'open', fop_table: 'ansprechpartner', fop_id: '_', fop_from: location.href}, true))
		.then(function () {
			window.open_url(self.href, false);
		});" href="<?php echo htmlentities(\TablesRouter\Ansprechpartner::createURL2(['from' => $_GET['from'] ?? null, 'popup' => $_GET['popup'] ?? null])); ?>"><i class="material-icons">add</i> <?php echo(sprintf(_('create %s'), _('Kontaktperson'))); ?></a><?php }if(((\FOP\User::getGruppe())) && ((\FOP\User::getGruppe())) && ((\FOP\User::getGruppe()))) { ?><div class="to-form" style='display: inline;' enctype="multipart/form-data" method="POST" action="FOP/Import/mitglied_ImportUpload?">
    <label class="input-custom-file mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
		<input style="display: none;" name="importfile" type="file" onchange="var tf = $(this).closest('.to-form'); $('<form></form>').appendTo(document.body).attr('enctype', tf.attr('enctype')).attr('method', tf.attr('method')).attr('action', tf.attr('action')).append(tf).submit();">
		<i class="material-icons">cloud_upload</i>
      Importieren
    </label>
</div>
<?php }if((!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?><a class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="#" onclick="reloadansprechpartner({action: 'exportCSV'}); return false;">
		<i class="material-icons">view_comfy</i>
		<?php echo(_('CSV-Export')); ?>
	</a><?php } ?></div><?php 
								\FOP\User::getIsGuest();
								$itemheight = 32;
								$itemsperpage = ceil(1080 / $itemheight * 0.8);
								$page = (isset($_GET['page_ansprechpartner']) ? intval($_GET['page_ansprechpartner']) : 0);
								$addlines = (isset($_GET['addlines_ansprechpartner']) ? intval($_GET['addlines_ansprechpartner']) : 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;

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

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

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

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

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

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

											];
											$columns['tel2'] = $col;
										}
									
										if(true){
											$col = [
												'id' => 'email',
												'desc' => _('E-Mail'),
												'order' => ++$order,
												'width' => 180, // default value
												'collapsed' => 0

											];
											$columns['email'] = $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('ansprechpartner'))->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='mitglied'
												data-order='<?php echo intval($columns['mitglied']['order']); ?>'
												data-width='<?php echo intval($columns['mitglied']['width']); ?>'
												data-collapsed='<?php echo intval($columns['mitglied']['collapsed']); ?>'
												style='width: <?php echo intval($columns['mitglied']['width']); ?>px; <?php if ($columns['mitglied']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadansprechpartner(); 
		}});
		
		win.append(getfilter_ansprechpartner_mitgliedListMultiFilter()); win.find('input').first().focus();
	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_ansprechpartner'] == 'mitglied ASC') {
			query['sort_ansprechpartner'] = 'mitglied DESC';
		 } else if (query['sort_ansprechpartner'] == 'mitglied DESC') {
		 	delete query['sort_ansprechpartner'];
		 } else {
			query['sort_ansprechpartner'] = 'mitglied ASC';
		 }
		 reloadansprechpartner();
		 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(_('von Mitglied')); ?>'><?php echo(_('von Mitglied')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'mitglied ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'mitglied DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_ansprechpartner_mitglied']) || isset($_GET['range_max_ansprechpartner_mitglied']) || isset($_GET['deps_ansprechpartner_mitglied']) || isset($_GET['fullsearch_ansprechpartner_mitglied']) || isset($_GET['dynamic_ansprechpartner_mitglied']) || isset($_GET['search_ansprechpartner_mitglied']) || isset($_GET['searchnot_ansprechpartner_mitglied']) || isset($_GET['filter_ansprechpartner_mitglied'])) {
															// 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['mitglied']['header'] = ob_get_contents(); ob_end_clean();
											$columns['mitglied']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['mitglied']['width']); ?>px; <?php if ($columns['mitglied']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='mitglied'><?php
	
	call_user_func(function () use ($item) {
	$id = $item['mitglied'];
	$val = $item['mitglied::description'];
	$canView = $item['mitglied::canView'];
	if ($val !== null) {
		if ($canView) echo "<a tabindex=\"-1\" class=\"mdl-button mdl-button-small tbl-link\" data-tbl=\"mitglied\" data-id=\"".htmlentities($id)."\" onclick=\"event.stopPropagation(); event.preventDefault(); open_url(this.href, true);\" href=\"" . \TablesRouter\Mitglied::viewURL($id, ['from' => \FOP\Util::getBackURL()]) . "\">(…)</a>";echo htmlentities($val);
	} else {
		echo htmlentities(_('') ?: '-');
	}
	});
	
?>
</div><?php
											};
											$columns['mitglied']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='mitglied'
													data-order='<?php echo intval($columns['mitglied']['order']); ?>'
													data-width='<?php echo intval($columns['mitglied']['width']); ?>'
													data-collapsed='<?php echo intval($columns['mitglied']['collapsed']); ?>'
													style='width: <?php echo intval($columns['mitglied']['width']); ?>px; <?php if ($columns['mitglied']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='vorname'
												data-order='<?php echo intval($columns['vorname']['order']); ?>'
												data-width='<?php echo intval($columns['vorname']['width']); ?>'
												data-collapsed='<?php echo intval($columns['vorname']['collapsed']); ?>'
												style='width: <?php echo intval($columns['vorname']['width']); ?>px; <?php if ($columns['vorname']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadansprechpartner(); 
		}});
		
		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_ansprechpartner_vorname'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_ansprechpartner_vorname'] = text.val(); } else { delete query['search_ansprechpartner_vorname']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_ansprechpartner').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_ansprechpartner_vorname'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_ansprechpartner_vorname'] = text2.val(); } else { delete query['searchnot_ansprechpartner_vorname']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_ansprechpartner').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_ansprechpartner'] == 'vorname ASC') {
			query['sort_ansprechpartner'] = 'vorname DESC';
		 } else if (query['sort_ansprechpartner'] == 'vorname DESC') {
		 	delete query['sort_ansprechpartner'];
		 } else {
			query['sort_ansprechpartner'] = 'vorname ASC';
		 }
		 reloadansprechpartner();
		 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(_('Vorname')); ?>'><?php echo(_('Vorname')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'vorname ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'vorname DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_ansprechpartner_vorname']) || isset($_GET['range_max_ansprechpartner_vorname']) || isset($_GET['deps_ansprechpartner_vorname']) || isset($_GET['fullsearch_ansprechpartner_vorname']) || isset($_GET['dynamic_ansprechpartner_vorname']) || isset($_GET['search_ansprechpartner_vorname']) || isset($_GET['searchnot_ansprechpartner_vorname']) || isset($_GET['filter_ansprechpartner_vorname'])) {
															// 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['vorname']['header'] = ob_get_contents(); ob_end_clean();
											$columns['vorname']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['vorname']['width']); ?>px; <?php if ($columns['vorname']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='vorname'><span class='overflow-text' title="<?php echo htmlentities($item['vorname']); ?>"><?php echo htmlentities($item['vorname']); ?></span></div><?php
											};
											$columns['vorname']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='vorname'
													data-order='<?php echo intval($columns['vorname']['order']); ?>'
													data-width='<?php echo intval($columns['vorname']['width']); ?>'
													data-collapsed='<?php echo intval($columns['vorname']['collapsed']); ?>'
													style='width: <?php echo intval($columns['vorname']['width']); ?>px; <?php if ($columns['vorname']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='name'
												data-order='<?php echo intval($columns['name']['order']); ?>'
												data-width='<?php echo intval($columns['name']['width']); ?>'
												data-collapsed='<?php echo intval($columns['name']['collapsed']); ?>'
												style='width: <?php echo intval($columns['name']['width']); ?>px; <?php if ($columns['name']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadansprechpartner(); 
		}});
		
		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_ansprechpartner_name'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_ansprechpartner_name'] = text.val(); } else { delete query['search_ansprechpartner_name']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_ansprechpartner').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_ansprechpartner_name'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_ansprechpartner_name'] = text2.val(); } else { delete query['searchnot_ansprechpartner_name']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_ansprechpartner').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_ansprechpartner'] == 'name ASC') {
			query['sort_ansprechpartner'] = 'name DESC';
		 } else if (query['sort_ansprechpartner'] == 'name DESC') {
		 	delete query['sort_ansprechpartner'];
		 } else {
			query['sort_ansprechpartner'] = 'name ASC';
		 }
		 reloadansprechpartner();
		 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(_('Nachname')); ?>'><?php echo(_('Nachname')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'name ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'name DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_ansprechpartner_name']) || isset($_GET['range_max_ansprechpartner_name']) || isset($_GET['deps_ansprechpartner_name']) || isset($_GET['fullsearch_ansprechpartner_name']) || isset($_GET['dynamic_ansprechpartner_name']) || isset($_GET['search_ansprechpartner_name']) || isset($_GET['searchnot_ansprechpartner_name']) || isset($_GET['filter_ansprechpartner_name'])) {
															// filter indicator
															?><i class='material-icons fop-small'>filter_list</i><?php
														}
														// search indicator
														?><i class='material-icons fop-small'>search</i>
													</span>
												<div class='fop-column-handle'></div>
											</div><?php
											$columns['name']['header'] = ob_get_contents(); ob_end_clean();
											$columns['name']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['name']['width']); ?>px; <?php if ($columns['name']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='name'><span class='overflow-text' title="<?php echo htmlentities($item['name']); ?>"><?php echo htmlentities($item['name']); ?></span></div><?php
											};
											$columns['name']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='name'
													data-order='<?php echo intval($columns['name']['order']); ?>'
													data-width='<?php echo intval($columns['name']['width']); ?>'
													data-collapsed='<?php echo intval($columns['name']['collapsed']); ?>'
													style='width: <?php echo intval($columns['name']['width']); ?>px; <?php if ($columns['name']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='stellung'
												data-order='<?php echo intval($columns['stellung']['order']); ?>'
												data-width='<?php echo intval($columns['stellung']['width']); ?>'
												data-collapsed='<?php echo intval($columns['stellung']['collapsed']); ?>'
												style='width: <?php echo intval($columns['stellung']['width']); ?>px; <?php if ($columns['stellung']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadansprechpartner(); 
		}});
		
		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_ansprechpartner_stellung'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_ansprechpartner_stellung'] = text.val(); } else { delete query['search_ansprechpartner_stellung']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_ansprechpartner').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_ansprechpartner_stellung'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_ansprechpartner_stellung'] = text2.val(); } else { delete query['searchnot_ansprechpartner_stellung']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_ansprechpartner').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_ansprechpartner'] == 'stellung ASC') {
			query['sort_ansprechpartner'] = 'stellung DESC';
		 } else if (query['sort_ansprechpartner'] == 'stellung DESC') {
		 	delete query['sort_ansprechpartner'];
		 } else {
			query['sort_ansprechpartner'] = 'stellung ASC';
		 }
		 reloadansprechpartner();
		 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(_('Beziehung zum Mitglied')); ?>'><?php echo(_('Beziehung zum Mitglied')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'stellung ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'stellung DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_ansprechpartner_stellung']) || isset($_GET['range_max_ansprechpartner_stellung']) || isset($_GET['deps_ansprechpartner_stellung']) || isset($_GET['fullsearch_ansprechpartner_stellung']) || isset($_GET['dynamic_ansprechpartner_stellung']) || isset($_GET['search_ansprechpartner_stellung']) || isset($_GET['searchnot_ansprechpartner_stellung']) || isset($_GET['filter_ansprechpartner_stellung'])) {
															// 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['stellung']['header'] = ob_get_contents(); ob_end_clean();
											$columns['stellung']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['stellung']['width']); ?>px; <?php if ($columns['stellung']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='stellung'><span class='overflow-text' title="<?php echo htmlentities($item['stellung']); ?>"><?php echo htmlentities($item['stellung']); ?></span></div><?php
											};
											$columns['stellung']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='stellung'
													data-order='<?php echo intval($columns['stellung']['order']); ?>'
													data-width='<?php echo intval($columns['stellung']['width']); ?>'
													data-collapsed='<?php echo intval($columns['stellung']['collapsed']); ?>'
													style='width: <?php echo intval($columns['stellung']['width']); ?>px; <?php if ($columns['stellung']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='tel'
												data-order='<?php echo intval($columns['tel']['order']); ?>'
												data-width='<?php echo intval($columns['tel']['width']); ?>'
												data-collapsed='<?php echo intval($columns['tel']['collapsed']); ?>'
												style='width: <?php echo intval($columns['tel']['width']); ?>px; <?php if ($columns['tel']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadansprechpartner(); 
		}});
		
		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_ansprechpartner_tel'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_ansprechpartner_tel'] = text.val(); } else { delete query['search_ansprechpartner_tel']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_ansprechpartner').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_ansprechpartner_tel'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_ansprechpartner_tel'] = text2.val(); } else { delete query['searchnot_ansprechpartner_tel']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_ansprechpartner').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_ansprechpartner'] == 'tel ASC') {
			query['sort_ansprechpartner'] = 'tel DESC';
		 } else if (query['sort_ansprechpartner'] == 'tel DESC') {
		 	delete query['sort_ansprechpartner'];
		 } else {
			query['sort_ansprechpartner'] = 'tel ASC';
		 }
		 reloadansprechpartner();
		 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(_('Telefon')); ?>'><?php echo(_('Telefon')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'tel ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'tel DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_ansprechpartner_tel']) || isset($_GET['range_max_ansprechpartner_tel']) || isset($_GET['deps_ansprechpartner_tel']) || isset($_GET['fullsearch_ansprechpartner_tel']) || isset($_GET['dynamic_ansprechpartner_tel']) || isset($_GET['search_ansprechpartner_tel']) || isset($_GET['searchnot_ansprechpartner_tel']) || isset($_GET['filter_ansprechpartner_tel'])) {
															// 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['tel']['header'] = ob_get_contents(); ob_end_clean();
											$columns['tel']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['tel']['width']); ?>px; <?php if ($columns['tel']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='tel'><a target='tel' href="tel:<?php echo htmlentities(($item['tel'])); ?>" onclick="event.stopPropagation(); "><?php echo htmlentities(\FOP\Sanitizers::no_phone($item['tel'])); ?></a></div><?php
											};
											$columns['tel']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='tel'
													data-order='<?php echo intval($columns['tel']['order']); ?>'
													data-width='<?php echo intval($columns['tel']['width']); ?>'
													data-collapsed='<?php echo intval($columns['tel']['collapsed']); ?>'
													style='width: <?php echo intval($columns['tel']['width']); ?>px; <?php if ($columns['tel']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='tel2'
												data-order='<?php echo intval($columns['tel2']['order']); ?>'
												data-width='<?php echo intval($columns['tel2']['width']); ?>'
												data-collapsed='<?php echo intval($columns['tel2']['collapsed']); ?>'
												style='width: <?php echo intval($columns['tel2']['width']); ?>px; <?php if ($columns['tel2']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadansprechpartner(); 
		}});
		
		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_ansprechpartner_tel2'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_ansprechpartner_tel2'] = text.val(); } else { delete query['search_ansprechpartner_tel2']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_ansprechpartner').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_ansprechpartner_tel2'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_ansprechpartner_tel2'] = text2.val(); } else { delete query['searchnot_ansprechpartner_tel2']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_ansprechpartner').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_ansprechpartner'] == 'tel2 ASC') {
			query['sort_ansprechpartner'] = 'tel2 DESC';
		 } else if (query['sort_ansprechpartner'] == 'tel2 DESC') {
		 	delete query['sort_ansprechpartner'];
		 } else {
			query['sort_ansprechpartner'] = 'tel2 ASC';
		 }
		 reloadansprechpartner();
		 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(_('Telefon 2')); ?>'><?php echo(_('Telefon 2')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'tel2 ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'tel2 DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_ansprechpartner_tel2']) || isset($_GET['range_max_ansprechpartner_tel2']) || isset($_GET['deps_ansprechpartner_tel2']) || isset($_GET['fullsearch_ansprechpartner_tel2']) || isset($_GET['dynamic_ansprechpartner_tel2']) || isset($_GET['search_ansprechpartner_tel2']) || isset($_GET['searchnot_ansprechpartner_tel2']) || isset($_GET['filter_ansprechpartner_tel2'])) {
															// 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['tel2']['header'] = ob_get_contents(); ob_end_clean();
											$columns['tel2']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['tel2']['width']); ?>px; <?php if ($columns['tel2']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='tel2'><a target='tel' href="tel:<?php echo htmlentities(($item['tel2'])); ?>" onclick="event.stopPropagation(); "><?php echo htmlentities(\FOP\Sanitizers::no_phone($item['tel2'])); ?></a></div><?php
											};
											$columns['tel2']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='tel2'
													data-order='<?php echo intval($columns['tel2']['order']); ?>'
													data-width='<?php echo intval($columns['tel2']['width']); ?>'
													data-collapsed='<?php echo intval($columns['tel2']['collapsed']); ?>'
													style='width: <?php echo intval($columns['tel2']['width']); ?>px; <?php if ($columns['tel2']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='email'
												data-order='<?php echo intval($columns['email']['order']); ?>'
												data-width='<?php echo intval($columns['email']['width']); ?>'
												data-collapsed='<?php echo intval($columns['email']['collapsed']); ?>'
												style='width: <?php echo intval($columns['email']['width']); ?>px; <?php if ($columns['email']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadansprechpartner(); 
		}});
		
		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_ansprechpartner_email'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_ansprechpartner_email'] = text.val(); } else { delete query['search_ansprechpartner_email']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_ansprechpartner').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_ansprechpartner_email'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_ansprechpartner_email'] = text2.val(); } else { delete query['searchnot_ansprechpartner_email']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_ansprechpartner').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_ansprechpartner'] == 'email ASC') {
			query['sort_ansprechpartner'] = 'email DESC';
		 } else if (query['sort_ansprechpartner'] == 'email DESC') {
		 	delete query['sort_ansprechpartner'];
		 } else {
			query['sort_ansprechpartner'] = 'email ASC';
		 }
		 reloadansprechpartner();
		 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(_('E-Mail')); ?>'><?php echo(_('E-Mail')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'email ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_ansprechpartner']) && $_GET['sort_ansprechpartner'] == 'email DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_ansprechpartner_email']) || isset($_GET['range_max_ansprechpartner_email']) || isset($_GET['deps_ansprechpartner_email']) || isset($_GET['fullsearch_ansprechpartner_email']) || isset($_GET['dynamic_ansprechpartner_email']) || isset($_GET['search_ansprechpartner_email']) || isset($_GET['searchnot_ansprechpartner_email']) || isset($_GET['filter_ansprechpartner_email'])) {
															// 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['email']['header'] = ob_get_contents(); ob_end_clean();
											$columns['email']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['email']['width']); ?>px; <?php if ($columns['email']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='email'><span class='overflow-text'><a onclick="event.stopPropagation();<?php if ((!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?>event.preventDefault(); window.open_over(document.baseURI + 'Tables/Fop_mail_host_box_draft/create?to=' + encodeURIComponent(this.href.substr(7)) + '&popup&from=' + encodeURIComponent(document.baseURI + 'jscloser.php?action=popup&close')); <?php } ?>
" href="<?php echo ('mailto:' . htmlentities(($item['email']))); ?>"><?php echo htmlentities($item['email']); ?></a></span></div><?php
											};
											$columns['email']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='email'
													data-order='<?php echo intval($columns['email']['order']); ?>'
													data-width='<?php echo intval($columns['email']['width']); ?>'
													data-collapsed='<?php echo intval($columns['email']['collapsed']); ?>'
													style='width: <?php echo intval($columns['email']['width']); ?>px; <?php if ($columns['email']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									

									// sort by order
									uasort($columns, function ($a, $b) {
										return $a['order'] - $b['order'];
									});
									?>
									<style type='text/css'>
										#ansprechpartner-table .fop-table-header {
											height: <?php echo 32; ?>px;
										}
										#ansprechpartner-table .fop-table-header .fop-table-column .title,
										#ansprechpartner-table .fop-column-handle,
										#ansprechpartner-table .fop-table-row,
										#ansprechpartner-table .fop-table-row .fop-table-column,
										#ansprechpartner-table .fop-table-column-multicontrol,
										#ansprechpartner-table .fop-filter-button {
											height: 32px;
											line-height: 32px;
										}
										</style>
											<div class="fop-table" data-table-id="ansprechpartner">
											<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="ansprechpartner__all-checkbox">
														<input class="mdl-checkbox__input" id="ansprechpartner__all-checkbox" type="checkbox" onchange="checkansprechpartner('all', 'ID', this.checked);">
														</label>
														<button type="button" class="mdl-button mdl-js-button mdl-button--icon ansprechpartner__mass-action" style='visibility: hidden;' onclick="$.get('DataView/Ansprechpartner/permissions?id=' + checkansprechpartner(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_ansprechpartner_') == 0 || key.indexOf('range_max_ansprechpartner_') == 0 || key.indexOf('deps_ansprechpartner_') == 0 || key.indexOf('fullsearch_ansprechpartner_') == 0 || key.indexOf('dynamic_ansprechpartner_') == 0 || key.indexOf('search_ansprechpartner_') == 0 || key.indexOf('searchnot_ansprechpartner_') == 0 || key.indexOf('filter_ansprechpartner_') == 0) delete query[key]; reloadansprechpartner(); $(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_ansprechpartner_ID'] = checkansprechpartner(null, 'ID'); delete query['page_ansprechpartner']; reloadansprechpartner(); $(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(checkansprechpartner(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;
			}
			checkansprechpartner(newticks, 'ID', 'set');
		} $(this).closest('.overlay').click(); return false;">
					<span style="float:left;"><i class="material-icons">colorize</i></span><span class="fop-menu-caption" title="<?php echo(_('limit range')); ?>"><?php echo(_('limit range')); ?> (<span class='cnt'></span>)
					</span>
				</span>
			</span>
		<?php } ?><?php
		if(true && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?>
			<span class="mdl-list__item mdl-button">
				<span class="mdl-list__item mdl-button" data-interaction-name="exportCSV_multi" style="margin-right:auto; text-align:left;"
					onclick="location.href = 'DataView/Ansprechpartner/exportCSV?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&filter_ansprechpartner_ID=' + escape(checkansprechpartner(null, 'ID')); $(this).closest('.overlay').click(); return false;">
					<span style="float:left;"><i class="material-icons">view_comfy</i></span><span class="fop-menu-caption" title="<?php echo(_('CSV-Export')); ?>"><?php echo(_('CSV-Export')); ?> (<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/Ansprechpartner/delete?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&id=' + escape(checkansprechpartner(null, 'ID'))).then(function () { reloadansprechpartner(); }, 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('ansprechpartner', <?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: 'ansprechpartner', 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_ansprechpartner" <?php \EasyEditor\Navigation::printScroll('dv.Ansprechpartner', '/* scroll horiz */ 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_ansprechpartner\'] || 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_ansprechpartner\'] = wantedPage;
														reloadansprechpartner(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) {
													?>
													<div class="fop-table-row" style="" data-ansprechpartner-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(reloadansprechpartner({action: \'open\', fop_table: \'ansprechpartner\', fop_id: ' .  htmlentities(json_encode($item['ID'])) . ', fop_from: location.href}, true), false);"';
														}
													}?> >

													<?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 ansprechpartner__checkbox ansprechpartner__checkbox ansprechpartner__checkbox-ID-<?php echo htmlentities($item['ID']); ?>" style="width: auto;" for="ansprechpartner__<?php echo htmlentities($itempos); ?>-checkbox">
													<input class="mdl-checkbox__input" id="ansprechpartner__<?php echo htmlentities($itempos); ?>-checkbox" type="checkbox" onchange="<?php if (isset($item['ID'])) echo 'checkansprechpartner(' . htmlentities(json_encode($item['ID'])) . ', \'ID\', this.checked); ' ?>">
													</label><button type="button" class="mdl-button mdl-js-button mdl-button--icon ansprechpartner__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-ansprechpartner-action-<?php echo $item['ID'] ?? 0; ?>">
														<?php
		if(isset($item['ID']) && $item['operation::view']) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="view" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Ansprechpartner::viewURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick=" if (!event.ctrlKey) { open_url(reloadansprechpartner({action: 'open', fop_table: 'ansprechpartner', fop_id: <?php echo htmlentities(json_encode($item['ID'])); ?>, fop_from: location.href}, true), false); return false; } $(this).closest('.overlay').click(); return false;  
					open_url(this.href, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">find_in_page</i></span><span class="fop-menu-caption" title="<?php echo(_('open')); ?>"><?php echo(_('open')); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && $item['operation::view'] && $item['operation::edit']) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="edit" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Ansprechpartner::editURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, false);
					$(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']) && $item['operation::delete']) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="delete" style="margin-right:auto; text-align:left;" href="#"
				onclick="if(!confirm(<?php echo htmlentities(json_encode(_('confirmdelete'))); ?>)) return false;   $.get('Tables/Ansprechpartner/delete?ajax&id=<?php echo htmlentities($item['ID']);?>&from=<?php echo htmlentities(\FOP\Util::getBackUrl());?>').then(function () { reloadansprechpartner(); }, 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, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">delete</i></span><span class="fop-menu-caption" title="<?php echo(_('delete')); ?>"><?php echo(_('delete')); ?></span>
			</a>
		<?php } ?>
													</ul><?php
		if(isset($item['ID']) && $item['operation::view'] && $item['operation::edit']) {
			?><a class="mdl-button mdl-js-button mdl-button--icon tbl-link" data-tbl="ansprechpartner" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="edit" href="<?php echo htmlentities(\TablesRouter\Ansprechpartner::editURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();    reloadansprechpartner();
					$(this).closest('.overlay').click();
					if (this.href != '#') {
						open_url(this.href, false);
					}
					event.preventDefault();"
				title="<?php echo(_('edit')); ?>">
				<i class="material-icons">edit</i>
			</a><?php } ?><?php
		if(isset($item['ID']) && $item['operation::view']) {
			?><a class="mdl-button mdl-js-button mdl-button--icon tbl-link" data-tbl="ansprechpartner" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="view" href="<?php echo htmlentities(\TablesRouter\Ansprechpartner::viewURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();  if (!event.ctrlKey) { open_url(reloadansprechpartner({action: 'open', fop_table: 'ansprechpartner', fop_id: <?php echo htmlentities(json_encode($item['ID'])); ?>, fop_from: location.href}, true), false); return false; }  reloadansprechpartner();
					$(this).closest('.overlay').click();
					if (this.href != '#') {
						open_url(this.href, false);
					}
					event.preventDefault();"
				title="<?php echo(_('open')); ?>">
				<i class="material-icons">find_in_page</i>
			</a><?php } ?>
													</div><?php } ?><?php
													
													foreach ($columns AS $col) {
														$col['render']($item);
													}
													?></div>
												 <?php }?>

													</div>
												</div>

												
												
												</div><?php
												
	
    
  }

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

    
  }

  public static function permissionsAction($id) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
		$ids = new \FOP\IDList($id);
		header('Content-Type: application/json');
		
		$perms = \FOP\Database::query('SELECT COUNT(*) AS __cnt, SUM(CASE (TRUE) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('exportCSV_multi').', 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 ((COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('H67218v9').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('H67218v9').'.'.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) FROM '.qi('mitglied').' '.qi('H67218v9').' WHERE '.qi('H67218v9').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getGruppe()).') FROM '.qi('mitglied').' '.qi('RIGXOrgL').' WHERE '.qi('RIGXOrgL').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getGruppe()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('cZ5SfN8d').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('cZ5SfN8d').' WHERE '.qi('cZ5SfN8d').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE))) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('delete').' FROM '.qi('ansprechpartner').' WHERE ' . $ids->toSQL(qi('ID')))->fetch(\PDO::FETCH_ASSOC);
		
		return $perms;
	
    
  }

  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 */ '.qi('ID').' AS '.qi('ID').',
									/* email */ '.qi('email').' AS '.qi('email').',
									/* mitglied */ '.qi('mitglied').' AS '.qi('mitglied').',
									/* mitglied::canView */ '.qi('ref:mitglied').'.'.qi('mitglied:canView').' AS '.qi('mitglied::canView').',
									/* mitglied::description */ '.qi('ref:mitglied').'.'.qi('mitglied:description').' AS '.qi('mitglied::description').',
									/* name */ '.qi('name').' AS '.qi('name').',
									/* operation::create */ (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('KRTKa3PB').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('KRTKa3PB').'.'.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) FROM '.qi('mitglied').' '.qi('KRTKa3PB').' WHERE '.qi('KRTKa3PB').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getGruppe()).') FROM '.qi('mitglied').' '.qi('7mTqtpk9').' WHERE '.qi('7mTqtpk9').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getGruppe()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('gKmZLtRS').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('gKmZLtRS').' WHERE '.qi('gKmZLtRS').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AS '.qi('operation::create').',
									/* operation::delete */ (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('H67218v9').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('H67218v9').'.'.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) FROM '.qi('mitglied').' '.qi('H67218v9').' WHERE '.qi('H67218v9').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getGruppe()).') FROM '.qi('mitglied').' '.qi('RIGXOrgL').' WHERE '.qi('RIGXOrgL').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getGruppe()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('cZ5SfN8d').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('cZ5SfN8d').' WHERE '.qi('cZ5SfN8d').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AS '.qi('operation::delete').',
									/* operation::edit */ (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('YOIkqjys').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('YOIkqjys').'.'.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) FROM '.qi('mitglied').' '.qi('YOIkqjys').' WHERE '.qi('YOIkqjys').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getGruppe()).') FROM '.qi('mitglied').' '.qi('kNgaTDJo').' WHERE '.qi('kNgaTDJo').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getGruppe()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('trKroP0m').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('trKroP0m').' WHERE '.qi('trKroP0m').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AS '.qi('operation::edit').',
									/* operation::index */ ' . (!\FOP\User::getIsGuest() ? 1 : 0) . ' AS '.qi('operation::index').',
									/* operation::view */ (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Thhyngzk').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Thhyngzk').' WHERE '.qi('Thhyngzk').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('W0vaH3nS').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('W0vaH3nS').'.'.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) FROM '.qi('mitglied').' '.qi('W0vaH3nS').' WHERE '.qi('W0vaH3nS').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('OQrh8QE0').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('OQrh8QE0').' WHERE '.qi('OQrh8QE0').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AS '.qi('operation::view').',
									/* stellung */ '.qi('stellung').' AS '.qi('stellung').',
									/* tel */ '.qi('tel').' AS '.qi('tel').',
									/* tel2 */ '.qi('tel2').' AS '.qi('tel2').',
									/* vorname */ '.qi('vorname').' AS '.qi('vorname').',
									1
								FROM '.qi('ansprechpartner').' '.qi('ansprechpartner').'
								LEFT JOIN (SELECT '.qi('ID').' AS '.qi('mitglied:ID').', CONCAT('.qi('mitglied').'.'.qi('vorname').', \' \', '.qi('mitglied').'.'.qi('name').') AS '.qi('mitglied:description').', ((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)) AS '.qi('mitglied:canView').' FROM '.qi('mitglied').') '.qi('ref:mitglied').' ON '.qi('ref:mitglied').'.'.qi('mitglied:ID').' = '.qi('mitglied').'
								WHERE (((COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Thhyngzk').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Thhyngzk').' WHERE '.qi('Thhyngzk').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('W0vaH3nS').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('W0vaH3nS').'.'.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) FROM '.qi('mitglied').' '.qi('W0vaH3nS').' WHERE '.qi('W0vaH3nS').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('OQrh8QE0').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('OQrh8QE0').' WHERE '.qi('OQrh8QE0').'.'.qi('ID').' = '.qi('ansprechpartner').'.'.qi('mitglied').' LIMIT 1), FALSE))))) AS t
								LEFT JOIN '.qi('mitglied').' AS '.qi('sorter-mitglied').' ON t.'.qi('mitglied').' = '.qi('sorter-mitglied').'.'.qi('ID').'
								WHERE ' . (isset($params['filter_ansprechpartner_mitglied']) ? ($params['filter_ansprechpartner_mitglied'] !== '' ? ('(' . (new \FOP\IDList($params['filter_ansprechpartner_mitglied']))->toSQL('t.'.qi('mitglied').'') . ') AND ') : '') : '') . 
								(isset($params['filter_ansprechpartner_vorname']) ? ($params['filter_ansprechpartner_vorname'] !== '' ? ('(' . (new \FOP\IDList($params['filter_ansprechpartner_vorname']))->toSQL('t.'.qi('vorname').'') . ') AND ') : '') : '') . 
								(isset($params['filter_ansprechpartner_name']) ? ($params['filter_ansprechpartner_name'] !== '' ? ('(' . (new \FOP\IDList($params['filter_ansprechpartner_name']))->toSQL('t.'.qi('name').'') . ') AND ') : '') : '') . 
								(isset($params['filter_ansprechpartner_stellung']) ? ($params['filter_ansprechpartner_stellung'] !== '' ? ('(' . (new \FOP\IDList($params['filter_ansprechpartner_stellung']))->toSQL('t.'.qi('stellung').'') . ') AND ') : '') : '') . 
								(isset($params['filter_ansprechpartner_tel']) ? ($params['filter_ansprechpartner_tel'] !== '' ? ('(' . (new \FOP\IDList($params['filter_ansprechpartner_tel']))->toSQL('t.'.qi('tel').'') . ') AND ') : '') : '') . 
								(isset($params['filter_ansprechpartner_tel2']) ? ($params['filter_ansprechpartner_tel2'] !== '' ? ('(' . (new \FOP\IDList($params['filter_ansprechpartner_tel2']))->toSQL('t.'.qi('tel2').'') . ') AND ') : '') : '') . 
								(isset($params['filter_ansprechpartner_email']) ? ($params['filter_ansprechpartner_email'] !== '' ? ('(' . (new \FOP\IDList($params['filter_ansprechpartner_email']))->toSQL('t.'.qi('email').'') . ') AND ') : '') : '') . 
								(isset($params['filter_ansprechpartner_ID']) ? ($params['filter_ansprechpartner_ID'] !== '' ? ('(' . (new \FOP\IDList($params['filter_ansprechpartner_ID']))->toSQL('t.'.qi('ID').'') . ') AND ') : '') : '') . 
								(isset($params['search_ansprechpartner_vorname']) ? 't.'.qi('vorname').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_ansprechpartner_vorname'] . '%') . ' AND ' : '') . 
								(isset($params['search_ansprechpartner_name']) ? 't.'.qi('name').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_ansprechpartner_name'] . '%') . ' AND ' : '') . 
								(isset($params['search_ansprechpartner_stellung']) ? 't.'.qi('stellung').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_ansprechpartner_stellung'] . '%') . ' AND ' : '') . 
								(isset($params['search_ansprechpartner_tel']) ? 't.'.qi('tel').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_ansprechpartner_tel'] . '%') . ' AND ' : '') . 
								(isset($params['search_ansprechpartner_tel2']) ? 't.'.qi('tel2').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_ansprechpartner_tel2'] . '%') . ' AND ' : '') . 
								(isset($params['search_ansprechpartner_email']) ? 't.'.qi('email').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_ansprechpartner_email'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_ansprechpartner_vorname']) ? 'NOT t.'.qi('vorname').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_ansprechpartner_vorname'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_ansprechpartner_name']) ? 'NOT t.'.qi('name').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_ansprechpartner_name'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_ansprechpartner_stellung']) ? 'NOT t.'.qi('stellung').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_ansprechpartner_stellung'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_ansprechpartner_tel']) ? 'NOT t.'.qi('tel').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_ansprechpartner_tel'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_ansprechpartner_tel2']) ? 'NOT t.'.qi('tel2').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_ansprechpartner_tel2'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_ansprechpartner_email']) ? 'NOT t.'.qi('email').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_ansprechpartner_email'] . '%') . ' AND ' : '') . 
								(isset($params['search_ansprechpartner']) ? '(' . 't.'.qi('vorname').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_ansprechpartner'] . '%') . ' OR ' . 't.'.qi('name').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_ansprechpartner'] . '%') . ' OR ' . 't.'.qi('stellung').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_ansprechpartner'] . '%') . ' OR ' . 't.'.qi('tel').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_ansprechpartner'] . '%') . ' OR ' . 't.'.qi('tel2').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_ansprechpartner'] . '%') . ' OR ' . 't.'.qi('email').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_ansprechpartner'] . '%') . ') AND ' : '') . 
								'
								 TRUE ';
								return $sql;
	
    
  }

  public static function getfilter_ansprechpartner_mitgliedItemsByStringAction($fstr) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
		// Auf aktive DataView-Items einschränken
		$params = $_GET;
		unset($params['filter_ansprechpartner_mitglied']);
		return \Types\Mitglied::getItems(null, -1, $fstr, ''.qi('ID').' IN (SELECT DISTINCT t.'.qi('mitglied').''.self::getSQL($params).')');
	

    
  }

  public static function getData($sqladdon, $params, $stream = false ) { 
    
    
    // --- BLOCK: main ---
    
								$sql = self::getSQL($params);

								$order = (\FOP\Util::array_value(array(
									'mitglied ASC' => 'ORDER BY '.qi('sorter-mitglied').'.'.qi('name').' , '.qi('sorter-mitglied').'.'.qi('name').' , '.qi('sorter-mitglied').'.'.qi('name').' , '.qi('sorter-mitglied').'.'.qi('name').' , '.qi('sorter-mitglied').'.'.qi('name').' , '.qi('sorter-mitglied').'.'.qi('name').' , '.qi('sorter-mitglied').'.'.qi('name').' , '.qi('sorter-mitglied').'.'.qi('name').' , '.qi('sorter-mitglied').'.'.qi('name').' , '.qi('sorter-mitglied').'.'.qi('name').' , '.qi('sorter-mitglied').'.'.qi('name').' , '.qi('sorter-mitglied').'.'.qi('vorname').' , '.qi('sorter-mitglied').'.'.qi('vorname').' , '.qi('sorter-mitglied').'.'.qi('vorname').' , '.qi('sorter-mitglied').'.'.qi('vorname').' , '.qi('sorter-mitglied').'.'.qi('vorname').' , '.qi('sorter-mitglied').'.'.qi('vorname').' , '.qi('sorter-mitglied').'.'.qi('vorname').' , '.qi('sorter-mitglied').'.'.qi('vorname').' , '.qi('sorter-mitglied').'.'.qi('vorname').' , '.qi('sorter-mitglied').'.'.qi('vorname').' , '.qi('sorter-mitglied').'.'.qi('vorname').' ',
									'mitglied DESC' => 'ORDER BY '.qi('sorter-mitglied').'.'.qi('name').' DESC, '.qi('sorter-mitglied').'.'.qi('name').' DESC, '.qi('sorter-mitglied').'.'.qi('name').' DESC, '.qi('sorter-mitglied').'.'.qi('name').' DESC, '.qi('sorter-mitglied').'.'.qi('name').' DESC, '.qi('sorter-mitglied').'.'.qi('name').' DESC, '.qi('sorter-mitglied').'.'.qi('name').' DESC, '.qi('sorter-mitglied').'.'.qi('name').' DESC, '.qi('sorter-mitglied').'.'.qi('name').' DESC, '.qi('sorter-mitglied').'.'.qi('name').' DESC, '.qi('sorter-mitglied').'.'.qi('name').' DESC, '.qi('sorter-mitglied').'.'.qi('vorname').' DESC, '.qi('sorter-mitglied').'.'.qi('vorname').' DESC, '.qi('sorter-mitglied').'.'.qi('vorname').' DESC, '.qi('sorter-mitglied').'.'.qi('vorname').' DESC, '.qi('sorter-mitglied').'.'.qi('vorname').' DESC, '.qi('sorter-mitglied').'.'.qi('vorname').' DESC, '.qi('sorter-mitglied').'.'.qi('vorname').' DESC, '.qi('sorter-mitglied').'.'.qi('vorname').' DESC, '.qi('sorter-mitglied').'.'.qi('vorname').' DESC, '.qi('sorter-mitglied').'.'.qi('vorname').' DESC, '.qi('sorter-mitglied').'.'.qi('vorname').' DESC',
									'email ASC' => 'ORDER BY t.'.qi('email').' ASC',
									'tel ASC' => 'ORDER BY t.'.qi('tel').' ASC',
									'tel2 ASC' => 'ORDER BY t.'.qi('tel2').' ASC',
									'vorname ASC' => 'ORDER BY t.'.qi('vorname').' ASC',
									'name ASC' => 'ORDER BY t.'.qi('name').' ASC',
									'stellung ASC' => 'ORDER BY t.'.qi('stellung').' ASC',
									'email DESC' => 'ORDER BY t.'.qi('email').' DESC',
									'tel DESC' => 'ORDER BY t.'.qi('tel').' DESC',
									'tel2 DESC' => 'ORDER BY t.'.qi('tel2').' DESC',
									'vorname DESC' => 'ORDER BY t.'.qi('vorname').' DESC',
									'name DESC' => 'ORDER BY t.'.qi('name').' DESC',
									'stellung DESC' => 'ORDER BY t.'.qi('stellung').' DESC',
									'' => ''), isset($params['sort_ansprechpartner']) ? $params['sort_ansprechpartner'] : '') ?: '');
								// 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['mitglied'] = \FOP\Sanitizers::null_converter($item['mitglied']);
											$item['tel'] = \FOP\Sanitizers::a_phone($item['tel']);
											$item['tel2'] = \FOP\Sanitizers::a_phone($item['tel2']);
											$item['email'] = \FOP\Sanitizers::a_text($item['email']);
											
											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['mitglied'] = \FOP\Sanitizers::null_converter($item['mitglied']);
										$item['tel'] = \FOP\Sanitizers::a_phone($item['tel']);
										$item['tel2'] = \FOP\Sanitizers::a_phone($item['tel2']);
										$item['email'] = \FOP\Sanitizers::a_text($item['email']);
										
									}
									unset($item);

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

									
								}

								return $result;
	
    
  }

  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['filter_ansprechpartner_vorname'])) {
		if ($params['filter_ansprechpartner_vorname'] == '_null') {
			array_push($filters, _('Vorname') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_ansprechpartner_vorname']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Vorname') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_ansprechpartner_name'])) {
		if ($params['filter_ansprechpartner_name'] == '_null') {
			array_push($filters, _('Nachname') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_ansprechpartner_name']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Nachname') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_ansprechpartner_stellung'])) {
		if ($params['filter_ansprechpartner_stellung'] == '_null') {
			array_push($filters, _('Beziehung zum Mitglied') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_ansprechpartner_stellung']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Beziehung zum Mitglied') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_ansprechpartner_tel'])) {
		if ($params['filter_ansprechpartner_tel'] == '_null') {
			array_push($filters, _('Telefon') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_ansprechpartner_tel']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Telefon') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_ansprechpartner_tel2'])) {
		if ($params['filter_ansprechpartner_tel2'] == '_null') {
			array_push($filters, _('Telefon 2') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_ansprechpartner_tel2']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Telefon 2') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_ansprechpartner_email'])) {
		if ($params['filter_ansprechpartner_email'] == '_null') {
			array_push($filters, _('E-Mail') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_ansprechpartner_email']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('E-Mail') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_ansprechpartner_mitglied'])) {
		if ($params['filter_ansprechpartner_mitglied'] == '_null') {
			array_push($filters, _('von Mitglied') . ': ' . _(''));
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_ansprechpartner_mitglied']))->all() AS $val) {
				$value = 
  \FOP\Database::query('SELECT CONCAT('.qi('mitglied').'.'.qi('vorname').', \' \', '.qi('mitglied').'.'.qi('name').') AS description FROM '.qi('mitglied').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($val))->fetchColumn() ?: _('')
;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('von Mitglied') . ': ' . implode(', ', $values));
		}
	}if (isset($params['search_ansprechpartner_vorname'])) {
		array_push($filters, _('vorname') . ' ' . _('filter_contains') . ' ' . $params['search_ansprechpartner_vorname']);
	}if (isset($params['search_ansprechpartner_name'])) {
		array_push($filters, _('name') . ' ' . _('filter_contains') . ' ' . $params['search_ansprechpartner_name']);
	}if (isset($params['search_ansprechpartner_stellung'])) {
		array_push($filters, _('stellung') . ' ' . _('filter_contains') . ' ' . $params['search_ansprechpartner_stellung']);
	}if (isset($params['search_ansprechpartner_tel'])) {
		array_push($filters, _('tel') . ' ' . _('filter_contains') . ' ' . $params['search_ansprechpartner_tel']);
	}if (isset($params['search_ansprechpartner_tel2'])) {
		array_push($filters, _('tel2') . ' ' . _('filter_contains') . ' ' . $params['search_ansprechpartner_tel2']);
	}if (isset($params['search_ansprechpartner_email'])) {
		array_push($filters, _('email') . ' ' . _('filter_contains') . ' ' . $params['search_ansprechpartner_email']);
	}if (isset($params['searchnot_ansprechpartner_vorname'])) {
		array_push($filters, _('vorname') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_ansprechpartner_vorname']);
	}if (isset($params['searchnot_ansprechpartner_name'])) {
		array_push($filters, _('name') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_ansprechpartner_name']);
	}if (isset($params['searchnot_ansprechpartner_stellung'])) {
		array_push($filters, _('stellung') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_ansprechpartner_stellung']);
	}if (isset($params['searchnot_ansprechpartner_tel'])) {
		array_push($filters, _('tel') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_ansprechpartner_tel']);
	}if (isset($params['searchnot_ansprechpartner_tel2'])) {
		array_push($filters, _('tel2') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_ansprechpartner_tel2']);
	}if (isset($params['searchnot_ansprechpartner_email'])) {
		array_push($filters, _('email') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_ansprechpartner_email']);
	}
		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(\'_ansprechpartner_\')) delete query[q];} reloadansprechpartner(); ">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 == 'ansprechpartner') {
	\FOP\Session::setPayload('dv-ansprechpartner', [
		'id' => 'ansprechpartner',
		'tbl' => 'ansprechpartner',
		'idcol' => 'ID',
		'prev' => \DataViewRouter\Ansprechpartner::stepURL('ansprechpartner', 'XXX', -1),
		'next' => \DataViewRouter\Ansprechpartner::stepURL('ansprechpartner', '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\Ansprechpartner::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();

    
  }


  
  

  
  
}



