<?php

namespace DataView;

class Fop_mail_host_box_dir_email_directory {
  
  

  
  

    // --- Statische Methoden ---
  
  public static function renderTabTableAction($id) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
     ?><div class='fop-dv-buttonbar'><?php if(((false)) && (!\FOP\User::getIsGuest())) { ?><?php if (\FOP\Database::query('SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() == 1) { ?><a class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored" onclick="var self = this; $.get(reloadfop_mail_host_box_dir_email_directory({action: 'open', fop_table: 'fop_mail_host_box_dir_email', fop_id: '_', fop_from: location.href}, true)).then(function () { open_url(self.href, false);}); return false;" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::createURL2(['from' => \FOP\Util::getBackUrl(), 'column_directory' => $id])); ?>"><i class="material-icons">add</i> <?php echo(sprintf(_('create %s'), _('Email'))); ?></a><?php } ?><?php } ?></div><?php 
								\FOP\User::getIsGuest();
								$itemheight = 32;
								$itemsperpage = ceil(1080 / $itemheight * 0.8);
								$page = (isset($_GET['page_fop_mail_host_box_dir_email_directory']) ? intval($_GET['page_fop_mail_host_box_dir_email_directory']) : 0);
								$addlines = (isset($_GET['addlines_fop_mail_host_box_dir_email_directory']) ? intval($_GET['addlines_fop_mail_host_box_dir_email_directory']) : 0);
								$firstitem = $page * $itemsperpage;
								$sqladdon = ' LIMIT ' . ($itemsperpage * 2) . ' OFFSET ' . ($firstitem);
								$data = self::getData($sqladdon, $_GET, $id);
								$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 + 34 + 34 + 34;
								$additionalLines = 0;

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

											];
											$columns['hasAttachments'] = $col;
										}
									
										if(true){
											$col = [
												'id' => 'timestamp',
												'desc' => _('receivedat'),
												'order' => ++$order,
												'width' => 160, // default value
												'collapsed' => 0

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

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

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

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

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

											];
											$columns['recipient'] = $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_box_dir_email_directory'))->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='hasAttachments'
												data-order='<?php echo intval($columns['hasAttachments']['order']); ?>'
												data-width='<?php echo intval($columns['hasAttachments']['width']); ?>'
												data-collapsed='<?php echo intval($columns['hasAttachments']['collapsed']); ?>'
												style='width: <?php echo intval($columns['hasAttachments']['width']); ?>px; <?php if ($columns['hasAttachments']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host_box_dir_email_directory(); 
		}});
		win.append($('<input type=\'checkbox\'' + (querySet('filter_fop_mail_host_box_dir_email_directory_hasAttachments', '0') ? ' checked>': '>')).change(function (){querySet('filter_fop_mail_host_box_dir_email_directory_hasAttachments', '0', $(this).prop('checked')); changed=true;})).append('<i class=\'material-icons\'></i><br/>').append($('<input type=\'checkbox\'' + (querySet('filter_fop_mail_host_box_dir_email_directory_hasAttachments', '1') ? ' checked>': '>')).change(function (){querySet('filter_fop_mail_host_box_dir_email_directory_hasAttachments', '1', $(this).prop('checked')); changed=true;})).append('<i class=\'material-icons\'>attachment</i><br/>');
		return false;
	">
													<span class='title-title' title='<?php echo(_('📎')); ?>'><?php echo(_('📎')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'hasAttachments ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'hasAttachments DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_box_dir_email_directory_hasAttachments']) || isset($_GET['range_max_fop_mail_host_box_dir_email_directory_hasAttachments']) || isset($_GET['deps_fop_mail_host_box_dir_email_directory_hasAttachments']) || isset($_GET['fullsearch_fop_mail_host_box_dir_email_directory_hasAttachments']) || isset($_GET['dynamic_fop_mail_host_box_dir_email_directory_hasAttachments']) || isset($_GET['search_fop_mail_host_box_dir_email_directory_hasAttachments']) || isset($_GET['searchnot_fop_mail_host_box_dir_email_directory_hasAttachments']) || isset($_GET['filter_fop_mail_host_box_dir_email_directory_hasAttachments'])) {
															// 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['hasAttachments']['header'] = ob_get_contents(); ob_end_clean();
											$columns['hasAttachments']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['hasAttachments']['width']); ?>px; <?php if ($columns['hasAttachments']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='hasAttachments'><i class='material-icons'><?php echo htmlentities(\Types\FopemailhasAttachments::toIcon($item['hasAttachments'])); ?></i></div><?php
											};
											$columns['hasAttachments']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='hasAttachments'
													data-order='<?php echo intval($columns['hasAttachments']['order']); ?>'
													data-width='<?php echo intval($columns['hasAttachments']['width']); ?>'
													data-collapsed='<?php echo intval($columns['hasAttachments']['collapsed']); ?>'
													style='width: <?php echo intval($columns['hasAttachments']['width']); ?>px; <?php if ($columns['hasAttachments']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='timestamp'
												data-order='<?php echo intval($columns['timestamp']['order']); ?>'
												data-width='<?php echo intval($columns['timestamp']['width']); ?>'
												data-collapsed='<?php echo intval($columns['timestamp']['collapsed']); ?>'
												style='width: <?php echo intval($columns['timestamp']['width']); ?>px; <?php if ($columns['timestamp']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host_box_dir_email_directory(); 
		}}, 600);
		date_filter(win, 'fop_mail_host_box_dir_email_directory', 'timestamp', <?php echo htmlentities(json_encode(_('period'))); ?>, <?php echo htmlentities(json_encode(\FOP\I18n::getShortLocale())); ?>, <?php echo htmlentities(json_encode(_('dateformat_moment'))); ?>, function() { reloadfop_mail_host_box_dir_email_directory();  reloadfop_mail_host_box_dir_email_directory(); });
	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_box_dir_email_directory'] == 'timestamp ASC') {
			query['sort_fop_mail_host_box_dir_email_directory'] = 'timestamp DESC';
		 } else if (query['sort_fop_mail_host_box_dir_email_directory'] == 'timestamp DESC') {
		 	delete query['sort_fop_mail_host_box_dir_email_directory'];
		 } else {
			query['sort_fop_mail_host_box_dir_email_directory'] = 'timestamp ASC';
		 }
		 reloadfop_mail_host_box_dir_email_directory();
		 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(_('receivedat')); ?>'><?php echo(_('receivedat')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'timestamp ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'timestamp DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_box_dir_email_directory_timestamp']) || isset($_GET['range_max_fop_mail_host_box_dir_email_directory_timestamp']) || isset($_GET['deps_fop_mail_host_box_dir_email_directory_timestamp']) || isset($_GET['fullsearch_fop_mail_host_box_dir_email_directory_timestamp']) || isset($_GET['dynamic_fop_mail_host_box_dir_email_directory_timestamp']) || isset($_GET['search_fop_mail_host_box_dir_email_directory_timestamp']) || isset($_GET['searchnot_fop_mail_host_box_dir_email_directory_timestamp']) || isset($_GET['filter_fop_mail_host_box_dir_email_directory_timestamp'])) {
															// 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['timestamp']['header'] = ob_get_contents(); ob_end_clean();
											$columns['timestamp']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['timestamp']['width']); ?>px; <?php if ($columns['timestamp']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='timestamp'><span class='overflow-text' title="<?php echo htmlentities(($item['timestamp']) ? strftime(_('datetimeformat_php2'), intval($item['timestamp'])) : ''); ?>"><?php echo htmlentities(($item['timestamp']) ? strftime(_('datetimeformat_php2'), intval($item['timestamp'])) : ''); ?></span></div><?php
											};
											$columns['timestamp']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='timestamp'
													data-order='<?php echo intval($columns['timestamp']['order']); ?>'
													data-width='<?php echo intval($columns['timestamp']['width']); ?>'
													data-collapsed='<?php echo intval($columns['timestamp']['collapsed']); ?>'
													style='width: <?php echo intval($columns['timestamp']['width']); ?>px; <?php if ($columns['timestamp']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='senderDisplay'
												data-order='<?php echo intval($columns['senderDisplay']['order']); ?>'
												data-width='<?php echo intval($columns['senderDisplay']['width']); ?>'
												data-collapsed='<?php echo intval($columns['senderDisplay']['collapsed']); ?>'
												style='width: <?php echo intval($columns['senderDisplay']['width']); ?>px; <?php if ($columns['senderDisplay']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host_box_dir_email_directory(); 
		}});
		
		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_box_dir_email_directory_senderDisplay'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_fop_mail_host_box_dir_email_directory_senderDisplay'] = text.val(); } else { delete query['search_fop_mail_host_box_dir_email_directory_senderDisplay']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host_box_dir_email_directory').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_box_dir_email_directory_senderDisplay'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_fop_mail_host_box_dir_email_directory_senderDisplay'] = text2.val(); } else { delete query['searchnot_fop_mail_host_box_dir_email_directory_senderDisplay']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host_box_dir_email_directory').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_box_dir_email_directory'] == 'senderDisplay ASC') {
			query['sort_fop_mail_host_box_dir_email_directory'] = 'senderDisplay DESC';
		 } else if (query['sort_fop_mail_host_box_dir_email_directory'] == 'senderDisplay DESC') {
		 	delete query['sort_fop_mail_host_box_dir_email_directory'];
		 } else {
			query['sort_fop_mail_host_box_dir_email_directory'] = 'senderDisplay ASC';
		 }
		 reloadfop_mail_host_box_dir_email_directory();
		 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(_('senderdisplay')); ?>'><?php echo(_('senderdisplay')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'senderDisplay ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'senderDisplay DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_box_dir_email_directory_senderDisplay']) || isset($_GET['range_max_fop_mail_host_box_dir_email_directory_senderDisplay']) || isset($_GET['deps_fop_mail_host_box_dir_email_directory_senderDisplay']) || isset($_GET['fullsearch_fop_mail_host_box_dir_email_directory_senderDisplay']) || isset($_GET['dynamic_fop_mail_host_box_dir_email_directory_senderDisplay']) || isset($_GET['search_fop_mail_host_box_dir_email_directory_senderDisplay']) || isset($_GET['searchnot_fop_mail_host_box_dir_email_directory_senderDisplay']) || isset($_GET['filter_fop_mail_host_box_dir_email_directory_senderDisplay'])) {
															// 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['senderDisplay']['header'] = ob_get_contents(); ob_end_clean();
											$columns['senderDisplay']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['senderDisplay']['width']); ?>px; <?php if ($columns['senderDisplay']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='senderDisplay'><span class='overflow-text' title="<?php echo htmlentities($item['senderDisplay']); ?>"><?php echo htmlentities($item['senderDisplay']); ?></span></div><?php
											};
											$columns['senderDisplay']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='senderDisplay'
													data-order='<?php echo intval($columns['senderDisplay']['order']); ?>'
													data-width='<?php echo intval($columns['senderDisplay']['width']); ?>'
													data-collapsed='<?php echo intval($columns['senderDisplay']['collapsed']); ?>'
													style='width: <?php echo intval($columns['senderDisplay']['width']); ?>px; <?php if ($columns['senderDisplay']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='senderEmail'
												data-order='<?php echo intval($columns['senderEmail']['order']); ?>'
												data-width='<?php echo intval($columns['senderEmail']['width']); ?>'
												data-collapsed='<?php echo intval($columns['senderEmail']['collapsed']); ?>'
												style='width: <?php echo intval($columns['senderEmail']['width']); ?>px; <?php if ($columns['senderEmail']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host_box_dir_email_directory(); 
		}});
		
		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_box_dir_email_directory_senderEmail'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_fop_mail_host_box_dir_email_directory_senderEmail'] = text.val(); } else { delete query['search_fop_mail_host_box_dir_email_directory_senderEmail']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host_box_dir_email_directory').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_box_dir_email_directory_senderEmail'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_fop_mail_host_box_dir_email_directory_senderEmail'] = text2.val(); } else { delete query['searchnot_fop_mail_host_box_dir_email_directory_senderEmail']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host_box_dir_email_directory').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_box_dir_email_directory'] == 'senderEmail ASC') {
			query['sort_fop_mail_host_box_dir_email_directory'] = 'senderEmail DESC';
		 } else if (query['sort_fop_mail_host_box_dir_email_directory'] == 'senderEmail DESC') {
		 	delete query['sort_fop_mail_host_box_dir_email_directory'];
		 } else {
			query['sort_fop_mail_host_box_dir_email_directory'] = 'senderEmail ASC';
		 }
		 reloadfop_mail_host_box_dir_email_directory();
		 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(_('sender')); ?>'><?php echo(_('sender')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'senderEmail ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'senderEmail DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_box_dir_email_directory_senderEmail']) || isset($_GET['range_max_fop_mail_host_box_dir_email_directory_senderEmail']) || isset($_GET['deps_fop_mail_host_box_dir_email_directory_senderEmail']) || isset($_GET['fullsearch_fop_mail_host_box_dir_email_directory_senderEmail']) || isset($_GET['dynamic_fop_mail_host_box_dir_email_directory_senderEmail']) || isset($_GET['search_fop_mail_host_box_dir_email_directory_senderEmail']) || isset($_GET['searchnot_fop_mail_host_box_dir_email_directory_senderEmail']) || isset($_GET['filter_fop_mail_host_box_dir_email_directory_senderEmail'])) {
															// 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['senderEmail']['header'] = ob_get_contents(); ob_end_clean();
											$columns['senderEmail']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['senderEmail']['width']); ?>px; <?php if ($columns['senderEmail']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='senderEmail'><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['senderEmail']))); ?>"><?php echo htmlentities($item['senderEmail']); ?></a></span></div><?php
											};
											$columns['senderEmail']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='senderEmail'
													data-order='<?php echo intval($columns['senderEmail']['order']); ?>'
													data-width='<?php echo intval($columns['senderEmail']['width']); ?>'
													data-collapsed='<?php echo intval($columns['senderEmail']['collapsed']); ?>'
													style='width: <?php echo intval($columns['senderEmail']['width']); ?>px; <?php if ($columns['senderEmail']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='subject'
												data-order='<?php echo intval($columns['subject']['order']); ?>'
												data-width='<?php echo intval($columns['subject']['width']); ?>'
												data-collapsed='<?php echo intval($columns['subject']['collapsed']); ?>'
												style='width: <?php echo intval($columns['subject']['width']); ?>px; <?php if ($columns['subject']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host_box_dir_email_directory(); 
		}});
		
		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_box_dir_email_directory_subject'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_fop_mail_host_box_dir_email_directory_subject'] = text.val(); } else { delete query['search_fop_mail_host_box_dir_email_directory_subject']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host_box_dir_email_directory').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_box_dir_email_directory_subject'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_fop_mail_host_box_dir_email_directory_subject'] = text2.val(); } else { delete query['searchnot_fop_mail_host_box_dir_email_directory_subject']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host_box_dir_email_directory').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_box_dir_email_directory'] == 'subject ASC') {
			query['sort_fop_mail_host_box_dir_email_directory'] = 'subject DESC';
		 } else if (query['sort_fop_mail_host_box_dir_email_directory'] == 'subject DESC') {
		 	delete query['sort_fop_mail_host_box_dir_email_directory'];
		 } else {
			query['sort_fop_mail_host_box_dir_email_directory'] = 'subject ASC';
		 }
		 reloadfop_mail_host_box_dir_email_directory();
		 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(_('subject')); ?>'><?php echo(_('subject')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'subject ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'subject DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_box_dir_email_directory_subject']) || isset($_GET['range_max_fop_mail_host_box_dir_email_directory_subject']) || isset($_GET['deps_fop_mail_host_box_dir_email_directory_subject']) || isset($_GET['fullsearch_fop_mail_host_box_dir_email_directory_subject']) || isset($_GET['dynamic_fop_mail_host_box_dir_email_directory_subject']) || isset($_GET['search_fop_mail_host_box_dir_email_directory_subject']) || isset($_GET['searchnot_fop_mail_host_box_dir_email_directory_subject']) || isset($_GET['filter_fop_mail_host_box_dir_email_directory_subject'])) {
															// 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['subject']['header'] = ob_get_contents(); ob_end_clean();
											$columns['subject']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['subject']['width']); ?>px; <?php if ($columns['subject']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='subject'><span class='overflow-text' title="<?php echo htmlentities($item['subject']); ?>"><?php echo htmlentities($item['subject']); ?></span></div><?php
											};
											$columns['subject']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='subject'
													data-order='<?php echo intval($columns['subject']['order']); ?>'
													data-width='<?php echo intval($columns['subject']['width']); ?>'
													data-collapsed='<?php echo intval($columns['subject']['collapsed']); ?>'
													style='width: <?php echo intval($columns['subject']['width']); ?>px; <?php if ($columns['subject']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='content'
												data-order='<?php echo intval($columns['content']['order']); ?>'
												data-width='<?php echo intval($columns['content']['width']); ?>'
												data-collapsed='<?php echo intval($columns['content']['collapsed']); ?>'
												style='width: <?php echo intval($columns['content']['width']); ?>px; <?php if ($columns['content']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host_box_dir_email_directory(); 
		}});
		
		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_box_dir_email_directory_content'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_fop_mail_host_box_dir_email_directory_content'] = text.val(); } else { delete query['search_fop_mail_host_box_dir_email_directory_content']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host_box_dir_email_directory').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_box_dir_email_directory_content'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_fop_mail_host_box_dir_email_directory_content'] = text2.val(); } else { delete query['searchnot_fop_mail_host_box_dir_email_directory_content']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host_box_dir_email_directory').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_box_dir_email_directory'] == 'content ASC') {
			query['sort_fop_mail_host_box_dir_email_directory'] = 'content DESC';
		 } else if (query['sort_fop_mail_host_box_dir_email_directory'] == 'content DESC') {
		 	delete query['sort_fop_mail_host_box_dir_email_directory'];
		 } else {
			query['sort_fop_mail_host_box_dir_email_directory'] = 'content ASC';
		 }
		 reloadfop_mail_host_box_dir_email_directory();
		 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(_('content')); ?>'><?php echo(_('content')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'content ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'content DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_box_dir_email_directory_content']) || isset($_GET['range_max_fop_mail_host_box_dir_email_directory_content']) || isset($_GET['deps_fop_mail_host_box_dir_email_directory_content']) || isset($_GET['fullsearch_fop_mail_host_box_dir_email_directory_content']) || isset($_GET['dynamic_fop_mail_host_box_dir_email_directory_content']) || isset($_GET['search_fop_mail_host_box_dir_email_directory_content']) || isset($_GET['searchnot_fop_mail_host_box_dir_email_directory_content']) || isset($_GET['filter_fop_mail_host_box_dir_email_directory_content'])) {
															// 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['content']['header'] = ob_get_contents(); ob_end_clean();
											$columns['content']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['content']['width']); ?>px; <?php if ($columns['content']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='content'><?php 
	$html = preg_replace('/^<!DOCTYPE.+?>/m', '', \FOP\Sanitizers::htmlentities_decode($item['content'])); ?>
	<span style="display: block;" onmouseenter='handleHTMLOverlay(event, &apos;#overlayFormcontent<?php echo htmlentities($item['ID'] ?? 'fail'); ?>&apos;);' onmouseleave='handleHTMLOverlayFade(event, &apos;#overlayFormcontent<?php echo htmlentities($item['ID'] ?? 'fail'); ?>&apos;);' ng-non-bindable><?php echo htmlentities(mb_substr(preg_replace('/[ \t\r\n]+/', ' ', strip_tags(preg_replace('/<style.*?\/style>/s', '', html_entity_decode($item['content'])))), 0, 50) . (strlen(preg_replace('/[ \t\r\n]+/', ' ', strip_tags(preg_replace('/<style.*?\/style>/s', '', html_entity_decode($item['content']))))) >= 50 ? '...' : ''));  ?></span>
	<div class="overlay-iframe" id="overlayFormcontent<?php echo $item['ID'] ?? 'fail'; ?>">
		<div class="iframe-container" id="iframecontainer">
			<?php echo \FOP\Util::SanitizeUserHtml($html); ?>
		</div>
	</div>
</div><?php
											};
											$columns['content']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='content'
													data-order='<?php echo intval($columns['content']['order']); ?>'
													data-width='<?php echo intval($columns['content']['width']); ?>'
													data-collapsed='<?php echo intval($columns['content']['collapsed']); ?>'
													style='width: <?php echo intval($columns['content']['width']); ?>px; <?php if ($columns['content']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
													</div><?php
											};
										}
										
									
										
										if(true){
											ob_start();
											?><div class="fop-table-column overlay"
												data-column='recipient'
												data-order='<?php echo intval($columns['recipient']['order']); ?>'
												data-width='<?php echo intval($columns['recipient']['width']); ?>'
												data-collapsed='<?php echo intval($columns['recipient']['collapsed']); ?>'
												style='width: <?php echo intval($columns['recipient']['width']); ?>px; <?php if ($columns['recipient']['collapsed'] == 1) { echo ' display: none;'; } ?>'>
												<span class='title' onclick="
		var changed = false, win = dropDownFixPosition($(this), null, function() { if (changed) {
			
			reloadfop_mail_host_box_dir_email_directory(); 
		}});
		
		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_box_dir_email_directory_recipient'])
		text.on('change keyup paste', function () { if (text.val()) { query['search_fop_mail_host_box_dir_email_directory_recipient'] = text.val(); } else { delete query['search_fop_mail_host_box_dir_email_directory_recipient']; } changed = true; });
		text.focus();
		text.select();
		text.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host_box_dir_email_directory').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_box_dir_email_directory_recipient'])
		text2.on('change keyup paste', function () { if (text2.val()) { query['searchnot_fop_mail_host_box_dir_email_directory_recipient'] = text2.val(); } else { delete query['searchnot_fop_mail_host_box_dir_email_directory_recipient']; } changed = true; });
		text2.keydown(function (event) {if ((event.keyCode || event.which) == 13) {$('#table_fop_mail_host_box_dir_email_directory').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_box_dir_email_directory'] == 'recipient ASC') {
			query['sort_fop_mail_host_box_dir_email_directory'] = 'recipient DESC';
		 } else if (query['sort_fop_mail_host_box_dir_email_directory'] == 'recipient DESC') {
		 	delete query['sort_fop_mail_host_box_dir_email_directory'];
		 } else {
			query['sort_fop_mail_host_box_dir_email_directory'] = 'recipient ASC';
		 }
		 reloadfop_mail_host_box_dir_email_directory();
		 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(_('recipient')); ?>'><?php echo(_('recipient')); ?></span>
													<?php // sort indicator
														if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'recipient ASC') {
															?><i class='material-icons fop-small'>keyboard_arrow_down</i><?php
														} else if (isset($_GET['sort_fop_mail_host_box_dir_email_directory']) && $_GET['sort_fop_mail_host_box_dir_email_directory'] == 'recipient DESC') {
															?><i class='material-icons fop-small'>keyboard_arrow_up</i><?php
														}
														if (isset($_GET['range_min_fop_mail_host_box_dir_email_directory_recipient']) || isset($_GET['range_max_fop_mail_host_box_dir_email_directory_recipient']) || isset($_GET['deps_fop_mail_host_box_dir_email_directory_recipient']) || isset($_GET['fullsearch_fop_mail_host_box_dir_email_directory_recipient']) || isset($_GET['dynamic_fop_mail_host_box_dir_email_directory_recipient']) || isset($_GET['search_fop_mail_host_box_dir_email_directory_recipient']) || isset($_GET['searchnot_fop_mail_host_box_dir_email_directory_recipient']) || isset($_GET['filter_fop_mail_host_box_dir_email_directory_recipient'])) {
															// 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['recipient']['header'] = ob_get_contents(); ob_end_clean();
											$columns['recipient']['render'] = function ($item) use (&$columns, $itemheight) {
												// Render-Callback für eine Zelle
												?><div class='fop-table-column'
													style='width: <?php echo intval($columns['recipient']['width']); ?>px; <?php if ($columns['recipient']['collapsed'] == 1) { echo ' display: none;'; } ?> height: <?php echo $itemheight; ?>px; ' data-column='recipient'><span class='overflow-text' title="<?php echo htmlentities($item['recipient']); ?>"><?php echo htmlentities($item['recipient']); ?></span></div><?php
											};
											$columns['recipient']['renderSum'] = function ($item) use (&$columns) {
												// Render-Callback Summe
												?><div class='fop-table-column fop-table-column-aggregate'
													data-column='recipient'
													data-order='<?php echo intval($columns['recipient']['order']); ?>'
													data-width='<?php echo intval($columns['recipient']['width']); ?>'
													data-collapsed='<?php echo intval($columns['recipient']['collapsed']); ?>'
													style='width: <?php echo intval($columns['recipient']['width']); ?>px; <?php if ($columns['recipient']['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_box_dir_email_directory-table .fop-table-header {
											height: <?php echo 32; ?>px;
										}
										#fop_mail_host_box_dir_email_directory-table .fop-table-header .fop-table-column .title,
										#fop_mail_host_box_dir_email_directory-table .fop-column-handle,
										#fop_mail_host_box_dir_email_directory-table .fop-table-row,
										#fop_mail_host_box_dir_email_directory-table .fop-table-row .fop-table-column,
										#fop_mail_host_box_dir_email_directory-table .fop-table-column-multicontrol,
										#fop_mail_host_box_dir_email_directory-table .fop-filter-button {
											height: 32px;
											line-height: 32px;
										}
										</style>
											<div class="fop-table" data-table-id="fop_mail_host_box_dir_email_directory">
											<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_box_dir_email_directory__all-checkbox">
														<input class="mdl-checkbox__input" id="fop_mail_host_box_dir_email_directory__all-checkbox" type="checkbox" onchange="checkfop_mail_host_box_dir_email_directory('all', 'ID', this.checked);">
														</label>
														<button type="button" class="mdl-button mdl-js-button mdl-button--icon fop_mail_host_box_dir_email_directory__mass-action" style='visibility: hidden;' onclick="$.get('DataView/Fop_mail_host_box_dir_email_directory/permissions?id=' + checkfop_mail_host_box_dir_email_directory(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_box_dir_email_directory_') == 0 || key.indexOf('range_max_fop_mail_host_box_dir_email_directory_') == 0 || key.indexOf('deps_fop_mail_host_box_dir_email_directory_') == 0 || key.indexOf('fullsearch_fop_mail_host_box_dir_email_directory_') == 0 || key.indexOf('dynamic_fop_mail_host_box_dir_email_directory_') == 0 || key.indexOf('search_fop_mail_host_box_dir_email_directory_') == 0 || key.indexOf('searchnot_fop_mail_host_box_dir_email_directory_') == 0 || key.indexOf('filter_fop_mail_host_box_dir_email_directory_') == 0) delete query[key]; reloadfop_mail_host_box_dir_email_directory(); $(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_box_dir_email_directory_ID'] = checkfop_mail_host_box_dir_email_directory(null, 'ID'); delete query['page_fop_mail_host_box_dir_email_directory']; reloadfop_mail_host_box_dir_email_directory(); $(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_box_dir_email_directory(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_box_dir_email_directory(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::getIsLoggedIn()))) { ?>
			<span class="mdl-list__item mdl-button">
				<span class="mdl-list__item mdl-button" data-interaction-name="delete_mails" style="margin-right:auto; text-align:left;"
					onclick="location.href = 'Tables/Fop_mail_host_box_dir_email/emailDelete?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&id=' + escape(checkfop_mail_host_box_dir_email_directory(null, 'ID')); $(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(_('Löschen')); ?>"><?php echo(_('Löschen')); ?> (<span class='cnt'></span>)
					</span>
				</span>
			</span>
		<?php } ?><?php
		if(true && ((\FOP\User::getIsLoggedIn()))) { ?>
			<span class="mdl-list__item mdl-button">
				<span class="mdl-list__item mdl-button" data-interaction-name="flag_mails" style="margin-right:auto; text-align:left;"
					onclick="location.href = 'Tables/Fop_mail_host_box_dir_email/emailFlag?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&id=' + escape(checkfop_mail_host_box_dir_email_directory(null, 'ID')); $(this).closest('.overlay').click(); return false;">
					<span style="float:left;"><i class="material-icons">markunread</i></span><span class="fop-menu-caption" title="<?php echo(_('Als ungelesen Markieren')); ?>"><?php echo(_('Als ungelesen Markieren')); ?> (<span class='cnt'></span>)
					</span>
				</span>
			</span>
		<?php } ?><?php
		if(true && ((\FOP\User::getIsLoggedIn()))) { ?>
			<span class="mdl-list__item mdl-button">
				<span class="mdl-list__item mdl-button" data-interaction-name="spam_mails" style="margin-right:auto; text-align:left;"
					onclick="location.href = 'Tables/Fop_mail_host_box_dir_email/emailSpam?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&id=' + escape(checkfop_mail_host_box_dir_email_directory(null, 'ID')); $(this).closest('.overlay').click(); return false;">
					<span style="float:left;"><i class="material-icons">block</i></span><span class="fop-menu-caption" title="<?php echo(_('Spam')); ?>"><?php echo(_('Spam')); ?> (<span class='cnt'></span>)
					</span>
				</span>
			</span>
		<?php } ?><?php
		if(true && ((false))) { ?>
			<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_box_dir_email/delete?ajax&from=<?php echo urlencode(\FOP\Util::getBackUrl()); ?>&id=' + escape(checkfop_mail_host_box_dir_email_directory(null, 'ID'))).then(function () { reloadfop_mail_host_box_dir_email_directory(); }, 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_box_dir_email_directory', <?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_box_dir_email_directory', 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_box_dir_email_directory" <?php \EasyEditor\Navigation::printScroll('dv.Fop_mail_host_box_dir_email_directory', '/* 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_box_dir_email_directory\'] || 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_box_dir_email_directory\'] = wantedPage;
														reloadfop_mail_host_box_dir_email_directory(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="<?php echo 'background: ' .htmlentities((function ($item) {return $item['::color'];})($item)).'!important;'; ?> " data-fop_mail_host_box_dir_email-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_box_dir_email_directory({action: \'open\', fop_table: \'fop_mail_host_box_dir_email\', 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_box_dir_email_directory__checkbox fop_mail_host_box_dir_email_directory__checkbox fop_mail_host_box_dir_email_directory__checkbox-ID-<?php echo htmlentities($item['ID']); ?>" style="width: auto;" for="fop_mail_host_box_dir_email_directory__<?php echo htmlentities($itempos); ?>-checkbox">
													<input class="mdl-checkbox__input" id="fop_mail_host_box_dir_email_directory__<?php echo htmlentities($itempos); ?>-checkbox" type="checkbox" onchange="<?php if (isset($item['ID'])) echo 'checkfop_mail_host_box_dir_email_directory(' . htmlentities(json_encode($item['ID'])) . ', \'ID\', this.checked); ' ?>">
													</label><button type="button" class="mdl-button mdl-js-button mdl-button--icon fop_mail_host_box_dir_email_directory__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_box_dir_email_directory-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_box_dir_email::viewURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick=" if (!event.ctrlKey) { open_url(reloadfop_mail_host_box_dir_email_directory({action: 'open', fop_table: 'fop_mail_host_box_dir_email', 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_box_dir_email::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())) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="answer" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_draft::answerURL2(['mail' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">question_answer</i></span><span class="fop-menu-caption" title="<?php echo(_('antworten')); ?>"><?php echo(_('antworten')); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((false))) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="create_fop_mail_host_box_dir_email_recipient_email" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email_recipient::createURL2(['column_email' => $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'), _('E-Mail-Empfänger'))); ?>"><?php echo(sprintf(_('create %s'), _('E-Mail-Empfänger'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && ((false))) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="create_fop_mail_host_box_dir_email_thread_email" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email_thread::createURL2(['column_email' => $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'), _('emaildirectorythread_singular'))); ?>"><?php echo(sprintf(_('create %s'), _('emaildirectorythread_singular'))); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && $item['operation::view']) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="delete_mails" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::emailDeleteURL2(['id' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					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(_('Löschen')); ?>"><?php echo(_('Löschen')); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && $item['operation::view']) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="flag_mails" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::emailFlagURL2(['id' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">markunread</i></span><span class="fop-menu-caption" title="<?php echo(_('Als ungelesen Markieren')); ?>"><?php echo(_('Als ungelesen Markieren')); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && (!\FOP\User::getIsGuest())) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="forward" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_draft::forwardURL2(['mail' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">forward</i></span><span class="fop-menu-caption" title="<?php echo(_('weiterleiten')); ?>"><?php echo(_('weiterleiten')); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && $item['operation::view']) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="spam_mails" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::emailSpamURL2(['id' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">block</i></span><span class="fop-menu-caption" title="<?php echo(_('Spam')); ?>"><?php echo(_('Spam')); ?></span>
			</a>
		<?php } ?><?php
		if(isset($item['ID']) && (!\FOP\User::getIsGuest())) { ?>
			<a class="mdl-list__item mdl-button" data-interaction-name="to-aufgabe" style="margin-right:auto; text-align:left;" href="<?php echo htmlentities(\TablesRouter\Aufgabe::createURL2(['email' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="   
					open_url(this.href, false);
					$(this).closest('.overlay').click();
					return false;">
				<span><i class="material-icons">🎫</i></span><span class="fop-menu-caption" title="<?php echo(sprintf(_('in %s umwandeln'), _('Aufgabe'))); ?>"><?php echo(sprintf(_('in %s umwandeln'), _('Aufgabe'))); ?></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_box_dir_email/delete?ajax&id=<?php echo htmlentities($item['ID']);?>&from=<?php echo htmlentities(\FOP\Util::getBackUrl());?>').then(function () { reloadfop_mail_host_box_dir_email_directory(); }, 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']) {
			?><a class="mdl-button mdl-js-button mdl-button--icon tbl-link" data-tbl="fop_mail_host_box_dir_email" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="delete_mails" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::emailDeleteURL2(['id' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();    reloadfop_mail_host_box_dir_email_directory();
					$(this).closest('.overlay').click();
					if (this.href != '#') {
						open_url(this.href, false);
					}
					event.preventDefault();"
				title="<?php echo(_('Löschen')); ?>">
				<i class="material-icons">delete</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_box_dir_email" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="spam_mails" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::emailSpamURL2(['id' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();    reloadfop_mail_host_box_dir_email_directory();
					$(this).closest('.overlay').click();
					if (this.href != '#') {
						open_url(this.href, false);
					}
					event.preventDefault();"
				title="<?php echo(_('Spam')); ?>">
				<i class="material-icons">block</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_box_dir_email" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="flag_mails" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::emailFlagURL2(['id' => $item['ID'], 'from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();    reloadfop_mail_host_box_dir_email_directory();
					$(this).closest('.overlay').click();
					if (this.href != '#') {
						open_url(this.href, false);
					}
					event.preventDefault();"
				title="<?php echo(_('Als ungelesen Markieren')); ?>">
				<i class="material-icons">markunread</i>
			</a><?php } ?><?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_box_dir_email" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="edit" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::editURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();    reloadfop_mail_host_box_dir_email_directory();
					$(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_box_dir_email" data-id="<?php echo htmlentities($item['ID']); ?>" data-interaction-name="view" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::viewURL($item['ID'], ['from' => \FOP\Util::getBackUrl()])); ?>"
				onclick="event.stopPropagation();  if (!event.ctrlKey) { open_url(reloadfop_mail_host_box_dir_email_directory({action: 'open', fop_table: 'fop_mail_host_box_dir_email', fop_id: <?php echo htmlentities(json_encode($item['ID'])); ?>, fop_from: location.href}, true), false); return false; }  reloadfop_mail_host_box_dir_email_directory();
					$(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 renderScript($id) { 
    
    
    // --- BLOCK: main ---
    
								\FOP\I18n::ensureIsLoaded();
								?>
								<script type="text/javascript">
									
    function changefilter_fop_mail_host_box_dir_email_directory_directoryListMultiFilter(val, cb) {
		  if (val) {
			  querySet('filter_fop_mail_host_box_dir_email_directory_directory', val, cb.checked);
		  } else {
			  delete query['filter_fop_mail_host_box_dir_email_directory_directory'];
		  }reloadfop_mail_host_box_dir_email_directory();
        
    }

		var i0dec7a58dc88701df8d36f7f4cfa744092063acbb54c1cbf46c1cbb71e5af753timeout = null;
		function changefilter_fop_mail_host_box_dir_email_directory_directorySearchFilter(val, callback) {
			if(i0dec7a58dc88701df8d36f7f4cfa744092063acbb54c1cbf46c1cbb71e5af753timeout) clearTimeout(i0dec7a58dc88701df8d36f7f4cfa744092063acbb54c1cbf46c1cbb71e5af753timeout);

			i0dec7a58dc88701df8d36f7f4cfa744092063acbb54c1cbf46c1cbb71e5af753timeout = setTimeout(function() {
				$.getJSON(reloadfop_mail_host_box_dir_email_directory({action: 'getfilter_fop_mail_host_box_dir_email_directory_directoryItemsByString', 'fstr': val}, true), function(r) {
					callback(r);
					query['filter_fop_mail_host_box_dir_email_directory_directory_orig'] = val;
				});
			}, 300);
		}

	function getfilter_fop_mail_host_box_dir_email_directory_directoryListMultiFilter() {
		var gui = $("<div class='fop-floatsorter'></div>");
		// TODO: usability #1866 auf ajax warten bevor ENTER behandelt wird
		var fstr = <?php echo(isset($_GET['filter_fop_mail_host_box_dir_email_directory_directory_orig']) ? json_encode($_GET['filter_fop_mail_host_box_dir_email_directory_directory_orig']) : '""') ?>;
		var search = $('<div class="mdl-textfield mdl-js-textfield">' + 
			'<input value="" class="mdl-textfield__input" id="0dec7a58dc88701df8d36f7f4cfa744092063acbb54c1cbf46c1cbb71e5af753" type="text">' +
			'<label class="mdl-textfield__label" for="0dec7a58dc88701df8d36f7f4cfa744092063acbb54c1cbf46c1cbb71e5af753">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_fop_mail_host_box_dir_email_directory_directory', $(inp).data('value'), true);
							hasChecked = true;
						}
					});
				} else {
					// untick all
					search.find('input').val('');
					query['filter_fop_mail_host_box_dir_email_directory_directory_orig'] = '';
					delete query['filter_fop_mail_host_box_dir_email_directory_directory'];
					reload('', items);
					hasChecked = true;
				}
				if (hasChecked) {reloadfop_mail_host_box_dir_email_directory();
					
				} else {
					$('#table_fop_mail_host_box_dir_email_directory').find('.fop-table-row:first').click();
				}
			} else {
				changefilter_fop_mail_host_box_dir_email_directory_directorySearchFilter(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\Fop_mail_host_box_dir_email_directory::getfilter_fop_mail_host_box_dir_email_directory_directoryItemsByStringAction('', $id));
		?>;

		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_fop_mail_host_box_dir_email_directory_directory_orig'] = '';
				delete query['filter_fop_mail_host_box_dir_email_directory_directory'];
				reload('', items);reloadfop_mail_host_box_dir_email_directory();
				
			})).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_fop_mail_host_box_dir_email_directory_directory', value);
				if (!fstr || checked || descr.toLowerCase().includes(fstr.toLowerCase())) {
					checkboxes.append($('<input type=\'checkbox\'  onclick=\'changefilter_fop_mail_host_box_dir_email_directory_directoryListMultiFilter("' + 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_fop_mail_host_box_dir_email_directory_directoryListMultiFilter(val, cb) {
		  if (val) {
			  querySet('filter_fop_mail_host_box_dir_email_directory_directory', val, cb.checked);
		  } else {
			  delete query['filter_fop_mail_host_box_dir_email_directory_directory'];
		  }reloadfop_mail_host_box_dir_email_directory();
        
    }

		var i0dec7a58dc88701df8d36f7f4cfa744092063acbb54c1cbf46c1cbb71e5af753timeout = null;
		function changefilter_fop_mail_host_box_dir_email_directory_directorySearchFilter(val, callback) {
			if(i0dec7a58dc88701df8d36f7f4cfa744092063acbb54c1cbf46c1cbb71e5af753timeout) clearTimeout(i0dec7a58dc88701df8d36f7f4cfa744092063acbb54c1cbf46c1cbb71e5af753timeout);

			i0dec7a58dc88701df8d36f7f4cfa744092063acbb54c1cbf46c1cbb71e5af753timeout = setTimeout(function() {
				$.getJSON(reloadfop_mail_host_box_dir_email_directory({action: 'getfilter_fop_mail_host_box_dir_email_directory_directoryItemsByString', 'fstr': val}, true), function(r) {
					callback(r);
					query['filter_fop_mail_host_box_dir_email_directory_directory_orig'] = val;
				});
			}, 300);
		}

	function getfilter_fop_mail_host_box_dir_email_directory_directoryListMultiFilter() {
		var gui = $("<div class='fop-floatsorter'></div>");
		// TODO: usability #1866 auf ajax warten bevor ENTER behandelt wird
		var fstr = <?php echo(isset($_GET['filter_fop_mail_host_box_dir_email_directory_directory_orig']) ? json_encode($_GET['filter_fop_mail_host_box_dir_email_directory_directory_orig']) : '""') ?>;
		var search = $('<div class="mdl-textfield mdl-js-textfield">' + 
			'<input value="" class="mdl-textfield__input" id="0dec7a58dc88701df8d36f7f4cfa744092063acbb54c1cbf46c1cbb71e5af753" type="text">' +
			'<label class="mdl-textfield__label" for="0dec7a58dc88701df8d36f7f4cfa744092063acbb54c1cbf46c1cbb71e5af753">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_fop_mail_host_box_dir_email_directory_directory', $(inp).data('value'), true);
							hasChecked = true;
						}
					});
				} else {
					// untick all
					search.find('input').val('');
					query['filter_fop_mail_host_box_dir_email_directory_directory_orig'] = '';
					delete query['filter_fop_mail_host_box_dir_email_directory_directory'];
					reload('', items);
					hasChecked = true;
				}
				if (hasChecked) {reloadfop_mail_host_box_dir_email_directory();
					
				} else {
					$('#table_fop_mail_host_box_dir_email_directory').find('.fop-table-row:first').click();
				}
			} else {
				changefilter_fop_mail_host_box_dir_email_directory_directorySearchFilter(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\Fop_mail_host_box_dir_email_directory::getfilter_fop_mail_host_box_dir_email_directory_directoryItemsByStringAction('', $id));
		?>;

		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_fop_mail_host_box_dir_email_directory_directory_orig'] = '';
				delete query['filter_fop_mail_host_box_dir_email_directory_directory'];
				reload('', items);reloadfop_mail_host_box_dir_email_directory();
				
			})).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_fop_mail_host_box_dir_email_directory_directory', value);
				if (!fstr || checked || descr.toLowerCase().includes(fstr.toLowerCase())) {
					checkboxes.append($('<input type=\'checkbox\'  onclick=\'changefilter_fop_mail_host_box_dir_email_directory_directoryListMultiFilter("' + 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 updateNumberfop_mail_host_box_dir_email_directory(col) {
										//var checklist = window.DataViewChecked['fop_mail_host_box_dir_email_directory'][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_box_dir_email_directory'] && window.DataViewChecked['fop_mail_host_box_dir_email_directory'][col].ranges.length > 0) {
											$('.fop_mail_host_box_dir_email_directory__mass-action').css('visibility', 'visible');
											$('.fop_mail_host_box_dir_email_directory__action').css('visibility', 'hidden');
										} else {
											$('.fop_mail_host_box_dir_email_directory__mass-action').css('visibility', 'hidden');
											$('.fop_mail_host_box_dir_email_directory__action').css('visibility', 'visible');
										}
										$('.fop_mail_host_box_dir_email_directory__checkbox').each(function (idx, x) {
											for (var cssclass of x.classList) {
												if (cssclass.startsWith('fop_mail_host_box_dir_email_directory__checkbox-'+col+'-')) {
													var my_id = cssclass.substr(('fop_mail_host_box_dir_email_directory__checkbox-'+col+'-').length);
													if (window.DataViewChecked) {
														x.MaterialCheckbox[checklist.has(my_id) ? 'check' : 'uncheck']();
													}
												}
											}
										});
									}
									function reloadfop_mail_host_box_dir_email_directory (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 } ?>
										nq["id"] = <?php echo json_encode($id); ?>; 
										if (params) {
											for (var i in params) nq[i] = params[i];
											var action = nq['action'];
											delete nq['action'];
											let querystr = "DataView/Fop_mail_host_box_dir_email_directory/" + 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::getIsLoggedIn())) && (!\FOP\User::getIsGuest())) { ?>
											delete nq['action'];
											querystr = "DataView/Fop_mail_host_box_dir_email_directory/renderTabTable?" + Object.keys(nq).map(function(k){ return k + "=" +  encodeURIComponent(nq[k]); }).join("&");
											// per Ajax laden
											if(!$("#fop_mail_host_box_dir_email_directory-table")?.parent()?.parent()?.hasClass('fop-form-feature-collapsed') || $("#fop_mail_host_box_dir_email_directory-table")?.parent()?.parent()?.hasClass('fop-form-feature-mode-area')) {
											$.get(querystr, function(data){
												var tab = $("#fop_mail_host_box_dir_email_directory-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_box_dir_email_directory('ID');
											});
											} else {
												// gesamten Tab ersetzen
												var tab = $("#fop_mail_host_box_dir_email_directory-table");
												tab.children().remove();
												el = tab.html('<div class="fop-lazy-reload" onclick="reloadfop_mail_host_box_dir_email_directory()"></div>');
											}
											<?php } ?>
											
										}
									}
									function checkfop_mail_host_box_dir_email_directory (id, col, checked) {
										// ID-Liste aufbauen
										if (!window.DataViewChecked) window.DataViewChecked = {};
										if (!window.DataViewChecked['fop_mail_host_box_dir_email_directory']) window.DataViewChecked['fop_mail_host_box_dir_email_directory'] = {};
										if (!window.DataViewChecked['fop_mail_host_box_dir_email_directory'][col]) window.DataViewChecked['fop_mail_host_box_dir_email_directory'][col] = new IDList();

										// Abfrage aller gecheckten IDs für eine Tabelle
										if (!id) {
											return window.DataViewChecked['fop_mail_host_box_dir_email_directory'][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_box_dir_email_directory({action: 'getids', col: col}, true), function (ids) {
													window.DataViewChecked['fop_mail_host_box_dir_email_directory'][col] = new IDList(ids);
													updateNumberfop_mail_host_box_dir_email_directory(col);
												});
											} else {
												window.DataViewChecked['fop_mail_host_box_dir_email_directory'][col] = new IDList();
												updateNumberfop_mail_host_box_dir_email_directory(col);
											}
										} else {
											var ids = new IDList(id);
											var allcb = $('#fop_mail_host_box_dir_email_directory__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_box_dir_email_directory'][col] = ids;
											} else for (id of ids.all()) {
												if (checked) {
													window.DataViewChecked['fop_mail_host_box_dir_email_directory'][col].push(id);
												} else {
													window.DataViewChecked['fop_mail_host_box_dir_email_directory'][col].remove(id);
												}
											}
											updateNumberfop_mail_host_box_dir_email_directory(col);
										}
									}
								</script><?php

    
  }

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

	</script>
	<?php
	
    
  }

  public static function getSQL($params, $id) { 
    
    
    // --- 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 /* ::color */ CASE  WHEN NOT ('.qi('fop_mail_host_box_dir_email').'.'.qi('seen').') THEN (\'#f0f2\')  ELSE NULL END AS '.qi('::color').',
									/* ID */ '.qi('ID').' AS '.qi('ID').',
									/* boxid */ '.qi('boxid').' AS '.qi('boxid').',
									/* content */ '.qi('content').' AS '.qi('content').',
									/* directory */ '.qi('directory').' AS '.qi('directory').',
									/* directory::canView */ '.qi('ref:directory').'.'.qi('directory:canView').' AS '.qi('directory::canView').',
									/* directory::description */ '.qi('ref:directory').'.'.qi('directory:description').' AS '.qi('directory::description').',
									/* hasAttachments */ EXISTS (SELECT (TRUE) FROM '.qi('fop_mail_host_box_dir_email_attachment').' '.qi('exp0Y3r8').' WHERE '.qi('exp0Y3r8').'.'.qi('email').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('ID').' LIMIT 1) AS '.qi('hasAttachments').',
									/* msgid */ '.qi('msgid').' AS '.qi('msgid').',
									/* operation::create */ (FALSE) AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('PXLLPZCy').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('PXLLPZCy').' WHERE '.qi('PXLLPZCy').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)) AS '.qi('operation::create').',
									/* operation::delete */ (FALSE) AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('FTZDyDjf').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('FTZDyDjf').' WHERE '.qi('FTZDyDjf').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)) AS '.qi('operation::delete').',
									/* operation::edit */ (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('KcSSV43E').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('KcSSV43E').' WHERE '.qi('KcSSV43E').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)) AS '.qi('operation::edit').',
									/* operation::index */ ' . (!\FOP\User::getIsGuest() ? 1 : 0) . ' AS '.qi('operation::index').',
									/* operation::view */ ('.\FOP\Database::quote(\FOP\User::getIsLoggedIn()).') AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('p0EDqmbn').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('p0EDqmbn').' WHERE '.qi('p0EDqmbn').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)) AS '.qi('operation::view').',
									/* recipient */ (SELECT (CONCAT('.qi('vruMkJVV').'.'.qi('display').', \' <\', '.qi('vruMkJVV').'.'.qi('address').', \'>\')) FROM '.qi('fop_mail_host_box_dir_email_recipient').' '.qi('vruMkJVV').' WHERE '.qi('vruMkJVV').'.'.qi('email').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('ID').' LIMIT 1) AS '.qi('recipient').',
									/* seen */ '.qi('seen').' AS '.qi('seen').',
									/* senderDisplay */ '.qi('senderDisplay').' AS '.qi('senderDisplay').',
									/* senderEmail */ '.qi('senderEmail').' AS '.qi('senderEmail').',
									/* subject */ '.qi('subject').' AS '.qi('subject').',
									/* timestamp */ '.qi('timestamp').' AS '.qi('timestamp').',
									/* type */ '.qi('type').' AS '.qi('type').',
									/* uid */ '.qi('uid').' AS '.qi('uid').',
									1
								FROM '.qi('fop_mail_host_box_dir_email').' '.qi('fop_mail_host_box_dir_email').'
								LEFT JOIN (SELECT '.qi('ID').' AS '.qi('directory:ID').', CONCAT('.qi('fop_mail_host_box_dir').'.'.qi('name').', \' - \', (SELECT ('.qi('tcayeuX5').'.'.qi('from_address').') FROM '.qi('fop_mail_host_box').' '.qi('tcayeuX5').' WHERE '.qi('tcayeuX5').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir').'.'.qi('mailbox').' LIMIT 1)) AS '.qi('directory:description').', ((COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir').'.'.qi('mailbox').' LIMIT 1), FALSE))) AS '.qi('directory:canView').' FROM '.qi('fop_mail_host_box_dir').') '.qi('ref:directory').' ON '.qi('ref:directory').'.'.qi('directory:ID').' = '.qi('directory').'
								WHERE ('.qi('directory').' = ' . \FOP\Database::quote($id) . ')
									AND (('.\FOP\Database::quote(\FOP\User::getIsLoggedIn()).') AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('p0EDqmbn').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('p0EDqmbn').' WHERE '.qi('p0EDqmbn').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)))) AS t
								WHERE ' . (isset($params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) ? ($params['range_min_fop_mail_host_box_dir_email_directory_timestamp'] !== '' && is_numeric($params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) ? 't.'.qi('timestamp').' >= ' . \FOP\Database::quote($params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) . ' AND ' : '') : '') . 
								(isset($params['range_max_fop_mail_host_box_dir_email_directory_timestamp']) ? ($params['range_max_fop_mail_host_box_dir_email_directory_timestamp'] !== '' && is_numeric($params['range_max_fop_mail_host_box_dir_email_directory_timestamp']) ? 't.'.qi('timestamp').' <= ' . \FOP\Database::quote($params['range_max_fop_mail_host_box_dir_email_directory_timestamp']) . ' AND ' : '') : '') . 
								(isset($params['filter_fop_mail_host_box_dir_email_directory_timestamp']) ? ($params['filter_fop_mail_host_box_dir_email_directory_timestamp'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_timestamp']))->toSQL('t.'.qi('timestamp').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_box_dir_email_directory_senderDisplay']) ? ($params['filter_fop_mail_host_box_dir_email_directory_senderDisplay'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_senderDisplay']))->toSQL('t.'.qi('senderDisplay').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_box_dir_email_directory_senderEmail']) ? ($params['filter_fop_mail_host_box_dir_email_directory_senderEmail'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_senderEmail']))->toSQL('t.'.qi('senderEmail').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_box_dir_email_directory_recipient']) ? ($params['filter_fop_mail_host_box_dir_email_directory_recipient'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_recipient']))->toSQL('t.'.qi('recipient').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_box_dir_email_directory_hasAttachments']) ? ($params['filter_fop_mail_host_box_dir_email_directory_hasAttachments'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_hasAttachments']))->toSQL('t.'.qi('hasAttachments').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_box_dir_email_directory_subject']) ? ($params['filter_fop_mail_host_box_dir_email_directory_subject'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_subject']))->toSQL('t.'.qi('subject').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_box_dir_email_directory_content']) ? ($params['filter_fop_mail_host_box_dir_email_directory_content'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_content']))->toSQL('t.'.qi('content').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_box_dir_email_directory_directory']) ? ($params['filter_fop_mail_host_box_dir_email_directory_directory'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_directory']))->toSQL('t.'.qi('directory').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_box_dir_email_directory_seen']) ? ($params['filter_fop_mail_host_box_dir_email_directory_seen'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_seen']))->toSQL('t.'.qi('seen').'') . ') AND ') : '') : '') . 
								(isset($params['filter_fop_mail_host_box_dir_email_directory_ID']) ? ($params['filter_fop_mail_host_box_dir_email_directory_ID'] !== '' ? ('(' . (new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_ID']))->toSQL('t.'.qi('ID').'') . ') AND ') : '') : '') . 
								(isset($params['search_fop_mail_host_box_dir_email_directory_senderDisplay']) ? 't.'.qi('senderDisplay').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_box_dir_email_directory_senderDisplay'] . '%') . ' AND ' : '') . 
								(isset($params['search_fop_mail_host_box_dir_email_directory_senderEmail']) ? 't.'.qi('senderEmail').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_box_dir_email_directory_senderEmail'] . '%') . ' AND ' : '') . 
								(isset($params['search_fop_mail_host_box_dir_email_directory_recipient']) ? 't.'.qi('recipient').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_box_dir_email_directory_recipient'] . '%') . ' AND ' : '') . 
								(isset($params['search_fop_mail_host_box_dir_email_directory_subject']) ? 't.'.qi('subject').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_box_dir_email_directory_subject'] . '%') . ' AND ' : '') . 
								(isset($params['search_fop_mail_host_box_dir_email_directory_content']) ? 't.'.qi('content').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_box_dir_email_directory_content'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_fop_mail_host_box_dir_email_directory_senderDisplay']) ? 'NOT t.'.qi('senderDisplay').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_fop_mail_host_box_dir_email_directory_senderDisplay'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_fop_mail_host_box_dir_email_directory_senderEmail']) ? 'NOT t.'.qi('senderEmail').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_fop_mail_host_box_dir_email_directory_senderEmail'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_fop_mail_host_box_dir_email_directory_recipient']) ? 'NOT t.'.qi('recipient').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_fop_mail_host_box_dir_email_directory_recipient'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_fop_mail_host_box_dir_email_directory_subject']) ? 'NOT t.'.qi('subject').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_fop_mail_host_box_dir_email_directory_subject'] . '%') . ' AND ' : '') . 
								(isset($params['searchnot_fop_mail_host_box_dir_email_directory_content']) ? 'NOT t.'.qi('content').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['searchnot_fop_mail_host_box_dir_email_directory_content'] . '%') . ' AND ' : '') . 
								(isset($params['search_fop_mail_host_box_dir_email_directory']) ? '(' . 't.'.qi('senderDisplay').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_box_dir_email_directory'] . '%') . ' OR ' . 't.'.qi('senderEmail').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_box_dir_email_directory'] . '%') . ' OR ' . 't.'.qi('recipient').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_box_dir_email_directory'] . '%') . ' OR ' . 't.'.qi('subject').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_box_dir_email_directory'] . '%') . ' OR ' . 't.'.qi('content').' '.(\FOP\Database::getDriver() == 'pgsql' ? 'ILIKE' : 'LIKE').' ' . \FOP\Database::quote('%' . $params['search_fop_mail_host_box_dir_email_directory'] . '%') . ') AND ' : '') . 
								'
								 TRUE ';
								return $sql;
	
    
  }

  public static function getidsAction($col, $id) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
			$q = \FOP\Database::query('SELECT t.'.qi($col).' '.self::getSQL($_GET, $id));
			$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 (('.\FOP\Database::quote(\FOP\User::getIsLoggedIn()).') AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('p0EDqmbn').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('p0EDqmbn').' WHERE '.qi('p0EDqmbn').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE))) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('delete_mails').', SUM(CASE (('.\FOP\Database::quote(\FOP\User::getIsLoggedIn()).') AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('p0EDqmbn').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('p0EDqmbn').' WHERE '.qi('p0EDqmbn').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE))) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('spam_mails').', SUM(CASE (('.\FOP\Database::quote(\FOP\User::getIsLoggedIn()).') AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('p0EDqmbn').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('p0EDqmbn').' WHERE '.qi('p0EDqmbn').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE))) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('flag_mails').', 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 ((FALSE) AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('FTZDyDjf').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('FTZDyDjf').' WHERE '.qi('FTZDyDjf').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE))) WHEN TRUE THEN 1 ELSE 0 END) AS '.qi('delete').' FROM '.qi('fop_mail_host_box_dir_email').' WHERE ' . $ids->toSQL(qi('ID')))->fetch(\PDO::FETCH_ASSOC);
		
		return $perms;
	
    
  }

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

    
  }

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

								$order = (\FOP\Util::array_value(array(
									'senderEmail ASC' => 'ORDER BY t.'.qi('senderEmail').' ASC',
									'content ASC' => 'ORDER BY t.'.qi('content').' ASC',
									'senderDisplay ASC' => 'ORDER BY t.'.qi('senderDisplay').' ASC',
									'recipient ASC' => 'ORDER BY t.'.qi('recipient').' ASC',
									'subject ASC' => 'ORDER BY t.'.qi('subject').' ASC',
									'timestamp ASC' => 'ORDER BY t.'.qi('timestamp').' ASC',
									'senderEmail DESC' => 'ORDER BY t.'.qi('senderEmail').' DESC',
									'content DESC' => 'ORDER BY t.'.qi('content').' DESC',
									'senderDisplay DESC' => 'ORDER BY t.'.qi('senderDisplay').' DESC',
									'recipient DESC' => 'ORDER BY t.'.qi('recipient').' DESC',
									'subject DESC' => 'ORDER BY t.'.qi('subject').' DESC',
									'timestamp DESC' => 'ORDER BY t.'.qi('timestamp').' DESC',
									'' => ''), isset($params['sort_fop_mail_host_box_dir_email_directory']) ? $params['sort_fop_mail_host_box_dir_email_directory'] : '') ?: 'ORDER BY '.qi('t').'.'.qi('timestamp').' DESC');
								// 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['timestamp'] = intval($item['timestamp']);
											$item['senderEmail'] = \FOP\Sanitizers::a_text($item['senderEmail']);
											$item['directory'] = \FOP\Sanitizers::null_converter($item['directory']);
											$item['seen'] = \FOP\Util::BoolSanitizer($item['seen']);
											
											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['timestamp'] = intval($item['timestamp']);
										$item['senderEmail'] = \FOP\Sanitizers::a_text($item['senderEmail']);
										$item['directory'] = \FOP\Sanitizers::null_converter($item['directory']);
										$item['seen'] = \FOP\Util::BoolSanitizer($item['seen']);
										
									}
									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 ( // Corner Case: Monat
		isset($params['range_min_fop_mail_host_box_dir_email_directory_timestamp'])
		&& isset($params['range_max_fop_mail_host_box_dir_email_directory_timestamp'])
		&& (date('d', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) == '01') //check first day of month
		&& (date('d', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp']) == date('t', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp'])) //check last day of month
		&& (date('Y-m', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) == date('Y-m', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp'])) //check if same year and month
	) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('first day of last month', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				query[&apos;range_max_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('last day of last month', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				reloadfop_mail_host_box_dir_email_directory(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('first day of next month', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				query[&apos;range_max_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('last day of next month', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				reloadfop_mail_host_box_dir_email_directory(); ">add_circle_outline</i>' : ''),
			htmlentities(_('receivedat') . ': ' . strftime('%B', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) . ' ' . date('Y', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']))
		]);
	} else if ( // Corner Case: Tag
		isset($params['range_min_fop_mail_host_box_dir_email_directory_timestamp'])
		&& isset($params['range_max_fop_mail_host_box_dir_email_directory_timestamp'])
		&& (date('Y-m-d', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) == (date('Y-m-d', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp'])))
	) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('last day', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				query[&apos;range_max_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('last day', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				reloadfop_mail_host_box_dir_email_directory(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('next day', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				query[&apos;range_max_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('next day', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				reloadfop_mail_host_box_dir_email_directory(); ">add_circle_outline</i>' : ''),
			htmlentities(_('receivedat') . ': ' . date('d.m.Y', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']))
		]);
	} else if ( // Corner Case: Jahr
		isset($params['range_min_fop_mail_host_box_dir_email_directory_timestamp'])
		&& isset($params['range_max_fop_mail_host_box_dir_email_directory_timestamp'])
		&& (date('Y', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) == (date('Y', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp'])))
		&& ((date('m-d', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) == '01-01'))
		&& ((date('m-d', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp']) == '12-31'))
	) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('first day of January last year', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				query[&apos;range_max_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('last day of December last year', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				reloadfop_mail_host_box_dir_email_directory(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('first day of January next year', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				query[&apos;range_max_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('last day of December next year', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				reloadfop_mail_host_box_dir_email_directory(); ">add_circle_outline</i>' : ''),
			htmlentities(_('receivedat') . ': ' . date('Y', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']))
		]);
	} else if ( // Corner Case: Quartal
		isset($params['range_min_fop_mail_host_box_dir_email_directory_timestamp'])
		&& isset($params['range_max_fop_mail_host_box_dir_email_directory_timestamp'])
		&& ( (
		 ((date('m-d', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) == '01-01'))
		&& ((date('m-d', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp']) == '03-31')) )
		|| (
		 ((date('m-d', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) == '04-01'))
		&& ((date('m-d', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp']) == '06-30')) )
		|| (
		 ((date('m-d', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) == '07-01'))
		&& ((date('m-d', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp']) == '09-30')) )
		|| (
		 ((date('m-d', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) == '10-01'))
		&& ((date('m-d', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp']) == '12-31')) )
	) ) {
		array_push($filters, [
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
					query[&apos;range_min_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('first day of -3 months', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
					query[&apos;range_max_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('last day of -3 months', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
					reloadfop_mail_host_box_dir_email_directory(); ">remove_circle_outline</i>' : ''),
			($showButton ? '<i class="material-icons fop-small" style="cursor: pointer;" onclick="
				query[&apos;range_min_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('first day of +3 months', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				query[&apos;range_max_fop_mail_host_box_dir_email_directory_timestamp&apos;] = &apos;'.strtotime('last day of +3 months', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp']).'&apos;;
				reloadfop_mail_host_box_dir_email_directory(); ">add_circle_outline</i>' : ''),	
			htmlentities(_('receivedat') . ': Q' . (ceil((date('m', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']))/3)) . ' (' . date('d.m.', $params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) . ' - ' . date('d.m.Y', $params['range_max_fop_mail_host_box_dir_email_directory_timestamp']) . ')')
		]);
	}
	else if (isset($params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) && isset($params['range_max_fop_mail_host_box_dir_email_directory_timestamp'])) {
		array_push($filters, _('receivedat') . ': ' . (($params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) ? strftime(_('datetimeformat_php2'), intval($params['range_min_fop_mail_host_box_dir_email_directory_timestamp'])) : '') . ' ' . _('filters_between') . ' ' . (($params['range_max_fop_mail_host_box_dir_email_directory_timestamp']) ? strftime(_('datetimeformat_php2'), intval($params['range_max_fop_mail_host_box_dir_email_directory_timestamp'])) : ''));
	} else if (isset($params['range_min_fop_mail_host_box_dir_email_directory_timestamp'])) {
		array_push($filters, _('receivedat') . ': ' . _('filters_from') . ' ' . (($params['range_min_fop_mail_host_box_dir_email_directory_timestamp']) ? strftime(_('datetimeformat_php2'), intval($params['range_min_fop_mail_host_box_dir_email_directory_timestamp'])) : ''));
	} else if (isset($params['range_max_fop_mail_host_box_dir_email_directory_timestamp'])) {
		array_push($filters, _('receivedat') . ': ' . _('filters_to') . ' ' . (($params['range_max_fop_mail_host_box_dir_email_directory_timestamp']) ? strftime(_('datetimeformat_php2'), intval($params['range_max_fop_mail_host_box_dir_email_directory_timestamp'])) : ''));
	}if (isset($params['filter_fop_mail_host_box_dir_email_directory_timestamp'])) {
		if ($params['filter_fop_mail_host_box_dir_email_directory_timestamp'] == '_null') {
			array_push($filters, _('receivedat') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_timestamp']))->all() AS $val) {
				$value = ($val) ? strftime(_('datetimeformat_php2'), intval($val)) : '';
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('receivedat') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_box_dir_email_directory_senderDisplay'])) {
		if ($params['filter_fop_mail_host_box_dir_email_directory_senderDisplay'] == '_null') {
			array_push($filters, _('senderdisplay') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_senderDisplay']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('senderdisplay') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_box_dir_email_directory_senderEmail'])) {
		if ($params['filter_fop_mail_host_box_dir_email_directory_senderEmail'] == '_null') {
			array_push($filters, _('sender') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_senderEmail']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('sender') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_box_dir_email_directory_recipient'])) {
		if ($params['filter_fop_mail_host_box_dir_email_directory_recipient'] == '_null') {
			array_push($filters, _('recipient') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_recipient']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('recipient') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_box_dir_email_directory_hasAttachments'])) {
		if ($params['filter_fop_mail_host_box_dir_email_directory_hasAttachments'] == '_null') {
			array_push($filters, _('📎') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_hasAttachments']))->all() AS $val) {
				$value = \Types\FopemailhasAttachments::toIcon($val);
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('📎') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_box_dir_email_directory_subject'])) {
		if ($params['filter_fop_mail_host_box_dir_email_directory_subject'] == '_null') {
			array_push($filters, _('subject') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_subject']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('subject') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_box_dir_email_directory_content'])) {
		if ($params['filter_fop_mail_host_box_dir_email_directory_content'] == '_null') {
			array_push($filters, _('content') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_content']))->all() AS $val) {
				$value = mb_substr(preg_replace('/[ \t\r\n]+/', ' ', strip_tags(preg_replace('/<style.*?\/style>/s', '', html_entity_decode($val)))), 0, 20) . (strlen($val) >= 20 ? '...' : '');
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('content') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_box_dir_email_directory_seen'])) {
		if ($params['filter_fop_mail_host_box_dir_email_directory_seen'] == '_null') {
			array_push($filters, _('seen') . ': ' . 'NULL');
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_seen']))->all() AS $val) {
				$value = $val;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('seen') . ': ' . implode(', ', $values));
		}
	}if (isset($params['filter_fop_mail_host_box_dir_email_directory_directory'])) {
		if ($params['filter_fop_mail_host_box_dir_email_directory_directory'] == '_null') {
			array_push($filters, _('directory') . ': ' . _(''));
		} else {
			$values = [];
			foreach ((new \FOP\IDList($params['filter_fop_mail_host_box_dir_email_directory_directory']))->all() AS $val) {
				$value = 
  \FOP\Database::query('SELECT CONCAT('.qi('fop_mail_host_box_dir').'.'.qi('name').', \' - \', (SELECT ('.qi('tcayeuX5').'.'.qi('from_address').') FROM '.qi('fop_mail_host_box').' '.qi('tcayeuX5').' WHERE '.qi('tcayeuX5').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir').'.'.qi('mailbox').' LIMIT 1)) AS description FROM '.qi('fop_mail_host_box_dir').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($val))->fetchColumn() ?: _('')
;
				if ($value) array_push($values, $value);
			}
			array_push($filters, _('directory') . ': ' . implode(', ', $values));
		}
	}if (isset($params['search_fop_mail_host_box_dir_email_directory_senderDisplay'])) {
		array_push($filters, _('senderDisplay') . ' ' . _('filter_contains') . ' ' . $params['search_fop_mail_host_box_dir_email_directory_senderDisplay']);
	}if (isset($params['search_fop_mail_host_box_dir_email_directory_senderEmail'])) {
		array_push($filters, _('senderEmail') . ' ' . _('filter_contains') . ' ' . $params['search_fop_mail_host_box_dir_email_directory_senderEmail']);
	}if (isset($params['search_fop_mail_host_box_dir_email_directory_recipient'])) {
		array_push($filters, _('recipient') . ' ' . _('filter_contains') . ' ' . $params['search_fop_mail_host_box_dir_email_directory_recipient']);
	}if (isset($params['search_fop_mail_host_box_dir_email_directory_subject'])) {
		array_push($filters, _('subject') . ' ' . _('filter_contains') . ' ' . $params['search_fop_mail_host_box_dir_email_directory_subject']);
	}if (isset($params['search_fop_mail_host_box_dir_email_directory_content'])) {
		array_push($filters, _('content') . ' ' . _('filter_contains') . ' ' . $params['search_fop_mail_host_box_dir_email_directory_content']);
	}if (isset($params['searchnot_fop_mail_host_box_dir_email_directory_senderDisplay'])) {
		array_push($filters, _('senderDisplay') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_fop_mail_host_box_dir_email_directory_senderDisplay']);
	}if (isset($params['searchnot_fop_mail_host_box_dir_email_directory_senderEmail'])) {
		array_push($filters, _('senderEmail') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_fop_mail_host_box_dir_email_directory_senderEmail']);
	}if (isset($params['searchnot_fop_mail_host_box_dir_email_directory_recipient'])) {
		array_push($filters, _('recipient') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_fop_mail_host_box_dir_email_directory_recipient']);
	}if (isset($params['searchnot_fop_mail_host_box_dir_email_directory_subject'])) {
		array_push($filters, _('subject') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_fop_mail_host_box_dir_email_directory_subject']);
	}if (isset($params['searchnot_fop_mail_host_box_dir_email_directory_content'])) {
		array_push($filters, _('content') . ' ' . _('filter_contains_not') . ' ' . $params['searchnot_fop_mail_host_box_dir_email_directory_content']);
	}
		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_box_dir_email_directory_\')) delete query[q];} reloadfop_mail_host_box_dir_email_directory(); ">clear</i>' : '');
		} else {
			$result = _('no_filter');
		}
		return $result;
	
    
  }

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

if ($fop_table == 'fop_mail_host_box_dir_email') {
	\FOP\Session::setPayload('dv-fop_mail_host_box_dir_email', [
		'id' => 'fop_mail_host_box_dir_email_directory',
		'tbl' => 'fop_mail_host_box_dir_email',
		'idcol' => 'ID',
		'prev' => \DataViewRouter\Fop_mail_host_box_dir_email_directory::stepURL('fop_mail_host_box_dir_email', 'XXX', -1),
		'next' => \DataViewRouter\Fop_mail_host_box_dir_email_directory::stepURL('fop_mail_host_box_dir_email', 'XXX',  1),
		'from' => $fop_from,
		'param_id' => $id
	]);
	
	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_box_dir_email::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, $dv['param_id']);
	$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();

    
  }


  
  

  
  
}



