<?php

namespace Tables;

class Doc {
  
  

  
  

    // --- Statische Methoden ---
  
  public static function getDefaults() { 
    
    
    // --- BLOCK: main ---
    
	// erstellt ein leeres Objekt zum Befüllen mit Daten oder als Default fürs Create-Formular
	$data = ['type' => \Tables\Doc::getDefaultDoctype(),
		'date' => time(),
		'subject' => '',
		'notes' => '',
		'to-mitglied' => null,
		'to-protokoll' => null,
		'to-gruppe' => null,
		'archive' => FALSE];
	return $data;
	
    
  }

  public static function getDefaultDoctype() { 
    
    
    // --- BLOCK: main ---
    return \FOP\Configuration::getTablesDocDefaultDoctype();
    
  }

  public static function fastuploadAction() { 
    
    
    // --- BLOCK: 0_CSRFValidate ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') \FOP\Session::validateCSRFToken(); else \FOP\Session::getCSRFToken();

    // --- BLOCK: 0_CSRF_ensure ---
    
	\FOP\Session::getCSRFToken();
    // --- BLOCK: access ---
    if(!(((\FOP\User::getDokument())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		
		/* Validatoren */
		
		\FOP\Files::validate($_POST['file']);

		
		/* Sanitizer */

		$_POST['file'] = \FOP\Files::sanitizeUpload($_POST['file']);

		
	}
	
    // --- BLOCK: main ---
    
		// Main block
	
    // --- BLOCK: main-1 ---
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		if (true) {
			\FOP\Database::beginTransaction();
    // --- BLOCK: main-2:save-main ---
    
		$defaults = \Tables\Doc::getDefaults();
		$defaults['file'] = $_POST['file'];
		// TableItemAccess für PHP auswerten
		if (!((\FOP\User::getDokument()) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) : (true)) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) : (true)) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-protokoll']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-protokoll']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-protokoll']) . '')->fetchColumn()))) : (true)) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) : (true)) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-gruppe']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-gruppe']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-gruppe']) . '')->fetchColumn()))) : (true)))) throw new \FOP\AccessDeniedException('accessdenied');
		$id = \Tables\Doc::create($defaults);
	
    // --- BLOCK: main-3 ---
    
			\FOP\Database::commitTransaction();
			
		}
		
		if (isset($_POST['upload'])) {
			
			
			if (isset($_POST['fop-from']) && $_POST['fop-from']) {
				// Redirect zu fop-from
				header('Location: ' . (isset($id) && is_string($id) ? preg_replace('/&insert_param=(.*)$/', '&$1=' . ($id instanceof \FOP\IDList ? $id->toString() : $id), $_POST['fop-from']) : $_POST['fop-from']));
			} else {
				header('Location: ' . \FOPRouter\Index::indexURL2(['popup' => $_GET['popup'] ?? null]) . '#snack:' . (_('Upload erfolgreich')));
			}
			die();
	
		}
		die(json_encode($_POST));
	} else {
    // --- BLOCK: main-4:load-main ---
    
		$data = \Tables\Doc::getDefaults();
	
    // --- BLOCK: main-4:load-main-init-file ---
    $data['file'] = NULL;
	
    // --- BLOCK: main-4:load-~sanitize ---
    
		\Tables\Doc::sanitizeDefaults($data, true);
	
    // --- BLOCK: main-5 ---
    ?><?php
			header('Content-Type: text/html; charset=UTF-8');
			header('X-XSS-Protection: 1; mode=block');
			header('Strict-Transport-Security: max-age=63072000');
			header('X-Content-Type-Options: nosniff');
			header("Content-Security-Policy: default-src *  data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';");


		?><!DOCTYPE html><html><head><title><?php echo(_('Schnell-Upload')); ?></title><base href='<?php echo \FOP\Util::getCurrentBaseurl(); ?>'><meta name="google" content="notranslate"><meta http-equiv="Content-Language" content="<?php echo htmlentities(\FOP\I18n::getLocale()); ?>"><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="style_dependencies.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><link rel="stylesheet" type="text/css" href="style.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><script type="text/javascript" src="js/script_dependencies.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="mobile-web-app-capable" content="yes"><link rel="manifest" href="manifest.webmanifest"><script type="text/javascript">moment.locale('<?php echo(\FOP\I18n::getShortLocale()); ?>');</script><script type="text/javascript" src="js/form.js"></script><script type="text/javascript">window.globals = <?php
	echo json_encode(['user:superadmin' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSuperadmin(), 'user:mitglied' => /* TODO: resanitizer später mal */(integer) \FOP\User::getMitglied(), 'user:gruppe' => /* TODO: resanitizer später mal */(integer) \FOP\User::getGruppe(), 'user:campaign' => /* TODO: resanitizer später mal */(integer) \FOP\User::getCampaign(), 'user:sammlung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSammlung(), 'user:protokoll' => /* TODO: resanitizer später mal */(integer) \FOP\User::getProtokoll(), 'user:ID' => /* TODO: resanitizer später mal */(integer) \FOP\User::getID(), 'user:buchhaltung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getBuchhaltung()]);
?>;</script><script type="text/javascript" src="angular/<?php echo(\FOP\I18n::getShortLocale()); ?>/js/alltypes.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><script type="text/javascript" src="angular/angular-i18n/angular-locale_<?php echo \FOP\I18n::getAngularLocale(); ?>.js"></script><script type="text/javascript" src="js/date-filter.js"></script><script type="text/javascript" src="js/dropdown.js"></script><script type="text/javascript" src="js/numeric.js"></script><script type="text/javascript" src="js/getparam.js"></script><script type="text/javascript" src="js/tables.js"></script>
		<script type="text/javascript" src="js/parsehash.js"></script><script type="text/javascript">
		window.query = <?php echo json_encode($_GET, JSON_FORCE_OBJECT); ?>;
		window.baseurl = <?php echo json_encode(\FOP\Util::getCurrentBaseurl()); ?>;

		window.i18n_weiter = <?php echo json_encode(_('Weiter'));?>;
		//Filter I18n:
		window.i18n_quartal = <?php echo json_encode(_('Quarter'));?>;
		window.i18n_alle = <?php echo json_encode(_('All'));?>;
		window.i18n_leere = <?php echo json_encode(_('Empty'));?>;
		window.i18n_tag = <?php echo json_encode(_('Tag'));?>;
		window.i18n_woche = <?php echo json_encode(_('Woche'));?>;
		window.i18n_zeitraum = <?php echo json_encode(_('Period'));?>;
		window.i18n_monat = <?php echo json_encode(_('Monat'));?>;
		window.i18n_jahr = <?php echo json_encode(_('Jahr'));?>;
		window.i18n_von = <?php echo json_encode(_('filters_from'));?>;
		window.i18n_bis = <?php echo json_encode(_('filters_to'));?>;
		window.i18n_tabButton = <?php echo json_encode(_('open_in_new_tab'));?>;
		window.i18n_closeButton = <?php echo json_encode(_('close'));?>;
		</script></head><script type="text/javascript">const fopPushPublicKey = '<?php echo(addslashes(\FOP\Configuration::getFOPPushPublicKey())); ?>';
        const fopUserID = <?php echo(intval(\FOP\User::getID())); ?>;
        var fopPushDisabled = false;
    </script><script type="text/javascript" src="js/serviceworkersetup.js"></script><body ng-app='app'>
		<div class='mdl-js-snackbar mdl-snackbar' id='snackbar'>
			<div class='mdl-snackbar__text'></div>
			<button class='mdl-snackbar__action' type='button'></button>
		</div>
		<script>
			var snackbar = document.querySelector('#snackbar');
			componentHandler.upgradeElement(snackbar, 'MaterialSnackbar');
			$(function () {
				setTimeout(function () {
					$('.fop-layout').scrollTop(0);
				}, 0);
			});
		</script>

		<?php if (isset($_GET['popup'])) { ?>
		<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo(_('Schnell-Upload')); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      	</header>
			<style>
				.content {
					margin-top: 0px !important;
				}
			</style>
			<div id='content' class='popup' >
		<?php } else { ?>
			<div class="fop-layout mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
			<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo(_('Schnell-Upload')); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      		</header>


				<?php  \EasyEditor\Navigation::render(); ?>
      
				<main class="mdl-layout__content" id="content">
					<div class="fop-content">
						<?php } ?>
						
							<div class="content" id="1">
								

								<form
									
									action="<?php echo \TablesRouter\Doc::fastuploadURL2(['popup' => $_GET['popup'] ?? null]); ?>"
									method="post"
									enctype="multipart/form-data" ng-submit='submit($event)'
									onsubmit="
										if (window.running_uploads) {
											event.preventDefault();
											alert('<?php echo htmlentities(json_encode(_('fileUploadStillActive')));?>');
										}
									"
								 
								id="cardform-wf_doc_fastupload"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_doc_fastupload" ng-init="form = <?php echo htmlentities(json_encode([]));
									?>;"
								>
								<?php
								 echo '<input type="hidden" name="csrftoken" value="' . htmlentities(\FOP\Session::getCSRFToken()) . '">';
								 if (isset($_GET['from'])) echo '<input type="hidden" name="fop-from" value="' . htmlentities($_GET['from']) . '">';
								 ?>
								<div id='fop-upbar'></div>
								
									<?php
									$features = [];
									if (true && (true)) {
									$feature = [
										'id' => 'buttons',
										'title' => _('Aktionen'),
										'order' => '300', // 300 (50)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => false,
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || true)) {
									$feature = [
										'id' => 'main',
										'title' => _('Daten'),
										'order' => '100', // 100 (20)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => false,
										'visibility' => '0' .'||'. (true ? 'true' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									

									
									$upbar_collapsed = (bool) \FOP\Database::query('SELECT '.qi('value').' FROM fop_form_feature a WHERE subid = \'upbar\' AND '.qi('key').' = \'collapsed\' AND form = \'wf:doc:fastupload\' AND '.qi('user').' = '.intval(\FOP\User::getID()).'')->fetch(\PDO::FETCH_COLUMN);
									

									/* fill in the content of the features */
									if (true && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['buttons']);
										?><div id='wf_doc_fastupload_buttons' class='mdl-cell mdl-cell--12-col' style='flex-wrap: wrap;'><?php if (true) { ?><button onclick="
		var errors = $(this).closest('form').find('.fop-form-error:visible, .is-invalid').filter((i, x) => $(x).parents('.novalidate').length ? false : true);
		if (errors.length) {
			event.preventDefault();
			alert(errors.closest('.fop-form-content').prev('.fop-form-label').text() + ' Es sind noch Fehler im Formular bei Feld');
			return;
		} /* TODO: i18n */
		
	" type="submit" name="upload" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">cloud_upload</i><?php echo(_('Upload')); ?></button><?php } ?>
									</div><script type='text/javascript'>
		// copy all buttons to #fop-upbar
		$(function () {
    var btn = document.getElementById("fop-bar-mainbutton");
    var upbar = $('#fop-upbar');
    var upbar_buttons = document.getElementById("fop-bar-container");

    // Check if the elements already exist
    if (!btn || !upbar_buttons) {
        if (!btn) {
            btn = $('<div id="fop-bar-mainbutton" class="mdl-button fop-button-half fop-button-margin mdl-button--raised"><i class="material-icons">keyboard_arrow_right</i></div>')
                .click(function () {
                    if (btn.find('i').text() == 'keyboard_arrow_right') {
                        upbar_buttons.fadeOut(400);
                        btn.find('i').text('keyboard_arrow_left');
                    } else {
                        upbar_buttons.fadeIn(400);
                        btn.find('i').text('keyboard_arrow_right');
                    }
                });
            upbar.append(btn);
        }

        if (!upbar_buttons) {
            upbar_buttons = $('<div id="fop-bar-container" style="max-width: 290px"></div>'); //dependant on the mdl-buttons width, caps of upbar buttons at exactly 4 buttons
            upbar.append(upbar_buttons);
        }

        var buttons = $('#wf_doc_fastupload_buttons').find('.mdl-button');
        buttons.each(function (i, v) {
            var button = $(v);
            var newbutton = $('<div></div>');
            newbutton.attr('class', button.attr('class'));
            newbutton.attr('title', button.attr('title'));
            newbutton.append(button.find('.material-icons').clone(false));
            newbutton.click(function () {
                button[0].click();
            });
            upbar_buttons.append(newbutton);
        });
    }
});

	</script><?php
										\EasyEditor\FormFeature::pop();
										$features['buttons']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main']);
										?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_file" id="column_file">
		<!-- Feld "file": file -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="file"><?php echo(_('file')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		

	
		<div>

<?php
       $maxupload =  \FOP\Util::convertIniBytes(ini_get('upload_max_filesize'));

?>
<div class="fop-file-upload dropzone dropzone-file" id="zone<?php echo htmlentities(\FOP\Files::getNextDummyCounter($data['file'])); ?>"
<?php if ($data['file']) {
						$fileInfo = \FOP\Database::query('SELECT filename AS name, size FROM fop_files WHERE '.qi('ID').' = ' . \FOP\Database::quote($data['file']))->fetch(\PDO::FETCH_ASSOC);
						$fileInfo['accepted'] = true;
						echo ' data-fileinfo="' . htmlentities(json_encode($fileInfo)) . '"';
}
					?>>
  <div class="dz-message"><?php echo(_('dropfiles')); ?></div>
  <input type="hidden" class="fileinput" name="file" value="<?php echo htmlentities(\FOP\Files::getLastDummyCounter($data['file'])); ?>">
</div>


<script>
	Dropzone.autoDiscover = false;
   $(function (){
	   $('.dropzone-file').each(function(){
			var dropzoneElement = this;
		   if ($(this).attr('data-dropzone-attached')) return;
		   $(this).attr('data-dropzone-attached', true);

		   let dummycounter = $(dropzoneElement).find('input').val();
		   let zone = this;

		   $(this).dropzone({
				maxFiles: 1,
				addRemoveLinks: true,
				paramName: 'file_' + dummycounter,
				url: 'FOP/Files/upload?x=' + dummycounter,
				maxFilesize: <?php echo \FOP\Util::convertIniBytes(ini_get('upload_max_filesize')); ?> / 1000 / 1000,
				timeout: 30*60*1000,

				dictDefaultMessage: '<?php echo(addslashes(_('dropfiles'))) ?>',
				dictFallbackMessage: '<?php echo(addslashes(_('dropfiles_notpossible'))) ?>',
				dictFileTooBig: '<?php echo(addslashes(_('dropfiles_toobig'))) ?>',
				dictInvalidFileType: '<?php echo(addslashes(_('dropfiles_invalidtype'))) ?>',
				dictResponseError: '<?php echo(addslashes(_('dropfiles_responseerror'))) ?>',
				dictCancelUpload: '<?php echo(addslashes(_('dropfiles_cancelupload'))) ?>',
				dictUploadCanceled: '<?php echo(addslashes(_('dropfiles_uploadcanceled'))) ?>',
				dictCancelUploadConfirmation: '<?php echo(addslashes(_('dropfiles_cancelupload_confirmation'))) ?>',
				dictRemoveFile: '<?php echo(addslashes(_('dropfiles_removefile'))) ?>',
				dictRemoveFileConfirmation: '<?php echo(addslashes(_('dropfiles_removefile_confirmation'))) ?>',

				init: function(){
					let prevfile = null;
					let self = this;

					// Datei anzeigen, die schon hochgeladen wurde
					if (dropzoneElement.dataset['fileinfo']) {
						let f = JSON.parse(dropzoneElement.dataset['fileinfo']);
						self.files.push(f);
						self.emit('addedfile', f);
						self.emit('complete', f);
						prevfile = f;
					}

					/* keep track of uploads */
					this.on('sending', function () {
						window.running_uploads = (window.running_uploads || 0) + 1;
					});
					this.on('complete', function () {
						window.running_uploads = (window.running_uploads || 0) - 1;
					});
					
					
						this.on('addedfile', function() {
							if (prevfile) self.removeFile(prevfile);
						});

						this.on('success', function(file, file_id) {
							prevfile = file;
							file.file_id = file_id;
							$(zone).find('.fileinput').val(file_id);
						});

						this.on('removedfile', function(file) {
							$(zone).find('.fileinput').val('0');
						});
					
				}
		   });
	   });
    });
				</script>
		</div>
		
	</div>
	</div><?php
										\EasyEditor\FormFeature::pop();
										$features['main']['html'] = ob_get_contents();
										ob_end_clean();
									}
									

									uasort($features, function ($a, $b) {
										return strnatcmp($a['order'], $b['order']);
									});
									foreach ($features AS $feature) {
										\EasyEditor\FormFeature::render($feature);
									}
									?><script type='text/javascript'>
										$(function(){
											// bei Änderungen: prüfen, ob Form geändert wurde
											var formData = $('#cardform-wf_doc_fastupload').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-wf_doc_fastupload').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-wf_doc_fastupload').on('submit', function () {
												document.body.onbeforeunload = undefined;
											});
											<?php if ($upbar_collapsed) {
												?>$('#fop-bar-mainbutton').click();<?php
											} ?>
											$('#fop-bar-mainbutton').click(function () {
												setTimeout(function () {
													setCFF('upbar', 'collapsed', $('#fop-bar-container').is(':visible') ? 0 : 1);
												}, 440); /* perfect timing for fadeOut */
											});
										});
										
										function setCFF(id, key, value) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFF?form=wf%3Adoc%3Afastupload&subid=' + encodeURIComponent(id) + '&key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value)).then(function () {
												if (key == 'reset') {
													location.reload();
												}
											});
											<?php } /* EditAccess */ ?>
										}
										function setCFFOrder(fids) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFFOrder?form=wf%3Adoc%3Afastupload&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_doc_fastupload')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_doc_fastupload input[type!="hidden"],textarea,select[tabindex!="-1"]').not('.fop-disabled *').filter(':visible:first').focus().select();
											}
										});

										$(window).keydown(function(event) {
											 if (event.ctrlKey && String.fromCharCode(event.which).toLowerCase() == 's') {
												 event.preventDefault();
												 $('button[type=submit]').click();
												 return false;
											 }
										});

										
										$(document).on('keyup',function(evt) {
										   if (evt.keyCode == 27) {
												if (window.parent) {
													window.close(); // iframe:close
												} else {
													window.history.back();
												}
											}
												});
										
									</script>

							</form>
							

							</div>
							<div class="content" id="focus-supersearch">
							</div>
							<div class="content" id="~spacer"><?php if (!isset($_GET['popup'])) { ?><div style="padding-bottom: 10cm;"></div><?php } ?>
							</div>
						<?php if (!isset($_GET['popup'])) { ?>
					</div>
				</main>
				
			</div>
		<?php } else { ?></div><?php } ?>
<?php if (!isset($_GET['popup'])) { ?><div class='fop-seal'></div><?php } ?></body></html><?php
    // --- BLOCK: main-6 ---
    }
    
  }

  public static function mergeAction($id = null ) { 
    
    
    // --- BLOCK: 0_CSRFValidate ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') \FOP\Session::validateCSRFToken(); else \FOP\Session::getCSRFToken();

    // --- BLOCK: 0_CSRF_ensure ---
    
	\FOP\Session::getCSRFToken();
    // --- BLOCK: access ---
    if(!(!\FOP\User::getIsGuest())) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		
		/* Validatoren */
		
		if ((!isset($_POST['cancel']))) \Types\Doc::validate($_POST['olddoc']);

		
		/* Sanitizer */

		if ((!isset($_POST['cancel']))) $_POST['olddoc'] = \FOP\Sanitizers::null_filter($_POST['olddoc']);

		
	}
	
    // --- BLOCK: main ---
    
		// Main block
	
    // --- BLOCK: main-1 ---
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		if (!isset($_POST['cancel'])) {
			\FOP\Database::beginTransaction();
    // --- BLOCK: main-2:save-clone-prepare ---
    
		$data = self::view($id);
	
    // --- BLOCK: main-2:save-main ---
    /* view */
    // --- BLOCK: main-2:save-revisionSave ---
    
		\FOP\Database::query('UPDATE '.qi('doc_revision').' SET '.qi('doc').' = ' . intval($_POST['olddoc']) . ' WHERE '.qi('doc').' = ' . intval($id));
		self::delete($id, true); // disregard permissions
		$id = $_POST['olddoc'];
	
    // --- BLOCK: main-3 ---
    
			\FOP\Database::commitTransaction();
			
		}
		
		if (isset($_POST['cancel'])) {
			
			if (isset($_POST['fop-from']) && $_POST['fop-from']) {
				// Redirect zu fop-from
				header('Location: ' . preg_replace('/&insert_param=(.*)$/', '&$1=' . ($id instanceof \FOP\IDList ? $id->toString() : $id), $_POST['fop-from']));
			} else {
				header('Location: ' . \TablesRouter\Doc::viewURL2(['id' => $id, 'popup' => $_GET['popup'] ?? null]));
			}
			die();
	
		}
		if (isset($_POST['ok'])) {
			
			if (isset($_POST['fop-from']) && $_POST['fop-from']) {
				// Redirect zu fop-from
				header('Location: ' . preg_replace('/&insert_param=(.*)$/', '&$1=' . ($id instanceof \FOP\IDList ? $id->toString() : $id), $_POST['fop-from']));
			} else {
				header('Location: ' . \TablesRouter\Doc::viewURL2(['id' => $id, 'popup' => $_GET['popup'] ?? null]));
			}
			die();
	
		}
		die(json_encode($_POST));
	} else {
    // --- BLOCK: main-4:load-main ---
    
		$data = self::view($id); // TODO: klären, wer die Funktion bereitstellt (momentan crud/view.fop)
	
    // --- BLOCK: main-4:load-main-init-olddoc ---
    $data['olddoc'] = NULL;
	
    // --- BLOCK: main-5 ---
    ?><?php
			header('Content-Type: text/html; charset=UTF-8');
			header('X-XSS-Protection: 1; mode=block');
			header('Strict-Transport-Security: max-age=63072000');
			header('X-Content-Type-Options: nosniff');
			header("Content-Security-Policy: default-src *  data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';");


		?><!DOCTYPE html><html><head><title><?php echo(_('Duplikat/Version zusammenführen')); ?></title><base href='<?php echo \FOP\Util::getCurrentBaseurl(); ?>'><meta name="google" content="notranslate"><meta http-equiv="Content-Language" content="<?php echo htmlentities(\FOP\I18n::getLocale()); ?>"><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="style_dependencies.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><link rel="stylesheet" type="text/css" href="style.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><script type="text/javascript" src="js/script_dependencies.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="mobile-web-app-capable" content="yes"><link rel="manifest" href="manifest.webmanifest"><script type="text/javascript">moment.locale('<?php echo(\FOP\I18n::getShortLocale()); ?>');</script><script type="text/javascript" src="js/form.js"></script><script type="text/javascript">window.globals = <?php
	echo json_encode(['user:superadmin' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSuperadmin(), 'user:mitglied' => /* TODO: resanitizer später mal */(integer) \FOP\User::getMitglied(), 'user:gruppe' => /* TODO: resanitizer später mal */(integer) \FOP\User::getGruppe(), 'user:campaign' => /* TODO: resanitizer später mal */(integer) \FOP\User::getCampaign(), 'user:sammlung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSammlung(), 'user:protokoll' => /* TODO: resanitizer später mal */(integer) \FOP\User::getProtokoll(), 'user:ID' => /* TODO: resanitizer später mal */(integer) \FOP\User::getID(), 'user:buchhaltung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getBuchhaltung()]);
?>;</script><script type="text/javascript" src="angular/<?php echo(\FOP\I18n::getShortLocale()); ?>/js/alltypes.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><script type="text/javascript" src="angular/angular-i18n/angular-locale_<?php echo \FOP\I18n::getAngularLocale(); ?>.js"></script><script type="text/javascript" src="js/date-filter.js"></script><script type="text/javascript" src="js/dropdown.js"></script><script type="text/javascript" src="js/numeric.js"></script><script type="text/javascript" src="js/getparam.js"></script><script type="text/javascript" src="js/tables.js"></script>
		<script type="text/javascript" src="js/parsehash.js"></script><script type="text/javascript">
		window.query = <?php echo json_encode($_GET, JSON_FORCE_OBJECT); ?>;
		window.baseurl = <?php echo json_encode(\FOP\Util::getCurrentBaseurl()); ?>;

		window.i18n_weiter = <?php echo json_encode(_('Weiter'));?>;
		//Filter I18n:
		window.i18n_quartal = <?php echo json_encode(_('Quarter'));?>;
		window.i18n_alle = <?php echo json_encode(_('All'));?>;
		window.i18n_leere = <?php echo json_encode(_('Empty'));?>;
		window.i18n_tag = <?php echo json_encode(_('Tag'));?>;
		window.i18n_woche = <?php echo json_encode(_('Woche'));?>;
		window.i18n_zeitraum = <?php echo json_encode(_('Period'));?>;
		window.i18n_monat = <?php echo json_encode(_('Monat'));?>;
		window.i18n_jahr = <?php echo json_encode(_('Jahr'));?>;
		window.i18n_von = <?php echo json_encode(_('filters_from'));?>;
		window.i18n_bis = <?php echo json_encode(_('filters_to'));?>;
		window.i18n_tabButton = <?php echo json_encode(_('open_in_new_tab'));?>;
		window.i18n_closeButton = <?php echo json_encode(_('close'));?>;
		</script></head><script type="text/javascript">const fopPushPublicKey = '<?php echo(addslashes(\FOP\Configuration::getFOPPushPublicKey())); ?>';
        const fopUserID = <?php echo(intval(\FOP\User::getID())); ?>;
        var fopPushDisabled = false;
    </script><script type="text/javascript" src="js/serviceworkersetup.js"></script><body ng-app='app'>
		<div class='mdl-js-snackbar mdl-snackbar' id='snackbar'>
			<div class='mdl-snackbar__text'></div>
			<button class='mdl-snackbar__action' type='button'></button>
		</div>
		<script>
			var snackbar = document.querySelector('#snackbar');
			componentHandler.upgradeElement(snackbar, 'MaterialSnackbar');
			$(function () {
				setTimeout(function () {
					$('.fop-layout').scrollTop(0);
				}, 0);
			});
		</script>

		<?php if (isset($_GET['popup'])) { ?>
		<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<?php
	if ($dv = \FOP\Session::getPayload('dv-doc')) { ?>
	<?php if (isset($dv['prev'])) {?><a href="<?php echo htmlentities(str_replace('XXX', urlencode($id), $dv['prev'])); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">keyboard_arrow_left</i>
	</a><?php } ?>
	<a href="<?php echo htmlentities($dv['from']); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">view_list</i>
	</a>
	<?php if (isset($dv['next'])) {?><a href="<?php echo htmlentities(str_replace('XXX', urlencode($id), $dv['next'])); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">keyboard_arrow_right</i>
	</a><?php } ?><?php } ?><span class="mdl-layout-title"><?php echo(_('Duplikat/Version zusammenführen')); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      	</header>
			<style>
				.content {
					margin-top: 0px !important;
				}
			</style>
			<div id='content' class='popup' >
		<?php } else { ?>
			<div class="fop-layout mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
			<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<?php
	if ($dv = \FOP\Session::getPayload('dv-doc')) { ?>
	<?php if (isset($dv['prev'])) {?><a href="<?php echo htmlentities(str_replace('XXX', urlencode($id), $dv['prev'])); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">keyboard_arrow_left</i>
	</a><?php } ?>
	<a href="<?php echo htmlentities($dv['from']); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">view_list</i>
	</a>
	<?php if (isset($dv['next'])) {?><a href="<?php echo htmlentities(str_replace('XXX', urlencode($id), $dv['next'])); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">keyboard_arrow_right</i>
	</a><?php } ?><?php } ?><span class="mdl-layout-title"><?php echo(_('Duplikat/Version zusammenführen')); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      		</header>


				<?php  \EasyEditor\Navigation::render(); ?>
      
				<main class="mdl-layout__content" id="content">
					<div class="fop-content">
						<?php } ?>
						
							<div class="content" id="1">
								<?php if (\FOP\Database::query('SELECT '.qi('file').' FROM '.qi('doc_revision').' WHERE '.qi('doc').' = ' . \FOP\Database::quote($id) . ' ORDER BY created DESC')->fetchColumn()) { ?>
									<div class='mdl-grid form-document-container'>
										<div class='mdl-cell mdl-cell--6-col form-document'>
											<iframe style='width:100%;height:100%;' src='fop-files/<?php echo intval(\FOP\Database::query('SELECT '.qi('file').' FROM '.qi('doc_revision').' WHERE '.qi('doc').' = ' . \FOP\Database::quote($id) . ' ORDER BY created DESC')->fetchColumn()); ?>/x?inline'></iframe>
										</div>
										<div class='mdl-cell mdl-cell--6-col form-form'>
								<?php } ?>

								<form
									
									action="<?php echo \TablesRouter\Doc::mergeURL2(['popup' => $_GET['popup'] ?? null, 'id' => $id]); ?>"
									method="post"
									enctype="multipart/form-data" ng-submit='submit($event)'
									onsubmit="
										if (window.running_uploads) {
											event.preventDefault();
											alert('<?php echo htmlentities(json_encode(_('fileUploadStillActive')));?>');
										}
									"
								 
								id="cardform-wf_doc_merge"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_doc_merge" ng-init="form = <?php echo htmlentities(json_encode([]));
									?>;"
								>
								<?php
								 echo '<input type="hidden" name="csrftoken" value="' . htmlentities(\FOP\Session::getCSRFToken()) . '">';
								 if (isset($_GET['from'])) echo '<input type="hidden" name="fop-from" value="' . htmlentities($_GET['from']) . '">';
								 ?>
								<div id='fop-upbar'></div>
								
									<?php
									$features = [];
									if (true && (true)) {
									$feature = [
										'id' => 'buttons',
										'title' => _('Aktionen'),
										'order' => '300', // 300 (50)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || true || (!isset($_POST['cancel'])))) {
									$feature = [
										'id' => 'main',
										'title' => _('Daten'),
										'order' => '100', // 100 (20)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. (true ? 'true' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? 'true' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									

									
									/* load order from database
										schema: fop_form_feature(user, form, subid, key, value)
										key = (order, mode, position, collapsed)
									*/
									$upbar_collapsed = false;
									// default values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', (SELECT '.qi('value').' FROM fop_form_feature b WHERE a.subid = b.subid AND a.'.qi('key').' = b.'.qi('key').' AND '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY '.qi('value').' ORDER BY COUNT(*) DESC LIMIT 1) AS '.qi('value').' FROM fop_form_feature a WHERE '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY subid, '.qi('key'))->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										}
									}
									// form specific special values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', '.qi('value').' FROM fop_form_feature a WHERE form = \'wf:doc:merge\' AND '.qi('user').' = '.intval(\FOP\User::getID()).'')->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										} else if ($setting['subid'] == 'upbar' && $setting['key'] == 'collapsed') {
											$upbar_collapsed = (bool) $setting['value'];
										}
									}

									/* fill in the content of the features */
									if (true && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['buttons']);
										?><div id='wf_doc_merge_buttons' class='mdl-cell mdl-cell--12-col' style='flex-wrap: wrap;'><?php if (true) { ?><button onclick="
		var errors = $(this).closest('form').find('.fop-form-error:visible, .is-invalid').filter((i, x) => $(x).parents('.novalidate').length ? false : true);
		if (errors.length) {
			event.preventDefault();
			alert(errors.closest('.fop-form-content').prev('.fop-form-label').text() + ' Es sind noch Fehler im Formular bei Feld');
			return;
		} /* TODO: i18n */
		
	" type="submit" name="ok" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">done</i><?php echo(_('zuordnen')); ?></button><?php } ?>
									&nbsp;<?php if (true) { ?><button onclick="$(this).closest('form').find('.mdl-textfield__error:visible').hide();
		$('[required]').removeAttr('required');
	" type="submit" name="cancel" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">cancel</i><?php echo(_('abbrechen')); ?></button><?php } ?>
									</div><script type='text/javascript'>
		// copy all buttons to #fop-upbar
		$(function () {
    var btn = document.getElementById("fop-bar-mainbutton");
    var upbar = $('#fop-upbar');
    var upbar_buttons = document.getElementById("fop-bar-container");

    // Check if the elements already exist
    if (!btn || !upbar_buttons) {
        if (!btn) {
            btn = $('<div id="fop-bar-mainbutton" class="mdl-button fop-button-half fop-button-margin mdl-button--raised"><i class="material-icons">keyboard_arrow_right</i></div>')
                .click(function () {
                    if (btn.find('i').text() == 'keyboard_arrow_right') {
                        upbar_buttons.fadeOut(400);
                        btn.find('i').text('keyboard_arrow_left');
                    } else {
                        upbar_buttons.fadeIn(400);
                        btn.find('i').text('keyboard_arrow_right');
                    }
                });
            upbar.append(btn);
        }

        if (!upbar_buttons) {
            upbar_buttons = $('<div id="fop-bar-container" style="max-width: 290px"></div>'); //dependant on the mdl-buttons width, caps of upbar buttons at exactly 4 buttons
            upbar.append(upbar_buttons);
        }

        var buttons = $('#wf_doc_merge_buttons').find('.mdl-button');
        buttons.each(function (i, v) {
            var button = $(v);
            var newbutton = $('<div></div>');
            newbutton.attr('class', button.attr('class'));
            newbutton.attr('title', button.attr('title'));
            newbutton.append(button.find('.material-icons').clone(false));
            newbutton.click(function () {
                button[0].click();
            });
            upbar_buttons.append(newbutton);
        });
    }
});

	</script><?php
										\EasyEditor\FormFeature::pop();
										$features['buttons']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || true || (!isset($_POST['cancel'])))) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main']);
										?><p><b>Achtung! Dieser Schritt kann nicht rückgängig gemacht werden. Bitte sorgfältig lesen.</b></p><p>Mit dieser Aktion entfernen Sie das neue Dokument und ordnen es stattdessen als neue Version eines älteren Dokuments ein. Führen Sie diese Aktion dann aus, wenn Sie ein Dokument doppelt gescannt haben oder ein Dokument erneut scannen, weil zum Beispiel Unterschriften hinzu gekommen sind.</p><?php if ((!isset($_POST['cancel']))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_olddoc" id="column_olddoc">
		<!-- Feld "Zuordnen zu": olddoc -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="olddoc"><?php echo(_('Zuordnen zu')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\Doc::renderEditform_wf_doc_merge_olddocAction($data['olddoc'], [], '');
?> &nbsp;	<?php if (\TablesRouter\Doc::createAccess()) { ?>  <a tabindex='-1' class='unimportant button' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Doc::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=doc%26colinsert=olddoc%26el=" + encodeURIComponent(id) + "%26close%26insert_param=colvalue", "_blank", "width=739, height=395"); return false;'><i class="material-icons">add</i></a> <?php } ?> &nbsp;	<a tabindex='-1' class='unimportant button fop-ddt-search' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Doc::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=doc%26colinsert=olddoc%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=doc", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div>
	</div>
	</div><?php } ?><?php
										\EasyEditor\FormFeature::pop();
										$features['main']['html'] = ob_get_contents();
										ob_end_clean();
									}
									

									uasort($features, function ($a, $b) {
										return strnatcmp($a['order'], $b['order']);
									});
									foreach ($features AS $feature) {
										\EasyEditor\FormFeature::render($feature);
									}
									?><script type='text/javascript'>
										function setCFF(id, key, value) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFF?form=wf%3Adoc%3Amerge&subid=' + encodeURIComponent(id) + '&key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value)).then(function () {
												if (key == 'reset') {
													location.reload();
												}
											});
											<?php } /* EditAccess */ ?>
										}
										function setCFFOrder(fids) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFFOrder?form=wf%3Adoc%3Amerge&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_doc_merge')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_doc_merge input[type!="hidden"],textarea,select[tabindex!="-1"]').not('.fop-disabled *').filter(':visible:first').focus().select();
											}
										});

										$(window).keydown(function(event) {
											 if (event.ctrlKey && String.fromCharCode(event.which).toLowerCase() == 's') {
												 event.preventDefault();
												 $('button[type=submit]').click();
												 return false;
											 }
										});

										
										$(document).on('keyup',function(evt) {
										   if (evt.keyCode == 27) {
												if (window.parent) {
													window.close(); // iframe:close
												} else {
													window.history.back();
												}
											}
												});
										
									</script>

							</form>
							<?php if (\FOP\Database::query('SELECT '.qi('file').' FROM '.qi('doc_revision').' WHERE '.qi('doc').' = ' . \FOP\Database::quote($id) . ' ORDER BY created DESC')->fetchColumn()) { ?></div></div><?php } ?>

							</div>
							<div class="content" id="focus-supersearch">
							</div>
							<div class="content" id="~spacer"><?php if (!isset($_GET['popup'])) { ?><div style="padding-bottom: 10cm;"></div><?php } ?>
							</div>
						<?php if (!isset($_GET['popup'])) { ?>
					</div>
				</main>
				
			</div>
		<?php } else { ?></div><?php } ?>
<?php if (!isset($_GET['popup'])) { ?><div class='fop-seal'></div><?php } ?></body></html><?php
    // --- BLOCK: main-6 ---
    }
    
  }

  public static function archiveAction($id = null ) { 
    
    
    // --- BLOCK: 0_CSRFValidate ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') \FOP\Session::validateCSRFToken(); else \FOP\Session::getCSRFToken();

    // --- BLOCK: 0_CSRF_ensure ---
    
	\FOP\Session::getCSRFToken();
    // --- BLOCK: _split-IDs ---
    
		/* do not stress the idlist budget */
		$max_items = intdiv(ini_get('max_input_vars') - 30 /* Reserve für feste Spalten */, 3+1);
		$id = new \FOP\IDList($id);
		$rest = $id->splice($max_items);
		if ($rest) {
			$_GET['from'] = \TablesRouter\Doc::archiveURL2(['id' => $rest, 'from' => $_GET['from'] ?? null]);
		}
	
    // --- BLOCK: access ---
    if(!((!\FOP\User::getIsGuest()) && ((\FOP\User::getDokument())) && ((\FOP\User::getDokument())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		
		/* Validatoren */
		
		

		
		/* Sanitizer */

		

		
	}
	
    // --- BLOCK: access-itemlist-doc-85d1b573ee36a75e68edfb481189fc7817384d39e08985b286816a5d2410d60f ---
    
		// ID-Liste neu aufbauen und nur die übrig lassen, die auch erlaubt sind
		$id_ = new \FOP\IDList($id);
		$id = new \FOP\IDList();
		foreach (\FOP\Database::query('SELECT '.qi('ID').' FROM '.qi('doc').' WHERE ((('.qi('doc').'.'.qi('archive').') = (0))) AND ' . $id_->toSQL(qi('ID')))->fetchAll(\PDO::FETCH_COLUMN) AS $id_sub) {
			$id->push($id_sub);
		}
	
    // --- BLOCK: access-itemlist-doc-edit ---
    
		// ID-Liste neu aufbauen und nur die übrig lassen, die auch erlaubt sind
		$id_ = new \FOP\IDList($id);
		$id = new \FOP\IDList();
		foreach (\FOP\Database::query('SELECT '.qi('ID').' FROM '.qi('doc').' WHERE (('.\FOP\Database::quote(\FOP\User::getDokument()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('a3H18ePF').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('a3H18ePF').' WHERE '.qi('a3H18ePF').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('fXl0iMc3').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('fXl0iMc3').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('fXl0iMc3').' WHERE '.qi('fXl0iMc3').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('iVCI3rck').' WHERE '.qi('iVCI3rck').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-protokoll').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Ot4cBnlj').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Ot4cBnlj').' WHERE '.qi('Ot4cBnlj').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('K2POIfyF').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('K2POIfyF').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('K2POIfyF').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('K2POIfyF').' WHERE '.qi('K2POIfyF').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-gruppe').' LIMIT 1), TRUE))) AND ' . $id_->toSQL(qi('ID')))->fetchAll(\PDO::FETCH_COLUMN) AS $id_sub) {
			$id->push($id_sub);
		}
	
    // --- BLOCK: access-itemlist-doc-view ---
    
		// ID-Liste neu aufbauen und nur die übrig lassen, die auch erlaubt sind
		$id_ = new \FOP\IDList($id);
		$id = new \FOP\IDList();
		foreach (\FOP\Database::query('SELECT '.qi('ID').' FROM '.qi('doc').' WHERE (('.\FOP\Database::quote(\FOP\User::getDokument()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('ok3G4wPh').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('ok3G4wPh').' WHERE '.qi('ok3G4wPh').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('2Hyq8DKe').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('2Hyq8DKe').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('2Hyq8DKe').' WHERE '.qi('2Hyq8DKe').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('jYtYUs5c').' WHERE '.qi('jYtYUs5c').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-protokoll').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('bmxCMQlw').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('bmxCMQlw').' WHERE '.qi('bmxCMQlw').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('9lhFb6lb').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('9lhFb6lb').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('9lhFb6lb').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('9lhFb6lb').' WHERE '.qi('9lhFb6lb').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-gruppe').' LIMIT 1), TRUE))) AND ' . $id_->toSQL(qi('ID')))->fetchAll(\PDO::FETCH_COLUMN) AS $id_sub) {
			$id->push($id_sub);
		}
	
    // --- BLOCK: main ---
    
		// Main block
	
    // --- BLOCK: main-1 ---
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		if (true) {
			\FOP\Database::beginTransaction();
    // --- BLOCK: main-2:save-main ---
    /* Multi */ $result = new \FOP\IDList();
    // --- BLOCK: main-2:save-main-list-fop_list ---
    
		// List Save
		if (isset($_POST['fop_list_ID'])) foreach ($_POST['fop_list_ID'] AS $i => $subid) {
			// Subdaten extrahieren
			if (!$subid && $_POST['fop_list'][$i] != '0') {
				// es wird ein Create
				$subdata = \Tables\Doc::getDefaults();
				\Tables\Doc::sanitizeDefaults($subdata, false);
			} else {
				// es ist ein Edit
				$subdata = [];
			}
			
				$subdata['archive'] = $_POST['fop_list_archive'][$i];
				$subdata['ID'] = $_POST['fop_list_ID'][$i];
			if ($subid) {
				// existierendes Element
				if ($_POST['fop_list'][$i] == '0') {
					// zur Löschung markiert
					// achtet selbst auf Permissions
					\Tables\Doc::delete($subid);
				} else {
					// achtet selbst auf Permissions
					\Tables\Doc::edit($subid, $subdata);
					
					
				}
			} else if ($_POST['fop_list'][$i] != '0') {
				// noch keine ID: erstellen
				if (((\FOP\User::getDokument()))) {
					// TODO: TIAR-Create prüfen
					try {
						$subid = \Tables\Doc::create($subdata);
						
						
					} catch (\FOP\AccessDeniedException $e) {
						// ignore duplicate
						if ($e->getMessage() != 'duplicateinsert') {
							throw $e;
						}
					}
				}
			}
		}
	
    // --- BLOCK: main-3 ---
    
			\FOP\Database::commitTransaction();
			
		}
		
		if (isset($_POST['Tables:Doc:index'])) {
			
			
			if (isset($_POST['fop-from']) && $_POST['fop-from']) {
				// Redirect zu fop-from
				header('Location: ' . (isset($id) && is_string($id) ? preg_replace('/&insert_param=(.*)$/', '&$1=' . ($id instanceof \FOP\IDList ? $id->toString() : $id), $_POST['fop-from']) : $_POST['fop-from']));
			} else {
				header('Location: ' . \TablesRouter\Doc::indexURL2(['popup' => $_GET['popup'] ?? null, 'filter_doc_ID' => $result->toString()]));
			}
			die();
	
		}
		die(json_encode($_POST));
	} else {
    // --- BLOCK: main-4:load-main ---
    
		$data = \Tables\Doc::getDefaults();
	
    // --- BLOCK: main-4:load-main-list-fop_list ---
    
		$fop_list = [];
		array_push($fop_list, ...\Tables\Doc::loadArchiveFop_listItems($id));
	
    // --- BLOCK: main-4:load-main-list~default-archive ---
    array_walk($fop_list, function (&$data) {
		$data['archive'] = 1;
	});
    // --- BLOCK: main-4:load-~sanitize ---
    
		\Tables\Doc::sanitizeDefaults($data, true);
	
    // --- BLOCK: main-5 ---
    ?><?php
			header('Content-Type: text/html; charset=UTF-8');
			header('X-XSS-Protection: 1; mode=block');
			header('Strict-Transport-Security: max-age=63072000');
			header('X-Content-Type-Options: nosniff');
			header("Content-Security-Policy: default-src *  data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';");


		?><!DOCTYPE html><html><head><title><?php echo(_('archivieren')); ?></title><base href='<?php echo \FOP\Util::getCurrentBaseurl(); ?>'><meta name="google" content="notranslate"><meta http-equiv="Content-Language" content="<?php echo htmlentities(\FOP\I18n::getLocale()); ?>"><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="style_dependencies.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><link rel="stylesheet" type="text/css" href="style.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><script type="text/javascript" src="js/script_dependencies.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="mobile-web-app-capable" content="yes"><link rel="manifest" href="manifest.webmanifest"><script type="text/javascript">moment.locale('<?php echo(\FOP\I18n::getShortLocale()); ?>');</script><script type="text/javascript" src="js/form.js"></script><script type="text/javascript">window.globals = <?php
	echo json_encode(['user:superadmin' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSuperadmin(), 'user:mitglied' => /* TODO: resanitizer später mal */(integer) \FOP\User::getMitglied(), 'user:gruppe' => /* TODO: resanitizer später mal */(integer) \FOP\User::getGruppe(), 'user:campaign' => /* TODO: resanitizer später mal */(integer) \FOP\User::getCampaign(), 'user:sammlung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSammlung(), 'user:protokoll' => /* TODO: resanitizer später mal */(integer) \FOP\User::getProtokoll(), 'user:ID' => /* TODO: resanitizer später mal */(integer) \FOP\User::getID(), 'user:buchhaltung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getBuchhaltung()]);
?>;</script><script type="text/javascript" src="angular/<?php echo(\FOP\I18n::getShortLocale()); ?>/js/alltypes.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><script type="text/javascript" src="angular/angular-i18n/angular-locale_<?php echo \FOP\I18n::getAngularLocale(); ?>.js"></script><script type="text/javascript" src="js/date-filter.js"></script><script type="text/javascript" src="js/dropdown.js"></script><script type="text/javascript" src="js/numeric.js"></script><script type="text/javascript" src="js/getparam.js"></script><script type="text/javascript" src="js/tables.js"></script>
		<script type="text/javascript" src="js/parsehash.js"></script><script type="text/javascript">
		window.query = <?php echo json_encode($_GET, JSON_FORCE_OBJECT); ?>;
		window.baseurl = <?php echo json_encode(\FOP\Util::getCurrentBaseurl()); ?>;

		window.i18n_weiter = <?php echo json_encode(_('Weiter'));?>;
		//Filter I18n:
		window.i18n_quartal = <?php echo json_encode(_('Quarter'));?>;
		window.i18n_alle = <?php echo json_encode(_('All'));?>;
		window.i18n_leere = <?php echo json_encode(_('Empty'));?>;
		window.i18n_tag = <?php echo json_encode(_('Tag'));?>;
		window.i18n_woche = <?php echo json_encode(_('Woche'));?>;
		window.i18n_zeitraum = <?php echo json_encode(_('Period'));?>;
		window.i18n_monat = <?php echo json_encode(_('Monat'));?>;
		window.i18n_jahr = <?php echo json_encode(_('Jahr'));?>;
		window.i18n_von = <?php echo json_encode(_('filters_from'));?>;
		window.i18n_bis = <?php echo json_encode(_('filters_to'));?>;
		window.i18n_tabButton = <?php echo json_encode(_('open_in_new_tab'));?>;
		window.i18n_closeButton = <?php echo json_encode(_('close'));?>;
		</script></head><script type="text/javascript">const fopPushPublicKey = '<?php echo(addslashes(\FOP\Configuration::getFOPPushPublicKey())); ?>';
        const fopUserID = <?php echo(intval(\FOP\User::getID())); ?>;
        var fopPushDisabled = false;
    </script><script type="text/javascript" src="js/serviceworkersetup.js"></script><body ng-app='app'>
		<div class='mdl-js-snackbar mdl-snackbar' id='snackbar'>
			<div class='mdl-snackbar__text'></div>
			<button class='mdl-snackbar__action' type='button'></button>
		</div>
		<script>
			var snackbar = document.querySelector('#snackbar');
			componentHandler.upgradeElement(snackbar, 'MaterialSnackbar');
			$(function () {
				setTimeout(function () {
					$('.fop-layout').scrollTop(0);
				}, 0);
			});
		</script>

		<?php if (isset($_GET['popup'])) { ?>
		<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo(_('archivieren')); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      	</header>
			<style>
				.content {
					margin-top: 0px !important;
				}
			</style>
			<div id='content' class='popup' >
		<?php } else { ?>
			<div class="fop-layout mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
			<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo(_('archivieren')); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      		</header>


				<?php  \EasyEditor\Navigation::render(); ?>
      
				<main class="mdl-layout__content" id="content">
					<div class="fop-content">
						<?php } ?>
						
							<div class="content" id="0-rest">
		<?php
		if (isset($rest)) {
			echo sprintf(_('Formular auf %d Einträge beschränkt, %d verbleiben'), $id->count(), $rest->count());
		}
		?>
	
							</div>
							<div class="content" id="1">
								

								<form
									
									action="<?php echo \TablesRouter\Doc::archiveURL2(['popup' => $_GET['popup'] ?? null, 'id' => $id]); ?>"
									method="post"
									enctype="multipart/form-data" ng-submit='submit($event)'
									onsubmit="
										if (window.running_uploads) {
											event.preventDefault();
											alert('<?php echo htmlentities(json_encode(_('fileUploadStillActive')));?>');
										}
									"
								 
								id="cardform-wf_doc_archive"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_doc_archive" ng-init="form = <?php echo htmlentities(json_encode([]));
									?>;"
								>
								<?php
								 echo '<input type="hidden" name="csrftoken" value="' . htmlentities(\FOP\Session::getCSRFToken()) . '">';
								 if (isset($_GET['from'])) echo '<input type="hidden" name="fop-from" value="' . htmlentities($_GET['from']) . '">';
								 ?>
								<div id='fop-upbar'></div>
								
									<?php
									$features = [];
									if (true && (true)) {
									$feature = [
										'id' => 'buttons',
										'title' => _('Aktionen'),
										'order' => '300', // 300 (50)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || false || false)) {
									$feature = [
										'id' => 'main',
										'title' => _('Daten'),
										'order' => '100', // 100 (20)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. '0' .'||'. '0'
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || true)) {
									$feature = [
										'id' => 'fop_list',
										'title' => _(''),
										'order' => 'z-fop_list', // 
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. (true ? 'true' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									

									
									/* load order from database
										schema: fop_form_feature(user, form, subid, key, value)
										key = (order, mode, position, collapsed)
									*/
									$upbar_collapsed = false;
									// default values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', (SELECT '.qi('value').' FROM fop_form_feature b WHERE a.subid = b.subid AND a.'.qi('key').' = b.'.qi('key').' AND '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY '.qi('value').' ORDER BY COUNT(*) DESC LIMIT 1) AS '.qi('value').' FROM fop_form_feature a WHERE '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY subid, '.qi('key'))->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										}
									}
									// form specific special values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', '.qi('value').' FROM fop_form_feature a WHERE form = \'wf:doc:archive\' AND '.qi('user').' = '.intval(\FOP\User::getID()).'')->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										} else if ($setting['subid'] == 'upbar' && $setting['key'] == 'collapsed') {
											$upbar_collapsed = (bool) $setting['value'];
										}
									}

									/* fill in the content of the features */
									if (true && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['buttons']);
										?><div id='wf_doc_archive_buttons' class='mdl-cell mdl-cell--12-col' style='flex-wrap: wrap;'><?php if (true) { ?><button onclick="
		var errors = $(this).closest('form').find('.fop-form-error:visible, .is-invalid').filter((i, x) => $(x).parents('.novalidate').length ? false : true);
		if (errors.length) {
			event.preventDefault();
			alert(errors.closest('.fop-form-content').prev('.fop-form-label').text() + ' Es sind noch Fehler im Formular bei Feld');
			return;
		} /* TODO: i18n */
		
	" type="submit" name="Tables:Doc:index" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">save</i><?php echo(_('Speichern')); ?></button><?php } ?>
									</div><script type='text/javascript'>
		// copy all buttons to #fop-upbar
		$(function () {
    var btn = document.getElementById("fop-bar-mainbutton");
    var upbar = $('#fop-upbar');
    var upbar_buttons = document.getElementById("fop-bar-container");

    // Check if the elements already exist
    if (!btn || !upbar_buttons) {
        if (!btn) {
            btn = $('<div id="fop-bar-mainbutton" class="mdl-button fop-button-half fop-button-margin mdl-button--raised"><i class="material-icons">keyboard_arrow_right</i></div>')
                .click(function () {
                    if (btn.find('i').text() == 'keyboard_arrow_right') {
                        upbar_buttons.fadeOut(400);
                        btn.find('i').text('keyboard_arrow_left');
                    } else {
                        upbar_buttons.fadeIn(400);
                        btn.find('i').text('keyboard_arrow_right');
                    }
                });
            upbar.append(btn);
        }

        if (!upbar_buttons) {
            upbar_buttons = $('<div id="fop-bar-container" style="max-width: 290px"></div>'); //dependant on the mdl-buttons width, caps of upbar buttons at exactly 4 buttons
            upbar.append(upbar_buttons);
        }

        var buttons = $('#wf_doc_archive_buttons').find('.mdl-button');
        buttons.each(function (i, v) {
            var button = $(v);
            var newbutton = $('<div></div>');
            newbutton.attr('class', button.attr('class'));
            newbutton.attr('title', button.attr('title'));
            newbutton.append(button.find('.material-icons').clone(false));
            newbutton.click(function () {
                button[0].click();
            });
            upbar_buttons.append(newbutton);
        });
    }
});

	</script><?php
										\EasyEditor\FormFeature::pop();
										$features['buttons']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || false || false)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main']);
										?><?php
										\EasyEditor\FormFeature::pop();
										$features['main']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['fop_list']);
										?><span id='fop_list' class='mdl-cell mdl-cell--12-col mdl-grid' >
	
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card">
	<div class="mdl-cell mdl-cell--12-col" style="align-items: start; overflow: auto; max-height: calc(100vh - 300px); align-items: start;">
		<table class='mdl-data-table mdl-js-data-table mdl-shadow--2dp table-dense table-editable'>
			<thead>
				<tr >
					<th class='mdl-data-table__cell--non-numeric'>-</th>
					
						<?php if (true || true) { ?>
							<th class='mdl-data-table__cell--non-numeric'><?php echo(_('Archiv')); ?></th>
						<?php } ?>
				</tr>
			</thead>
			<tbody>
				<?php
				foreach ($fop_list AS $row) {
					self::archiveListFop_listAction($row, $data);
				}
				if (false) { ?>
				<tr class='wfl-create'>
					<td colspan='42' class='mdl-data-table__cell--non-numeric'>
					  
				<button type='button' class='mdl-button mdl-js-button mdl-button--colored mdl-button--raised' onclick='var tr = $(this).closest(".wfl-create"); $.get("Tables/Doc/archiveListFop_list?_&id=<?php echo htmlentities(\FOP\Util::urlencode($id)); ?>", function (html) { var h = $(html).insertBefore(tr); upgradeDOM(h); h.find("input:not([type=hidden]),textarea").first().focus(); }); event.stopPropagation();'><i class="material-icons">add</i> <?php echo(sprintf(_('add %s'), _('Dokument'))); ?></button>
					  
					</td>
				</tr>
				<?php } ?>
			</tbody>
		</table>
	</div>
	</div>
	</span><?php
										\EasyEditor\FormFeature::pop();
										$features['fop_list']['html'] = ob_get_contents();
										ob_end_clean();
									}
									

									uasort($features, function ($a, $b) {
										return strnatcmp($a['order'], $b['order']);
									});
									foreach ($features AS $feature) {
										\EasyEditor\FormFeature::render($feature);
									}
									?><script type='text/javascript'>
										$(function(){
											// bei Änderungen: prüfen, ob Form geändert wurde
											var formData = $('#cardform-wf_doc_archive').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-wf_doc_archive').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-wf_doc_archive').on('submit', function () {
												document.body.onbeforeunload = undefined;
											});
											<?php if ($upbar_collapsed) {
												?>$('#fop-bar-mainbutton').click();<?php
											} ?>
											$('#fop-bar-mainbutton').click(function () {
												setTimeout(function () {
													setCFF('upbar', 'collapsed', $('#fop-bar-container').is(':visible') ? 0 : 1);
												}, 440); /* perfect timing for fadeOut */
											});
										});
										
										function setCFF(id, key, value) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFF?form=wf%3Adoc%3Aarchive&subid=' + encodeURIComponent(id) + '&key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value)).then(function () {
												if (key == 'reset') {
													location.reload();
												}
											});
											<?php } /* EditAccess */ ?>
										}
										function setCFFOrder(fids) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFFOrder?form=wf%3Adoc%3Aarchive&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_doc_archive')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_doc_archive input[type!="hidden"],textarea,select[tabindex!="-1"]').not('.fop-disabled *').filter(':visible:first').focus().select();
											}
										});

										$(window).keydown(function(event) {
											 if (event.ctrlKey && String.fromCharCode(event.which).toLowerCase() == 's') {
												 event.preventDefault();
												 $('button[type=submit]').click();
												 return false;
											 }
										});

										
										$(document).on('keyup',function(evt) {
										   if (evt.keyCode == 27) {
												if (window.parent) {
													window.close(); // iframe:close
												} else {
													window.history.back();
												}
											}
												});
										
									</script>
									<script></script> <!-- Benötigt, damit die Striped-Zählung unterbunden wird und das nachfolgende Card weiß bleibt-->
									<div class="grid-card mdl-cell mdl-cell--12-col">
										<script type='text/javascript'>$(function(){$('[type=submit]').click();});</script>
									</div>
									

							</form>
							

							</div>
							<div class="content" id="focus-supersearch">
							</div>
							<div class="content" id="~spacer"><?php if (!isset($_GET['popup'])) { ?><div style="padding-bottom: 10cm;"></div><?php } ?>
							</div>
						<?php if (!isset($_GET['popup'])) { ?>
					</div>
				</main>
				
			</div>
		<?php } else { ?></div><?php } ?>
<?php if (!isset($_GET['popup'])) { ?><div class='fop-seal'></div><?php } ?></body></html><?php
    // --- BLOCK: main-6 ---
    }
    
  }

  public static function deleteConfirmAction($id = null ) { 
    
    // Methodenimplementierung überschrieben.
    throw new \FOP\AccessDeniedException();return false;
  }

  public static function viewAction($id = null ) { 
    
    
    // --- BLOCK: 0_CSRFValidate ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') \FOP\Session::validateCSRFToken(); else \FOP\Session::getCSRFToken();

    // --- BLOCK: 0_CSRF_ensure ---
    
	\FOP\Session::getCSRFToken();
    // --- BLOCK: access ---
    if(!(!\FOP\User::getIsGuest())) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		
		/* Validatoren */
		
		

		
		/* Sanitizer */

		

		
	}
	
    // --- BLOCK: fetch ---
    
	\FOP\I18n::ensureIsLoaded();
	$row = self::view($id);

    // --- BLOCK: main ---
    
		// Main block
	
    // --- BLOCK: main-1 ---
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		if (!isset($_POST['ok'])) {
			\FOP\Database::beginTransaction();
    // --- BLOCK: main-2:save-clone-prepare ---
    
		$data = self::view($id);
	
    // --- BLOCK: main-2:save-main ---
    /* view */
    // --- BLOCK: main-3 ---
    
			\FOP\Database::commitTransaction();
			
		}
		
		if (isset($_POST['ok'])) {
			
			
			if (isset($_POST['fop-from']) && $_POST['fop-from']) {
				// Redirect zu fop-from
				header('Location: ' . (isset($id) && is_string($id) ? preg_replace('/&insert_param=(.*)$/', '&$1=' . ($id instanceof \FOP\IDList ? $id->toString() : $id), $_POST['fop-from']) : $_POST['fop-from']));
			} else {
				if ($to = (isset($_GET['popup']) ? \FOP\Util::getCurrentBaseurl().'jscloser.php?action=popup' : \FOP\Session::getPayload('dv-doc')['from'] ?? null)) {
					header('Location: ' . $to);
					die();
				}
				if (!\TablesRouter\Doc::indexAccess()) {
					if (!\FOPRouter\Index::indexAccess()) {
						header('Location: ' . \FOPRouter\Index::indexURL2(['popup' => $_GET['popup'] ?? null]));
						die();
					}
					header('Location: ' . \FOPRouter\Index::indexURL2(['popup' => $_GET['popup'] ?? null]));
					die();
				}
				header('Location: ' . \TablesRouter\Doc::indexURL2(['popup' => $_GET['popup'] ?? null]));
			}
			die();
	
		}
		die(json_encode($_POST));
	} else {
    // --- BLOCK: main-4:load-main ---
    
		$data = self::view($id); // TODO: klären, wer die Funktion bereitstellt (momentan crud/view.fop)
	
    // --- BLOCK: main-5 ---
    ?><?php
			header('Content-Type: text/html; charset=UTF-8');
			header('X-XSS-Protection: 1; mode=block');
			header('Strict-Transport-Security: max-age=63072000');
			header('X-Content-Type-Options: nosniff');
			header("Content-Security-Policy: default-src *  data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';");


		?><!DOCTYPE html><html><head><title><?php echo htmlentities(str_replace('%s', \FOP\Database::query('SELECT CONCAT('.qi('doc').'.'.qi('subject').', \' - \', '.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('doc').'.'.qi('date').')'.(\FOP\Database::getDriver() == 'mysql' ? '' : '::date') . ', '.\FOP\Database::sessionVarSQL('dateformat').')) AS description FROM '.qi('doc').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() ?: '', _('%s'))); ?></title><base href='<?php echo \FOP\Util::getCurrentBaseurl(); ?>'><meta name="google" content="notranslate"><meta http-equiv="Content-Language" content="<?php echo htmlentities(\FOP\I18n::getLocale()); ?>"><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="style_dependencies.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><link rel="stylesheet" type="text/css" href="style.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><script type="text/javascript" src="js/script_dependencies.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="mobile-web-app-capable" content="yes"><link rel="manifest" href="manifest.webmanifest"><script type="text/javascript">moment.locale('<?php echo(\FOP\I18n::getShortLocale()); ?>');</script><script type="text/javascript" src="js/form.js"></script><script type="text/javascript">window.globals = <?php
	echo json_encode(['user:superadmin' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSuperadmin(), 'user:mitglied' => /* TODO: resanitizer später mal */(integer) \FOP\User::getMitglied(), 'user:gruppe' => /* TODO: resanitizer später mal */(integer) \FOP\User::getGruppe(), 'user:campaign' => /* TODO: resanitizer später mal */(integer) \FOP\User::getCampaign(), 'user:sammlung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSammlung(), 'user:protokoll' => /* TODO: resanitizer später mal */(integer) \FOP\User::getProtokoll(), 'user:ID' => /* TODO: resanitizer später mal */(integer) \FOP\User::getID(), 'user:buchhaltung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getBuchhaltung()]);
?>;</script><script type="text/javascript" src="angular/<?php echo(\FOP\I18n::getShortLocale()); ?>/js/alltypes.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><script type="text/javascript" src="angular/angular-i18n/angular-locale_<?php echo \FOP\I18n::getAngularLocale(); ?>.js"></script><script type="text/javascript" src="js/date-filter.js"></script><script type="text/javascript" src="js/dropdown.js"></script><script type="text/javascript" src="js/numeric.js"></script><script type="text/javascript" src="js/getparam.js"></script><script type="text/javascript" src="js/tables.js"></script>
		<script type="text/javascript" src="js/parsehash.js"></script><script type="text/javascript">
		window.query = <?php echo json_encode($_GET, JSON_FORCE_OBJECT); ?>;
		window.baseurl = <?php echo json_encode(\FOP\Util::getCurrentBaseurl()); ?>;

		window.i18n_weiter = <?php echo json_encode(_('Weiter'));?>;
		//Filter I18n:
		window.i18n_quartal = <?php echo json_encode(_('Quarter'));?>;
		window.i18n_alle = <?php echo json_encode(_('All'));?>;
		window.i18n_leere = <?php echo json_encode(_('Empty'));?>;
		window.i18n_tag = <?php echo json_encode(_('Tag'));?>;
		window.i18n_woche = <?php echo json_encode(_('Woche'));?>;
		window.i18n_zeitraum = <?php echo json_encode(_('Period'));?>;
		window.i18n_monat = <?php echo json_encode(_('Monat'));?>;
		window.i18n_jahr = <?php echo json_encode(_('Jahr'));?>;
		window.i18n_von = <?php echo json_encode(_('filters_from'));?>;
		window.i18n_bis = <?php echo json_encode(_('filters_to'));?>;
		window.i18n_tabButton = <?php echo json_encode(_('open_in_new_tab'));?>;
		window.i18n_closeButton = <?php echo json_encode(_('close'));?>;
		</script></head><script type="text/javascript">const fopPushPublicKey = '<?php echo(addslashes(\FOP\Configuration::getFOPPushPublicKey())); ?>';
        const fopUserID = <?php echo(intval(\FOP\User::getID())); ?>;
        var fopPushDisabled = false;
    </script><script type="text/javascript" src="js/serviceworkersetup.js"></script><body ng-app='app'>
		<div class='mdl-js-snackbar mdl-snackbar' id='snackbar'>
			<div class='mdl-snackbar__text'></div>
			<button class='mdl-snackbar__action' type='button'></button>
		</div>
		<script>
			var snackbar = document.querySelector('#snackbar');
			componentHandler.upgradeElement(snackbar, 'MaterialSnackbar');
			$(function () {
				setTimeout(function () {
					$('.fop-layout').scrollTop(0);
				}, 0);
			});
		</script>

		<?php if (isset($_GET['popup'])) { ?>
		<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<?php
	if ($dv = \FOP\Session::getPayload('dv-doc')) { ?>
	<?php if (isset($dv['prev'])) {?><a href="<?php echo htmlentities(str_replace('XXX', urlencode($id), $dv['prev'])); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">keyboard_arrow_left</i>
	</a><?php } ?>
	<a href="<?php echo htmlentities($dv['from']); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">view_list</i>
	</a>
	<?php if (isset($dv['next'])) {?><a href="<?php echo htmlentities(str_replace('XXX', urlencode($id), $dv['next'])); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">keyboard_arrow_right</i>
	</a><?php } ?><?php } ?><span class="mdl-layout-title"><?php echo htmlentities(str_replace('%s', \FOP\Database::query('SELECT CONCAT('.qi('doc').'.'.qi('subject').', \' - \', '.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('doc').'.'.qi('date').')'.(\FOP\Database::getDriver() == 'mysql' ? '' : '::date') . ', '.\FOP\Database::sessionVarSQL('dateformat').')) AS description FROM '.qi('doc').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() ?: '', _('%s'))); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      	</header>
			<style>
				.content {
					margin-top: 0px !important;
				}
			</style>
			<div id='content' class='popup' >
		<?php } else { ?>
			<div class="fop-layout mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
			<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<?php
	if ($dv = \FOP\Session::getPayload('dv-doc')) { ?>
	<?php if (isset($dv['prev'])) {?><a href="<?php echo htmlentities(str_replace('XXX', urlencode($id), $dv['prev'])); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">keyboard_arrow_left</i>
	</a><?php } ?>
	<a href="<?php echo htmlentities($dv['from']); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">view_list</i>
	</a>
	<?php if (isset($dv['next'])) {?><a href="<?php echo htmlentities(str_replace('XXX', urlencode($id), $dv['next'])); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">keyboard_arrow_right</i>
	</a><?php } ?><?php } ?><span class="mdl-layout-title"><?php echo htmlentities(str_replace('%s', \FOP\Database::query('SELECT CONCAT('.qi('doc').'.'.qi('subject').', \' - \', '.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('doc').'.'.qi('date').')'.(\FOP\Database::getDriver() == 'mysql' ? '' : '::date') . ', '.\FOP\Database::sessionVarSQL('dateformat').')) AS description FROM '.qi('doc').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() ?: '', _('%s'))); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      		</header>


				<?php  \EasyEditor\Navigation::render(); ?>
      
				<main class="mdl-layout__content" id="content">
					<div class="fop-content">
						<?php } ?>
						
							<div class="content" id="1">
								<?php if (\FOP\Database::query('SELECT '.qi('file').' FROM '.qi('doc_revision').' WHERE '.qi('doc').' = ' . \FOP\Database::quote($id) . ' ORDER BY created DESC')->fetchColumn()) { ?>
									<div class='mdl-grid form-document-container'>
										<div class='mdl-cell mdl-cell--6-col form-document'>
											<iframe style='width:100%;height:100%;' src='fop-files/<?php echo intval(\FOP\Database::query('SELECT '.qi('file').' FROM '.qi('doc_revision').' WHERE '.qi('doc').' = ' . \FOP\Database::quote($id) . ' ORDER BY created DESC')->fetchColumn()); ?>/x?inline'></iframe>
										</div>
										<div class='mdl-cell mdl-cell--6-col form-form'>
								<?php } ?>

								<form
									
									action="<?php echo \TablesRouter\Doc::viewURL2(['popup' => $_GET['popup'] ?? null, 'id' => $id]); ?>"
									method="post"
									enctype="multipart/form-data" ng-submit='submit($event)'
									onsubmit="
										if (window.running_uploads) {
											event.preventDefault();
											alert('<?php echo htmlentities(json_encode(_('fileUploadStillActive')));?>');
										}
									"
								 
								id="cardform-wf_doc_view"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_doc_view" ng-init="form = <?php echo htmlentities(json_encode(['type' => $data['type']]));
									?>;"
								>
								<?php
								 echo '<input type="hidden" name="csrftoken" value="' . htmlentities(\FOP\Session::getCSRFToken()) . '">';
								 if (isset($_GET['from'])) echo '<input type="hidden" name="fop-from" value="' . htmlentities($_GET['from']) . '">';
								 ?>
								<div id='fop-upbar'></div>
								<?php \DataView\Doc_revision_doc::renderScript($id); ?>
									<?php
									$features = [];
									if ((true) && (!\FOP\User::getIsGuest()) && (true)) {
									$feature = [
										'id' => 'doc_revision_doc_table',
										'title' => _('revisions'),
										'order' => '500-100', // 500-100 (50)
										'mode' => 'tab', // tab (50)
										'position' => 'full', // 
										'collapsed' => 0, // 0 (51) / 1 (50)
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (true)) {
									$feature = [
										'id' => 'buttons',
										'title' => _('Aktionen'),
										'order' => '300', // 300 (50)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || true || true || true || true || true || true || true || true || true || true || true)) {
									$feature = [
										'id' => 'main',
										'title' => _('Daten'),
										'order' => '100', // 100 (20)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? '(form[\'lBXFiXqU\'])' : '0')
											 .'||'. (true ? '(form[\'6GSnIHxl\'])' : '0')
											 .'||'. (true ? '(form[\'51Tp3gKR\'])' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									

									
									/* load order from database
										schema: fop_form_feature(user, form, subid, key, value)
										key = (order, mode, position, collapsed)
									*/
									$upbar_collapsed = false;
									// default values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', (SELECT '.qi('value').' FROM fop_form_feature b WHERE a.subid = b.subid AND a.'.qi('key').' = b.'.qi('key').' AND '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY '.qi('value').' ORDER BY COUNT(*) DESC LIMIT 1) AS '.qi('value').' FROM fop_form_feature a WHERE '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY subid, '.qi('key'))->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										}
									}
									// form specific special values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', '.qi('value').' FROM fop_form_feature a WHERE form = \'wf:doc:view\' AND '.qi('user').' = '.intval(\FOP\User::getID()).'')->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										} else if ($setting['subid'] == 'upbar' && $setting['key'] == 'collapsed') {
											$upbar_collapsed = (bool) $setting['value'];
										}
									}

									/* fill in the content of the features */
									if ((true) && (!\FOP\User::getIsGuest()) && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['doc_revision_doc_table']);
										?>
	<?php if ((!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?>
	<div id="doc_revision_doc-table" class="fop-dv"><?php
		if (\EasyEditor\FormFeature::isCollapsed()) {
			// #3198 lazy rendering:
			echo '<div class="fop-lazy-reload" onclick="reloaddoc_revision_doc()"></div>'; // CSS class .fop-lazy-reload will be clicked after being showed
		} else {
			\DataView\Doc_revision_doc::renderTabTableAction($id);
		}
	?></div>
	<?php } ?>
	<?php
										\EasyEditor\FormFeature::pop();
										$features['doc_revision_doc_table']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['buttons']);
										?><div id='wf_doc_view_buttons' class='mdl-cell mdl-cell--12-col' style='flex-wrap: wrap;'>
		<?php if (true && $data['operation::view'] == 1 && $data['operation::edit'] == 1 && ((\FOP\User::getDokument())) && ((\FOP\User::getDokument()))) { ?><a title="<?php echo(_('editbtn')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\Doc::editURL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>mode_edit</i> <?php echo(_('editbtn')); ?></a><?php } ?>&nbsp;<?php if (true) { ?><button onclick="$(this).closest('form').find('.mdl-textfield__error:visible').hide();
		$('[required]').removeAttr('required');
	" type="submit" name="ok" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">check</i><?php echo(_('ok')); ?></button><?php } ?>
									&nbsp;
		<?php if (true && $data['operation::view'] == 1 && ((\FOP\User::getDokument()))) { ?><a title="<?php echo(_('Duplikat/Version zusammenführen')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\Doc::mergeURL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>⛙</i> <?php echo(_('Duplikat/Version zusammenführen')); ?></a><?php } ?>&nbsp;
		<?php if ($data['operation::view'] == 1 && $data['operation::edit'] == 1 && $data['operation::85d1b573ee36a75e68edfb481189fc7817384d39e08985b286816a5d2410d60f'] == 1 && $data['operation::85d1b573ee36a75e68edfb481189fc7817384d39e08985b286816a5d2410d60f'] == 1 && $data['operation::view'] == 1 && $data['operation::edit'] == 1 && (!\FOP\User::getIsGuest()) && ((\FOP\User::getDokument())) && ((\FOP\User::getDokument()))) { ?><a title="<?php echo(_('archivieren')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\Doc::archiveURL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>archive</i> <?php echo(_('archivieren')); ?></a><?php } ?>&nbsp;
		<?php if ($data['operation::delete'] == 1 && $data['operation::delete'] == 1 && ((false) && (\FOP\User::getDokument()))) { ?><a title="<?php echo(_('deletebtn')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\Doc::deleteConfirmURL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null, 'from' => $_GET['from'] ?? \FOP\Session::getPayload('dv-doc')['from'] ?? null])); ?>"><i class='material-icons'>delete</i> <?php echo(_('deletebtn')); ?></a><?php } ?></div><script type='text/javascript'>
		// copy all buttons to #fop-upbar
		$(function () {
    var btn = document.getElementById("fop-bar-mainbutton");
    var upbar = $('#fop-upbar');
    var upbar_buttons = document.getElementById("fop-bar-container");

    // Check if the elements already exist
    if (!btn || !upbar_buttons) {
        if (!btn) {
            btn = $('<div id="fop-bar-mainbutton" class="mdl-button fop-button-half fop-button-margin mdl-button--raised"><i class="material-icons">keyboard_arrow_right</i></div>')
                .click(function () {
                    if (btn.find('i').text() == 'keyboard_arrow_right') {
                        upbar_buttons.fadeOut(400);
                        btn.find('i').text('keyboard_arrow_left');
                    } else {
                        upbar_buttons.fadeIn(400);
                        btn.find('i').text('keyboard_arrow_right');
                    }
                });
            upbar.append(btn);
        }

        if (!upbar_buttons) {
            upbar_buttons = $('<div id="fop-bar-container" style="max-width: 290px"></div>'); //dependant on the mdl-buttons width, caps of upbar buttons at exactly 4 buttons
            upbar.append(upbar_buttons);
        }

        var buttons = $('#wf_doc_view_buttons').find('.mdl-button');
        buttons.each(function (i, v) {
            var button = $(v);
            var newbutton = $('<div></div>');
            newbutton.attr('class', button.attr('class'));
            newbutton.attr('title', button.attr('title'));
            newbutton.append(button.find('.material-icons').clone(false));
            newbutton.click(function () {
                button[0].click();
            });
            upbar_buttons.append(newbutton);
        });
    }
});

	</script><?php
										\EasyEditor\FormFeature::pop();
										$features['buttons']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || true || true || true || true || true || true || true || true || true || true || true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main']);
										?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_file" id="column_file">
		<!-- Feld "download": file -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="file"><?php echo(_('download')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<?php if ($data['file']) { ?><a target='_blank' onclick='event.stopPropagation()' href='fop-files/<?php echo urlencode(htmlentities($data['file'])); ?>/x'><?php call_user_func(function($v) { $result = \FOP\Database::query('SELECT filename FROM fop_files WHERE '.qi('ID').' = '.intval($v))->fetch(\PDO::FETCH_ASSOC); echo htmlentities($result['filename']); }, $data['file']); ?></a><?php } else { echo '-'; } ?>
	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_type" id="column_type">
		<!-- Feld "Kategorie": type -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="type"><?php echo(_('Kategorie')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<?php
	
	$sql = 'SELECT '.qi('ID').' AS '.qi('ID').', '.qi('docType').'.'.qi('name').' AS description, (('.\FOP\Database::quote(\FOP\User::getDokument()).')) AS '.qi('canView').' FROM '.qi('docType').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($data['type']);
	$docType_result = \FOP\Database::query($sql);
	if ($docType_row = $docType_result->fetch(\PDO::FETCH_ASSOC)) {
		if ($docType_row['canView']) echo "<a onclick=\"event.preventDefault(); open_url(this.href, false);\" href=\"" . \TablesRouter\DocType::viewURL($data['type'], ['from' => \FOP\Util::getBackURL()]) . "\" class=\"tbl-link\" data-tbl=\"docType\" data-id=\"".htmlentities($docType_row['ID'])."\">";echo htmlentities($docType_row['description']);if ($docType_row['canView']) echo "</a>";
	} else {
		echo htmlentities(_('-') ?: '-');
	}
	
?>

	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_subject" id="column_subject">
		<!-- Feld "Betreff": subject -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="subject"><?php echo(_('Betreff')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		
	<?php echo htmlentities($data['subject']); ?>
	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_notes" id="column_notes">
		<!-- Feld "Notizen": notes -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="notes"><?php echo(_('Notizen')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		
<div ng-non-bindable class='fop-textarea' >
<?php echo \FOP\Util::SanitizeUserHtml($data['notes']); ?>
</div>

	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_date" id="column_date">
		<!-- Feld "Erfassungsdatum": date -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="date"><?php echo(_('Erfassungsdatum')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		
	<?php echo htmlentities(($data['date']) ? strftime(_('dateformat_php2'), intval($data['date'])) : ''); ?>
	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_to_gruppe" id="column_to-gruppe" ng-show='form[&apos;lBXFiXqU&apos;]'>
		<!-- Feld "linked to %s|Gruppe": to-gruppe -->
	<div ng-show='form[&apos;lBXFiXqU&apos;]'	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="to-gruppe"><?php echo(sprintf(_('linked to %s'), _('Gruppe'))); ?>: </label>
	</div>
	<div ng-show='form[&apos;lBXFiXqU&apos;]'	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<?php
	
	$sql = 'SELECT '.qi('ID').' AS '.qi('ID').', '.qi('gruppe').'.'.qi('name').' AS description, ((CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('gruppe').'.'.qi('public').'))) END)) AS '.qi('canView').' FROM '.qi('gruppe').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($data['to-gruppe']);
	$gruppe_result = \FOP\Database::query($sql);
	if ($gruppe_row = $gruppe_result->fetch(\PDO::FETCH_ASSOC)) {
		if ($gruppe_row['canView']) echo "<a onclick=\"event.preventDefault(); open_url(this.href, true);\" href=\"" . \TablesRouter\Gruppe::viewURL($data['to-gruppe'], ['from' => \FOP\Util::getBackURL()]) . "\" class=\"tbl-link\" data-tbl=\"gruppe\" data-id=\"".htmlentities($gruppe_row['ID'])."\">";echo htmlentities($gruppe_row['description']);if ($gruppe_row['canView']) echo "</a>";
	} else {
		echo htmlentities(_('-') ?: '-');
	}
	
?>

	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_to_mitglied" id="column_to-mitglied" ng-show='form[&apos;6GSnIHxl&apos;]'>
		<!-- Feld "linked to %s|Mitglied": to-mitglied -->
	<div ng-show='form[&apos;6GSnIHxl&apos;]'	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="to-mitglied"><?php echo(sprintf(_('linked to %s'), _('Mitglied'))); ?>: </label>
	</div>
	<div ng-show='form[&apos;6GSnIHxl&apos;]'	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<?php
	
	$sql = 'SELECT '.qi('ID').' AS '.qi('ID').', CONCAT('.qi('mitglied').'.'.qi('vorname').', \' \', '.qi('mitglied').'.'.qi('name').') AS description, ((CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('mitglied').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) AND (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('mitglied').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('mitglied').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) AND (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('mitglied').'.'.qi('superadmin').') END)) AS '.qi('canView').' FROM '.qi('mitglied').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($data['to-mitglied']);
	$mitglied_result = \FOP\Database::query($sql);
	if ($mitglied_row = $mitglied_result->fetch(\PDO::FETCH_ASSOC)) {
		if ($mitglied_row['canView']) echo "<a onclick=\"event.preventDefault(); open_url(this.href, true);\" href=\"" . \TablesRouter\Mitglied::viewURL($data['to-mitglied'], ['from' => \FOP\Util::getBackURL()]) . "\" class=\"tbl-link\" data-tbl=\"mitglied\" data-id=\"".htmlentities($mitglied_row['ID'])."\">";echo htmlentities($mitglied_row['description']);if ($mitglied_row['canView']) echo "</a>";
	} else {
		echo htmlentities(_('-') ?: '-');
	}
	
?>

	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_to_protokoll" id="column_to-protokoll" ng-show='form[&apos;51Tp3gKR&apos;]'>
		<!-- Feld "linked to %s|Protokoll": to-protokoll -->
	<div ng-show='form[&apos;51Tp3gKR&apos;]'	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="to-protokoll"><?php echo(sprintf(_('linked to %s'), _('Protokoll'))); ?>: </label>
	</div>
	<div ng-show='form[&apos;51Tp3gKR&apos;]'	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<?php
	
	$sql = 'SELECT '.qi('ID').' AS '.qi('ID').', CONCAT('.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('protokoll').'.'.qi('date').')'.(\FOP\Database::getDriver() == 'mysql' ? '' : '::date') . ', '.\FOP\Database::sessionVarSQL('dateformat').'), \': \', '.qi('protokoll').'.'.qi('bez').') AS description, (('.\FOP\Database::quote(\FOP\User::getProtokoll()).')) AS '.qi('canView').' FROM '.qi('protokoll').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($data['to-protokoll']);
	$protokoll_result = \FOP\Database::query($sql);
	if ($protokoll_row = $protokoll_result->fetch(\PDO::FETCH_ASSOC)) {
		if ($protokoll_row['canView']) echo "<a onclick=\"event.preventDefault(); open_url(this.href, false);\" href=\"" . \TablesRouter\Protokoll::viewURL($data['to-protokoll'], ['from' => \FOP\Util::getBackURL()]) . "\" class=\"tbl-link\" data-tbl=\"protokoll\" data-id=\"".htmlentities($protokoll_row['ID'])."\">";echo htmlentities($protokoll_row['description']);if ($protokoll_row['canView']) echo "</a>";
	} else {
		echo htmlentities(_('-') ?: '-');
	}
	
?>

	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_first" id="column_first">
		<!-- Feld "firstrevision": first -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="first"><?php echo(_('firstrevision')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		
	<?php echo htmlentities(($data['first']) ? strftime(_('dateformat_php2'), intval($data['first'])) : ''); ?>
	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_last" id="column_last">
		<!-- Feld "currentrevision": last -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="last"><?php echo(_('currentrevision')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		
	<?php echo htmlentities(($data['last']) ? strftime(_('dateformat_php2'), intval($data['last'])) : ''); ?>
	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_archive" id="column_archive">
		<!-- Feld "Archiv": archive -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="archive"><?php echo(_('Archiv')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<?php if($data['archive'] == 1){ ?>✓<?php }else{ ?>✗<?php }?>
	</div>
	</div><?php
										\EasyEditor\FormFeature::pop();
										$features['main']['html'] = ob_get_contents();
										ob_end_clean();
									}
									

									uasort($features, function ($a, $b) {
										return strnatcmp($a['order'], $b['order']);
									});
									foreach ($features AS $feature) {
										\EasyEditor\FormFeature::render($feature);
									}
									?><script type='text/javascript'>
										function setCFF(id, key, value) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFF?form=wf%3Adoc%3Aview&subid=' + encodeURIComponent(id) + '&key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value)).then(function () {
												if (key == 'reset') {
													location.reload();
												}
											});
											<?php } /* EditAccess */ ?>
										}
										function setCFFOrder(fids) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFFOrder?form=wf%3Adoc%3Aview&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_doc_view')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_doc_view input[type!="hidden"],textarea,select[tabindex!="-1"]').not('.fop-disabled *').filter(':visible:first').focus().select();
											}
										});

										$(window).keydown(function(event) {
											 if (event.ctrlKey && String.fromCharCode(event.which).toLowerCase() == 's') {
												 event.preventDefault();
												 $('button[type=submit]').click();
												 return false;
											 }
										});

										
										$(document).on('keyup',function(evt) {
										   if (evt.keyCode == 27) {
												if (window.parent) {
													window.close(); // iframe:close
												} else {
													window.history.back();
												}
											}
												});
										
									</script>

							</form>
							<?php if (\FOP\Database::query('SELECT '.qi('file').' FROM '.qi('doc_revision').' WHERE '.qi('doc').' = ' . \FOP\Database::quote($id) . ' ORDER BY created DESC')->fetchColumn()) { ?></div></div><?php } ?>

							</div>
							<div class="content" id="focus-supersearch">
							</div>
							<div class="content" id="focus-supersearch">
		<script type='text/javascript'>
			$(function () {
				var focusfield = $('#supersearch');
				if (focusfield.length) {
					focusfield[0].focus();
					focusfield[0].select();
				}
			});
		</script>
	
							</div>
							<div class="content" id="~spacer"><?php if (!isset($_GET['popup'])) { ?><div style="padding-bottom: 10cm;"></div><?php } ?>
							</div>
						<?php if (!isset($_GET['popup'])) { ?>
					</div>
				</main>
				
			</div>
		<?php } else { ?></div><?php } ?>
<?php if (!isset($_GET['popup'])) { ?><div class='fop-seal'></div><?php } ?></body></html><?php
    // --- BLOCK: main-6 ---
    }
    
  }

  public static function createAction($column_to_mitglied = null , $column_to_protokoll = null , $column_to_gruppe = null ) { 
    
    
    // --- BLOCK: 0_CSRFValidate ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') \FOP\Session::validateCSRFToken(); else \FOP\Session::getCSRFToken();

    // --- BLOCK: 0_CSRF_ensure ---
    
	\FOP\Session::getCSRFToken();
    // --- BLOCK: access ---
    if(!((!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && ((\FOP\User::getDokument())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		
		/* Validatoren */
		
		if ((!isset($_POST['cancel']))) \Types\DocType::validate($_POST['type']);
		if ((!isset($_POST['cancel']))) \Types\MitgliedNullDMS::validate($_POST['to-mitglied']);
		if ((!isset($_POST['cancel']))) \Types\ProtokollNullDMS::validate($_POST['to-protokoll']);
		if ((!isset($_POST['cancel']))) \Types\GruppeNullDMS::validate($_POST['to-gruppe']);
		if ((!isset($_POST['cancel']))) \FOP\Files::validate($_POST['file']);

		
		/* Sanitizer */

		if ((!isset($_POST['cancel']))) $_POST['type'] = \FOP\Sanitizers::null_filter($_POST['type']);
		$_POST['date'] = \FOP\Sanitizers::convert_date_to_unix_timestamp($_POST['date']);
		$_POST['notes'] = \FOP\Sanitizers::htmlentities_decode($_POST['notes']);
		if ((!isset($_POST['cancel']))) $_POST['to-mitglied'] = \FOP\Sanitizers::null_filter($_POST['to-mitglied']);
		if ((!isset($_POST['cancel']))) $_POST['to-protokoll'] = \FOP\Sanitizers::null_filter($_POST['to-protokoll']);
		if ((!isset($_POST['cancel']))) $_POST['to-gruppe'] = \FOP\Sanitizers::null_filter($_POST['to-gruppe']);
		if ((!isset($_POST['cancel']))) $_POST['file'] = \FOP\Files::sanitizeUpload($_POST['file']);

		
	}
	
    // --- BLOCK: access+~to-gruppe:a761039152588d38de8934a8ef9cd3ef65093cda444a340e07f86ce069fb99b8:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-gruppe']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-gruppe']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-gruppe']) . '')->fetchColumn()))) : (true))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~to-mitglied:33682e8723b3cd8b498e3a6159829621f77b9e56d893e1f1f25004c6bbbc3df9:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) : (true))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~to-mitglied:865172ed5768c242d6b45e5ff377351532fd3bc8c82279a12d976c55f56fff3b:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) : (true))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~to-mitglied:f71986f7b3a9dafab8aaa15c1a3c801bb7f4afc6ecdd7755e359372112ead8e0:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) : (true))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~to-protokoll:90a970a85288f06c92e34926b2f5b53f07be6328cf66691de41ccccb9b01670a:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-protokoll']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-protokoll']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-protokoll']) . '')->fetchColumn()))) : (true))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-gruppe-bcwXCW1H ---
    
		if ($column_to_gruppe !== null && \FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('gruppe').'.'.qi('public').'))) END) FROM '.qi('gruppe').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($column_to_gruppe))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-mitglied-8oS4CA4y ---
    
		if ($column_to_mitglied !== null && \FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('mitglied').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($column_to_mitglied))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-mitglied-aknxOsQe ---
    
		if ($column_to_mitglied !== null && \FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('mitglied').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('mitglied').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($column_to_mitglied))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-mitglied-mDdHq6xV ---
    
		if ($column_to_mitglied !== null && \FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('mitglied').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($column_to_mitglied))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-mitglied-select ---
    
		if ($column_to_mitglied !== null && \FOP\Database::query('SELECT '.(\FOP\User::getIsGuest() ? 'false' : 'true').' FROM '.qi('mitglied').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($column_to_mitglied))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-protokoll-DF38Sz26 ---
    
		if ($column_to_protokoll !== null && \FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($column_to_protokoll))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: main ---
    
		// Main block
	
    // --- BLOCK: main-1 ---
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		if (!isset($_POST['cancel'])) {
			\FOP\Database::beginTransaction();
    // --- BLOCK: main-2:save-main ---
    
		$defaults = \Tables\Doc::getDefaults();
		$defaults['file'] = $_POST['file'];
		$defaults['date'] = $_POST['date'];
		$defaults['subject'] = $_POST['subject'];
		$defaults['notes'] = $_POST['notes'];
		$defaults['archive'] = $_POST['archive'];
		if ((!isset($_POST['cancel']))) $defaults['type'] = $_POST['type'];
		if ((!isset($_POST['cancel']))) $defaults['to-mitglied'] = $_POST['to-mitglied'];
		if ((!isset($_POST['cancel']))) $defaults['to-protokoll'] = $_POST['to-protokoll'];
		if ((!isset($_POST['cancel']))) $defaults['to-gruppe'] = $_POST['to-gruppe'];
		// TableItemAccess für PHP auswerten
		if (!((\FOP\User::getDokument()) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) : (true)) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) : (true)) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-protokoll']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-protokoll']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-protokoll']) . '')->fetchColumn()))) : (true)) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-mitglied']) . '')->fetchColumn()))) : (true)) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-gruppe']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-gruppe']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['to-gruppe']) . '')->fetchColumn()))) : (true)))) throw new \FOP\AccessDeniedException('accessdenied');
		$id = \Tables\Doc::create($defaults);
	
    // --- BLOCK: main-3 ---
    
			\FOP\Database::commitTransaction();
			
		}
		
		if (isset($_POST['cancel'])) {
			
			
			if (isset($_POST['fop-from']) && $_POST['fop-from']) {
				// Redirect zu fop-from
				header('Location: ' . (isset($id) && is_string($id) ? preg_replace('/&insert_param=(.*)$/', '&$1=' . ($id instanceof \FOP\IDList ? $id->toString() : $id), $_POST['fop-from']) : $_POST['fop-from']));
			} else {
				header('Location: ' . \TablesRouter\Doc::indexURL2(['popup' => $_GET['popup'] ?? null]));
			}
			die();
	
		}
		if (isset($_POST['save'])) {
			
			if (isset($_POST['fop-from']) && $_POST['fop-from'] && strrpos($_POST['fop-from'], 'insert_param') !== false) {
				// Redirect zu fop-from
				header('Location: ' . preg_replace('/&insert_param=(.*)$/', '&$1=' . ($id instanceof \FOP\IDList ? $id->toString() : $id), $_POST['fop-from']));
			} else {
				if (!\TablesRouter\Doc::viewAccess($id)) {
					if (!\TablesRouter\Doc::indexAccess()) {
						header('Location: ' . \FOPRouter\Index::indexURL2(['popup' => $_GET['popup'] ?? null, 'from' => $_POST['fop-from'] ?? null]));
						die();
					}
					header('Location: ' . \TablesRouter\Doc::indexURL2(['popup' => $_GET['popup'] ?? null, 'from' => $_POST['fop-from'] ?? null]));
					die();
				}
				header('Location: ' . \TablesRouter\Doc::viewURL2(['id' => $id, 'popup' => $_GET['popup'] ?? null, 'from' => $_POST['fop-from'] ?? null]));
			}
			die();
	
		}
		die(json_encode($_POST));
	} else {
    // --- BLOCK: main-4:load-main ---
    
		$data = \Tables\Doc::getDefaults();
	
    // --- BLOCK: main-4:load-main-init-file ---
    $data['file'] = NULL;
	
    // --- BLOCK: main-4:load-override ---
    
		$hidden = [];
		if (isset($column_to_mitglied)) {
			
			$hidden['to-mitglied'] = $column_to_mitglied;
			$data['to-mitglied'] = $column_to_mitglied;
		}
		if (isset($column_to_protokoll)) {
			
			$hidden['to-protokoll'] = $column_to_protokoll;
			$data['to-protokoll'] = $column_to_protokoll;
		}
		if (isset($column_to_gruppe)) {
			
			$hidden['to-gruppe'] = $column_to_gruppe;
			$data['to-gruppe'] = $column_to_gruppe;
		}
	
    // --- BLOCK: main-4:load-~dms-category-gruppe ---
    
		if ($data['to-gruppe'] && !\FOP\Database::query('SELECT '.qi('has-gruppe').' FROM '.qi('docType').' WHERE ID = ' . \FOP\Database::quote($data['type']))->fetchColumn()) {
			// change category to a category that has connection to gruppe
			$data['type'] = \FOP\Database::query('SELECT '.qi('ID').' FROM '.qi('docType').' WHERE '.qi('has-gruppe'))->fetchColumn(); // TODO: access rule??
		}
	
    // --- BLOCK: main-4:load-~dms-category-mitglied ---
    
		if ($data['to-mitglied'] && !\FOP\Database::query('SELECT '.qi('has-mitglied').' FROM '.qi('docType').' WHERE ID = ' . \FOP\Database::quote($data['type']))->fetchColumn()) {
			// change category to a category that has connection to mitglied
			$data['type'] = \FOP\Database::query('SELECT '.qi('ID').' FROM '.qi('docType').' WHERE '.qi('has-mitglied'))->fetchColumn(); // TODO: access rule??
		}
	
    // --- BLOCK: main-4:load-~dms-category-protokoll ---
    
		if ($data['to-protokoll'] && !\FOP\Database::query('SELECT '.qi('has-protokoll').' FROM '.qi('docType').' WHERE ID = ' . \FOP\Database::quote($data['type']))->fetchColumn()) {
			// change category to a category that has connection to protokoll
			$data['type'] = \FOP\Database::query('SELECT '.qi('ID').' FROM '.qi('docType').' WHERE '.qi('has-protokoll'))->fetchColumn(); // TODO: access rule??
		}
	
    // --- BLOCK: main-4:load-~sanitize ---
    
		\Tables\Doc::sanitizeDefaults($data, true);
	
    // --- BLOCK: main-5 ---
    ?><?php
			header('Content-Type: text/html; charset=UTF-8');
			header('X-XSS-Protection: 1; mode=block');
			header('Strict-Transport-Security: max-age=63072000');
			header('X-Content-Type-Options: nosniff');
			header("Content-Security-Policy: default-src *  data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';");


		?><!DOCTYPE html><html><head><title><?php echo(sprintf(_('create %s'), _('Dokument'))); ?></title><base href='<?php echo \FOP\Util::getCurrentBaseurl(); ?>'><meta name="google" content="notranslate"><meta http-equiv="Content-Language" content="<?php echo htmlentities(\FOP\I18n::getLocale()); ?>"><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="style_dependencies.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><link rel="stylesheet" type="text/css" href="style.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><script type="text/javascript" src="js/script_dependencies.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="mobile-web-app-capable" content="yes"><link rel="manifest" href="manifest.webmanifest"><script type="text/javascript">moment.locale('<?php echo(\FOP\I18n::getShortLocale()); ?>');</script><script type="text/javascript" src="js/form.js"></script><script type="text/javascript">window.globals = <?php
	echo json_encode(['user:superadmin' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSuperadmin(), 'user:mitglied' => /* TODO: resanitizer später mal */(integer) \FOP\User::getMitglied(), 'user:gruppe' => /* TODO: resanitizer später mal */(integer) \FOP\User::getGruppe(), 'user:campaign' => /* TODO: resanitizer später mal */(integer) \FOP\User::getCampaign(), 'user:sammlung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSammlung(), 'user:protokoll' => /* TODO: resanitizer später mal */(integer) \FOP\User::getProtokoll(), 'user:ID' => /* TODO: resanitizer später mal */(integer) \FOP\User::getID(), 'user:buchhaltung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getBuchhaltung()]);
?>;</script><script type="text/javascript" src="angular/<?php echo(\FOP\I18n::getShortLocale()); ?>/js/alltypes.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><script type="text/javascript" src="angular/angular-i18n/angular-locale_<?php echo \FOP\I18n::getAngularLocale(); ?>.js"></script><script type="text/javascript" src="js/date-filter.js"></script><script type="text/javascript" src="js/dropdown.js"></script><script type="text/javascript" src="js/numeric.js"></script><script type="text/javascript" src="js/getparam.js"></script><script type="text/javascript" src="js/tables.js"></script>
		<script type="text/javascript" src="js/parsehash.js"></script><script type="text/javascript">
		window.query = <?php echo json_encode($_GET, JSON_FORCE_OBJECT); ?>;
		window.baseurl = <?php echo json_encode(\FOP\Util::getCurrentBaseurl()); ?>;

		window.i18n_weiter = <?php echo json_encode(_('Weiter'));?>;
		//Filter I18n:
		window.i18n_quartal = <?php echo json_encode(_('Quarter'));?>;
		window.i18n_alle = <?php echo json_encode(_('All'));?>;
		window.i18n_leere = <?php echo json_encode(_('Empty'));?>;
		window.i18n_tag = <?php echo json_encode(_('Tag'));?>;
		window.i18n_woche = <?php echo json_encode(_('Woche'));?>;
		window.i18n_zeitraum = <?php echo json_encode(_('Period'));?>;
		window.i18n_monat = <?php echo json_encode(_('Monat'));?>;
		window.i18n_jahr = <?php echo json_encode(_('Jahr'));?>;
		window.i18n_von = <?php echo json_encode(_('filters_from'));?>;
		window.i18n_bis = <?php echo json_encode(_('filters_to'));?>;
		window.i18n_tabButton = <?php echo json_encode(_('open_in_new_tab'));?>;
		window.i18n_closeButton = <?php echo json_encode(_('close'));?>;
		</script></head><script type="text/javascript">const fopPushPublicKey = '<?php echo(addslashes(\FOP\Configuration::getFOPPushPublicKey())); ?>';
        const fopUserID = <?php echo(intval(\FOP\User::getID())); ?>;
        var fopPushDisabled = false;
    </script><script type="text/javascript" src="js/serviceworkersetup.js"></script><body ng-app='app'>
		<div class='mdl-js-snackbar mdl-snackbar' id='snackbar'>
			<div class='mdl-snackbar__text'></div>
			<button class='mdl-snackbar__action' type='button'></button>
		</div>
		<script>
			var snackbar = document.querySelector('#snackbar');
			componentHandler.upgradeElement(snackbar, 'MaterialSnackbar');
			$(function () {
				setTimeout(function () {
					$('.fop-layout').scrollTop(0);
				}, 0);
			});
		</script>

		<?php if (isset($_GET['popup'])) { ?>
		<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo(sprintf(_('create %s'), _('Dokument'))); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      	</header>
			<style>
				.content {
					margin-top: 0px !important;
				}
			</style>
			<div id='content' class='popup' >
		<?php } else { ?>
			<div class="fop-layout mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
			<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo(sprintf(_('create %s'), _('Dokument'))); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      		</header>


				<?php  \EasyEditor\Navigation::render(); ?>
      
				<main class="mdl-layout__content" id="content">
					<div class="fop-content">
						<?php } ?>
						
							<div class="content" id="1">
								

								<form
									
									action="<?php echo \TablesRouter\Doc::createURL2(['popup' => $_GET['popup'] ?? null]); ?>"
									method="post"
									enctype="multipart/form-data" ng-submit='submit($event)'
									onsubmit="
										if (window.running_uploads) {
											event.preventDefault();
											alert('<?php echo htmlentities(json_encode(_('fileUploadStillActive')));?>');
										}
									"
								 
								id="cardform-wf_doc_create"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_doc_create" ng-init="form = <?php echo htmlentities(json_encode(['to-mitglied' => $data['to-mitglied'], 'to-protokoll' => $data['to-protokoll'], 'to-gruppe' => $data['to-gruppe'], 'type' => $data['type']]));
									?>;"
								>
								<?php
								 echo '<input type="hidden" name="csrftoken" value="' . htmlentities(\FOP\Session::getCSRFToken()) . '">';
								 if (isset($_GET['from'])) echo '<input type="hidden" name="fop-from" value="' . htmlentities($_GET['from']) . '">';
								 ?>
								<div id='fop-upbar'></div>
								
									<?php
									$features = [];
									if (true && (true)) {
									$feature = [
										'id' => 'buttons',
										'title' => _('Aktionen'),
										'order' => '300', // 300 (50)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || (!isset($_POST['cancel'])) || true || true || true || true || (!isset($_POST['cancel'])) || (!isset($_POST['cancel'])) || (!isset($_POST['cancel'])) || (!isset($_POST['cancel'])))) {
									$feature = [
										'id' => 'main',
										'title' => _('Daten'),
										'order' => '100', // 100 (20)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. ((!isset($_POST['cancel'])) ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? 'true' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? '(form[\'lBXFiXqU\'])' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? '(form[\'6GSnIHxl\'])' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? '(form[\'51Tp3gKR\'])' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									

									
									/* load order from database
										schema: fop_form_feature(user, form, subid, key, value)
										key = (order, mode, position, collapsed)
									*/
									$upbar_collapsed = false;
									// default values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', (SELECT '.qi('value').' FROM fop_form_feature b WHERE a.subid = b.subid AND a.'.qi('key').' = b.'.qi('key').' AND '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY '.qi('value').' ORDER BY COUNT(*) DESC LIMIT 1) AS '.qi('value').' FROM fop_form_feature a WHERE '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY subid, '.qi('key'))->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										}
									}
									// form specific special values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', '.qi('value').' FROM fop_form_feature a WHERE form = \'wf:doc:create\' AND '.qi('user').' = '.intval(\FOP\User::getID()).'')->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										} else if ($setting['subid'] == 'upbar' && $setting['key'] == 'collapsed') {
											$upbar_collapsed = (bool) $setting['value'];
										}
									}

									/* fill in the content of the features */
									if (true && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['buttons']);
										?><div id='wf_doc_create_buttons' class='mdl-cell mdl-cell--12-col' style='flex-wrap: wrap;'><?php if (true) { ?><button onclick="
		var errors = $(this).closest('form').find('.fop-form-error:visible, .is-invalid').filter((i, x) => $(x).parents('.novalidate').length ? false : true);
		if (errors.length) {
			event.preventDefault();
			alert(errors.closest('.fop-form-content').prev('.fop-form-label').text() + ' Es sind noch Fehler im Formular bei Feld');
			return;
		} /* TODO: i18n */
		
	" type="submit" name="save" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">save</i><?php echo(_('save')); ?></button><?php } ?>
									&nbsp;<?php if (true) { ?><button onclick="$(this).closest('form').find('.mdl-textfield__error:visible').hide();
		$('[required]').removeAttr('required');
	" type="submit" name="cancel" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">cancel</i><?php echo(_('cancel')); ?></button><?php } ?>
									</div><script type='text/javascript'>
		// copy all buttons to #fop-upbar
		$(function () {
    var btn = document.getElementById("fop-bar-mainbutton");
    var upbar = $('#fop-upbar');
    var upbar_buttons = document.getElementById("fop-bar-container");

    // Check if the elements already exist
    if (!btn || !upbar_buttons) {
        if (!btn) {
            btn = $('<div id="fop-bar-mainbutton" class="mdl-button fop-button-half fop-button-margin mdl-button--raised"><i class="material-icons">keyboard_arrow_right</i></div>')
                .click(function () {
                    if (btn.find('i').text() == 'keyboard_arrow_right') {
                        upbar_buttons.fadeOut(400);
                        btn.find('i').text('keyboard_arrow_left');
                    } else {
                        upbar_buttons.fadeIn(400);
                        btn.find('i').text('keyboard_arrow_right');
                    }
                });
            upbar.append(btn);
        }

        if (!upbar_buttons) {
            upbar_buttons = $('<div id="fop-bar-container" style="max-width: 290px"></div>'); //dependant on the mdl-buttons width, caps of upbar buttons at exactly 4 buttons
            upbar.append(upbar_buttons);
        }

        var buttons = $('#wf_doc_create_buttons').find('.mdl-button');
        buttons.each(function (i, v) {
            var button = $(v);
            var newbutton = $('<div></div>');
            newbutton.attr('class', button.attr('class'));
            newbutton.attr('title', button.attr('title'));
            newbutton.append(button.find('.material-icons').clone(false));
            newbutton.click(function () {
                button[0].click();
            });
            upbar_buttons.append(newbutton);
        });
    }
});

	</script><?php
										\EasyEditor\FormFeature::pop();
										$features['buttons']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || (!isset($_POST['cancel'])) || true || true || true || true || (!isset($_POST['cancel'])) || (!isset($_POST['cancel'])) || (!isset($_POST['cancel'])) || (!isset($_POST['cancel'])))) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main']);
										?><?php if ((!isset($_POST['cancel']))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_type" id="column_type">
		<!-- Feld "Kategorie": type -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['type'])) { echo ' fop-disabled'; } ?>">
		<label for="type"><?php echo(_('Kategorie')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['type'])) { echo ' fop-disabled"><input type="hidden" name="type" value="' . htmlentities($hidden['type']); }
		?>">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\DocType::renderEditform_wf_doc_create_typeAction($data['type'], [], '');
?> &nbsp;	<?php if (\TablesRouter\DocType::createAccess()) { ?>  <a tabindex='-1' class='unimportant button' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\DocType::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'type\']'); ?>%26type=docType%26colinsert=type%26el=" + encodeURIComponent(id) + "%26close%26insert_param=colvalue", "_blank", "width=739, height=395"); return false;'><i class="material-icons">add</i></a> <?php } ?> &nbsp;	<a tabindex='-1' class='unimportant button fop-ddt-search' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\DocType::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'type\']'); ?>%26type=docType%26colinsert=type%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=docType", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div>
	</div>
	</div><?php } ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_subject" id="column_subject">
		<!-- Feld "Betreff": subject -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['subject'])) { echo ' fop-disabled'; } ?>">
		<label for="subject"><?php echo(_('Betreff')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['subject'])) { echo ' fop-disabled"><input type="hidden" name="subject" value="' . htmlentities($hidden['subject']); }
		?>">
		<div class="mdl-textfield mdl-js-textfield"><input onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			tabNext(this);
			return false;
		}
	"  class="mdl-textfield__input"  type="text" name="subject"  value="<?php echo htmlentities($data['subject']); ?>"/><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div>
	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_notes" id="column_notes">
		<!-- Feld "Notizen": notes -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['notes'])) { echo ' fop-disabled'; } ?>">
		<label for="notes"><?php echo(_('Notizen')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['notes'])) { echo ' fop-disabled"><input type="hidden" name="notes" value="' . htmlentities($hidden['notes']); }
		?>">
		
	<div tinymce-locale="<?php echo \FOP\I18n::getShortLocale(); ?>">
	
	<textarea ng-non-bindable rows="22" cols="50" name="notes" class="html-html"><?php echo htmlentities($data['notes']); ?></textarea>
	</div>
	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_date" id="column_date">
		<!-- Feld "Erfassungsdatum": date -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['date'])) { echo ' fop-disabled'; } ?>">
		<label for="date"><?php echo(_('Erfassungsdatum')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['date'])) { echo ' fop-disabled"><input type="hidden" name="date" value="' . htmlentities($hidden['date']); }
		?>">
		<div class="mdl-textfield mdl-js-textfield"><input onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			tabNext(this);
			return false;
		}
	" ts-locale='<?php echo (\FOP\I18n::getShortLocale()); ?>' ts-format='<?php echo (_('dateformat_moment')); ?>' class="mdl-textfield__input picker_date" id="date" type="text" name="date" value="<?php echo ($data['date']) ? strftime(_('dateformat_php2'), intval($data['date'])) : ''; ?>"/><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div>
	</div>
	</div><?php if ((!isset($_POST['cancel']))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_to_gruppe" id="column_to-gruppe" ng-show='form[&apos;lBXFiXqU&apos;]'>
		<!-- Feld "linked to %s|Gruppe": to-gruppe -->
	<div ng-show='form[&apos;lBXFiXqU&apos;]'	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['to-gruppe'])) { echo ' fop-disabled'; } ?>">
		<label for="to-gruppe"><?php echo(sprintf(_('linked to %s'), _('Gruppe'))); ?>: </label>
	</div>
	<div ng-show='form[&apos;lBXFiXqU&apos;]'	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['to-gruppe'])) { echo ' fop-disabled"><input type="hidden" name="to-gruppe" value="' . htmlentities($hidden['to-gruppe']); }
		?>">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\Gruppe::renderEditform_wf_doc_create_to_gruppeAction($data['to-gruppe'], [], '');
?> &nbsp;	<?php if (\TablesRouter\Gruppe::createAccess()) { ?>  <a tabindex='-1' class='unimportant button' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Gruppe::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'to-gruppe\']'); ?>%26type=gruppeNullDMS%26colinsert=to-gruppe%26el=" + encodeURIComponent(id) + "%26close%26insert_param=colvalue", "_blank", "width=739, height=395"); return false;'><i class="material-icons">add</i></a> <?php } ?> &nbsp;	<a tabindex='-1' class='unimportant button fop-ddt-search' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Gruppe::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'to-gruppe\']'); ?>%26type=gruppeNullDMS%26colinsert=to-gruppe%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=gruppeNullDMS", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div>
	</div>
	</div><?php } ?><?php if ((!isset($_POST['cancel']))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_to_mitglied" id="column_to-mitglied" ng-show='form[&apos;6GSnIHxl&apos;]'>
		<!-- Feld "linked to %s|Mitglied": to-mitglied -->
	<div ng-show='form[&apos;6GSnIHxl&apos;]'	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['to-mitglied'])) { echo ' fop-disabled'; } ?>">
		<label for="to-mitglied"><?php echo(sprintf(_('linked to %s'), _('Mitglied'))); ?>: </label>
	</div>
	<div ng-show='form[&apos;6GSnIHxl&apos;]'	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['to-mitglied'])) { echo ' fop-disabled"><input type="hidden" name="to-mitglied" value="' . htmlentities($hidden['to-mitglied']); }
		?>">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\Mitglied::renderEditform_wf_doc_create_to_mitgliedAction($data['to-mitglied'], [], '');
?> &nbsp;	<?php if (\TablesRouter\Mitglied::createAccess()) { ?>  <a tabindex='-1' class='unimportant button' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Mitglied::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'to-mitglied\']'); ?>%26type=mitgliedNullDMS%26colinsert=to-mitglied%26el=" + encodeURIComponent(id) + "%26close%26insert_param=colvalue", "_blank", "width=739, height=395"); return false;'><i class="material-icons">add</i></a> <?php } ?> &nbsp;	<a tabindex='-1' class='unimportant button fop-ddt-search' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Mitglied::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'to-mitglied\']'); ?>%26type=mitgliedNullDMS%26colinsert=to-mitglied%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=mitgliedNullDMS", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div>
	</div>
	</div><?php } ?><?php if ((!isset($_POST['cancel']))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_to_protokoll" id="column_to-protokoll" ng-show='form[&apos;51Tp3gKR&apos;]'>
		<!-- Feld "linked to %s|Protokoll": to-protokoll -->
	<div ng-show='form[&apos;51Tp3gKR&apos;]'	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['to-protokoll'])) { echo ' fop-disabled'; } ?>">
		<label for="to-protokoll"><?php echo(sprintf(_('linked to %s'), _('Protokoll'))); ?>: </label>
	</div>
	<div ng-show='form[&apos;51Tp3gKR&apos;]'	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['to-protokoll'])) { echo ' fop-disabled"><input type="hidden" name="to-protokoll" value="' . htmlentities($hidden['to-protokoll']); }
		?>">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\Protokoll::renderEditform_wf_doc_create_to_protokollAction($data['to-protokoll'], [], '');
?> &nbsp;	<?php if (\TablesRouter\Protokoll::createAccess()) { ?>  <a tabindex='-1' class='unimportant button' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Protokoll::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'to-protokoll\']'); ?>%26type=protokollNullDMS%26colinsert=to-protokoll%26el=" + encodeURIComponent(id) + "%26close%26insert_param=colvalue", "_blank", "width=739, height=395"); return false;'><i class="material-icons">add</i></a> <?php } ?> &nbsp;	<a tabindex='-1' class='unimportant button fop-ddt-search' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Protokoll::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'to-protokoll\']'); ?>%26type=protokollNullDMS%26colinsert=to-protokoll%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=protokollNullDMS", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div>
	</div>
	</div><?php } ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_archive" id="column_archive">
		<!-- Feld "Archiv": archive -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['archive'])) { echo ' fop-disabled'; } ?>">
		<label for="archive"><?php echo(_('Archiv')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['archive'])) { echo ' fop-disabled"><input type="hidden" name="archive" value="' . htmlentities($hidden['archive']); }
		?>">
		<input type="hidden" name="archive" id="archive" value="<?php echo ($data['archive']) ? '1' : '0'; ?>"/><label class="mdl-checkbox mdl-js-checkbox" style="width: unset;"><input onkeydown="
      if (event.keyCode == 13) {
         event.preventDefault();
         event.stopPropagation();
         tabNext(this);
         return false;
      }
   "  class="mdl-checkbox__input" id="archive__checkbox" type="checkbox" onchange="this.parentElement.previousElementSibling.value = this.checked ? 1 : 0;"<?php if ($data['archive']) echo ' checked'; ?>><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></label>
	</div>
	</div><?php if ((!isset($_POST['cancel']))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_file" id="column_file">
		<!-- Feld "file": file -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['file'])) { echo ' fop-disabled'; } ?>">
		<label for="file"><?php echo(_('file')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['file'])) { echo ' fop-disabled"><input type="hidden" name="file" value="' . htmlentities($hidden['file']); }
		?>">
		

	
		<div>

<?php
       $maxupload =  \FOP\Util::convertIniBytes(ini_get('upload_max_filesize'));

?>
<div class="fop-file-upload dropzone dropzone-file" id="zone<?php echo htmlentities(\FOP\Files::getNextDummyCounter($data['file'])); ?>"
<?php if ($data['file']) {
						$fileInfo = \FOP\Database::query('SELECT filename AS name, size FROM fop_files WHERE '.qi('ID').' = ' . \FOP\Database::quote($data['file']))->fetch(\PDO::FETCH_ASSOC);
						$fileInfo['accepted'] = true;
						echo ' data-fileinfo="' . htmlentities(json_encode($fileInfo)) . '"';
}
					?>>
  <div class="dz-message"><?php echo(_('dropfiles')); ?></div>
  <input type="hidden" class="fileinput" name="file" value="<?php echo htmlentities(\FOP\Files::getLastDummyCounter($data['file'])); ?>">
</div>


<script>
	Dropzone.autoDiscover = false;
   $(function (){
	   $('.dropzone-file').each(function(){
			var dropzoneElement = this;
		   if ($(this).attr('data-dropzone-attached')) return;
		   $(this).attr('data-dropzone-attached', true);

		   let dummycounter = $(dropzoneElement).find('input').val();
		   let zone = this;

		   $(this).dropzone({
				maxFiles: 1,
				addRemoveLinks: true,
				paramName: 'file_' + dummycounter,
				url: 'FOP/Files/upload?x=' + dummycounter,
				maxFilesize: <?php echo \FOP\Util::convertIniBytes(ini_get('upload_max_filesize')); ?> / 1000 / 1000,
				timeout: 30*60*1000,

				dictDefaultMessage: '<?php echo(addslashes(_('dropfiles'))) ?>',
				dictFallbackMessage: '<?php echo(addslashes(_('dropfiles_notpossible'))) ?>',
				dictFileTooBig: '<?php echo(addslashes(_('dropfiles_toobig'))) ?>',
				dictInvalidFileType: '<?php echo(addslashes(_('dropfiles_invalidtype'))) ?>',
				dictResponseError: '<?php echo(addslashes(_('dropfiles_responseerror'))) ?>',
				dictCancelUpload: '<?php echo(addslashes(_('dropfiles_cancelupload'))) ?>',
				dictUploadCanceled: '<?php echo(addslashes(_('dropfiles_uploadcanceled'))) ?>',
				dictCancelUploadConfirmation: '<?php echo(addslashes(_('dropfiles_cancelupload_confirmation'))) ?>',
				dictRemoveFile: '<?php echo(addslashes(_('dropfiles_removefile'))) ?>',
				dictRemoveFileConfirmation: '<?php echo(addslashes(_('dropfiles_removefile_confirmation'))) ?>',

				init: function(){
					let prevfile = null;
					let self = this;

					// Datei anzeigen, die schon hochgeladen wurde
					if (dropzoneElement.dataset['fileinfo']) {
						let f = JSON.parse(dropzoneElement.dataset['fileinfo']);
						self.files.push(f);
						self.emit('addedfile', f);
						self.emit('complete', f);
						prevfile = f;
					}

					/* keep track of uploads */
					this.on('sending', function () {
						window.running_uploads = (window.running_uploads || 0) + 1;
					});
					this.on('complete', function () {
						window.running_uploads = (window.running_uploads || 0) - 1;
					});
					
					
						this.on('addedfile', function() {
							if (prevfile) self.removeFile(prevfile);
						});

						this.on('success', function(file, file_id) {
							prevfile = file;
							file.file_id = file_id;
							$(zone).find('.fileinput').val(file_id);
						});

						this.on('removedfile', function(file) {
							$(zone).find('.fileinput').val('0');
						});
					
				}
		   });
	   });
    });
				</script>
		</div>
		
	</div>
	</div><?php } ?><?php
										\EasyEditor\FormFeature::pop();
										$features['main']['html'] = ob_get_contents();
										ob_end_clean();
									}
									

									uasort($features, function ($a, $b) {
										return strnatcmp($a['order'], $b['order']);
									});
									foreach ($features AS $feature) {
										\EasyEditor\FormFeature::render($feature);
									}
									?><script type='text/javascript'>
										$(function(){
											// bei Änderungen: prüfen, ob Form geändert wurde
											var formData = $('#cardform-wf_doc_create').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-wf_doc_create').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-wf_doc_create').on('submit', function () {
												document.body.onbeforeunload = undefined;
											});
											<?php if ($upbar_collapsed) {
												?>$('#fop-bar-mainbutton').click();<?php
											} ?>
											$('#fop-bar-mainbutton').click(function () {
												setTimeout(function () {
													setCFF('upbar', 'collapsed', $('#fop-bar-container').is(':visible') ? 0 : 1);
												}, 440); /* perfect timing for fadeOut */
											});
										});
										
										function setCFF(id, key, value) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFF?form=wf%3Adoc%3Acreate&subid=' + encodeURIComponent(id) + '&key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value)).then(function () {
												if (key == 'reset') {
													location.reload();
												}
											});
											<?php } /* EditAccess */ ?>
										}
										function setCFFOrder(fids) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFFOrder?form=wf%3Adoc%3Acreate&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_doc_create')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_doc_create input[type!="hidden"],textarea,select[tabindex!="-1"]').not('.fop-disabled *').filter(':visible:first').focus().select();
											}
										});

										$(window).keydown(function(event) {
											 if (event.ctrlKey && String.fromCharCode(event.which).toLowerCase() == 's') {
												 event.preventDefault();
												 $('button[type=submit]').click();
												 return false;
											 }
										});

										
										$(document).on('keyup',function(evt) {
										   if (evt.keyCode == 27) {
												if (window.parent) {
													window.close(); // iframe:close
												} else {
													window.history.back();
												}
											}
												});
										
									</script>

							</form>
							

							</div>
							<div class="content" id="focus-supersearch">
							</div>
							<div class="content" id="~spacer"><?php if (!isset($_GET['popup'])) { ?><div style="padding-bottom: 10cm;"></div><?php } ?>
							</div>
						<?php if (!isset($_GET['popup'])) { ?>
					</div>
				</main>
				
			</div>
		<?php } else { ?></div><?php } ?>
<?php if (!isset($_GET['popup'])) { ?><div class='fop-seal'></div><?php } ?></body></html><?php
    // --- BLOCK: main-6 ---
    }
    
  }

  public static function editAction($id = null ) { 
    
    
    // --- BLOCK: 0_CSRFValidate ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') \FOP\Session::validateCSRFToken(); else \FOP\Session::getCSRFToken();

    // --- BLOCK: 0_CSRF_ensure ---
    
	\FOP\Session::getCSRFToken();
    // --- BLOCK: access ---
    if(!(((\FOP\User::getDokument())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		
		/* Validatoren */
		
		if ((!isset($_POST['cancel']))) \Types\DocType::validate($_POST['type']);
		if ((!isset($_POST['cancel']))) \Types\MitgliedNullDMS::validate($_POST['to-mitglied']);
		if ((!isset($_POST['cancel']))) \Types\ProtokollNullDMS::validate($_POST['to-protokoll']);
		if ((!isset($_POST['cancel']))) \Types\GruppeNullDMS::validate($_POST['to-gruppe']);
		if ((!isset($_POST['cancel']))) \FOP\Files::validate($_POST['file']);

		
		/* Sanitizer */

		if ((!isset($_POST['cancel']))) $_POST['type'] = \FOP\Sanitizers::null_filter($_POST['type']);
		$_POST['date'] = \FOP\Sanitizers::convert_date_to_unix_timestamp($_POST['date']);
		$_POST['notes'] = \FOP\Sanitizers::htmlentities_decode($_POST['notes']);
		if ((!isset($_POST['cancel']))) $_POST['to-mitglied'] = \FOP\Sanitizers::null_filter($_POST['to-mitglied']);
		if ((!isset($_POST['cancel']))) $_POST['to-protokoll'] = \FOP\Sanitizers::null_filter($_POST['to-protokoll']);
		if ((!isset($_POST['cancel']))) $_POST['to-gruppe'] = \FOP\Sanitizers::null_filter($_POST['to-gruppe']);
		if ((!isset($_POST['cancel']))) $_POST['file'] = \FOP\Files::sanitizeUpload($_POST['file']);

		
	}
	
    // --- BLOCK: access+~to-gruppe:a761039152588d38de8934a8ef9cd3ef65093cda444a340e07f86ce069fb99b8:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-gruppe']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-gruppe']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-gruppe']) . '')->fetchColumn()))) : (true))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~to-mitglied:33682e8723b3cd8b498e3a6159829621f77b9e56d893e1f1f25004c6bbbc3df9:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) : (true))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~to-mitglied:865172ed5768c242d6b45e5ff377351532fd3bc8c82279a12d976c55f56fff3b:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) : (true))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~to-mitglied:f71986f7b3a9dafab8aaa15c1a3c801bb7f4afc6ecdd7755e359372112ead8e0:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-mitglied']) . '')->fetchColumn()))) : (true))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~to-protokoll:90a970a85288f06c92e34926b2f5b53f07be6328cf66691de41ccccb9b01670a:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-protokoll']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-protokoll']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['to-protokoll']) . '')->fetchColumn()))) : (true))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-doc-edit ---
    
		if ($id !== null && \FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getDokument()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('a3H18ePF').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('a3H18ePF').' WHERE '.qi('a3H18ePF').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('fXl0iMc3').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('fXl0iMc3').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('fXl0iMc3').' WHERE '.qi('fXl0iMc3').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('iVCI3rck').' WHERE '.qi('iVCI3rck').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-protokoll').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Ot4cBnlj').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Ot4cBnlj').' WHERE '.qi('Ot4cBnlj').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('K2POIfyF').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('K2POIfyF').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('K2POIfyF').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('K2POIfyF').' WHERE '.qi('K2POIfyF').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-gruppe').' LIMIT 1), TRUE)) FROM '.qi('doc').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: main ---
    
		// Main block
	
    // --- BLOCK: main-1 ---
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		if (!isset($_POST['cancel'])) {
			\FOP\Database::beginTransaction();
    // --- BLOCK: main-2:save-clone-prepare ---
    
		$data = self::view($id);
	
    // --- BLOCK: main-2:save-main ---
    
		$data_edit = [];
		$data_edit['file'] = $_POST['file'];
		$data_edit['date'] = $_POST['date'];
		$data_edit['subject'] = $_POST['subject'];
		$data_edit['notes'] = $_POST['notes'];
		$data_edit['archive'] = $_POST['archive'];
		if ((!isset($_POST['cancel']))) $data_edit['type'] = $_POST['type'];
		if ((!isset($_POST['cancel']))) $data_edit['to-mitglied'] = $_POST['to-mitglied'];
		if ((!isset($_POST['cancel']))) $data_edit['to-protokoll'] = $_POST['to-protokoll'];
		if ((!isset($_POST['cancel']))) $data_edit['to-gruppe'] = $_POST['to-gruppe'];
		self::edit($id, $data_edit);
		if (isset($data_edit['ID'])) {
			$id = $data_edit['ID'];
		}
	
    // --- BLOCK: main-3 ---
    
			\FOP\Database::commitTransaction();
			
		}
		
		if (isset($_POST['cancel'])) {
			
			if (isset($_POST['fop-from']) && $_POST['fop-from']) {
				// Redirect zu fop-from
				header('Location: ' . preg_replace('/&insert_param=(.*)$/', '&$1=' . ($id instanceof \FOP\IDList ? $id->toString() : $id), $_POST['fop-from']));
			} else {
				header('Location: ' . \TablesRouter\Doc::viewURL2(['id' => $id, 'popup' => $_GET['popup'] ?? null]));
			}
			die();
	
		}
		if (isset($_POST['save'])) {
			
			if (isset($_POST['fop-from']) && $_POST['fop-from']) {
				// Redirect zu fop-from
				header('Location: ' . preg_replace('/&insert_param=(.*)$/', '&$1=' . ($id instanceof \FOP\IDList ? $id->toString() : $id), $_POST['fop-from']));
			} else {
				header('Location: ' . \TablesRouter\Doc::viewURL2(['id' => $id, 'popup' => $_GET['popup'] ?? null]));
			}
			die();
	
		}
		die(json_encode($_POST));
	} else {
    // --- BLOCK: main-4:load-main ---
    
		$data = self::view($id); // TODO: klären, wer die Funktion bereitstellt (momentan crud/view.fop)
	
    // --- BLOCK: main-4:load-main-init-file ---
    $data['file'] = NULL;
	
    // --- BLOCK: main-5 ---
    ?><?php
			header('Content-Type: text/html; charset=UTF-8');
			header('X-XSS-Protection: 1; mode=block');
			header('Strict-Transport-Security: max-age=63072000');
			header('X-Content-Type-Options: nosniff');
			header("Content-Security-Policy: default-src *  data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';");


		?><!DOCTYPE html><html><head><title><?php echo htmlentities(str_replace('%s', \FOP\Database::query('SELECT CONCAT('.qi('doc').'.'.qi('subject').', \' - \', '.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('doc').'.'.qi('date').')'.(\FOP\Database::getDriver() == 'mysql' ? '' : '::date') . ', '.\FOP\Database::sessionVarSQL('dateformat').')) AS description FROM '.qi('doc').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() ?: '', _('edit %s'))); ?></title><base href='<?php echo \FOP\Util::getCurrentBaseurl(); ?>'><meta name="google" content="notranslate"><meta http-equiv="Content-Language" content="<?php echo htmlentities(\FOP\I18n::getLocale()); ?>"><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="style_dependencies.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><link rel="stylesheet" type="text/css" href="style.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><script type="text/javascript" src="js/script_dependencies.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="mobile-web-app-capable" content="yes"><link rel="manifest" href="manifest.webmanifest"><script type="text/javascript">moment.locale('<?php echo(\FOP\I18n::getShortLocale()); ?>');</script><script type="text/javascript" src="js/form.js"></script><script type="text/javascript">window.globals = <?php
	echo json_encode(['user:superadmin' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSuperadmin(), 'user:mitglied' => /* TODO: resanitizer später mal */(integer) \FOP\User::getMitglied(), 'user:gruppe' => /* TODO: resanitizer später mal */(integer) \FOP\User::getGruppe(), 'user:campaign' => /* TODO: resanitizer später mal */(integer) \FOP\User::getCampaign(), 'user:sammlung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSammlung(), 'user:protokoll' => /* TODO: resanitizer später mal */(integer) \FOP\User::getProtokoll(), 'user:ID' => /* TODO: resanitizer später mal */(integer) \FOP\User::getID(), 'user:buchhaltung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getBuchhaltung()]);
?>;</script><script type="text/javascript" src="angular/<?php echo(\FOP\I18n::getShortLocale()); ?>/js/alltypes.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><script type="text/javascript" src="angular/angular-i18n/angular-locale_<?php echo \FOP\I18n::getAngularLocale(); ?>.js"></script><script type="text/javascript" src="js/date-filter.js"></script><script type="text/javascript" src="js/dropdown.js"></script><script type="text/javascript" src="js/numeric.js"></script><script type="text/javascript" src="js/getparam.js"></script><script type="text/javascript" src="js/tables.js"></script>
		<script type="text/javascript" src="js/parsehash.js"></script><script type="text/javascript">
		window.query = <?php echo json_encode($_GET, JSON_FORCE_OBJECT); ?>;
		window.baseurl = <?php echo json_encode(\FOP\Util::getCurrentBaseurl()); ?>;

		window.i18n_weiter = <?php echo json_encode(_('Weiter'));?>;
		//Filter I18n:
		window.i18n_quartal = <?php echo json_encode(_('Quarter'));?>;
		window.i18n_alle = <?php echo json_encode(_('All'));?>;
		window.i18n_leere = <?php echo json_encode(_('Empty'));?>;
		window.i18n_tag = <?php echo json_encode(_('Tag'));?>;
		window.i18n_woche = <?php echo json_encode(_('Woche'));?>;
		window.i18n_zeitraum = <?php echo json_encode(_('Period'));?>;
		window.i18n_monat = <?php echo json_encode(_('Monat'));?>;
		window.i18n_jahr = <?php echo json_encode(_('Jahr'));?>;
		window.i18n_von = <?php echo json_encode(_('filters_from'));?>;
		window.i18n_bis = <?php echo json_encode(_('filters_to'));?>;
		window.i18n_tabButton = <?php echo json_encode(_('open_in_new_tab'));?>;
		window.i18n_closeButton = <?php echo json_encode(_('close'));?>;
		</script></head><script type="text/javascript">const fopPushPublicKey = '<?php echo(addslashes(\FOP\Configuration::getFOPPushPublicKey())); ?>';
        const fopUserID = <?php echo(intval(\FOP\User::getID())); ?>;
        var fopPushDisabled = false;
    </script><script type="text/javascript" src="js/serviceworkersetup.js"></script><body ng-app='app'>
		<div class='mdl-js-snackbar mdl-snackbar' id='snackbar'>
			<div class='mdl-snackbar__text'></div>
			<button class='mdl-snackbar__action' type='button'></button>
		</div>
		<script>
			var snackbar = document.querySelector('#snackbar');
			componentHandler.upgradeElement(snackbar, 'MaterialSnackbar');
			$(function () {
				setTimeout(function () {
					$('.fop-layout').scrollTop(0);
				}, 0);
			});
		</script>

		<?php if (isset($_GET['popup'])) { ?>
		<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo htmlentities(str_replace('%s', \FOP\Database::query('SELECT CONCAT('.qi('doc').'.'.qi('subject').', \' - \', '.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('doc').'.'.qi('date').')'.(\FOP\Database::getDriver() == 'mysql' ? '' : '::date') . ', '.\FOP\Database::sessionVarSQL('dateformat').')) AS description FROM '.qi('doc').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() ?: '', _('edit %s'))); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      	</header>
			<style>
				.content {
					margin-top: 0px !important;
				}
			</style>
			<div id='content' class='popup' >
		<?php } else { ?>
			<div class="fop-layout mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
			<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo htmlentities(str_replace('%s', \FOP\Database::query('SELECT CONCAT('.qi('doc').'.'.qi('subject').', \' - \', '.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('doc').'.'.qi('date').')'.(\FOP\Database::getDriver() == 'mysql' ? '' : '::date') . ', '.\FOP\Database::sessionVarSQL('dateformat').')) AS description FROM '.qi('doc').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() ?: '', _('edit %s'))); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      		</header>


				<?php  \EasyEditor\Navigation::render(); ?>
      
				<main class="mdl-layout__content" id="content">
					<div class="fop-content">
						<?php } ?>
						
							<div class="content" id="1">
								<?php if (\FOP\Database::query('SELECT '.qi('file').' FROM '.qi('doc_revision').' WHERE '.qi('doc').' = ' . \FOP\Database::quote($id) . ' ORDER BY created DESC')->fetchColumn()) { ?>
									<div class='mdl-grid form-document-container'>
										<div class='mdl-cell mdl-cell--6-col form-document'>
											<iframe style='width:100%;height:100%;' src='fop-files/<?php echo intval(\FOP\Database::query('SELECT '.qi('file').' FROM '.qi('doc_revision').' WHERE '.qi('doc').' = ' . \FOP\Database::quote($id) . ' ORDER BY created DESC')->fetchColumn()); ?>/x?inline'></iframe>
										</div>
										<div class='mdl-cell mdl-cell--6-col form-form'>
								<?php } ?>

								<form
									
									action="<?php echo \TablesRouter\Doc::editURL2(['popup' => $_GET['popup'] ?? null, 'id' => $id]); ?>"
									method="post"
									enctype="multipart/form-data" ng-submit='submit($event)'
									onsubmit="
										if (window.running_uploads) {
											event.preventDefault();
											alert('<?php echo htmlentities(json_encode(_('fileUploadStillActive')));?>');
										}
									"
								 
								id="cardform-wf_doc_edit"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_doc_edit" ng-init="form = <?php echo htmlentities(json_encode(['to-mitglied' => $data['to-mitglied'], 'to-protokoll' => $data['to-protokoll'], 'to-gruppe' => $data['to-gruppe'], 'type' => $data['type']]));
									?>;"
								>
								<?php
								 echo '<input type="hidden" name="csrftoken" value="' . htmlentities(\FOP\Session::getCSRFToken()) . '">';
								 if (isset($_GET['from'])) echo '<input type="hidden" name="fop-from" value="' . htmlentities($_GET['from']) . '">';
								 ?>
								<div id='fop-upbar'></div>
								
									<?php
									$features = [];
									if (true && (true)) {
									$feature = [
										'id' => 'buttons',
										'title' => _('Aktionen'),
										'order' => '300', // 300 (50)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || (!isset($_POST['cancel'])) || true || true || true || true || (!isset($_POST['cancel'])) || (!isset($_POST['cancel'])) || (!isset($_POST['cancel'])) || (!isset($_POST['cancel'])))) {
									$feature = [
										'id' => 'main',
										'title' => _('Daten'),
										'order' => '100', // 100 (20)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. ((!isset($_POST['cancel'])) ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? 'true' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? '(form[\'lBXFiXqU\'])' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? '(form[\'6GSnIHxl\'])' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? '(form[\'51Tp3gKR\'])' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									

									
									/* load order from database
										schema: fop_form_feature(user, form, subid, key, value)
										key = (order, mode, position, collapsed)
									*/
									$upbar_collapsed = false;
									// default values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', (SELECT '.qi('value').' FROM fop_form_feature b WHERE a.subid = b.subid AND a.'.qi('key').' = b.'.qi('key').' AND '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY '.qi('value').' ORDER BY COUNT(*) DESC LIMIT 1) AS '.qi('value').' FROM fop_form_feature a WHERE '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY subid, '.qi('key'))->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										}
									}
									// form specific special values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', '.qi('value').' FROM fop_form_feature a WHERE form = \'wf:doc:edit\' AND '.qi('user').' = '.intval(\FOP\User::getID()).'')->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										} else if ($setting['subid'] == 'upbar' && $setting['key'] == 'collapsed') {
											$upbar_collapsed = (bool) $setting['value'];
										}
									}

									/* fill in the content of the features */
									if (true && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['buttons']);
										?><div id='wf_doc_edit_buttons' class='mdl-cell mdl-cell--12-col' style='flex-wrap: wrap;'><?php if (true) { ?><button onclick="
		var errors = $(this).closest('form').find('.fop-form-error:visible, .is-invalid').filter((i, x) => $(x).parents('.novalidate').length ? false : true);
		if (errors.length) {
			event.preventDefault();
			alert(errors.closest('.fop-form-content').prev('.fop-form-label').text() + ' Es sind noch Fehler im Formular bei Feld');
			return;
		} /* TODO: i18n */
		
	" type="submit" name="save" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">save</i><?php echo(_('save')); ?></button><?php } ?>
									&nbsp;<?php if (true) { ?><button onclick="$(this).closest('form').find('.mdl-textfield__error:visible').hide();
		$('[required]').removeAttr('required');
	" type="submit" name="cancel" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">cancel</i><?php echo(_('cancel')); ?></button><?php } ?>
									</div><script type='text/javascript'>
		// copy all buttons to #fop-upbar
		$(function () {
    var btn = document.getElementById("fop-bar-mainbutton");
    var upbar = $('#fop-upbar');
    var upbar_buttons = document.getElementById("fop-bar-container");

    // Check if the elements already exist
    if (!btn || !upbar_buttons) {
        if (!btn) {
            btn = $('<div id="fop-bar-mainbutton" class="mdl-button fop-button-half fop-button-margin mdl-button--raised"><i class="material-icons">keyboard_arrow_right</i></div>')
                .click(function () {
                    if (btn.find('i').text() == 'keyboard_arrow_right') {
                        upbar_buttons.fadeOut(400);
                        btn.find('i').text('keyboard_arrow_left');
                    } else {
                        upbar_buttons.fadeIn(400);
                        btn.find('i').text('keyboard_arrow_right');
                    }
                });
            upbar.append(btn);
        }

        if (!upbar_buttons) {
            upbar_buttons = $('<div id="fop-bar-container" style="max-width: 290px"></div>'); //dependant on the mdl-buttons width, caps of upbar buttons at exactly 4 buttons
            upbar.append(upbar_buttons);
        }

        var buttons = $('#wf_doc_edit_buttons').find('.mdl-button');
        buttons.each(function (i, v) {
            var button = $(v);
            var newbutton = $('<div></div>');
            newbutton.attr('class', button.attr('class'));
            newbutton.attr('title', button.attr('title'));
            newbutton.append(button.find('.material-icons').clone(false));
            newbutton.click(function () {
                button[0].click();
            });
            upbar_buttons.append(newbutton);
        });
    }
});

	</script><?php
										\EasyEditor\FormFeature::pop();
										$features['buttons']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || (!isset($_POST['cancel'])) || true || true || true || true || (!isset($_POST['cancel'])) || (!isset($_POST['cancel'])) || (!isset($_POST['cancel'])) || (!isset($_POST['cancel'])))) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main']);
										?><?php if ((!isset($_POST['cancel']))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_type" id="column_type">
		<!-- Feld "Kategorie": type -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="type"><?php echo(_('Kategorie')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\DocType::renderEditform_wf_doc_edit_typeAction($data['type'], [], '');
?> &nbsp;	<?php if (\TablesRouter\DocType::createAccess()) { ?>  <a tabindex='-1' class='unimportant button' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\DocType::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'type\']'); ?>%26type=docType%26colinsert=type%26el=" + encodeURIComponent(id) + "%26close%26insert_param=colvalue", "_blank", "width=739, height=395"); return false;'><i class="material-icons">add</i></a> <?php } ?> &nbsp;	<a tabindex='-1' class='unimportant button fop-ddt-search' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\DocType::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'type\']'); ?>%26type=docType%26colinsert=type%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=docType", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div>
	</div>
	</div><?php } ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_subject" id="column_subject">
		<!-- Feld "Betreff": subject -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="subject"><?php echo(_('Betreff')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div class="mdl-textfield mdl-js-textfield"><input onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			tabNext(this);
			return false;
		}
	"  class="mdl-textfield__input"  type="text" name="subject"  value="<?php echo htmlentities($data['subject']); ?>"/><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div>
	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_notes" id="column_notes">
		<!-- Feld "Notizen": notes -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="notes"><?php echo(_('Notizen')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		
	<div tinymce-locale="<?php echo \FOP\I18n::getShortLocale(); ?>">
	
	<textarea ng-non-bindable rows="22" cols="50" name="notes" class="html-html"><?php echo htmlentities($data['notes']); ?></textarea>
	</div>
	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_date" id="column_date">
		<!-- Feld "Erfassungsdatum": date -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="date"><?php echo(_('Erfassungsdatum')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div class="mdl-textfield mdl-js-textfield"><input onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			tabNext(this);
			return false;
		}
	" ts-locale='<?php echo (\FOP\I18n::getShortLocale()); ?>' ts-format='<?php echo (_('dateformat_moment')); ?>' class="mdl-textfield__input picker_date" id="date" type="text" name="date" value="<?php echo ($data['date']) ? strftime(_('dateformat_php2'), intval($data['date'])) : ''; ?>"/><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div>
	</div>
	</div><?php if ((!isset($_POST['cancel']))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_to_gruppe" id="column_to-gruppe" ng-show='form[&apos;lBXFiXqU&apos;]'>
		<!-- Feld "linked to %s|Gruppe": to-gruppe -->
	<div ng-show='form[&apos;lBXFiXqU&apos;]'	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="to-gruppe"><?php echo(sprintf(_('linked to %s'), _('Gruppe'))); ?>: </label>
	</div>
	<div ng-show='form[&apos;lBXFiXqU&apos;]'	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\Gruppe::renderEditform_wf_doc_edit_to_gruppeAction($data['to-gruppe'], [], '');
?> &nbsp;	<?php if (\TablesRouter\Gruppe::createAccess()) { ?>  <a tabindex='-1' class='unimportant button' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Gruppe::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'to-gruppe\']'); ?>%26type=gruppeNullDMS%26colinsert=to-gruppe%26el=" + encodeURIComponent(id) + "%26close%26insert_param=colvalue", "_blank", "width=739, height=395"); return false;'><i class="material-icons">add</i></a> <?php } ?> &nbsp;	<a tabindex='-1' class='unimportant button fop-ddt-search' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Gruppe::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'to-gruppe\']'); ?>%26type=gruppeNullDMS%26colinsert=to-gruppe%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=gruppeNullDMS", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div>
	</div>
	</div><?php } ?><?php if ((!isset($_POST['cancel']))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_to_mitglied" id="column_to-mitglied" ng-show='form[&apos;6GSnIHxl&apos;]'>
		<!-- Feld "linked to %s|Mitglied": to-mitglied -->
	<div ng-show='form[&apos;6GSnIHxl&apos;]'	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="to-mitglied"><?php echo(sprintf(_('linked to %s'), _('Mitglied'))); ?>: </label>
	</div>
	<div ng-show='form[&apos;6GSnIHxl&apos;]'	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\Mitglied::renderEditform_wf_doc_edit_to_mitgliedAction($data['to-mitglied'], [], '');
?> &nbsp;	<?php if (\TablesRouter\Mitglied::createAccess()) { ?>  <a tabindex='-1' class='unimportant button' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Mitglied::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'to-mitglied\']'); ?>%26type=mitgliedNullDMS%26colinsert=to-mitglied%26el=" + encodeURIComponent(id) + "%26close%26insert_param=colvalue", "_blank", "width=739, height=395"); return false;'><i class="material-icons">add</i></a> <?php } ?> &nbsp;	<a tabindex='-1' class='unimportant button fop-ddt-search' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Mitglied::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'to-mitglied\']'); ?>%26type=mitgliedNullDMS%26colinsert=to-mitglied%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=mitgliedNullDMS", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div>
	</div>
	</div><?php } ?><?php if ((!isset($_POST['cancel']))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_to_protokoll" id="column_to-protokoll" ng-show='form[&apos;51Tp3gKR&apos;]'>
		<!-- Feld "linked to %s|Protokoll": to-protokoll -->
	<div ng-show='form[&apos;51Tp3gKR&apos;]'	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="to-protokoll"><?php echo(sprintf(_('linked to %s'), _('Protokoll'))); ?>: </label>
	</div>
	<div ng-show='form[&apos;51Tp3gKR&apos;]'	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\Protokoll::renderEditform_wf_doc_edit_to_protokollAction($data['to-protokoll'], [], '');
?> &nbsp;	<?php if (\TablesRouter\Protokoll::createAccess()) { ?>  <a tabindex='-1' class='unimportant button' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Protokoll::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'to-protokoll\']'); ?>%26type=protokollNullDMS%26colinsert=to-protokoll%26el=" + encodeURIComponent(id) + "%26close%26insert_param=colvalue", "_blank", "width=739, height=395"); return false;'><i class="material-icons">add</i></a> <?php } ?> &nbsp;	<a tabindex='-1' class='unimportant button fop-ddt-search' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Protokoll::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'to-protokoll\']'); ?>%26type=protokollNullDMS%26colinsert=to-protokoll%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=protokollNullDMS", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div>
	</div>
	</div><?php } ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_archive" id="column_archive">
		<!-- Feld "Archiv": archive -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="archive"><?php echo(_('Archiv')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<input type="hidden" name="archive" id="archive" value="<?php echo ($data['archive']) ? '1' : '0'; ?>"/><label class="mdl-checkbox mdl-js-checkbox" style="width: unset;"><input onkeydown="
      if (event.keyCode == 13) {
         event.preventDefault();
         event.stopPropagation();
         tabNext(this);
         return false;
      }
   "  class="mdl-checkbox__input" id="archive__checkbox" type="checkbox" onchange="this.parentElement.previousElementSibling.value = this.checked ? 1 : 0;"<?php if ($data['archive']) echo ' checked'; ?>><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></label>
	</div>
	</div><?php if ((!isset($_POST['cancel']))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_file" id="column_file">
		<!-- Feld "file": file -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="file"><?php echo(_('file')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		

	
		<div>

<?php
       $maxupload =  \FOP\Util::convertIniBytes(ini_get('upload_max_filesize'));

?>
<div class="fop-file-upload dropzone dropzone-file" id="zone<?php echo htmlentities(\FOP\Files::getNextDummyCounter($data['file'])); ?>"
<?php if ($data['file']) {
						$fileInfo = \FOP\Database::query('SELECT filename AS name, size FROM fop_files WHERE '.qi('ID').' = ' . \FOP\Database::quote($data['file']))->fetch(\PDO::FETCH_ASSOC);
						$fileInfo['accepted'] = true;
						echo ' data-fileinfo="' . htmlentities(json_encode($fileInfo)) . '"';
}
					?>>
  <div class="dz-message"><?php echo(_('dropfiles')); ?></div>
  <input type="hidden" class="fileinput" name="file" value="<?php echo htmlentities(\FOP\Files::getLastDummyCounter($data['file'])); ?>">
</div>


<script>
	Dropzone.autoDiscover = false;
   $(function (){
	   $('.dropzone-file').each(function(){
			var dropzoneElement = this;
		   if ($(this).attr('data-dropzone-attached')) return;
		   $(this).attr('data-dropzone-attached', true);

		   let dummycounter = $(dropzoneElement).find('input').val();
		   let zone = this;

		   $(this).dropzone({
				maxFiles: 1,
				addRemoveLinks: true,
				paramName: 'file_' + dummycounter,
				url: 'FOP/Files/upload?x=' + dummycounter,
				maxFilesize: <?php echo \FOP\Util::convertIniBytes(ini_get('upload_max_filesize')); ?> / 1000 / 1000,
				timeout: 30*60*1000,

				dictDefaultMessage: '<?php echo(addslashes(_('dropfiles'))) ?>',
				dictFallbackMessage: '<?php echo(addslashes(_('dropfiles_notpossible'))) ?>',
				dictFileTooBig: '<?php echo(addslashes(_('dropfiles_toobig'))) ?>',
				dictInvalidFileType: '<?php echo(addslashes(_('dropfiles_invalidtype'))) ?>',
				dictResponseError: '<?php echo(addslashes(_('dropfiles_responseerror'))) ?>',
				dictCancelUpload: '<?php echo(addslashes(_('dropfiles_cancelupload'))) ?>',
				dictUploadCanceled: '<?php echo(addslashes(_('dropfiles_uploadcanceled'))) ?>',
				dictCancelUploadConfirmation: '<?php echo(addslashes(_('dropfiles_cancelupload_confirmation'))) ?>',
				dictRemoveFile: '<?php echo(addslashes(_('dropfiles_removefile'))) ?>',
				dictRemoveFileConfirmation: '<?php echo(addslashes(_('dropfiles_removefile_confirmation'))) ?>',

				init: function(){
					let prevfile = null;
					let self = this;

					// Datei anzeigen, die schon hochgeladen wurde
					if (dropzoneElement.dataset['fileinfo']) {
						let f = JSON.parse(dropzoneElement.dataset['fileinfo']);
						self.files.push(f);
						self.emit('addedfile', f);
						self.emit('complete', f);
						prevfile = f;
					}

					/* keep track of uploads */
					this.on('sending', function () {
						window.running_uploads = (window.running_uploads || 0) + 1;
					});
					this.on('complete', function () {
						window.running_uploads = (window.running_uploads || 0) - 1;
					});
					
					
						this.on('addedfile', function() {
							if (prevfile) self.removeFile(prevfile);
						});

						this.on('success', function(file, file_id) {
							prevfile = file;
							file.file_id = file_id;
							$(zone).find('.fileinput').val(file_id);
						});

						this.on('removedfile', function(file) {
							$(zone).find('.fileinput').val('0');
						});
					
				}
		   });
	   });
    });
				</script>
		</div>
		
	</div>
	</div><?php } ?><?php
										\EasyEditor\FormFeature::pop();
										$features['main']['html'] = ob_get_contents();
										ob_end_clean();
									}
									

									uasort($features, function ($a, $b) {
										return strnatcmp($a['order'], $b['order']);
									});
									foreach ($features AS $feature) {
										\EasyEditor\FormFeature::render($feature);
									}
									?><script type='text/javascript'>
										$(function(){
											// bei Änderungen: prüfen, ob Form geändert wurde
											var formData = $('#cardform-wf_doc_edit').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-wf_doc_edit').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-wf_doc_edit').on('submit', function () {
												document.body.onbeforeunload = undefined;
											});
											<?php if ($upbar_collapsed) {
												?>$('#fop-bar-mainbutton').click();<?php
											} ?>
											$('#fop-bar-mainbutton').click(function () {
												setTimeout(function () {
													setCFF('upbar', 'collapsed', $('#fop-bar-container').is(':visible') ? 0 : 1);
												}, 440); /* perfect timing for fadeOut */
											});
										});
										
										function setCFF(id, key, value) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFF?form=wf%3Adoc%3Aedit&subid=' + encodeURIComponent(id) + '&key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value)).then(function () {
												if (key == 'reset') {
													location.reload();
												}
											});
											<?php } /* EditAccess */ ?>
										}
										function setCFFOrder(fids) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFFOrder?form=wf%3Adoc%3Aedit&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_doc_edit')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_doc_edit input[type!="hidden"],textarea,select[tabindex!="-1"]').not('.fop-disabled *').filter(':visible:first').focus().select();
											}
										});

										$(window).keydown(function(event) {
											 if (event.ctrlKey && String.fromCharCode(event.which).toLowerCase() == 's') {
												 event.preventDefault();
												 $('button[type=submit]').click();
												 return false;
											 }
										});

										
										$(document).on('keyup',function(evt) {
										   if (evt.keyCode == 27) {
												if (window.parent) {
													window.close(); // iframe:close
												} else {
													window.history.back();
												}
											}
												});
										
									</script>

							</form>
							<?php if (\FOP\Database::query('SELECT '.qi('file').' FROM '.qi('doc_revision').' WHERE '.qi('doc').' = ' . \FOP\Database::quote($id) . ' ORDER BY created DESC')->fetchColumn()) { ?></div></div><?php } ?>

							</div>
							<div class="content" id="focus-supersearch">
							</div>
							<div class="content" id="~spacer"><?php if (!isset($_GET['popup'])) { ?><div style="padding-bottom: 10cm;"></div><?php } ?>
							</div>
						<?php if (!isset($_GET['popup'])) { ?>
					</div>
				</main>
				
			</div>
		<?php } else { ?></div><?php } ?>
<?php if (!isset($_GET['popup'])) { ?><div class='fop-seal'></div><?php } ?></body></html><?php
    // --- BLOCK: main-6 ---
    }
    
  }

  public static function getFileAction($id) { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getDokument())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access-item-doc-view ---
    
		if (\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getDokument()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('ok3G4wPh').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('ok3G4wPh').' WHERE '.qi('ok3G4wPh').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('2Hyq8DKe').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('2Hyq8DKe').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('2Hyq8DKe').' WHERE '.qi('2Hyq8DKe').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('jYtYUs5c').' WHERE '.qi('jYtYUs5c').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-protokoll').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('bmxCMQlw').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('bmxCMQlw').' WHERE '.qi('bmxCMQlw').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('9lhFb6lb').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('9lhFb6lb').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('9lhFb6lb').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('9lhFb6lb').' WHERE '.qi('9lhFb6lb').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-gruppe').' LIMIT 1), TRUE)) FROM '.qi('doc').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: main ---
    
		return self::view($id)['file'];
	
    
  }

  public static function loadArchiveFop_listItems($id) { 
    
    
    // --- BLOCK: main ---
    
		/* TODO: SQL Query bauen mit SQLQuery-Fakten */
		$items =
		\FOP\Database::query('SELECT '.qi('doc').'.'.qi('ID').' AS '.qi('ID').', '.qi('doc').'.'.qi('type').', '.qi('doc').'.'.qi('date').', '.qi('doc').'.'.qi('subject').', '.qi('doc').'.'.qi('notes').', '.qi('doc').'.'.qi('to-mitglied').', '.qi('doc').'.'.qi('to-protokoll').', '.qi('doc').'.'.qi('to-gruppe').', '.qi('doc').'.'.qi('archive').', (SELECT MIN('.qi('2cOfKiO9').'.'.qi('created').') FROM '.qi('doc_revision').' '.qi('2cOfKiO9').' WHERE '.qi('2cOfKiO9').'.'.qi('doc').' = '.qi('doc').'.'.qi('ID').' LIMIT 1) AS '.qi('first').', (SELECT MAX('.qi('Y34Pv7BX').'.'.qi('created').') FROM '.qi('doc_revision').' '.qi('Y34Pv7BX').' WHERE '.qi('Y34Pv7BX').'.'.qi('doc').' = '.qi('doc').'.'.qi('ID').' LIMIT 1) AS '.qi('last').', (SELECT ('.qi('pcs0uG6Q').'.'.qi('file').') FROM '.qi('doc_revision').' '.qi('pcs0uG6Q').' WHERE '.qi('pcs0uG6Q').'.'.qi('doc').' = '.qi('doc').'.'.qi('ID').' ORDER BY '.qi('pcs0uG6Q').'.'.qi('created').' DESC LIMIT 1) AS '.qi('file').',
			((FALSE) AND ('.\FOP\Database::quote(\FOP\User::getDokument()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('jiHGDwTc').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('jiHGDwTc').' WHERE '.qi('jiHGDwTc').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('2L3JcPgq').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('2L3JcPgq').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('2L3JcPgq').' WHERE '.qi('2L3JcPgq').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('aVKzkIxT').' WHERE '.qi('aVKzkIxT').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-protokoll').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('oYgz3Zk9').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('oYgz3Zk9').' WHERE '.qi('oYgz3Zk9').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('Je6BzKDx').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('Je6BzKDx').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('Je6BzKDx').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('Je6BzKDx').' WHERE '.qi('Je6BzKDx').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-gruppe').' LIMIT 1), TRUE))) AS '.qi('canDelete').'
			FROM '.qi('doc').' 
			WHERE (('.\FOP\Database::quote(\FOP\User::getDokument()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('a3H18ePF').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('a3H18ePF').' WHERE '.qi('a3H18ePF').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('fXl0iMc3').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('fXl0iMc3').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('fXl0iMc3').' WHERE '.qi('fXl0iMc3').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('iVCI3rck').' WHERE '.qi('iVCI3rck').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-protokoll').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Ot4cBnlj').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Ot4cBnlj').' WHERE '.qi('Ot4cBnlj').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('K2POIfyF').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('K2POIfyF').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('K2POIfyF').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('K2POIfyF').' WHERE '.qi('K2POIfyF').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-gruppe').' LIMIT 1), TRUE))) AND (' . (new \FOP\IDList($id))->toSQL(qi('doc').'.'.qi('ID')) . ') ORDER BY '.qi('doc').'.'.qi('date').' DESC')->fetchAll(\PDO::FETCH_ASSOC);

		foreach($items as &$item) {
		}
		return $items;
	
    
  }

  public static function delete($id, $disregardPermissions = false ) { 
    
    
    // --- BLOCK: main ---
    
			$sql = 'SELECT ' . ($disregardPermissions ? 1 : '(FALSE) AND ('.\FOP\Database::quote(\FOP\User::getDokument()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('jiHGDwTc').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('jiHGDwTc').' WHERE '.qi('jiHGDwTc').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('2L3JcPgq').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('2L3JcPgq').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('2L3JcPgq').' WHERE '.qi('2L3JcPgq').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('aVKzkIxT').' WHERE '.qi('aVKzkIxT').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-protokoll').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('oYgz3Zk9').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('oYgz3Zk9').' WHERE '.qi('oYgz3Zk9').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('Je6BzKDx').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('Je6BzKDx').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('Je6BzKDx').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('Je6BzKDx').' WHERE '.qi('Je6BzKDx').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-gruppe').' LIMIT 1), TRUE))') . ' FROM '.qi('doc').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id);
			if (\FOP\Database::query($sql)->fetchColumn() != 1) {
				return false;
			}
			
			$sql = 'DELETE FROM  '.qi('doc').'  WHERE '.qi('ID').' = ' . \FOP\Database::quote($id);
			$result = \FOP\Database::query($sql);
			
			return true;
	
    
  }

  public static function archiveListFop_listAction($row = null , $parent = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: before-prepare-parent ---
    
		if (!isset($parent)) $parent = [];
	
    // --- BLOCK: before-prepare-row ---
    
		if (!is_array($row)) {
			$parentrow = [];
			$row = \Tables\Doc::getDefaults();
			$row['ID'] = '';
			$row['canDelete'] = true;
			\Tables\Doc::sanitizeDefaults($row, true, 'doc', $parentrow);
		} else {
			
			$row['archive'] = \FOP\Util::BoolSanitizer($row['archive']);			
			$row['canDelete'] = false;
		}
		
		
    // --- BLOCK: main ---
    
		?>
		<tr class='wfl-item'>
					<td class='mdl-data-table__cell--non-numeric'>
						<div>
							<?php if ($row['canDelete']) { ?>
							<div class='mdl-button mdl-js-button mdl-button--colored mdl-button--raised' onclick='$(this).closest("tr").fadeOut().find("input[name=&apos;fop_list[]&apos;]").val("0");'>
								<i class="material-icons">remove</i>
							</div>
							<?php } ?>
							<input type='hidden' name='fop_list[]' value='1'>
							<input type='hidden' name='fop_list_ID[]' value='<?php echo htmlentities($row['ID']); ?>'>
						</div>
					</td><?php
        // Unterscheidung Create/Edit
        if ($row['ID'] ? true : true) {
        	?><!-- Spalte "Archiv": archive
			--><td class='mdl-data-table__cell--non-numeric'><span><input type="hidden" name="fop_list_archive[]" id="fop_list_archive[]" value="<?php echo ($row['archive']) ? '1' : '0'; ?>"/><label class="mdl-checkbox mdl-js-checkbox" style="width: unset;"><input onkeydown="
      if (event.keyCode == 13) {
         event.preventDefault();
         event.stopPropagation();
         tabNext(this);
         return false;
      }
   "  class="mdl-checkbox__input" id="fop_list_archive[]__checkbox" type="checkbox" onchange="this.parentElement.previousElementSibling.value = this.checked ? 1 : 0;"<?php if ($row['archive']) echo ' checked'; ?>><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></label></span>
			</td><?php } else if (/* Create aber nicht edit: leere Zelle
			*/true || true) { ?><td>&nbsp;</td><?php } ?></tr><?php
	
    
  }

  public static function create($data, $disregardPermissions = false , $updateOnDuplicate = false ) { 
    
    
    // --- BLOCK: main ---
    
				$sql = 'INSERT INTO '.qi('doc').'(';
				
				$set = [];
				
					
					$set[qi('type')] = \FOP\Database::quote($data['type']);
					
				
					
					$set[qi('date')] = \FOP\Database::quote($data['date']);
					
				
					
					$set[qi('subject')] = \FOP\Database::quote($data['subject']);
					
				
					
					$set[qi('notes')] = \FOP\Database::quote($data['notes']);
					
				
					
					$set[qi('to-mitglied')] = \FOP\Database::quote($data['to-mitglied']);
					
				
					
					$set[qi('to-protokoll')] = \FOP\Database::quote($data['to-protokoll']);
					
				
					
					$set[qi('to-gruppe')] = \FOP\Database::quote($data['to-gruppe']);
					
				
					
					$set[qi('archive')] = \FOP\Database::quote($data['archive']);
					
				
					$set[qi('postboxtype')] = '' . \FOP\Database::quote($data['postboxtype'] ?? '') . '';
					$set[qi('msgid')] = '' . intval($data['msgid'] ?? '') . '';
					$set[qi('boxid')] = '' . intval($data['boxid'] ?? ''). '';
				$id = 0;

				$sql = $sql . implode(', ', array_keys($set)) . ') VALUES (' . implode(', ', array_values($set)) . ')';
				if ($updateOnDuplicate){
					// TODO: Postgres ON CONFLICT(...) DO UPDATE SET ...
					$set2 = [];
					foreach ($set AS $k => $v) {
						array_push($set2, "$k = $v");
					}
					if (\FOP\Database::getDriver() == 'mysql') {
						$sql .= ' ON DUPLICATE KEY UPDATE ' . implode(', ', $set2);
					} else {
						
					}
				}

				try {
					\FOP\Database::query($sql);
					$id = \FOP\Database::getLastInsertId();
				} catch (\PDOException $e) {
					if ($e->errorInfo[1] == 1062) {
						throw new \FOP\AccessDeniedException('duplicateinsert');
					}
                    throw $e; // weiterwerfen
				}
				$data['fop-id'] = $id; // für Hooks
				
	if (isset($data['file'])) {
		\FOP\Database::query('INSERT INTO '.qi('doc_revision').'('.qi('doc').', created, '.qi('file').') VALUES ('.\FOP\Database::quote($id).', UNIX_TIMESTAMP(), '.\FOP\Database::quote($data['file']).')');
	}

				return $id;

    
  }

  public static function view($id, $snippet = false , $ignoreAccess = false ) { 
    
    
    // --- BLOCK: main ---
    
		$sql = 'SELECT /* ID */ '.qi('ID').' AS '.qi('ID').',
									/* ID */ '.qi('doc').'.'.qi('ID').' AS '.qi('ID').',
									/* archive */ '.qi('doc').'.'.qi('archive').' AS '.qi('archive').',
									/* boxid */ '.qi('doc').'.'.qi('boxid').' AS '.qi('boxid').',
									/* date */ '.qi('doc').'.'.qi('date').' AS '.qi('date').',
									/* file */ (SELECT ('.qi('pcs0uG6Q').'.'.qi('file').') FROM '.qi('doc_revision').' '.qi('pcs0uG6Q').' WHERE '.qi('pcs0uG6Q').'.'.qi('doc').' = '.qi('doc').'.'.qi('ID').' ORDER BY '.qi('pcs0uG6Q').'.'.qi('created').' DESC LIMIT 1) AS '.qi('file').',
									/* first */ (SELECT MIN('.qi('2cOfKiO9').'.'.qi('created').') FROM '.qi('doc_revision').' '.qi('2cOfKiO9').' WHERE '.qi('2cOfKiO9').'.'.qi('doc').' = '.qi('doc').'.'.qi('ID').' LIMIT 1) AS '.qi('first').',
									/* last */ (SELECT MAX('.qi('Y34Pv7BX').'.'.qi('created').') FROM '.qi('doc_revision').' '.qi('Y34Pv7BX').' WHERE '.qi('Y34Pv7BX').'.'.qi('doc').' = '.qi('doc').'.'.qi('ID').' LIMIT 1) AS '.qi('last').',
									/* msgid */ '.qi('doc').'.'.qi('msgid').' AS '.qi('msgid').',
									/* notes */ '.qi('doc').'.'.qi('notes').' AS '.qi('notes').',
									/* operation::85d1b573ee36a75e68edfb481189fc7817384d39e08985b286816a5d2410d60f */ (('.qi('doc').'.'.qi('archive').') = (0)) AS '.qi('operation::85d1b573ee36a75e68edfb481189fc7817384d39e08985b286816a5d2410d60f').',
									/* operation::create */ ('.\FOP\Database::quote(\FOP\User::getDokument()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('Lz3GkDZU').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('Lz3GkDZU').' WHERE '.qi('Lz3GkDZU').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('NZmTwx0z').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('NZmTwx0z').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('NZmTwx0z').' WHERE '.qi('NZmTwx0z').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('S0UBR3pi').' WHERE '.qi('S0UBR3pi').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-protokoll').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('kXMUqzLH').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('kXMUqzLH').' WHERE '.qi('kXMUqzLH').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('7zme5GbR').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('7zme5GbR').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('7zme5GbR').' WHERE '.qi('7zme5GbR').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-gruppe').' LIMIT 1), TRUE)) AS '.qi('operation::create').',
									/* operation::delete */ (FALSE) AND ('.\FOP\Database::quote(\FOP\User::getDokument()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('jiHGDwTc').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('jiHGDwTc').' WHERE '.qi('jiHGDwTc').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('2L3JcPgq').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('2L3JcPgq').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('2L3JcPgq').' WHERE '.qi('2L3JcPgq').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('aVKzkIxT').' WHERE '.qi('aVKzkIxT').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-protokoll').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('oYgz3Zk9').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('oYgz3Zk9').' WHERE '.qi('oYgz3Zk9').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('Je6BzKDx').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('Je6BzKDx').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('Je6BzKDx').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('Je6BzKDx').' WHERE '.qi('Je6BzKDx').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-gruppe').' LIMIT 1), TRUE)) AS '.qi('operation::delete').',
									/* operation::edit */ ('.\FOP\Database::quote(\FOP\User::getDokument()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('a3H18ePF').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('a3H18ePF').' WHERE '.qi('a3H18ePF').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('fXl0iMc3').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('fXl0iMc3').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('fXl0iMc3').' WHERE '.qi('fXl0iMc3').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('iVCI3rck').' WHERE '.qi('iVCI3rck').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-protokoll').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Ot4cBnlj').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Ot4cBnlj').' WHERE '.qi('Ot4cBnlj').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('K2POIfyF').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('K2POIfyF').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('K2POIfyF').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('K2POIfyF').' WHERE '.qi('K2POIfyF').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-gruppe').' LIMIT 1), TRUE)) AS '.qi('operation::edit').',
									/* operation::index */ ' . (!\FOP\User::getIsGuest() ? 1 : 0) . ' AS '.qi('operation::index').',
									/* operation::view */ ('.\FOP\Database::quote(\FOP\User::getDokument()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('ok3G4wPh').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('ok3G4wPh').' WHERE '.qi('ok3G4wPh').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('2Hyq8DKe').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('2Hyq8DKe').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) FROM '.qi('mitglied').' '.qi('2Hyq8DKe').' WHERE '.qi('2Hyq8DKe').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getProtokoll()).') FROM '.qi('protokoll').' '.qi('jYtYUs5c').' WHERE '.qi('jYtYUs5c').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-protokoll').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('bmxCMQlw').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('bmxCMQlw').' WHERE '.qi('bmxCMQlw').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-mitglied').' LIMIT 1), TRUE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('9lhFb6lb').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('9lhFb6lb').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('9lhFb6lb').'.'.qi('public').'))) END) FROM '.qi('gruppe').' '.qi('9lhFb6lb').' WHERE '.qi('9lhFb6lb').'.'.qi('ID').' = '.qi('doc').'.'.qi('to-gruppe').' LIMIT 1), TRUE)) AS '.qi('operation::view').',
									/* postboxtype */ '.qi('doc').'.'.qi('postboxtype').' AS '.qi('postboxtype').',
									/* subject */ '.qi('doc').'.'.qi('subject').' AS '.qi('subject').',
									/* to-gruppe */ '.qi('doc').'.'.qi('to-gruppe').' AS '.qi('to-gruppe').',
									/* to-gruppe::canView */ (SELECT ('.qi('lBXFiXqU').'.'.qi('has-gruppe').') FROM '.qi('docType').' '.qi('lBXFiXqU').' WHERE '.qi('lBXFiXqU').'.'.qi('ID').' = '.qi('doc').'.'.qi('type').' LIMIT 1) AS '.qi('to-gruppe::canView').',
									/* to-gruppe::canView */ '.qi('ref:to-gruppe').'.'.qi('to-gruppe:canView').' AS '.qi('to-gruppe::canView').',
									/* to-gruppe::description */ '.qi('ref:to-gruppe').'.'.qi('to-gruppe:description').' AS '.qi('to-gruppe::description').',
									/* to-mitglied */ '.qi('doc').'.'.qi('to-mitglied').' AS '.qi('to-mitglied').',
									/* to-mitglied::canView */ (SELECT ('.qi('6GSnIHxl').'.'.qi('has-mitglied').') FROM '.qi('docType').' '.qi('6GSnIHxl').' WHERE '.qi('6GSnIHxl').'.'.qi('ID').' = '.qi('doc').'.'.qi('type').' LIMIT 1) AS '.qi('to-mitglied::canView').',
									/* to-mitglied::canView */ '.qi('ref:to-mitglied').'.'.qi('to-mitglied:canView').' AS '.qi('to-mitglied::canView').',
									/* to-mitglied::description */ '.qi('ref:to-mitglied').'.'.qi('to-mitglied:description').' AS '.qi('to-mitglied::description').',
									/* to-protokoll */ '.qi('doc').'.'.qi('to-protokoll').' AS '.qi('to-protokoll').',
									/* to-protokoll::canView */ (SELECT ('.qi('51Tp3gKR').'.'.qi('has-protokoll').') FROM '.qi('docType').' '.qi('51Tp3gKR').' WHERE '.qi('51Tp3gKR').'.'.qi('ID').' = '.qi('doc').'.'.qi('type').' LIMIT 1) AS '.qi('to-protokoll::canView').',
									/* to-protokoll::canView */ '.qi('ref:to-protokoll').'.'.qi('to-protokoll:canView').' AS '.qi('to-protokoll::canView').',
									/* to-protokoll::description */ '.qi('ref:to-protokoll').'.'.qi('to-protokoll:description').' AS '.qi('to-protokoll::description').',
									/* type */ '.qi('doc').'.'.qi('type').' AS '.qi('type').',
									/* type::canView */ '.qi('ref:type').'.'.qi('type:canView').' AS '.qi('type::canView').',
									/* type::description */ '.qi('ref:type').'.'.qi('type:description').' AS '.qi('type::description').',
									1
								FROM '.qi('doc').' '.qi('doc').'
								LEFT JOIN (SELECT '.qi('ID').' AS '.qi('type:ID').', '.qi('docType').'.'.qi('name').' AS '.qi('type:description').', (('.\FOP\Database::quote(\FOP\User::getDokument()).')) AS '.qi('type:canView').' FROM '.qi('docType').') '.qi('ref:type').' ON '.qi('ref:type').'.'.qi('type:ID').' = '.qi('doc').'.'.qi('type').'
								LEFT JOIN (SELECT '.qi('ID').' AS '.qi('to-protokoll:ID').', CONCAT('.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('protokoll').'.'.qi('date').')'.(\FOP\Database::getDriver() == 'mysql' ? '' : '::date') . ', '.\FOP\Database::sessionVarSQL('dateformat').'), \': \', '.qi('protokoll').'.'.qi('bez').') AS '.qi('to-protokoll:description').', (('.\FOP\Database::quote(\FOP\User::getProtokoll()).')) AS '.qi('to-protokoll:canView').' FROM '.qi('protokoll').') '.qi('ref:to-protokoll').' ON '.qi('ref:to-protokoll').'.'.qi('to-protokoll:ID').' = '.qi('doc').'.'.qi('to-protokoll').'
								LEFT JOIN (SELECT '.qi('ID').' AS '.qi('to-gruppe:ID').', '.qi('gruppe').'.'.qi('name').' AS '.qi('to-gruppe:description').', ((CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('hX7wRx63').' WHERE '.qi('hX7wRx63').'.'.qi('list').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('hX7wRx63').'.'.qi('item').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('yvRIjwTv').' WHERE '.qi('yvRIjwTv').'.'.qi('gruppe').' = '.qi('gruppe').'.'.qi('ID').' AND (('.qi('yvRIjwTv').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1))) AND (NOT ('.qi('gruppe').'.'.qi('public').'))) END)) AS '.qi('to-gruppe:canView').' FROM '.qi('gruppe').') '.qi('ref:to-gruppe').' ON '.qi('ref:to-gruppe').'.'.qi('to-gruppe:ID').' = '.qi('doc').'.'.qi('to-gruppe').'
								LEFT JOIN (SELECT '.qi('ID').' AS '.qi('to-mitglied:ID').', CONCAT('.qi('mitglied').'.'.qi('vorname').', \' \', '.qi('mitglied').'.'.qi('name').') AS '.qi('to-mitglied:description').', ((CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('mitglied').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) AND (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('mitglied').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('mitglied').'.'.qi('ID').' AND (EXISTS (SELECT (TRUE) FROM '.qi('gruppeVerantwortlich').' '.qi('eHueOsQC').' WHERE '.qi('eHueOsQC').'.'.qi('gruppe').' = '.qi('7sncgH3z').'.'.qi('list').' AND (('.qi('eHueOsQC').'.'.qi('mitglied').') = ('.\FOP\Database::sessionVarSQL('user').')) LIMIT 1)) LIMIT 1)))) END) AND (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('mitglied').'.'.qi('superadmin').') END)) AS '.qi('to-mitglied:canView').' FROM '.qi('mitglied').') '.qi('ref:to-mitglied').' ON '.qi('ref:to-mitglied').'.'.qi('to-mitglied:ID').' = '.qi('doc').'.'.qi('to-mitglied').'
								WHERE ('.qi('ID').' = ' . \FOP\Database::quote($id) . ')';
		$result = \FOP\Database::query($sql);
		if (!$row = $result->fetch(\PDO::FETCH_ASSOC)) {
			throw new \FOP\AccessDeniedException('notfoundread');
		} else if (!$ignoreAccess && !$row['operation::view']) {
			throw new \FOP\AccessDeniedException('accessdeniedread');
		}
		
		$row['type'] = \FOP\Sanitizers::null_converter($row['type']);
		$row['date'] = intval($row['date']);
		$row['to-mitglied'] = \FOP\Sanitizers::null_converter($row['to-mitglied']);
		$row['to-protokoll'] = \FOP\Sanitizers::null_converter($row['to-protokoll']);
		$row['to-gruppe'] = \FOP\Sanitizers::null_converter($row['to-gruppe']);
		$row['first'] = intval($row['first']);
		$row['last'] = intval($row['last']);
		$row['file'] = intval($row['file']);
		$row['archive'] = \FOP\Util::BoolSanitizer($row['archive']);
		

		if($snippet){
			$row['type'] = (
  \FOP\Database::query('SELECT '.qi('docType').'.'.qi('name').' AS description FROM '.qi('docType').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($row['type']))->fetchColumn() ?: _('-')
);
			$row['date'] = (($row['date']) ? strftime(_('dateformat_php2'), intval($row['date'])) : '');
			$row['subject'] = ($row['subject']);
			$row['notes'] = (mb_substr(preg_replace('/[ \t\r\n]+/', ' ', strip_tags(preg_replace('/<style.*?\/style>/s', '', html_entity_decode($row['notes'])))), 0, 20) . (strlen($row['notes']) >= 20 ? '...' : ''));
			$row['to-mitglied'] = (
  \FOP\Database::query('SELECT CONCAT('.qi('mitglied').'.'.qi('vorname').', \' \', '.qi('mitglied').'.'.qi('name').') AS description FROM '.qi('mitglied').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($row['to-mitglied']))->fetchColumn() ?: _('-')
);
			$row['to-protokoll'] = (
  \FOP\Database::query('SELECT CONCAT('.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('protokoll').'.'.qi('date').')'.(\FOP\Database::getDriver() == 'mysql' ? '' : '::date') . ', '.\FOP\Database::sessionVarSQL('dateformat').'), \': \', '.qi('protokoll').'.'.qi('bez').') AS description FROM '.qi('protokoll').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($row['to-protokoll']))->fetchColumn() ?: _('-')
);
			$row['to-gruppe'] = (
  \FOP\Database::query('SELECT '.qi('gruppe').'.'.qi('name').' AS description FROM '.qi('gruppe').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($row['to-gruppe']))->fetchColumn() ?: _('-')
);
			$row['first'] = (($row['first']) ? strftime(_('dateformat_php2'), intval($row['first'])) : '');
			$row['last'] = (($row['last']) ? strftime(_('dateformat_php2'), intval($row['last'])) : '');
			$row['file'] = (\FOP\Database::query('SELECT filename FROM fop_files WHERE '.qi('ID').' = ' . intval($row['file']))->fetchColumn());
			$row['archive'] = ($row['archive']);
			
		}


		return $row;

    
  }

  public static function searchOptionsdoc_revision_doc_deletecascadeAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Doc::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function searchOptionsform_wf_doc_merge_olddocAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Doc::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function searchOptionsform_wf_doc_revision_create_docAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Doc::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function searchOptionsform_wf_doc_revision_edit_docAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Doc::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function sanitizeDefaults(&$data, $sanitizeForForms, $refcol = null , $parentdata = null ) { 
    
    
    // --- BLOCK: main ---
    
		$virginData = self::getDefaults();
		// column: archive
		
		// column: date
		
		// column: notes
		
		// column: subject
		
		// column: to-gruppe
			if (!$data['to-gruppe']) {
				$data['to-gruppe'] = $sanitizeForForms ? '0' : null;
			}
		
		// column: to-mitglied
			if (!$data['to-mitglied']) {
				$data['to-mitglied'] = $sanitizeForForms ? '0' : null;
			}
		
		// column: to-protokoll
			if (!$data['to-protokoll']) {
				$data['to-protokoll'] = $sanitizeForForms ? '0' : null;
			}
		
		// column: type
			if (!$data['type']) {
				$data['type'] = $sanitizeForForms ? '0' : null;
			}
		
		if ($sanitizeForForms) {
			
			$data['type'] = \FOP\Sanitizers::null_converter($data['type']);
			$data['date'] = intval($data['date']);
			$data['to-mitglied'] = \FOP\Sanitizers::null_converter($data['to-mitglied']);
			$data['to-protokoll'] = \FOP\Sanitizers::null_converter($data['to-protokoll']);
			$data['to-gruppe'] = \FOP\Sanitizers::null_converter($data['to-gruppe']);
			$data['archive'] = \FOP\Util::BoolSanitizer($data['archive']);
		}
	
    
  }

  public static function edit($id, $data, $ignoreUniqueConstraints = false , $disregardPermissions = false ) { 
    
    
    // --- BLOCK: main ---
    
				
				$set = [];
				
					
					if (array_key_exists('type', $data)) {
						array_push($set, qi('type').' = ' . \FOP\Database::quote($data['type']));
					}
				
					
					if (array_key_exists('date', $data)) {
						array_push($set, qi('date').' = ' . \FOP\Database::quote($data['date']));
					}
				
					
					if (array_key_exists('subject', $data)) {
						array_push($set, qi('subject').' = ' . \FOP\Database::quote($data['subject']));
					}
				
					
					if (array_key_exists('notes', $data)) {
						array_push($set, qi('notes').' = ' . \FOP\Database::quote($data['notes']));
					}
				
					
					if (array_key_exists('to-mitglied', $data)) {
						array_push($set, qi('to-mitglied').' = ' . \FOP\Database::quote($data['to-mitglied']));
					}
				
					
					if (array_key_exists('to-protokoll', $data)) {
						array_push($set, qi('to-protokoll').' = ' . \FOP\Database::quote($data['to-protokoll']));
					}
				
					
					if (array_key_exists('to-gruppe', $data)) {
						array_push($set, qi('to-gruppe').' = ' . \FOP\Database::quote($data['to-gruppe']));
					}
				
					
					if (array_key_exists('archive', $data)) {
						array_push($set, qi('archive').' = ' . \FOP\Database::quote($data['archive']));
					}
				;
				
				if (count($set)) {
					try {
						\FOP\Database::query('UPDATE '.qi('doc').' SET ' . implode(', ', $set) . ' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id));
						if (isset($data['ID'])) {
							$id = $data['ID'];
						}
					} catch (\PDOException $e) {
						if ($e->errorInfo[1] == 1062) {
							if ($ignoreUniqueConstraints) {
								return false;
							}
							throw new \FOP\AccessDeniedException('duplicateupdate');
						}
						throw $e; // weiterwerfen
					}
				}
				$data['fop-id'] = $id; // für Hooks
				
	if (isset($data['file']) && $data['file'] != self::view($id)['file']) {
		\FOP\Database::query('INSERT INTO '.qi('doc_revision').'('.qi('doc').', created, '.qi('file').') VALUES ('.\FOP\Database::quote($id).', UNIX_TIMESTAMP(), '.\FOP\Database::quote($data['file']).')');
	}

				return true;

    
  }

  public static function renderEditdoc_revision_doc_deletecascadeAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Doc::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' class="selectdropdown mdlext-selectfield__select" name="value_doc_revision_doc" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Doc/searchOptionsdoc_revision_doc_deletecascade?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function renderEditform_wf_doc_merge_olddocAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Doc::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' class="selectdropdown mdlext-selectfield__select" name="olddoc" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Doc/searchOptionsform_wf_doc_merge_olddoc?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function renderEditform_wf_doc_revision_create_docAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Doc::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' class="selectdropdown mdlext-selectfield__select" name="doc" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Doc/searchOptionsform_wf_doc_revision_create_doc?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function renderEditform_wf_doc_revision_edit_docAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Doc::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' class="selectdropdown mdlext-selectfield__select" name="doc" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Doc/searchOptionsform_wf_doc_revision_edit_doc?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function deleteAction($id) { 
    
    // Methodenimplementierung überschrieben.
    throw new \FOP\AccessDeniedException();return false;
  }

  public static function indexAction() { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getDokument())) && (!\FOP\User::getIsGuest()))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: main ---
    ?><?php
			header('Content-Type: text/html; charset=UTF-8');
			header('X-XSS-Protection: 1; mode=block');
			header('Strict-Transport-Security: max-age=63072000');
			header('X-Content-Type-Options: nosniff');
			header("Content-Security-Policy: default-src *  data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';");


		?><!DOCTYPE html><html><head><title><?php echo(_('Dokumente')); ?></title><base href='<?php echo \FOP\Util::getCurrentBaseurl(); ?>'><meta name="google" content="notranslate"><meta http-equiv="Content-Language" content="<?php echo htmlentities(\FOP\I18n::getLocale()); ?>"><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="style_dependencies.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><link rel="stylesheet" type="text/css" href="style.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><script type="text/javascript" src="js/script_dependencies.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="mobile-web-app-capable" content="yes"><link rel="manifest" href="manifest.webmanifest"><script type="text/javascript">moment.locale('<?php echo(\FOP\I18n::getShortLocale()); ?>');</script><script type="text/javascript" src="js/form.js"></script><script type="text/javascript">window.globals = <?php
	echo json_encode(['user:superadmin' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSuperadmin(), 'user:mitglied' => /* TODO: resanitizer später mal */(integer) \FOP\User::getMitglied(), 'user:gruppe' => /* TODO: resanitizer später mal */(integer) \FOP\User::getGruppe(), 'user:campaign' => /* TODO: resanitizer später mal */(integer) \FOP\User::getCampaign(), 'user:sammlung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSammlung(), 'user:protokoll' => /* TODO: resanitizer später mal */(integer) \FOP\User::getProtokoll(), 'user:ID' => /* TODO: resanitizer später mal */(integer) \FOP\User::getID(), 'user:buchhaltung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getBuchhaltung()]);
?>;</script><script type="text/javascript" src="angular/<?php echo(\FOP\I18n::getShortLocale()); ?>/js/alltypes.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><script type="text/javascript" src="angular/angular-i18n/angular-locale_<?php echo \FOP\I18n::getAngularLocale(); ?>.js"></script><script type="text/javascript" src="js/date-filter.js"></script><script type="text/javascript" src="js/dropdown.js"></script><script type="text/javascript" src="js/numeric.js"></script><script type="text/javascript" src="js/getparam.js"></script><script type="text/javascript" src="js/tables.js"></script>
		<script type="text/javascript" src="js/parsehash.js"></script><script type="text/javascript">
		window.query = <?php echo json_encode($_GET, JSON_FORCE_OBJECT); ?>;
		window.baseurl = <?php echo json_encode(\FOP\Util::getCurrentBaseurl()); ?>;

		window.i18n_weiter = <?php echo json_encode(_('Weiter'));?>;
		//Filter I18n:
		window.i18n_quartal = <?php echo json_encode(_('Quarter'));?>;
		window.i18n_alle = <?php echo json_encode(_('All'));?>;
		window.i18n_leere = <?php echo json_encode(_('Empty'));?>;
		window.i18n_tag = <?php echo json_encode(_('Tag'));?>;
		window.i18n_woche = <?php echo json_encode(_('Woche'));?>;
		window.i18n_zeitraum = <?php echo json_encode(_('Period'));?>;
		window.i18n_monat = <?php echo json_encode(_('Monat'));?>;
		window.i18n_jahr = <?php echo json_encode(_('Jahr'));?>;
		window.i18n_von = <?php echo json_encode(_('filters_from'));?>;
		window.i18n_bis = <?php echo json_encode(_('filters_to'));?>;
		window.i18n_tabButton = <?php echo json_encode(_('open_in_new_tab'));?>;
		window.i18n_closeButton = <?php echo json_encode(_('close'));?>;
		</script></head><script type="text/javascript">const fopPushPublicKey = '<?php echo(addslashes(\FOP\Configuration::getFOPPushPublicKey())); ?>';
        const fopUserID = <?php echo(intval(\FOP\User::getID())); ?>;
        var fopPushDisabled = false;
    </script><script type="text/javascript" src="js/serviceworkersetup.js"></script><body ng-app='app'>
		<div class='mdl-js-snackbar mdl-snackbar' id='snackbar'>
			<div class='mdl-snackbar__text'></div>
			<button class='mdl-snackbar__action' type='button'></button>
		</div>
		<script>
			var snackbar = document.querySelector('#snackbar');
			componentHandler.upgradeElement(snackbar, 'MaterialSnackbar');
			$(function () {
				setTimeout(function () {
					$('.fop-layout').scrollTop(0);
				}, 0);
			});
		</script>

		<?php if (isset($_GET['popup'])) { ?>
		<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo(_('Dokumente')); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      	</header>
			<style>
				.content {
					margin-top: 0px !important;
				}
			</style>
			<div id='content' class='popup' >
		<?php } else { ?>
			<div class="fop-layout mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
			<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo(_('Dokumente')); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      		</header>


				<?php  \EasyEditor\Navigation::render(); ?>
      
				<main class="mdl-layout__content" id="content">
					<div class="fop-content">
						<?php } ?>
						
							<div class="content" id="1">
								

								<div
								 
								id="cardform-doc"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormDoc" ng-init="form = <?php echo htmlentities(json_encode([]));
									?>;"
								>
								<?php
								 ?>
								<div id='fop-upbar'></div>
								<?php \DataView\Doc::renderScript(); ?>
									<?php
									$features = [];
									if (true && (true)) {
									$feature = [
										'id' => 'main_table',
										'title' => _('table'),
										'order' => '500-100', // 500-100 (50)
										'mode' => 'area', // area (51) / tab (50)
										'position' => 'full', // 
										'collapsed' => 0, // 0 (51) / 1 (50)
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									

									
									/* load order from database
										schema: fop_form_feature(user, form, subid, key, value)
										key = (order, mode, position, collapsed)
									*/
									$upbar_collapsed = false;
									// default values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', (SELECT '.qi('value').' FROM fop_form_feature b WHERE a.subid = b.subid AND a.'.qi('key').' = b.'.qi('key').' AND '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY '.qi('value').' ORDER BY COUNT(*) DESC LIMIT 1) AS '.qi('value').' FROM fop_form_feature a WHERE '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY subid, '.qi('key'))->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										}
									}
									// form specific special values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', '.qi('value').' FROM fop_form_feature a WHERE form = \'doc\' AND '.qi('user').' = '.intval(\FOP\User::getID()).'')->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										} else if ($setting['subid'] == 'upbar' && $setting['key'] == 'collapsed') {
											$upbar_collapsed = (bool) $setting['value'];
										}
									}

									/* fill in the content of the features */
									if (true && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main_table']);
										?>
	<?php if (((\FOP\User::getDokument())) && (!\FOP\User::getIsGuest())) { ?>
	<div id="doc-table" class="fop-dv"><?php
		if (\EasyEditor\FormFeature::isCollapsed()) {
			// #3198 lazy rendering:
			echo '<div class="fop-lazy-reload" onclick="reloaddoc()"></div>'; // CSS class .fop-lazy-reload will be clicked after being showed
		} else {
			\DataView\Doc::renderTabTableAction();
		}
	?></div>
	<?php } ?>
	<?php
										\EasyEditor\FormFeature::pop();
										$features['main_table']['html'] = ob_get_contents();
										ob_end_clean();
									}
									

									uasort($features, function ($a, $b) {
										return strnatcmp($a['order'], $b['order']);
									});
									foreach ($features AS $feature) {
										\EasyEditor\FormFeature::render($feature);
									}
									?><script type='text/javascript'>
										$(function(){
											// bei Änderungen: prüfen, ob Form geändert wurde
											var formData = $('#cardform-doc').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-doc').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-doc').on('submit', function () {
												document.body.onbeforeunload = undefined;
											});
											<?php if ($upbar_collapsed) {
												?>$('#fop-bar-mainbutton').click();<?php
											} ?>
											$('#fop-bar-mainbutton').click(function () {
												setTimeout(function () {
													setCFF('upbar', 'collapsed', $('#fop-bar-container').is(':visible') ? 0 : 1);
												}, 440); /* perfect timing for fadeOut */
											});
										});
										
										function setCFF(id, key, value) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFF?form=doc&subid=' + encodeURIComponent(id) + '&key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value)).then(function () {
												if (key == 'reset') {
													location.reload();
												}
											});
											<?php } /* EditAccess */ ?>
										}
										function setCFFOrder(fids) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFFOrder?form=doc&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-doc')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-doc input[type!="hidden"],textarea,select[tabindex!="-1"]').not('.fop-disabled *').filter(':visible:first').focus().select();
											}
										});

										$(window).keydown(function(event) {
											 if (event.ctrlKey && String.fromCharCode(event.which).toLowerCase() == 's') {
												 event.preventDefault();
												 $('button[type=submit]').click();
												 return false;
											 }
										});

										
										$(document).on('keyup',function(evt) {
										   if (evt.keyCode == 27) {
												if (window.parent) {
													window.close(); // iframe:close
												} else {
													window.history.back();
												}
											}
												});
										
									</script>

							</div>
							

							</div>
							<div class="content" id="focus-supersearch">
		<script type='text/javascript'>
			$(function () {
				var focusfield = $('#supersearch');
				
				if (focusfield.length) {
					focusfield[0].focus();
					focusfield[0].select();
				}
			});
		</script>
	
							</div>
						<?php if (!isset($_GET['popup'])) { ?>
					</div>
				</main>
				
			</div>
		<?php } else { ?></div><?php } ?>
<?php if (!isset($_GET['popup'])) { ?><div class='fop-seal'></div><?php } ?></body></html><?php
    
  }


  
  

  
  
}



