<?php

namespace DataView;

class Fop_mail_host {
  
  

  
  

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

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

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

    
  }

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

	</script>
	<?php
	
    
  }

  public static function renderTabTableAction() { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
     ?><div class='fop-dv-buttonbar'><?php if((!\FOP\User::getIsGuest())) { ?><a class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored" onclick="
		var self = this;
		event.preventDefault();
		$.get(reloadfop_mail_host({action: 'open', fop_table: 'fop_mail_host', fop_id: '_', fop_from: location.href}, true))
		.then(function () {
			window.open_url(self.href, false);
		});" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host::createURL2(['from' => $_GET['from'] ?? null, 'popup' => $_GET['popup'] ?? null])); ?>"><i class="material-icons">add</i> <?php echo(sprintf(_('create %s'), _('emailhost'))); ?></a><?php } ?></div><?php 
								\FOP\User::getIsGuest();
								$itemheight = 32;
								$itemsperpage = ceil(1080 / $itemheight * 0.8);
								$page = (isset($_GET['page_fop_mail_host']) ? intval($_GET['page_fop_mail_host']) : 0);
								$addlines = (isset($_GET['addlines_fop_mail_host']) ? intval($_GET['addlines_fop_mail_host']) : 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' => 'name',
												'desc' => _('Name'),
												'order' => ++$order,
												'width' => 180, // default value
												'collapsed' => 0

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

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

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

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

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

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

											];
											$columns['smtp_auth'] = $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('fop_mail_host'))->fetchAll(\PDO::FETCH_ASSOC) AS $column => $c) {
										if (isset($columns[$c['column']])) {
											$columns[$c['column']]['order'] = $c['order']; // order, width, collapsed
											$columns[$c['column']]['width'] = $c['width']; // order, width, collapsed
											$columns[$c['column']]['collapsed'] = $c['collapsed']; // order, width, collapsed
										}
									}

									// DOM vor-rendern
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='name'
												data-order='<?php echo intval($columns['name']['order']); ?>'
												data-width='<?php echo intval($columns['name']['width']); ?>'
												data-collapsed='<?php echo intval($columns['name']['collapsed']); ?>'
												style='width: <?php echo intval($columns['name']['width']); ?>px; <?php if ($columns['name']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host(); 
		}});
		
		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_fop_mail_host_name'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_fop_mail_host_name'] = text.val(); } else { delete query['search_fop_mail_host_name']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host').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_fop_mail_host_name'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_fop_mail_host_name'] = text2.val(); } else { delete query['searchnot_fop_mail_host_name']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host').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_fop_mail_host'] == 'name ASC') {
			query['sort_fop_mail_host'] = 'name DESC';
		 } else if (query['sort_fop_mail_host'] == 'name DESC') {
		 	delete query['sort_fop_mail_host'];
		 } else {
			query['sort_fop_mail_host'] = 'name ASC';
		 }
		 reloadfop_mail_host();
		 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(_('Name')); ?>'><?php echo(_('Name')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'name ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'name DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_name']) || isset($_GET['range_max_fop_mail_host_name']) || isset($_GET['deps_fop_mail_host_name']) || isset($_GET['fullsearch_fop_mail_host_name']) || isset($_GET['dynamic_fop_mail_host_name']) || isset($_GET['search_fop_mail_host_name']) || isset($_GET['searchnot_fop_mail_host_name']) || isset($_GET['filter_fop_mail_host_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='imap_host'
												data-order='<?php echo intval($columns['imap_host']['order']); ?>'
												data-width='<?php echo intval($columns['imap_host']['width']); ?>'
												data-collapsed='<?php echo intval($columns['imap_host']['collapsed']); ?>'
												style='width: <?php echo intval($columns['imap_host']['width']); ?>px; <?php if ($columns['imap_host']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host(); 
		}});
		
		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_fop_mail_host_imap_host'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_fop_mail_host_imap_host'] = text.val(); } else { delete query['search_fop_mail_host_imap_host']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host').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_fop_mail_host_imap_host'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_fop_mail_host_imap_host'] = text2.val(); } else { delete query['searchnot_fop_mail_host_imap_host']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host').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_fop_mail_host'] == 'imap_host ASC') {
			query['sort_fop_mail_host'] = 'imap_host DESC';
		 } else if (query['sort_fop_mail_host'] == 'imap_host DESC') {
		 	delete query['sort_fop_mail_host'];
		 } else {
			query['sort_fop_mail_host'] = 'imap_host ASC';
		 }
		 reloadfop_mail_host();
		 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(_('imaphost')); ?>'><?php echo(_('imaphost')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'imap_host ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'imap_host DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_imap_host']) || isset($_GET['range_max_fop_mail_host_imap_host']) || isset($_GET['deps_fop_mail_host_imap_host']) || isset($_GET['fullsearch_fop_mail_host_imap_host']) || isset($_GET['dynamic_fop_mail_host_imap_host']) || isset($_GET['search_fop_mail_host_imap_host']) || isset($_GET['searchnot_fop_mail_host_imap_host']) || isset($_GET['filter_fop_mail_host_imap_host'])) {
															// 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['imap_host']['header'] = ob_get_contents(); ob_end_clean();
											$columns['imap_host']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['imap_host']['width']); ?>px; <?php if ($columns['imap_host']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='imap_host'><span class='overflow-text' title="<?php echo htmlentities($item['imap_host']); ?>"><?php echo htmlentities($item['imap_host']); ?></span></div><?php
											};
											$columns['imap_host']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='imap_host'
													data-order='<?php echo intval($columns['imap_host']['order']); ?>'
													data-width='<?php echo intval($columns['imap_host']['width']); ?>'
													data-collapsed='<?php echo intval($columns['imap_host']['collapsed']); ?>'
													style='width: <?php echo intval($columns['imap_host']['width']); ?>px; <?php if ($columns['imap_host']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='imap_port'
												data-order='<?php echo intval($columns['imap_port']['order']); ?>'
												data-width='<?php echo intval($columns['imap_port']['width']); ?>'
												data-collapsed='<?php echo intval($columns['imap_port']['collapsed']); ?>'
												style='width: <?php echo intval($columns['imap_port']['width']); ?>px; <?php if ($columns['imap_port']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host(); 
		}});
		var von, bis; win.append('<div class=\'fop-floatsorter\'>' + window.i18n_von + '</div>').append(von = $('<input type=\'number\' step=\'any\'><br>').val(query['range_min_fop_mail_host_imap_port']).on('change keyup paste', function () { query['range_min_fop_mail_host_imap_port'] = von.val(); delete query['page_fop_mail_host']; changed = true; }))
.append('<div>' + window.i18n_bis + '</div>').append(bis = $('<input type=\'number\' step=\'any\'>').val(query['range_max_fop_mail_host_imap_port']).on('change keyup paste', function () { query['range_max_fop_mail_host_imap_port'] = bis.val(); delete query['page_fop_mail_host']; changed = true; }))
; von.focus(); von.select();
	var icon, sortbtn	= $('<a class=\'mdl-button mdl-js-button mdl-button--icon mdl-button--colored\' style=\'display: inline-block;\'></a>')
		.append(icon = $('<i class=\'material-icons\'></i>').text('unfold_more'))
		.click(function() {
		 if (query['sort_fop_mail_host'] == 'imap_port ASC') {
			query['sort_fop_mail_host'] = 'imap_port DESC';
		 } else if (query['sort_fop_mail_host'] == 'imap_port DESC') {
		 	delete query['sort_fop_mail_host'];
		 } else {
			query['sort_fop_mail_host'] = 'imap_port ASC';
		 }
		 reloadfop_mail_host();
		 return false;
	});
	if (win.children().first().hasClass('fop-floatsorter')) {
		// floating layout
		win.prepend(sortbtn.css({float: 'right', margin: '0px'}));
	} else {
		// append to the end
		win.append(sortbtn);
	}
		return false;
	" style='text-align: right;'>
													<span class='title-title' title='<?php echo(_('imapport')); ?>'><?php echo(_('imapport')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'imap_port ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'imap_port DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_imap_port']) || isset($_GET['range_max_fop_mail_host_imap_port']) || isset($_GET['deps_fop_mail_host_imap_port']) || isset($_GET['fullsearch_fop_mail_host_imap_port']) || isset($_GET['dynamic_fop_mail_host_imap_port']) || isset($_GET['search_fop_mail_host_imap_port']) || isset($_GET['searchnot_fop_mail_host_imap_port']) || isset($_GET['filter_fop_mail_host_imap_port'])) {
															// 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['imap_port']['header'] = ob_get_contents(); ob_end_clean();
											$columns['imap_port']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['imap_port']['width']); ?>px; <?php if ($columns['imap_port']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='imap_port'><span style="white-space: nowrap; width: 100%; display: inline-block; text-align: right;"><?php echo htmlentities(\Types\Integer::print($item['imap_port'])); ?>
	</span></div><?php
											};
											$columns['imap_port']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='imap_port'
													data-order='<?php echo intval($columns['imap_port']['order']); ?>'
													data-width='<?php echo intval($columns['imap_port']['width']); ?>'
													data-collapsed='<?php echo intval($columns['imap_port']['collapsed']); ?>'
													style='width: <?php echo intval($columns['imap_port']['width']); ?>px; <?php if ($columns['imap_port']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='imap_auth'
												data-order='<?php echo intval($columns['imap_auth']['order']); ?>'
												data-width='<?php echo intval($columns['imap_auth']['width']); ?>'
												data-collapsed='<?php echo intval($columns['imap_auth']['collapsed']); ?>'
												style='width: <?php echo intval($columns['imap_auth']['width']); ?>px; <?php if ($columns['imap_auth']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host(); 
		}});
		win.append($('<input type=\'checkbox\'' + (querySet('filter_fop_mail_host_imap_auth', 'nossl') ? ' checked>': '>')).change(function (){querySet('filter_fop_mail_host_imap_auth', 'nossl', $(this).prop('checked')); changed=true;})).append('<span> </span><?php echo(_('nossl')); ?><br/>').append($('<input type=\'checkbox\'' + (querySet('filter_fop_mail_host_imap_auth', 'notls') ? ' checked>': '>')).change(function (){querySet('filter_fop_mail_host_imap_auth', 'notls', $(this).prop('checked')); changed=true;})).append('<span> </span><?php echo(_('notls')); ?><br/>').append($('<input type=\'checkbox\'' + (querySet('filter_fop_mail_host_imap_auth', 'ssl') ? ' checked>': '>')).change(function (){querySet('filter_fop_mail_host_imap_auth', 'ssl', $(this).prop('checked')); changed=true;})).append('<span> </span><?php echo(_('ssl')); ?><br/>').append($('<input type=\'checkbox\'' + (querySet('filter_fop_mail_host_imap_auth', 'starttls') ? ' checked>': '>')).change(function (){querySet('filter_fop_mail_host_imap_auth', 'starttls', $(this).prop('checked')); changed=true;})).append('<span> </span><?php echo(_('starttls')); ?><br/>').append($('<input type=\'checkbox\'' + (querySet('filter_fop_mail_host_imap_auth', 'novalidate-cert') ? ' checked>': '>')).change(function (){querySet('filter_fop_mail_host_imap_auth', 'novalidate-cert', $(this).prop('checked')); changed=true;})).append('<span> </span><?php echo(_('novalidate-cert')); ?><br/>');
		return false;
	">
													<span class='title-title' title='<?php echo(_('imapsecurity')); ?>'><?php echo(_('imapsecurity')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'imap_auth ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'imap_auth DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_imap_auth']) || isset($_GET['range_max_fop_mail_host_imap_auth']) || isset($_GET['deps_fop_mail_host_imap_auth']) || isset($_GET['fullsearch_fop_mail_host_imap_auth']) || isset($_GET['dynamic_fop_mail_host_imap_auth']) || isset($_GET['search_fop_mail_host_imap_auth']) || isset($_GET['searchnot_fop_mail_host_imap_auth']) || isset($_GET['filter_fop_mail_host_imap_auth'])) {
															// 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['imap_auth']['header'] = ob_get_contents(); ob_end_clean();
											$columns['imap_auth']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['imap_auth']['width']); ?>px; <?php if ($columns['imap_auth']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='imap_auth'><div><?php echo htmlentities(\Types\Emailauthtype::toStringShort($item['imap_auth'])); ?>
		<br></div></div><?php
											};
											$columns['imap_auth']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='imap_auth'
													data-order='<?php echo intval($columns['imap_auth']['order']); ?>'
													data-width='<?php echo intval($columns['imap_auth']['width']); ?>'
													data-collapsed='<?php echo intval($columns['imap_auth']['collapsed']); ?>'
													style='width: <?php echo intval($columns['imap_auth']['width']); ?>px; <?php if ($columns['imap_auth']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='smtp_host'
												data-order='<?php echo intval($columns['smtp_host']['order']); ?>'
												data-width='<?php echo intval($columns['smtp_host']['width']); ?>'
												data-collapsed='<?php echo intval($columns['smtp_host']['collapsed']); ?>'
												style='width: <?php echo intval($columns['smtp_host']['width']); ?>px; <?php if ($columns['smtp_host']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host(); 
		}});
		
		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_fop_mail_host_smtp_host'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_fop_mail_host_smtp_host'] = text.val(); } else { delete query['search_fop_mail_host_smtp_host']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host').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_fop_mail_host_smtp_host'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_fop_mail_host_smtp_host'] = text2.val(); } else { delete query['searchnot_fop_mail_host_smtp_host']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host').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_fop_mail_host'] == 'smtp_host ASC') {
			query['sort_fop_mail_host'] = 'smtp_host DESC';
		 } else if (query['sort_fop_mail_host'] == 'smtp_host DESC') {
		 	delete query['sort_fop_mail_host'];
		 } else {
			query['sort_fop_mail_host'] = 'smtp_host ASC';
		 }
		 reloadfop_mail_host();
		 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(_('smtphost')); ?>'><?php echo(_('smtphost')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'smtp_host ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'smtp_host DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_smtp_host']) || isset($_GET['range_max_fop_mail_host_smtp_host']) || isset($_GET['deps_fop_mail_host_smtp_host']) || isset($_GET['fullsearch_fop_mail_host_smtp_host']) || isset($_GET['dynamic_fop_mail_host_smtp_host']) || isset($_GET['search_fop_mail_host_smtp_host']) || isset($_GET['searchnot_fop_mail_host_smtp_host']) || isset($_GET['filter_fop_mail_host_smtp_host'])) {
															// 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['smtp_host']['header'] = ob_get_contents(); ob_end_clean();
											$columns['smtp_host']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['smtp_host']['width']); ?>px; <?php if ($columns['smtp_host']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='smtp_host'><span class='overflow-text' title="<?php echo htmlentities($item['smtp_host']); ?>"><?php echo htmlentities($item['smtp_host']); ?></span></div><?php
											};
											$columns['smtp_host']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='smtp_host'
													data-order='<?php echo intval($columns['smtp_host']['order']); ?>'
													data-width='<?php echo intval($columns['smtp_host']['width']); ?>'
													data-collapsed='<?php echo intval($columns['smtp_host']['collapsed']); ?>'
													style='width: <?php echo intval($columns['smtp_host']['width']); ?>px; <?php if ($columns['smtp_host']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='smtp_port'
												data-order='<?php echo intval($columns['smtp_port']['order']); ?>'
												data-width='<?php echo intval($columns['smtp_port']['width']); ?>'
												data-collapsed='<?php echo intval($columns['smtp_port']['collapsed']); ?>'
												style='width: <?php echo intval($columns['smtp_port']['width']); ?>px; <?php if ($columns['smtp_port']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host(); 
		}});
		var von, bis; win.append('<div class=\'fop-floatsorter\'>' + window.i18n_von + '</div>').append(von = $('<input type=\'number\' step=\'any\'><br>').val(query['range_min_fop_mail_host_smtp_port']).on('change keyup paste', function () { query['range_min_fop_mail_host_smtp_port'] = von.val(); delete query['page_fop_mail_host']; changed = true; }))
.append('<div>' + window.i18n_bis + '</div>').append(bis = $('<input type=\'number\' step=\'any\'>').val(query['range_max_fop_mail_host_smtp_port']).on('change keyup paste', function () { query['range_max_fop_mail_host_smtp_port'] = bis.val(); delete query['page_fop_mail_host']; changed = true; }))
; von.focus(); von.select();
	var icon, sortbtn	= $('<a class=\'mdl-button mdl-js-button mdl-button--icon mdl-button--colored\' style=\'display: inline-block;\'></a>')
		.append(icon = $('<i class=\'material-icons\'></i>').text('unfold_more'))
		.click(function() {
		 if (query['sort_fop_mail_host'] == 'smtp_port ASC') {
			query['sort_fop_mail_host'] = 'smtp_port DESC';
		 } else if (query['sort_fop_mail_host'] == 'smtp_port DESC') {
		 	delete query['sort_fop_mail_host'];
		 } else {
			query['sort_fop_mail_host'] = 'smtp_port ASC';
		 }
		 reloadfop_mail_host();
		 return false;
	});
	if (win.children().first().hasClass('fop-floatsorter')) {
		// floating layout
		win.prepend(sortbtn.css({float: 'right', margin: '0px'}));
	} else {
		// append to the end
		win.append(sortbtn);
	}
		return false;
	" style='text-align: right;'>
													<span class='title-title' title='<?php echo(_('smtpport')); ?>'><?php echo(_('smtpport')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'smtp_port ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'smtp_port DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_smtp_port']) || isset($_GET['range_max_fop_mail_host_smtp_port']) || isset($_GET['deps_fop_mail_host_smtp_port']) || isset($_GET['fullsearch_fop_mail_host_smtp_port']) || isset($_GET['dynamic_fop_mail_host_smtp_port']) || isset($_GET['search_fop_mail_host_smtp_port']) || isset($_GET['searchnot_fop_mail_host_smtp_port']) || isset($_GET['filter_fop_mail_host_smtp_port'])) {
															// 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['smtp_port']['header'] = ob_get_contents(); ob_end_clean();
											$columns['smtp_port']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['smtp_port']['width']); ?>px; <?php if ($columns['smtp_port']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='smtp_port'><span style="white-space: nowrap; width: 100%; display: inline-block; text-align: right;"><?php echo htmlentities(\Types\Integer::print($item['smtp_port'])); ?>
	</span></div><?php
											};
											$columns['smtp_port']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='smtp_port'
													data-order='<?php echo intval($columns['smtp_port']['order']); ?>'
													data-width='<?php echo intval($columns['smtp_port']['width']); ?>'
													data-collapsed='<?php echo intval($columns['smtp_port']['collapsed']); ?>'
													style='width: <?php echo intval($columns['smtp_port']['width']); ?>px; <?php if ($columns['smtp_port']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='smtp_auth'
												data-order='<?php echo intval($columns['smtp_auth']['order']); ?>'
												data-width='<?php echo intval($columns['smtp_auth']['width']); ?>'
												data-collapsed='<?php echo intval($columns['smtp_auth']['collapsed']); ?>'
												style='width: <?php echo intval($columns['smtp_auth']['width']); ?>px; <?php if ($columns['smtp_auth']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host(); 
		}});
		win.append($('<input type=\'checkbox\'' + (querySet('filter_fop_mail_host_smtp_auth', 'nossl') ? ' checked>': '>')).change(function (){querySet('filter_fop_mail_host_smtp_auth', 'nossl', $(this).prop('checked')); changed=true;})).append('<span> </span><?php echo(_('nossl')); ?><br/>').append($('<input type=\'checkbox\'' + (querySet('filter_fop_mail_host_smtp_auth', 'notls') ? ' checked>': '>')).change(function (){querySet('filter_fop_mail_host_smtp_auth', 'notls', $(this).prop('checked')); changed=true;})).append('<span> </span><?php echo(_('notls')); ?><br/>').append($('<input type=\'checkbox\'' + (querySet('filter_fop_mail_host_smtp_auth', 'ssl') ? ' checked>': '>')).change(function (){querySet('filter_fop_mail_host_smtp_auth', 'ssl', $(this).prop('checked')); changed=true;})).append('<span> </span><?php echo(_('ssl')); ?><br/>').append($('<input type=\'checkbox\'' + (querySet('filter_fop_mail_host_smtp_auth', 'starttls') ? ' checked>': '>')).change(function (){querySet('filter_fop_mail_host_smtp_auth', 'starttls', $(this).prop('checked')); changed=true;})).append('<span> </span><?php echo(_('starttls')); ?><br/>').append($('<input type=\'checkbox\'' + (querySet('filter_fop_mail_host_smtp_auth', 'novalidate-cert') ? ' checked>': '>')).change(function (){querySet('filter_fop_mail_host_smtp_auth', 'novalidate-cert', $(this).prop('checked')); changed=true;})).append('<span> </span><?php echo(_('novalidate-cert')); ?><br/>');
		return false;
	">
													<span class='title-title' title='<?php echo(_('smtpsecurity')); ?>'><?php echo(_('smtpsecurity')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'smtp_auth ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host']) && $_GET['sort_fop_mail_host'] == 'smtp_auth DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_smtp_auth']) || isset($_GET['range_max_fop_mail_host_smtp_auth']) || isset($_GET['deps_fop_mail_host_smtp_auth']) || isset($_GET['fullsearch_fop_mail_host_smtp_auth']) || isset($_GET['dynamic_fop_mail_host_smtp_auth']) || isset($_GET['search_fop_mail_host_smtp_auth']) || isset($_GET['searchnot_fop_mail_host_smtp_auth']) || isset($_GET['filter_fop_mail_host_smtp_auth'])) {
															// 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['smtp_auth']['header'] = ob_get_contents(); ob_end_clean();
											$columns['smtp_auth']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['smtp_auth']['width']); ?>px; <?php if ($columns['smtp_auth']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='smtp_auth'><div><?php echo htmlentities(\Types\Emailauthtype::toStringShort($item['smtp_auth'])); ?>
		<br></div></div><?php
											};
											$columns['smtp_auth']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='smtp_auth'
													data-order='<?php echo intval($columns['smtp_auth']['order']); ?>'
													data-width='<?php echo intval($columns['smtp_auth']['width']); ?>'
													data-collapsed='<?php echo intval($columns['smtp_auth']['collapsed']); ?>'
													style='width: <?php echo intval($columns['smtp_auth']['width']); ?>px; <?php if ($columns['smtp_auth']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									

									// sort by order
									uasort($columns, function ($a, $b) {
										return $a['order'] - $b['order'];
									});
									?>
									<style type='text/css'>
										#fop_mail_host-table .fop-table-header {
											height: <?php echo 32; ?>px;
										}
										#fop_mail_host-table .fop-table-header .fop-table-column .title,
										#fop_mail_host-table .fop-column-handle,
										#fop_mail_host-table .fop-table-row,
										#fop_mail_host-table .fop-table-row .fop-table-column,
										#fop_mail_host-table .fop-table-column-multicontrol,
										#fop_mail_host-table .fop-filter-button {
											height: 32px;
											line-height: 32px;
										}
										</style>
											<div class="fop-table" data-table-id="fop_mail_host">
											<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="fop_mail_host__all-checkbox">
														<input class="mdl-checkbox__input" id="fop_mail_host__all-checkbox" type="checkbox" onchange="checkfop_mail_host('all', 'ID', this.checked);">
														</label>
														<button type="button" class="mdl-button mdl-js-button mdl-button--icon fop_mail_host__mass-action" style='visibility: hidden;' onclick="$.get('DataView/Fop_mail_host/permissions?id=' + checkfop_mail_host(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_fop_mail_host_') == 0 || key.indexOf('range_max_fop_mail_host_') == 0 || key.indexOf('deps_fop_mail_host_') == 0 || key.indexOf('fullsearch_fop_mail_host_') == 0 || key.indexOf('dynamic_fop_mail_host_') == 0 || key.indexOf('search_fop_mail_host_') == 0 || key.indexOf('searchnot_fop_mail_host_') == 0 || key.indexOf('filter_fop_mail_host_') == 0) delete query[key]; reloadfop_mail_host(); $(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_fop_mail_host_ID'] = checkfop_mail_host(null, 'ID'); delete query['page_fop_mail_host']; reloadfop_mail_host(); $(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(checkfop_mail_host(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;
			}
			checkfop_mail_host(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())) { ?>
			<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/Fop_mail_host/delete?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&id=' + escape(checkfop_mail_host(null, 'ID'))).then(function () { reloadfop_mail_host(); }, 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('fop_mail_host', <?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: 'fop_mail_host', 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_fop_mail_host" <?php \EasyEditor\Navigation::printScroll('dv.Fop_mail_host', '/* 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_fop_mail_host\'] || 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_fop_mail_host\'] = wantedPage;
														reloadfop_mail_host(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-fop_mail_host-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(reloadfop_mail_host({action: \'open\', fop_table: \'fop_mail_host\', 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 fop_mail_host__checkbox fop_mail_host__checkbox fop_mail_host__checkbox-ID-<?php echo htmlentities($item['ID']); ?>" style="width: auto;" for="fop_mail_host__<?php echo htmlentities($itempos); ?>-checkbox">
													<input class="mdl-checkbox__input" id="fop_mail_host__<?php echo htmlentities($itempos); ?>-checkbox" type="checkbox" onchange="<?php if (isset($item['ID'])) echo 'checkfop_mail_host(' . htmlentities(json_encode($item['ID'])) . ', \'ID\', this.checked); ' ?>">
													</label><button type="button" class="mdl-button mdl-js-button mdl-button--icon fop_mail_host__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-fop_mail_host-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\Fop_mail_host::viewURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick=" if (!event.ctrlKey) { open_url(reloadfop_mail_host({action: 'open', fop_table: 'fop_mail_host', 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\Fop_mail_host::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']) && (!\FOP\User::getIsGuest()) && $item['operation::select']) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="create_fop_mail_host_box_email_server" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box::createURL2(['column_email_server' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">create</i></span><span class="fop-menu-caption" title="<?php echo(sprintf(_('create %s'), _('emailmailbox_singular'))); ?>"><?php echo(sprintf(_('create %s'), _('emailmailbox_singular'))); ?></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/Fop_mail_host/delete?ajax&id=<?php echo htmlentities($item['ID']);?>&from=<?php echo htmlentities(\FOP\Util::getBackUrl());?>').then(function () { reloadfop_mail_host(); }, 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="fop_mail_host" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="edit" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host::editURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();    reloadfop_mail_host();
					$(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="fop_mail_host" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="view" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host::viewURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();  if (!event.ctrlKey) { open_url(reloadfop_mail_host({action: 'open', fop_table: 'fop_mail_host', fop_id: <?php echo htmlentities(json_encode($item['ID'])); ?>, fop_from: location.href}, true), false); return false; }  reloadfop_mail_host();
					$(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('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 ('.(\FOP\User::getIsGuest() ? 'false' : 'true').') WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('delete').' FROM '.qi('fop_mail_host').' WHERE ' . $ids->toSQL(qi('ID')))->fetch(\PDO::FETCH_ASSOC);
		
		return $perms;
	
    
  }

  public static function getSQL($params) { 
    
    
    // --- BLOCK: dependency-fop_mail_host ---
    
		if (isset($params['select']) && $params['select'] == 'fop_mail_host') {
			$deps = [];
		}
	
    // --- BLOCK: main ---
    
								// returns a sql snippet 'FROM (...) AS t WHERE' where you can prepend your select clauses and append your ORDER LIMIT
								$sql = 'FROM (SELECT /* ID */ '.qi('ID').' AS '.qi('ID').',
									/* imap_auth */ '.qi('imap_auth').' AS '.qi('imap_auth').',
									/* imap_host */ '.qi('imap_host').' AS '.qi('imap_host').',
									/* imap_port */ '.qi('imap_port').' AS '.qi('imap_port').',
									/* name */ '.qi('name').' AS '.qi('name').',
									/* operation::create */ '.(\FOP\User::getIsGuest() ? 'false' : 'true').' AS '.qi('operation::create').',
									/* operation::delete */ '.(\FOP\User::getIsGuest() ? 'false' : 'true').' AS '.qi('operation::delete').',
									/* operation::edit */ '.(\FOP\User::getIsGuest() ? 'false' : 'true').' AS '.qi('operation::edit').',
									/* operation::index */ ' . (!\FOP\User::getIsGuest() ? 1 : 0) . ' AS '.qi('operation::index').',
									/* operation::select */ '.(\FOP\User::getIsGuest() ? 'false' : 'true').' AS '.qi('operation::select').',
									/* operation::view */ '.(\FOP\User::getIsGuest() ? 'false' : 'true').' AS '.qi('operation::view').',
									/* smtp_auth */ '.qi('smtp_auth').' AS '.qi('smtp_auth').',
									/* smtp_host */ '.qi('smtp_host').' AS '.qi('smtp_host').',
									/* smtp_port */ '.qi('smtp_port').' AS '.qi('smtp_port').',
									1
								FROM '.qi('fop_mail_host').' '.qi('fop_mail_host').'
								WHERE (('.(\FOP\User::getIsGuest() ? 'false' : 'true').'))
									AND (' . (isset($_GET['select']) && $_GET['select'] == 'fop_mail_host' ? 'TRUE' : 'TRUE') . ')) AS t
								WHERE ' . (isset($params['range_min_fop_mail_host_imap_port']) ? ($params['range_min_fop_mail_host_imap_port'] !== '' && is_numeric($params['range_min_fop_mail_host_imap_port']) ? 't.'.qi('imap_port').' >= ' . \FOP\Database::quote($params['range_min_fop_mail_host_imap_port']) . ' AND ' : '') : '') . 
								(isset($params['range_min_fop_mail_host_smtp_port']) ? ($params['range_min_fop_mail_host_smtp_port'] !== '' && is_numeric($params['range_min_fop_mail_host_smtp_port']) ? 't.'.qi('smtp_port').' >= ' . \FOP\Database::quote($params['range_min_fop_mail_host_smtp_port']) . ' AND ' : '') : '') . 
								(isset($params['range_max_fop_mail_host_imap_port']) ? ($params['range_max_fop_mail_host_imap_port'] !== '' && is_numeric($params['range_max_fop_mail_host_imap_port']) ? 't.'.qi('imap_port').' <= ' . \FOP\Database::quote($params['range_max_fop_mail_host_imap_port']) . ' AND ' : '') : '') . 
								(isset($params['range_max_fop_mail_host_smtp_port']) ? ($params['range_max_fop_mail_host_smtp_port'] !== '' && is_numeric($params['range_max_fop_mail_host_smtp_port']) ? 't.'.qi('smtp_port').' <= ' . \FOP\Database::quote($params['range_max_fop_mail_host_smtp_port']) . ' AND ' : '') : '') . 
								(isset($params['filter_fop_mail_host_name']) ? ($params['filter_fop_mail_host_name'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_name']))->toSQL('t.'.qi('name').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_imap_host']) ? ($params['filter_fop_mail_host_imap_host'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_imap_host']))->toSQL('t.'.qi('imap_host').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_imap_port']) ? ($params['filter_fop_mail_host_imap_port'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_imap_port']))->toSQL('t.'.qi('imap_port').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_imap_auth']) ? ($params['filter_fop_mail_host_imap_auth'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_imap_auth']))->toSQL('t.'.qi('imap_auth').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_smtp_host']) ? ($params['filter_fop_mail_host_smtp_host'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_smtp_host']))->toSQL('t.'.qi('smtp_host').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_smtp_port']) ? ($params['filter_fop_mail_host_smtp_port'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_smtp_port']))->toSQL('t.'.qi('smtp_port').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_smtp_auth']) ? ($params['filter_fop_mail_host_smtp_auth'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_smtp_auth']))->toSQL('t.'.qi('smtp_auth').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_ID']) ? ($params['filter_fop_mail_host_ID'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_ID']))->toSQL('t.'.qi('ID').'') . ') AND ') : '') : '') . 
								(isset($params['search_fop_mail_host_name']) ? 't.'.qi('name').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_name'] . '%') . ' AND ' : '') . 
								(isset($params['search_fop_mail_host_imap_host']) ? 't.'.qi('imap_host').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_imap_host'] . '%') . ' AND ' : '') . 
								(isset($params['search_fop_mail_host_smtp_host']) ? 't.'.qi('smtp_host').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_smtp_host'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_fop_mail_host_name']) ? 'NOT t.'.qi('name').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_fop_mail_host_name'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_fop_mail_host_imap_host']) ? 'NOT t.'.qi('imap_host').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_fop_mail_host_imap_host'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_fop_mail_host_smtp_host']) ? 'NOT t.'.qi('smtp_host').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_fop_mail_host_smtp_host'] . '%') . ' AND ' : '') . 
								(isset($params['search_fop_mail_host']) ? '(' . 't.'.qi('name').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host'] . '%') . ' OR ' . 't.'.qi('imap_host').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host'] . '%') . ' OR ' . 't.'.qi('smtp_host').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host'] . '%') . ') AND ' : '') . 
								'
								 TRUE ';
								return $sql;
	
    
  }

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

								$order = (\FOP\Util::array_value(array(
									'name ASC' => 'ORDER BY t.'.qi('name').' ASC',
									'imap_host ASC' => 'ORDER BY t.'.qi('imap_host').' ASC',
									'smtp_host ASC' => 'ORDER BY t.'.qi('smtp_host').' ASC',
									'imap_port ASC' => 'ORDER BY t.'.qi('imap_port').' ASC',
									'smtp_port ASC' => 'ORDER BY t.'.qi('smtp_port').' ASC',
									'name DESC' => 'ORDER BY t.'.qi('name').' DESC',
									'imap_host DESC' => 'ORDER BY t.'.qi('imap_host').' DESC',
									'smtp_host DESC' => 'ORDER BY t.'.qi('smtp_host').' DESC',
									'imap_port DESC' => 'ORDER BY t.'.qi('imap_port').' DESC',
									'smtp_port DESC' => 'ORDER BY t.'.qi('smtp_port').' DESC',
									'' => ''), isset($params['sort_fop_mail_host']) ? $params['sort_fop_mail_host'] : '') ?: '');
								// 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['imap_port'] = \Types\Integer::unpack($item['imap_port']);
											$item['smtp_port'] = \Types\Integer::unpack($item['smtp_port']);
											
											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['imap_port'] = \Types\Integer::unpack($item['imap_port']);
										$item['smtp_port'] = \Types\Integer::unpack($item['smtp_port']);
										
									}
									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['range_min_fop_mail_host_imap_port']) && isset($params['range_max_fop_mail_host_imap_port'])) {
		array_push($filters, _('imapport') . ': ' . (\Types\Integer::print($params['range_min_fop_mail_host_imap_port'])
	) . ' ' . _('filters_between') . ' ' . (\Types\Integer::print($params['range_max_fop_mail_host_imap_port'])
	));
	} else if (isset($params['range_min_fop_mail_host_imap_port'])) {
		array_push($filters, _('imapport') . ': ' . _('filters_from') . ' ' . (\Types\Integer::print($params['range_min_fop_mail_host_imap_port'])
	));
	} else if (isset($params['range_max_fop_mail_host_imap_port'])) {
		array_push($filters, _('imapport') . ': ' . _('filters_to') . ' ' . (\Types\Integer::print($params['range_max_fop_mail_host_imap_port'])
	));
	}
	if (isset($params['range_min_fop_mail_host_smtp_port']) && isset($params['range_max_fop_mail_host_smtp_port'])) {
		array_push($filters, _('smtpport') . ': ' . (\Types\Integer::print($params['range_min_fop_mail_host_smtp_port'])
	) . ' ' . _('filters_between') . ' ' . (\Types\Integer::print($params['range_max_fop_mail_host_smtp_port'])
	));
	} else if (isset($params['range_min_fop_mail_host_smtp_port'])) {
		array_push($filters, _('smtpport') . ': ' . _('filters_from') . ' ' . (\Types\Integer::print($params['range_min_fop_mail_host_smtp_port'])
	));
	} else if (isset($params['range_max_fop_mail_host_smtp_port'])) {
		array_push($filters, _('smtpport') . ': ' . _('filters_to') . ' ' . (\Types\Integer::print($params['range_max_fop_mail_host_smtp_port'])
	));
	}if (isset($params['filter_fop_mail_host_name'])) {
		if ($params['filter_fop_mail_host_name'] == '_null') {
			array_push($filters, _('Name') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_name']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('Name') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_imap_host'])) {
		if ($params['filter_fop_mail_host_imap_host'] == '_null') {
			array_push($filters, _('imaphost') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_imap_host']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('imaphost') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_imap_port'])) {
		if ($params['filter_fop_mail_host_imap_port'] == '_null') {
			array_push($filters, _('imapport') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_imap_port']))->all() AS $val) {
				$value = \Types\Integer::print($val)
	;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('imapport') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_imap_auth'])) {
		if ($params['filter_fop_mail_host_imap_auth'] == '_null') {
			array_push($filters, _('imapsecurity') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_imap_auth']))->all() AS $val) {
				$value = \Types\Emailauthtype::toString($val);
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('imapsecurity') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_smtp_host'])) {
		if ($params['filter_fop_mail_host_smtp_host'] == '_null') {
			array_push($filters, _('smtphost') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_smtp_host']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('smtphost') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_smtp_port'])) {
		if ($params['filter_fop_mail_host_smtp_port'] == '_null') {
			array_push($filters, _('smtpport') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_smtp_port']))->all() AS $val) {
				$value = \Types\Integer::print($val)
	;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('smtpport') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_smtp_auth'])) {
		if ($params['filter_fop_mail_host_smtp_auth'] == '_null') {
			array_push($filters, _('smtpsecurity') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_smtp_auth']))->all() AS $val) {
				$value = \Types\Emailauthtype::toString($val);
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('smtpsecurity') . ': ' . implode(', ', $values));
		}
	}if (isset($params['search_fop_mail_host_name'])) {
		array_push($filters, _('name') . ' ' . _('filter_contains') . ' ' . $params['search_fop_mail_host_name']);
	}if (isset($params['search_fop_mail_host_imap_host'])) {
		array_push($filters, _('imap_host') . ' ' . _('filter_contains') . ' ' . $params['search_fop_mail_host_imap_host']);
	}if (isset($params['search_fop_mail_host_smtp_host'])) {
		array_push($filters, _('smtp_host') . ' ' . _('filter_contains') . ' ' . $params['search_fop_mail_host_smtp_host']);
	}if (isset($params['searchnot_fop_mail_host_name'])) {
		array_push($filters, _('name') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_fop_mail_host_name']);
	}if (isset($params['searchnot_fop_mail_host_imap_host'])) {
		array_push($filters, _('imap_host') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_fop_mail_host_imap_host']);
	}if (isset($params['searchnot_fop_mail_host_smtp_host'])) {
		array_push($filters, _('smtp_host') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_fop_mail_host_smtp_host']);
	}
		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(\'_fop_mail_host_\')) delete query[q];} reloadfop_mail_host(); ">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 == 'fop_mail_host') {
	\FOP\Session::setPayload('dv-fop_mail_host', [
		'id' => 'fop_mail_host',
		'tbl' => 'fop_mail_host',
		'idcol' => 'ID',
		'prev' => \DataViewRouter\Fop_mail_host::stepURL('fop_mail_host', 'XXX', -1),
		'next' => \DataViewRouter\Fop_mail_host::stepURL('fop_mail_host', '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\Fop_mail_host::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();

    
  }


  
  

  
  
}



