<?php

namespace Tables;

class CampaignTarget {
  
  

  
  

    // --- Statische Methoden ---
  
  public static function cronTimeouts() { 
    
    
    // --- BLOCK: main ---
    
	if (\FOP\Database::getDriver() == 'mysql') {
		\FOP\Database::query('UPDATE '.qi('campaignTarget').', '.qi('campaignFollow').' SET '.qi('campaignTarget').'.'.qi('state').' = '.qi('campaignFollow').'.'.qi('nextState').' WHERE
			'.qi('campaignTarget').'.'.qi('campaign').' = '.qi('campaignFollow').'.'.qi('campaign').' AND
			'.qi('campaignTarget').'.'.qi('state').' = '.qi('campaignFollow').'.'.qi('state').' AND
			'.qi('campaignFollow').'.'.qi('nextCampaign').' IS NULL AND
			'.qi('campaignTarget').'.'.qi('lastUpdate').' < '.\FOP\Database::sessionVarSQL('time').' - '.qi('campaignFollow').'.'.qi('timeout').' * 60 * 60');
	} else {
		\FOP\Database::query('UPDATE '.qi('campaignTarget').' SET '.qi('state').' = '.qi('campaignFollow').'.'.qi('nextState').'
			FROM '.qi('campaignFollow').' WHERE
			'.qi('campaignTarget').'.'.qi('campaign').' = '.qi('campaignFollow').'.'.qi('campaign').' AND
			'.qi('campaignTarget').'.'.qi('state').' = '.qi('campaignFollow').'.'.qi('state').' AND
			'.qi('campaignFollow').'.'.qi('nextCampaign').' IS NULL AND
			'.qi('campaignTarget').'.'.qi('lastUpdate').' < '.\FOP\Database::sessionVarSQL('time').' - '.qi('campaignFollow').'.'.qi('timeout').' * 60 * 60');
	}

    
  }

  public static function getDefaults() { 
    
    
    // --- BLOCK: main ---
    
	// erstellt ein leeres Objekt zum Befüllen mit Daten oder als Default fürs Create-Formular
	$data = ['campaign' => null,
		'target' => null,
		'state' => \FOP\Database::query('SELECT COALESCE((SELECT '.qi('ID').' FROM '.qi('campaignState').' WHERE '.qi('aftercontact').' IS NOT NULL LIMIT 1), (SELECT '.qi('ID').' FROM '.qi('campaignState').' ORDER BY '.qi('order').' LIMIT 1))')->fetchColumn(),
		'note' => '',
		'creation' => time(),
		'lastUpdate' => null];
	return $data;
	
    
  }

  public static function multistatusAction($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+1);
		$id = new \FOP\IDList($id);
		$rest = $id->splice($max_items);
		if ($rest) {
			$_GET['from'] = \TablesRouter\CampaignTarget::multistatusURL2(['id' => $rest, 'from' => $_GET['from'] ?? null]);
		}
	
    // --- BLOCK: access ---
    if(!(((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		
		/* Validatoren */
		
		

		if (isset($_POST['fop_list_state'])) foreach ($_POST['fop_list_state'] AS $i => $val)
			if ($_POST['fop_list'][$i] != '0') \Types\CampaignState::validate($val);
		/* Sanitizer */

		

		if (isset($_POST['fop_list_state'])) foreach ($_POST['fop_list_state'] AS $idx => $val) $_POST['fop_list_state'][$idx] = \FOP\Sanitizers::null_filter($val);
	}
	
    // --- BLOCK: access-itemlist-campaignTarget-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('campaignTarget').' WHERE (('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('vOljclgU').' WHERE '.qi('vOljclgU').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('XXDtdS61').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('XXDtdS61').' WHERE '.qi('XXDtdS61').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('YOWPvw9s').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('YOWPvw9s').'.'.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('YOWPvw9s').' WHERE '.qi('YOWPvw9s').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Z2wISAZD').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Z2wISAZD').' WHERE '.qi('Z2wISAZD').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) AND ' . $id_->toSQL(qi('ID')))->fetchAll(\PDO::FETCH_COLUMN) AS $id_sub) {
			$id->push($id_sub);
		}
	
    // --- BLOCK: access-itemlist-campaignTarget-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('campaignTarget').' WHERE (('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('dHL279iX').' WHERE '.qi('dHL279iX').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('fbT2x3zb').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('fbT2x3zb').' WHERE '.qi('fbT2x3zb').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PmLIw5tN').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PmLIw5tN').'.'.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('PmLIw5tN').' WHERE '.qi('PmLIw5tN').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Ffzcl8KY').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Ffzcl8KY').' WHERE '.qi('Ffzcl8KY').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) 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\CampaignTarget::getDefaults();
				\Tables\CampaignTarget::sanitizeDefaults($subdata, false);
			} else {
				// es ist ein Edit
				$subdata = [];
			}
			
				$subdata['state'] = $_POST['fop_list_state'][$i];
				$subdata['note'] = $_POST['fop_list_note'][$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\CampaignTarget::delete($subid);
				} else {
					// achtet selbst auf Permissions
					\Tables\CampaignTarget::edit($subid, $subdata);
					
					
				}
			} else if ($_POST['fop_list'][$i] != '0') {
				// noch keine ID: erstellen
				if (((\FOP\User::getCampaign()) && (\FOP\User::getCampaign()))) {
					// TODO: TIAR-Create prüfen
					try {
						$subid = \Tables\CampaignTarget::create($subdata);
						
						
					} catch (\FOP\AccessDeniedException $e) {
						// ignore duplicate
						if ($e->getMessage() != 'duplicateinsert') {
							throw $e;
						}
					}
				}
			}
		}
	
    // --- BLOCK: main-3 ---
    
			\FOP\Database::commitTransaction();
			
		}
		
		if (isset($_POST['Tables:CampaignTarget: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\CampaignTarget::indexURL2(['popup' => $_GET['popup'] ?? null, 'filter_campaignTarget_ID' => $result->toString()]));
			}
			die();
	
		}
		die(json_encode($_POST));
	} else {
    // --- BLOCK: main-4:load-main ---
    
		$data = \Tables\CampaignTarget::getDefaults();
	
    // --- BLOCK: main-4:load-main-list-fop_list ---
    
		$fop_list = [];
		array_push($fop_list, ...\Tables\CampaignTarget::loadMultistatusFop_listItems($id));
	
    // --- BLOCK: main-4:load-~sanitize ---
    
		\Tables\CampaignTarget::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(_('Daten nachtragen')); ?></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(_('Daten nachtragen')); ?></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(_('Daten nachtragen')); ?></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\CampaignTarget::multistatusURL2(['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_campaignTarget_multistatus"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_campaignTarget_multistatus" 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:campaignTarget:multistatus\' 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_campaignTarget_multistatus_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:CampaignTarget: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_campaignTarget_multistatus_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(_('Ziel')); ?></th>
						<?php } ?>
						<?php if (true || !\FOP\User::getIsGuest()) { ?>
							<th class='mdl-data-table__cell--non-numeric'><?php echo(_('Status')); ?></th>
						<?php } ?>
						<?php if (true || !\FOP\User::getIsGuest()) { ?>
							<th class='mdl-data-table__cell--non-numeric'><?php echo(_('Notiz')); ?></th>
						<?php } ?>
				</tr>
			</thead>
			<tbody>
				<?php
				foreach ($fop_list AS $row) {
					self::multistatusListFop_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/CampaignTarget/multistatusListFop_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'), _('Empfänger'))); ?></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_campaignTarget_multistatus').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-wf_campaignTarget_multistatus').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-wf_campaignTarget_multistatus').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%3AcampaignTarget%3Amultistatus&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%3AcampaignTarget%3Amultistatus&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_campaignTarget_multistatus')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_campaignTarget_multistatus 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 multistatus2Action($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\CampaignTarget::multistatus2URL2(['id' => $rest, 'from' => $_GET['from'] ?? null]);
		}
	
    // --- BLOCK: access ---
    if(!(((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		
		/* Validatoren */
		
		\Types\CampaignState::validate($_POST['state']);

		
		/* Sanitizer */

		$_POST['state'] = \FOP\Sanitizers::null_filter($_POST['state']);

		
	}
	
    // --- BLOCK: access-itemlist-campaignTarget-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('campaignTarget').' WHERE (('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('vOljclgU').' WHERE '.qi('vOljclgU').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('XXDtdS61').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('XXDtdS61').' WHERE '.qi('XXDtdS61').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('YOWPvw9s').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('YOWPvw9s').'.'.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('YOWPvw9s').' WHERE '.qi('YOWPvw9s').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Z2wISAZD').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Z2wISAZD').' WHERE '.qi('Z2wISAZD').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) AND ' . $id_->toSQL(qi('ID')))->fetchAll(\PDO::FETCH_COLUMN) AS $id_sub) {
			$id->push($id_sub);
		}
	
    // --- BLOCK: access-itemlist-campaignTarget-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('campaignTarget').' WHERE (('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('dHL279iX').' WHERE '.qi('dHL279iX').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('fbT2x3zb').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('fbT2x3zb').' WHERE '.qi('fbT2x3zb').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PmLIw5tN').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PmLIw5tN').'.'.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('PmLIw5tN').' WHERE '.qi('PmLIw5tN').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Ffzcl8KY').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Ffzcl8KY').' WHERE '.qi('Ffzcl8KY').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) 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\CampaignTarget::getDefaults();
				\Tables\CampaignTarget::sanitizeDefaults($subdata, false);
			} else {
				// es ist ein Edit
				$subdata = [];
			}
			
				$subdata['note'] = $_POST['fop_list_note'][$i];
				$subdata['ID'] = $_POST['fop_list_ID'][$i];
				$subdata['state'] = $_POST['state'];
			if ($subid) {
				// existierendes Element
				if ($_POST['fop_list'][$i] == '0') {
					// zur Löschung markiert
					// achtet selbst auf Permissions
					\Tables\CampaignTarget::delete($subid);
				} else {
					// achtet selbst auf Permissions
					\Tables\CampaignTarget::edit($subid, $subdata);
					
					
				}
			} else if ($_POST['fop_list'][$i] != '0') {
				// noch keine ID: erstellen
				if (((\FOP\User::getCampaign()) && (\FOP\User::getCampaign()))) {
					// TODO: TIAR-Create prüfen
					try {
						$subid = \Tables\CampaignTarget::create($subdata);
						
						
					} catch (\FOP\AccessDeniedException $e) {
						// ignore duplicate
						if ($e->getMessage() != 'duplicateinsert') {
							throw $e;
						}
					}
				}
			}
		}
	
    // --- BLOCK: main-3 ---
    
			\FOP\Database::commitTransaction();
			
		}
		
		if (isset($_POST['Tables:CampaignTarget: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\CampaignTarget::indexURL2(['popup' => $_GET['popup'] ?? null, 'filter_campaignTarget_ID' => $result->toString()]));
			}
			die();
	
		}
		die(json_encode($_POST));
	} else {
    // --- BLOCK: main-4:load-main ---
    
		$data = \Tables\CampaignTarget::getDefaults();
	
    // --- BLOCK: main-4:load-main-list-fop_list ---
    
		$fop_list = [];
		array_push($fop_list, ...\Tables\CampaignTarget::loadMultistatus2Fop_listItems($id));
	
    // --- BLOCK: main-4:load-~sanitize ---
    
		\Tables\CampaignTarget::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(_('Status setzen')); ?></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(_('Status setzen')); ?></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(_('Status setzen')); ?></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\CampaignTarget::multistatus2URL2(['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_campaignTarget_multistatus2"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_campaignTarget_multistatus2" 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 || true)) {
									$feature = [
										'id' => 'main',
										'title' => _('Daten'),
										'order' => '100', // 100 (20)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. '0' .'||'. '0' .'||'. (true ? 'true' : '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:campaignTarget:multistatus2\' 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_campaignTarget_multistatus2_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:CampaignTarget: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_campaignTarget_multistatus2_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 || true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main']);
										?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_state" id="column_state">
		<!-- Feld "Status": state -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="state"><?php echo(_('Status')); ?>: </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\CampaignState::renderEditform_wf_campaignTarget_multistatus2_stateAction($data['state'], [], '');
?> &nbsp;	<?php if (\TablesRouter\CampaignState::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\CampaignState::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=campaignState%26colinsert=state%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\CampaignState::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=campaignState%26colinsert=state%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=campaignState", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div>
	</div>
	</div><?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(_('Ziel')); ?></th>
						<?php } ?>
						<?php if (true || !\FOP\User::getIsGuest()) { ?>
							<th class='mdl-data-table__cell--non-numeric'><?php echo(_('Notiz')); ?></th>
						<?php } ?>
				</tr>
			</thead>
			<tbody>
				<?php
				foreach ($fop_list AS $row) {
					self::multistatus2ListFop_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/CampaignTarget/multistatus2ListFop_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'), _('Empfänger'))); ?></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_campaignTarget_multistatus2').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-wf_campaignTarget_multistatus2').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-wf_campaignTarget_multistatus2').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%3AcampaignTarget%3Amultistatus2&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%3AcampaignTarget%3Amultistatus2&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_campaignTarget_multistatus2')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_campaignTarget_multistatus2 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 multiaddAction($column_target = 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::getCampaign()) && (\FOP\User::getCampaign())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		
		/* Validatoren */
		
		\Types\Campaign::validate($_POST['campaign']);

		if (isset($_POST['fop_list_state'])) foreach ($_POST['fop_list_state'] AS $i => $val)
			if ($_POST['fop_list'][$i] != '0') \Types\CampaignState::validate($val);
		/* Sanitizer */

		$_POST['campaign'] = \FOP\Sanitizers::null_filter($_POST['campaign']);

		if (isset($_POST['fop_list_state'])) foreach ($_POST['fop_list_state'] AS $idx => $val) $_POST['fop_list_state'][$idx] = \FOP\Sanitizers::null_filter($val);
	}
	
    // --- BLOCK: access+~campaign:6c87eaeb3f27fd76105907c05088f0d75b563f0afda50359d692790806c0b7ed:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['campaign']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['campaign']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['campaign']) . '')->fetchColumn()))) : (false))) throw new \FOP\AccessDeniedException();
		}
	
    // --- 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\CampaignTarget::getDefaults();
				\Tables\CampaignTarget::sanitizeDefaults($subdata, false);
			} else {
				// es ist ein Edit
				$subdata = [];
			}
			
				$subdata['state'] = $_POST['fop_list_state'][$i];
				$subdata['note'] = $_POST['fop_list_note'][$i];
				$subdata['ID'] = $_POST['fop_list_ID'][$i];
				$subdata['target'] = $_POST['fop_list_target'][$i];
				$subdata['campaign'] = $_POST['campaign'];
			if ($subid) {
				// existierendes Element
				if ($_POST['fop_list'][$i] == '0') {
					// zur Löschung markiert
					// achtet selbst auf Permissions
					\Tables\CampaignTarget::delete($subid);
				} else {
					// achtet selbst auf Permissions
					\Tables\CampaignTarget::edit($subid, $subdata);
					
					$result->push($subid);
				}
			} else if ($_POST['fop_list'][$i] != '0') {
				// noch keine ID: erstellen
				if (((\FOP\User::getCampaign()) && (\FOP\User::getCampaign()))) {
					// TODO: TIAR-Create prüfen
					try {
						$subid = \Tables\CampaignTarget::create($subdata);
						
						$result->push($subid);
					} catch (\FOP\AccessDeniedException $e) {
						// ignore duplicate
						if ($e->getMessage() != 'duplicateinsert') {
							throw $e;
						}
					}
				}
			}
		}
	
    // --- BLOCK: main-3 ---
    
			\FOP\Database::commitTransaction();
			
		}
		
		if (isset($_POST['Tables:CampaignTarget: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\CampaignTarget::indexURL2(['popup' => $_GET['popup'] ?? null, 'filter_campaignTarget_ID' => $result->toString()]));
			}
			die();
	
		}
		if (isset($_POST['next_campaign'])) {
			
			{
				header('Location: ' . \TablesRouter\Campaign::viewURL2(['popup' => $_GET['popup'] ?? null, 'from' => $_POST['fop-from'] ?? null, 'id' => $_POST['campaign']]));
			}
			die();
	
		}
		die(json_encode($_POST));
	} else {
    // --- BLOCK: main-4:load-fill-campaign ---
    
		/* TODO: Behandlung der Spalte campaign: Häufigsten Wert extrahieren */
	
    // --- BLOCK: main-4:load-main ---
    
		$data = \Tables\CampaignTarget::getDefaults();
	
    // --- BLOCK: main-4:load-main-list-fop_list ---
    
		$fop_list = [];
		
	
    // --- BLOCK: main-4:load-main-list~default-state ---
    array_walk($fop_list, function (&$data) {
		$data['state'] = (\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.qi('ZG6Q6jdg').'.'.qi('ID').') FROM '.qi('campaignState').' '.qi('ZG6Q6jdg').' WHERE TRUE AND ('.qi('ZG6Q6jdg').'.'.qi('aftercontact').')')->fetchColumn()));
	});
    // --- BLOCK: main-4:load-main-list~param ---
    
		/* do not stress the idlist budget */
		$max_items = intdiv(ini_get('max_input_vars') - 30 /* Reserve für feste Spalten */, 3+1+1);
		$column_target = new \FOP\IDList($column_target);
		$rest = $column_target->splice($max_items);
		if ($rest) {
			$_GET['from'] = \TablesRouter\CampaignTarget::multiaddURL2(['column_target' => $rest, 'from' => $_GET['from'] ?? null]);
		}
		foreach ($column_target->all() AS $value) {
			$item = \Tables\CampaignTarget::getDefaults();
			$item['target'] = $value;
			$item['ID'] = '';
			$item['canDelete'] = true;
			// TODO: Default-Werte, column_-Werte; evtl. einfach aus $data kopieren??
			\Tables\CampaignTarget::sanitizeDefaults($item, true);
			array_push($fop_list, $item);
		}
	
    // --- BLOCK: main-4:load-~sanitize ---
    
		\Tables\CampaignTarget::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(_('Zu %s hinzufügen'), _('Aktion'))); ?></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(_('Zu %s hinzufügen'), _('Aktion'))); ?></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(_('Zu %s hinzufügen'), _('Aktion'))); ?></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'), $column_target->count(), $rest->count());
		}
		?>
	
							</div>
							<div class="content" id="1">
								

								<form
									
									action="<?php echo \TablesRouter\CampaignTarget::multiaddURL2(['popup' => $_GET['popup'] ?? null, 'column_target' => $column_target]); ?>"
									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_campaignTarget_multiadd"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_campaignTarget_multiadd" ng-init="form = <?php echo htmlentities(json_encode(['campaign' => $data['campaign']]));
									?>;"
								>
								<?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 || true)) {
									$feature = [
										'id' => 'main',
										'title' => _('Daten'),
										'order' => '100', // 100 (20)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. '0' .'||'. '0' .'||'. (true ? 'true' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && (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:campaignTarget:multiadd\' 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_campaignTarget_multiadd_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="next_campaign" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">arrow_forward</i><?php echo(_('zur Kampagne')); ?></button><?php } ?>
									&nbsp;<?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:CampaignTarget: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_campaignTarget_multiadd_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 || true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main']);
										?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_campaign" id="column_campaign">
		<!-- Feld "Aktion": campaign -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="campaign"><?php echo(_('Aktion')); ?>: </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\Campaign::renderEditform_wf_campaignTarget_multiadd_campaignAction($data['campaign'], [], '');
?> &nbsp;	<?php if (\TablesRouter\Campaign::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\Campaign::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'campaign\']'); ?>%26type=campaign%26colinsert=campaign%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\Campaign::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'campaign\']'); ?>%26type=campaign%26colinsert=campaign%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=campaign", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div>
	</div>
	</div><?php
										\EasyEditor\FormFeature::pop();
										$features['main']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && (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(_('Ziel')); ?></th>
						<?php } ?>
						<?php if (true || !\FOP\User::getIsGuest()) { ?>
							<th class='mdl-data-table__cell--non-numeric'><?php echo(_('Status')); ?></th>
						<?php } ?>
						<?php if (true || !\FOP\User::getIsGuest()) { ?>
							<th class='mdl-data-table__cell--non-numeric'><?php echo(_('Notiz')); ?></th>
						<?php } ?>
				</tr>
			</thead>
			<tbody>
				<?php
				foreach ($fop_list AS $row) {
					self::multiaddListFop_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/CampaignTarget/multiaddListFop_list?_&column_target=<?php echo htmlentities(\FOP\Util::urlencode($column_target)); ?>", 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'), _('Empfänger'))); ?></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_campaignTarget_multiadd').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-wf_campaignTarget_multiadd').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-wf_campaignTarget_multiadd').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%3AcampaignTarget%3Amultiadd&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%3AcampaignTarget%3Amultiadd&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_campaignTarget_multiadd')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_campaignTarget_multiadd 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 deleteConfirmAction($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::getCampaign()) && (\FOP\User::getCampaign())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		
		/* Validatoren */
		
		

		
		/* Sanitizer */

		

		
	}
	
    // --- BLOCK: access-itemlist-campaignTarget-delete ---
    
		// 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('campaignTarget').' WHERE (('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('hKxqI7xl').' WHERE '.qi('hKxqI7xl').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('qnAG6U6I').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('qnAG6U6I').' WHERE '.qi('qnAG6U6I').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('MQUST27S').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('MQUST27S').'.'.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('MQUST27S').' WHERE '.qi('MQUST27S').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('UZUFh6Y1').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('UZUFh6Y1').' WHERE '.qi('UZUFh6Y1').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) 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 ---
    /* view */
    // --- BLOCK: main-3 ---
    
			\FOP\Database::commitTransaction();
			
		}
		
		if (isset($_POST['no'])) {
			
			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\CampaignTarget::viewURL2(['id' => $id, 'popup' => $_GET['popup'] ?? null]));
			}
			die();
	
		}
		if (isset($_POST['yes'])) {
			
			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 {
				header('Location: ' . \TablesRouter\CampaignTarget::deleteURL2(['id' => $id, 'popup' => $_GET['popup'] ?? null, 'from' => $_POST['fop-from'] ?? null]));
			}
			die();
	
		}
		die(json_encode($_POST));
	} else {
    // --- BLOCK: main-4:load-main ---
    
		$data = [];
	
    // --- 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(_('confirmdelete')); ?></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(_('confirmdelete')); ?></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(_('confirmdelete')); ?></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\CampaignTarget::deleteConfirmURL2(['popup' => $_GET['popup'] ?? null, 'id' => $id]); ?>"
									method="post"
									enctype="multipart/form-data" ng-submit='submit($event)'
								 
								id="cardform-wf_campaignTarget_deleteConfirm"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_campaignTarget_deleteConfirm" 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' => 'constraints',
										'title' => _(''),
										'order' => '200', // 200 (50)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'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)) {
									$feature = [
										'id' => 'main',
										'title' => _('Daten'),
										'order' => '100', // 100 (20)
										'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:campaignTarget:deleteConfirm\' 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['constraints']);
										?><div class='fop-delete-constraints'><?php
	$foundProblems = false;
	
?></div><?php
										\EasyEditor\FormFeature::pop();
										$features['constraints']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['buttons']);
										?><div id='wf_campaignTarget_deleteConfirm_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="no" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">cancel</i><?php echo(_('no')); ?></button><?php } ?>
									&nbsp;<?php if ((!$foundProblems)) { ?><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="yes" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">delete</i><?php echo(_('yes')); ?></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_campaignTarget_deleteConfirm_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']);
										?><?php echo htmlentities(_('confirmdelete')) . ' (' . $id->count() . '× ' . _('Empfänger') . ')'; ?><?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%3AcampaignTarget%3AdeleteConfirm&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%3AcampaignTarget%3AdeleteConfirm&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_campaignTarget_deleteConfirm')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_campaignTarget_deleteConfirm 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 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-campaignTarget')['from'] ?? null)) {
					header('Location: ' . $to);
					die();
				}
				if (!\TablesRouter\CampaignTarget::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\CampaignTarget::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-4:load-main_Not Modified ---
    
		header_remove('Pragma');
		header_remove('Cache-Control');
		header_remove('Expires');
		header('Cache-Control: private');
		header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $data['lastUpdate']) . ' GMT');
		header('ETag: "campaignTarget:view:' . $id . '"');
		if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $data['lastUpdate'] > 0 && $data['lastUpdate'] <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
			// cache ist noch aktuell
			header("HTTP/1.1 304 Not Modified");
			exit;
		}
	
    // --- 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(_('view')); ?></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-campaignTarget')) { ?>
	<?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(_('view')); ?></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-campaignTarget')) { ?>
	<?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(_('view')); ?></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\CampaignTarget::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_campaignTarget_view"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_campaignTarget_view" 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 || 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')
											
									];
									$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:campaignTarget: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 && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['buttons']);
										?><div id='wf_campaignTarget_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::getCampaign()) && (\FOP\User::getCampaign())) && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign()))) { ?><a title="<?php echo(_('editbtn')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\CampaignTarget::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 ($data['operation::view'] == 1 && $data['operation::is_mail'] == 1 && $data['operation::view'] == 1 && $data['operation::is_mail'] == 1 && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && (!\FOP\User::getIsGuest())) { ?><a title="<?php echo(_('campaignMassMailBTN')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\CampaignTarget::massMailSendURL2(['idlist' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>email</i> <?php echo(_('campaignMassMailBTN')); ?></a><?php } ?>&nbsp;
		<?php if ($data['operation::view'] == 1 && $data['operation::edit'] == 1 && $data['operation::view'] == 1 && $data['operation::edit'] == 1 && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign()))) { ?><a title="<?php echo(_('Daten nachtragen')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\CampaignTarget::multistatusURL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>edit</i> <?php echo(_('Daten nachtragen')); ?></a><?php } ?>&nbsp;
		<?php if ($data['operation::view'] == 1 && $data['operation::edit'] == 1 && $data['operation::view'] == 1 && $data['operation::edit'] == 1 && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign()))) { ?><a title="<?php echo(_('Status setzen')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\CampaignTarget::multistatus2URL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>star</i> <?php echo(_('Status setzen')); ?></a><?php } ?>&nbsp;
		<?php if (true && $data['operation::view'] == 1 && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign()))) { ?><a title="<?php echo(_('PDF Vorschau')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\CampaignTarget::pdfURL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>print</i> <?php echo(_('PDF Vorschau')); ?></a><?php } ?>&nbsp;
		<?php if ($data['operation::delete'] == 1 && $data['operation::delete'] == 1 && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign()))) { ?><a title="<?php echo(_('deletebtn')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\CampaignTarget::deleteConfirmURL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null, 'from' => $_GET['from'] ?? \FOP\Session::getPayload('dv-campaignTarget')['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_campaignTarget_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)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main']);
										?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_campaign" id="column_campaign">
		<!-- Feld "Aktion": campaign -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="campaign"><?php echo(_('Aktion')); ?>: </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('campaign').'.'.qi('name').' AS description, (('.\FOP\Database::quote(\FOP\User::getCampaign()).')) AS '.qi('canView').' FROM '.qi('campaign').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($data['campaign']);
	$campaign_result = \FOP\Database::query($sql);
	if ($campaign_row = $campaign_result->fetch(\PDO::FETCH_ASSOC)) {
		if ($campaign_row['canView']) echo "<a onclick=\"event.preventDefault(); open_url(this.href, true);\" href=\"" . \TablesRouter\Campaign::viewURL($data['campaign'], ['from' => \FOP\Util::getBackURL()]) . "\" class=\"tbl-link\" data-tbl=\"campaign\" data-id=\"".htmlentities($campaign_row['ID'])."\">";echo htmlentities($campaign_row['description']);if ($campaign_row['canView']) echo "</a>";
	} else {
		echo htmlentities(_('') ?: '-');
	}
	
?>

	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_target" id="column_target">
		<!-- Feld "Ziel": target -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="target"><?php echo(_('Ziel')); ?>: </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').', 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['target']);
	$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['target'], ['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_state" id="column_state">
		<!-- Feld "Status": state -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="state"><?php echo(_('Status')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<span class='fop-editable' style='width: 100%;<?php if (((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && $data['operation::view'] == 1 && $data['operation::edit'] == 1) {?> cursor: pointer;' onclick='
		event.preventDefault();
		event.stopPropagation();
		var cell = $(this).closest(&apos;.mdl-cell&apos;).parent(&apos;.mdl-cell&apos;);
		var div = get_overlay(this, function () {
			// submit the form in overlay
			div.find(&apos;form&apos;).submit();
		});
		$.get(&apos;Tables/CampaignTarget/stateEdit?id=&apos; + <?php echo htmlentities($id); ?>).then(function (html) {
			div.html(html);
			var iframe = div.find(&apos;iframe&apos;)[0];
			if (iframe) iframe.onload = function () {
				this.onload = function () {
					div.close();
					if (!window.noreload) location.reload(); // TODO: evtl. Ajax
					window.noreload = false;
				}
			};
			div.find(&apos;input[type=text], input[type=checkbox], textarea&apos;).select().focus().keydown(function (event) {
				if ([13/*, 38, 40*/, 9].includes(event.keyCode)) { // ENTER, up, down, tab
					$(this).closest(&apos;form&apos;).submit();
					event.preventDefault();
					event.stopPropagation();
					if (/*event.keyCode == 40 ||*/ event.keyCode == 9 && !event.shiftKey) {
						var n = cell.next(&apos;.mdl-cell:has(.fop-editable)&apos;).find(&apos;.fop-editable&apos;);
						if (n.length) {
							window.noreload = true;
							n.click();
						}
					}
					if (/*event.keyCode == 38 ||*/ event.keyCode == 9 && event.shiftKey) {
						var n = cell.prev(&apos;.mdl-cell:has(.fop-editable)&apos;).find(&apos;.fop-editable&apos;);
						if (n.length) {
							window.noreload = true;
							n.click();
						}
					}
				}
			});
		});
		div.text(&apos;🗘&apos;);
		return true;'<?php } else { ?>'<?php } ?>><?php
	
	$sql = 'SELECT '.qi('ID').' AS '.qi('ID').', '.qi('campaignState').'.'.qi('desc').' AS description, (('.\FOP\Database::quote(\FOP\User::getCampaign()).')) AS '.qi('canView').' FROM '.qi('campaignState').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($data['state']);
	$campaignState_result = \FOP\Database::query($sql);
	if ($campaignState_row = $campaignState_result->fetch(\PDO::FETCH_ASSOC)) {
		if ($campaignState_row['canView']) echo "<a onclick=\"event.preventDefault(); open_url(this.href, false);\" href=\"" . \TablesRouter\CampaignState::viewURL($data['state'], ['from' => \FOP\Util::getBackURL()]) . "\" class=\"tbl-link\" data-tbl=\"campaignState\" data-id=\"".htmlentities($campaignState_row['ID'])."\">";echo htmlentities($campaignState_row['description']);if ($campaignState_row['canView']) echo "</a>";
	} else {
		echo htmlentities(_('') ?: '-');
	}
	
?>
</span>
	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_note" id="column_note">
		<!-- Feld "Notiz": note -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="note"><?php echo(_('Notiz')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<span class='fop-editable' style='width: 100%;<?php if (((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && $data['operation::view'] == 1 && $data['operation::edit'] == 1) {?> cursor: pointer;' onclick='
		event.preventDefault();
		event.stopPropagation();
		var cell = $(this).closest(&apos;.mdl-cell&apos;).parent(&apos;.mdl-cell&apos;);
		var div = get_overlay(this, function () {
			// submit the form in overlay
			div.find(&apos;form&apos;).submit();
		});
		$.get(&apos;Tables/CampaignTarget/noteEdit?id=&apos; + <?php echo htmlentities($id); ?>).then(function (html) {
			div.html(html);
			var iframe = div.find(&apos;iframe&apos;)[0];
			if (iframe) iframe.onload = function () {
				this.onload = function () {
					div.close();
					if (!window.noreload) location.reload(); // TODO: evtl. Ajax
					window.noreload = false;
				}
			};
			div.find(&apos;input[type=text], input[type=checkbox], textarea&apos;).select().focus().keydown(function (event) {
				if ([13/*, 38, 40*/, 9].includes(event.keyCode)) { // ENTER, up, down, tab
					$(this).closest(&apos;form&apos;).submit();
					event.preventDefault();
					event.stopPropagation();
					if (/*event.keyCode == 40 ||*/ event.keyCode == 9 && !event.shiftKey) {
						var n = cell.next(&apos;.mdl-cell:has(.fop-editable)&apos;).find(&apos;.fop-editable&apos;);
						if (n.length) {
							window.noreload = true;
							n.click();
						}
					}
					if (/*event.keyCode == 38 ||*/ event.keyCode == 9 && event.shiftKey) {
						var n = cell.prev(&apos;.mdl-cell:has(.fop-editable)&apos;).find(&apos;.fop-editable&apos;);
						if (n.length) {
							window.noreload = true;
							n.click();
						}
					}
				}
			});
		});
		div.text(&apos;🗘&apos;);
		return true;'<?php } else { ?>'<?php } ?>><span><?php echo nl2br(htmlentities($data['note'])); ?></span></span>
	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_creation" id="column_creation">
		<!-- Feld "Erstellung": creation -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="creation"><?php echo(_('Erstellung')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		
	<?php echo htmlentities(($data['creation']) ? strftime(_('datetimeformat_php2'), intval($data['creation'])) : ''); ?>
	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_lastUpdate" id="column_lastUpdate">
		<!-- Feld "letzte Aktualisierung": lastUpdate -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="lastUpdate"><?php echo(_('letzte Aktualisierung')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		
	<?php echo htmlentities(($data['lastUpdate']) ? strftime(_('datetimeformat_php2'), intval($data['lastUpdate'])) : ''); ?>
	</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%3AcampaignTarget%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%3AcampaignTarget%3Aview&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_campaignTarget_view')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_campaignTarget_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>
							

							</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_target = null , $column_campaign = 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::getCampaign()) && (\FOP\User::getCampaign())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		
		/* Validatoren */
		
		if ((!isset($_POST['cancel']))) \Types\Campaign::validate($_POST['campaign']);
		if ((!isset($_POST['cancel']))) \Types\Mitglied::validate($_POST['target']);
		if ((!isset($_POST['cancel']))) \Types\CampaignState::validate($_POST['state']);

		
		/* Sanitizer */

		if ((!isset($_POST['cancel']))) $_POST['campaign'] = \FOP\Sanitizers::null_filter($_POST['campaign']);
		if ((!isset($_POST['cancel']))) $_POST['target'] = \FOP\Sanitizers::null_filter($_POST['target']);
		if ((!isset($_POST['cancel']))) $_POST['state'] = \FOP\Sanitizers::null_filter($_POST['state']);
		if (((false))) $_POST['creation'] = \FOP\Sanitizers::convert_datetime_to_unix_timestamp($_POST['creation']);
		if (((false))) $_POST['lastUpdate'] = \FOP\Sanitizers::convert_datetime_to_unix_timestamp($_POST['lastUpdate']);

		
	}
	
    // --- BLOCK: access+~campaign:6c87eaeb3f27fd76105907c05088f0d75b563f0afda50359d692790806c0b7ed:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['campaign']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['campaign']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['campaign']) . '')->fetchColumn()))) : (false))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~target:4f39b0d23932e247f462535fea9ee95e28937e996247ab473e49af31193b1405:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if ((!\FOP\User::getIsGuest()) && !isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('CoxcrW6l').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('CoxcrW6l').' WHERE '.qi('CoxcrW6l').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('CoxcrW6l').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('CoxcrW6l').' WHERE '.qi('CoxcrW6l').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('CoxcrW6l').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('CoxcrW6l').' WHERE '.qi('CoxcrW6l').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) : (false))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~target:5f3359c11668deac25a4d45137caa29a416637e0de1e06884fad3ad8c538cfe8:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if ((!\FOP\User::getIsGuest()) && !isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PW9rw6As').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PW9rw6As').'.'.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('PW9rw6As').' WHERE '.qi('PW9rw6As').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PW9rw6As').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PW9rw6As').'.'.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('PW9rw6As').' WHERE '.qi('PW9rw6As').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PW9rw6As').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PW9rw6As').'.'.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('PW9rw6As').' WHERE '.qi('PW9rw6As').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) : (false))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~target:88cf9919f703ad0057b87736d14ecb31e9db0fb50c4f6cde55baaa36bb5af625:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if ((!\FOP\User::getIsGuest()) && !isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('gamUdXIr').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('gamUdXIr').' WHERE '.qi('gamUdXIr').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('gamUdXIr').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('gamUdXIr').' WHERE '.qi('gamUdXIr').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('gamUdXIr').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('gamUdXIr').' WHERE '.qi('gamUdXIr').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) : (false))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~target:campaignTarget:campaign:target:unique ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (($data ?? null) && isset($data['ID'])) $_POST['ID'] = $data['ID'];
			if ((!\FOP\User::getIsGuest()) && !isset($_POST['cancel']) && !(true)) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-campaign-PZzRYmSJ ---
    
		if ($column_campaign !== null && \FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($column_campaign))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-mitglied-8oS4CA4y ---
    
		if ($column_target !== 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_target))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-mitglied-aknxOsQe ---
    
		if ($column_target !== 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_target))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-mitglied-mDdHq6xV ---
    
		if ($column_target !== 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_target))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-mitglied-select ---
    
		if ($column_target !== null && \FOP\Database::query('SELECT '.(\FOP\User::getIsGuest() ? 'false' : 'true').' FROM '.qi('mitglied').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($column_target))->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\CampaignTarget::getDefaults();
		$defaults['note'] = $_POST['note'];
		if ((!isset($_POST['cancel']))) $defaults['campaign'] = $_POST['campaign'];
		if ((!isset($_POST['cancel']))) $defaults['target'] = $_POST['target'];
		if ((!isset($_POST['cancel']))) $defaults['state'] = $_POST['state'];
		if (((false))) $defaults['creation'] = $_POST['creation'];
		if (((false))) $defaults['lastUpdate'] = $_POST['lastUpdate'];
		// TableItemAccess für PHP auswerten
		if (!((\FOP\User::getCampaign()) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['campaign']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['campaign']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['campaign']) . '')->fetchColumn()))) : (false)) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('gamUdXIr').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('gamUdXIr').' WHERE '.qi('gamUdXIr').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['target']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('gamUdXIr').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('gamUdXIr').' WHERE '.qi('gamUdXIr').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['target']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('gamUdXIr').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('gamUdXIr').' WHERE '.qi('gamUdXIr').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['target']) . '')->fetchColumn()))) : (false)) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PW9rw6As').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PW9rw6As').'.'.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('PW9rw6As').' WHERE '.qi('PW9rw6As').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['target']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PW9rw6As').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PW9rw6As').'.'.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('PW9rw6As').' WHERE '.qi('PW9rw6As').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['target']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PW9rw6As').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PW9rw6As').'.'.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('PW9rw6As').' WHERE '.qi('PW9rw6As').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['target']) . '')->fetchColumn()))) : (false)) && (\FOP\User::getCampaign()) && (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('CoxcrW6l').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('CoxcrW6l').' WHERE '.qi('CoxcrW6l').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['target']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('CoxcrW6l').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('CoxcrW6l').' WHERE '.qi('CoxcrW6l').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['target']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('CoxcrW6l').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('CoxcrW6l').' WHERE '.qi('CoxcrW6l').'.'.qi('ID').' = ' . \FOP\Database::quote($defaults['target']) . '')->fetchColumn()))) : (false)))) throw new \FOP\AccessDeniedException('accessdenied');
		$id = \Tables\CampaignTarget::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\CampaignTarget::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\CampaignTarget::viewAccess($id)) {
					if (!\TablesRouter\CampaignTarget::indexAccess()) {
						header('Location: ' . \FOPRouter\Index::indexURL2(['popup' => $_GET['popup'] ?? null, 'from' => $_POST['fop-from'] ?? null]));
						die();
					}
					header('Location: ' . \TablesRouter\CampaignTarget::indexURL2(['popup' => $_GET['popup'] ?? null, 'from' => $_POST['fop-from'] ?? null]));
					die();
				}
				header('Location: ' . \TablesRouter\CampaignTarget::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\CampaignTarget::getDefaults();
	
    // --- BLOCK: main-4:load-override ---
    
		$hidden = [];
		if (isset($column_target)) {
			
			$hidden['target'] = $column_target;
			$data['target'] = $column_target;
		}
		if (isset($column_campaign)) {
			
			$hidden['campaign'] = $column_campaign;
			$data['campaign'] = $column_campaign;
		}
	
    // --- BLOCK: main-4:load-~sanitize ---
    
		\Tables\CampaignTarget::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'), _('Empfänger'))); ?></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'), _('Empfänger'))); ?></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'), _('Empfänger'))); ?></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\CampaignTarget::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_campaignTarget_create"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_campaignTarget_create" ng-init="form = <?php echo htmlentities(json_encode(['campaign' => $data['campaign'], 'target' => $data['target'], 'ID' => $data['ID']]));
									?>;"
								>
								<?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 || ((false)) || ((false)) || (!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' .'||'. (true ? 'true' : '0')
											 .'||'. (((false)) ? 'true' : '0')
											 .'||'. (((false)) ? 'true' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? 'true' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? '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:campaignTarget: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_campaignTarget_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_campaignTarget_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 || true || ((false)) || ((false)) || (!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_campaign" id="column_campaign">
		<!-- Feld "Aktion": campaign -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['campaign'])) { echo ' fop-disabled'; } ?>">
		<label for="campaign"><?php echo(_('Aktion')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['campaign'])) { echo ' fop-disabled"><input type="hidden" name="campaign" value="' . htmlentities($hidden['campaign']); }
		?>">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\Campaign::renderEditform_wf_campaignTarget_create_campaignAction($data['campaign'], [], '');
?> &nbsp;	<?php if (\TablesRouter\Campaign::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\Campaign::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'campaign\']'); ?>%26type=campaign%26colinsert=campaign%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\Campaign::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'campaign\']'); ?>%26type=campaign%26colinsert=campaign%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=campaign", "_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_target" id="column_target">
		<!-- Feld "Ziel": target -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['target'])) { echo ' fop-disabled'; } ?>">
		<label for="target"><?php echo(_('Ziel')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['target'])) { echo ' fop-disabled"><input type="hidden" name="target" value="' . htmlentities($hidden['target']); }
		?>">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\Mitglied::renderEditform_wf_campaignTarget_create_targetAction($data['target'], [], '');
?> &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[\'target\']'); ?>%26type=mitglied%26colinsert=target%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[\'target\']'); ?>%26type=mitglied%26colinsert=target%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=mitglied", "_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_state" id="column_state">
		<!-- Feld "Status": state -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['state'])) { echo ' fop-disabled'; } ?>">
		<label for="state"><?php echo(_('Status')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['state'])) { echo ' fop-disabled"><input type="hidden" name="state" value="' . htmlentities($hidden['state']); }
		?>">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\CampaignState::renderEditform_wf_campaignTarget_create_stateAction($data['state'], [], '');
?> &nbsp;	<?php if (\TablesRouter\CampaignState::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\CampaignState::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=campaignState%26colinsert=state%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\CampaignState::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=campaignState%26colinsert=state%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=campaignState", "_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_note" id="column_note">
		<!-- Feld "Notiz": note -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['note'])) { echo ' fop-disabled'; } ?>">
		<label for="note"><?php echo(_('Notiz')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['note'])) { echo ' fop-disabled"><input type="hidden" name="note" value="' . htmlentities($hidden['note']); }
		?>">
		<div style="width: 100%;" class="mdl-textfield mdl-js-textfield"><textarea onkeydown='if (event.keyCode == 13 && event.ctrlKey) { event.preventDefault(); event.stopPropagation(); tabNext(this); return false; }' class="mdl-textfield__input" rows="8" cols="80" name="note" id="note" ><?php echo htmlentities($data['note']); ?></textarea><label class="mdl-textfield__label" for="note"><?php echo(_('text')); ?></label><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div>
	</div>
	</div><?php if (((false))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_creation" id="column_creation">
		<!-- Feld "Erstellung": creation -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['creation'])) { echo ' fop-disabled'; } ?>">
		<label for="creation"><?php echo(_('Erstellung')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['creation'])) { echo ' fop-disabled"><input type="hidden" name="creation" value="' . htmlentities($hidden['creation']); }
		?>">
		<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 (_('datetimeformat_moment')); ?>' class="mdl-textfield__input picker_datetime" id="creation" type="text" name="creation" value="<?php echo ($data['creation']) ? strftime(_('datetimeformat_php2'), intval($data['creation'])) : ''; ?>"/><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div>
	</div>
	</div><?php } ?><?php if (((false))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_lastUpdate" id="column_lastUpdate">
		<!-- Feld "letzte Aktualisierung": lastUpdate -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label<?php if (isset($hidden['lastUpdate'])) { echo ' fop-disabled'; } ?>">
		<label for="lastUpdate"><?php echo(_('letzte Aktualisierung')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content<?php
			if (isset($hidden['lastUpdate'])) { echo ' fop-disabled"><input type="hidden" name="lastUpdate" value="' . htmlentities($hidden['lastUpdate']); }
		?>">
		<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 (_('datetimeformat_moment')); ?>' class="mdl-textfield__input picker_datetime" id="lastUpdate" type="text" name="lastUpdate" value="<?php echo ($data['lastUpdate']) ? strftime(_('datetimeformat_php2'), intval($data['lastUpdate'])) : ''; ?>"/><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></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_campaignTarget_create').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-wf_campaignTarget_create').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-wf_campaignTarget_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%3AcampaignTarget%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%3AcampaignTarget%3Acreate&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_campaignTarget_create')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_campaignTarget_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::getCampaign()) && (\FOP\User::getCampaign())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		$data = self::view($id);
		/* Validatoren */
		
		if ((!isset($_POST['cancel']))) \Types\Campaign::validate($_POST['campaign']);
		if ((!isset($_POST['cancel']))) \Types\Mitglied::validate($_POST['target']);
		if ((!isset($_POST['cancel']))) \Types\CampaignState::validate($_POST['state']);

		
		/* Sanitizer */

		if ((!isset($_POST['cancel']))) $_POST['campaign'] = \FOP\Sanitizers::null_filter($_POST['campaign']);
		if ((!isset($_POST['cancel']))) $_POST['target'] = \FOP\Sanitizers::null_filter($_POST['target']);
		if ((!isset($_POST['cancel']))) $_POST['state'] = \FOP\Sanitizers::null_filter($_POST['state']);
		if (((false)) && ($data['creation::canEdit'] == 1)) $_POST['creation'] = \FOP\Sanitizers::convert_datetime_to_unix_timestamp($_POST['creation']);
		if (((false)) && ($data['lastUpdate::canEdit'] == 1)) $_POST['lastUpdate'] = \FOP\Sanitizers::convert_datetime_to_unix_timestamp($_POST['lastUpdate']);

		
	}
	
    // --- BLOCK: access+~campaign:6c87eaeb3f27fd76105907c05088f0d75b563f0afda50359d692790806c0b7ed:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['campaign']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['campaign']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['campaign']) . '')->fetchColumn()))) : (false))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~target:4f39b0d23932e247f462535fea9ee95e28937e996247ab473e49af31193b1405: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('CoxcrW6l').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('CoxcrW6l').' WHERE '.qi('CoxcrW6l').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('CoxcrW6l').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('CoxcrW6l').' WHERE '.qi('CoxcrW6l').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('CoxcrW6l').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('CoxcrW6l').' WHERE '.qi('CoxcrW6l').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) : (false))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~target:5f3359c11668deac25a4d45137caa29a416637e0de1e06884fad3ad8c538cfe8: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('PW9rw6As').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PW9rw6As').'.'.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('PW9rw6As').' WHERE '.qi('PW9rw6As').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PW9rw6As').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PW9rw6As').'.'.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('PW9rw6As').' WHERE '.qi('PW9rw6As').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PW9rw6As').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PW9rw6As').'.'.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('PW9rw6As').' WHERE '.qi('PW9rw6As').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) : (false))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~target:88cf9919f703ad0057b87736d14ecb31e9db0fb50c4f6cde55baaa36bb5af625: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('gamUdXIr').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('gamUdXIr').' WHERE '.qi('gamUdXIr').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('gamUdXIr').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('gamUdXIr').' WHERE '.qi('gamUdXIr').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('gamUdXIr').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('gamUdXIr').' WHERE '.qi('gamUdXIr').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['target']) . '')->fetchColumn()))) : (false))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access+~target:campaignTarget:campaign:target:unique ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (($data ?? null) && isset($data['ID'])) $_POST['ID'] = $data['ID'];
			if (!isset($_POST['cancel']) && !(true)) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-campaignTarget-edit ---
    
		if ($id !== null && \FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('vOljclgU').' WHERE '.qi('vOljclgU').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('XXDtdS61').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('XXDtdS61').' WHERE '.qi('XXDtdS61').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('YOWPvw9s').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('YOWPvw9s').'.'.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('YOWPvw9s').' WHERE '.qi('YOWPvw9s').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Z2wISAZD').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Z2wISAZD').' WHERE '.qi('Z2wISAZD').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) FROM '.qi('campaignTarget').' 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['note'] = $_POST['note'];
		if ((!isset($_POST['cancel']))) $data_edit['campaign'] = $_POST['campaign'];
		if ((!isset($_POST['cancel']))) $data_edit['target'] = $_POST['target'];
		if ((!isset($_POST['cancel']))) $data_edit['state'] = $_POST['state'];
		if (((false)) && ($data['creation::canEdit'] == 1)) $data_edit['creation'] = $_POST['creation'];
		if (((false)) && ($data['lastUpdate::canEdit'] == 1)) $data_edit['lastUpdate'] = $_POST['lastUpdate'];
		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\CampaignTarget::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\CampaignTarget::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_Not Modified ---
    
		header_remove('Pragma');
		header_remove('Cache-Control');
		header_remove('Expires');
		header('Cache-Control: private');
		header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $data['lastUpdate']) . ' GMT');
		header('ETag: "campaignTarget:edit:' . $id . '"');
		if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $data['lastUpdate'] > 0 && $data['lastUpdate'] <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
			// cache ist noch aktuell
			header("HTTP/1.1 304 Not Modified");
			exit;
		}
	
    // --- 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(_('edit %s'), _('Empfänger'))); ?></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(_('edit %s'), _('Empfänger'))); ?></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(_('edit %s'), _('Empfänger'))); ?></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\CampaignTarget::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_campaignTarget_edit"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_campaignTarget_edit" ng-init="form = <?php echo htmlentities(json_encode(['campaign' => $data['campaign'], 'target' => $data['target'], 'ID' => $data['ID']]));
									?>;"
								>
								<?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 || ((false)) && ($data['creation::canEdit'] == 1) || ((false)) && ($data['lastUpdate::canEdit'] == 1) || (!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' .'||'. (true ? 'true' : '0')
											 .'||'. (((false)) && ($data['creation::canEdit'] == 1) ? 'true' : '0')
											 .'||'. (((false)) && ($data['lastUpdate::canEdit'] == 1) ? 'true' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? 'true' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? '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:campaignTarget: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_campaignTarget_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_campaignTarget_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 || true || ((false)) && ($data['creation::canEdit'] == 1) || ((false)) && ($data['lastUpdate::canEdit'] == 1) || (!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_campaign" id="column_campaign">
		<!-- Feld "Aktion": campaign -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="campaign"><?php echo(_('Aktion')); ?>: </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\Campaign::renderEditform_wf_campaignTarget_edit_campaignAction($data['campaign'], [], '');
?> &nbsp;	<?php if (\TablesRouter\Campaign::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\Campaign::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'campaign\']'); ?>%26type=campaign%26colinsert=campaign%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\Campaign::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'campaign\']'); ?>%26type=campaign%26colinsert=campaign%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=campaign", "_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_target" id="column_target">
		<!-- Feld "Ziel": target -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="target"><?php echo(_('Ziel')); ?>: </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\Mitglied::renderEditform_wf_campaignTarget_edit_targetAction($data['target'], [], '');
?> &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[\'target\']'); ?>%26type=mitglied%26colinsert=target%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[\'target\']'); ?>%26type=mitglied%26colinsert=target%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=mitglied", "_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_state" id="column_state">
		<!-- Feld "Status": state -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="state"><?php echo(_('Status')); ?>: </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\CampaignState::renderEditform_wf_campaignTarget_edit_stateAction($data['state'], [], '');
?> &nbsp;	<?php if (\TablesRouter\CampaignState::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\CampaignState::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=campaignState%26colinsert=state%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\CampaignState::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=campaignState%26colinsert=state%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=campaignState", "_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_note" id="column_note">
		<!-- Feld "Notiz": note -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="note"><?php echo(_('Notiz')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div style="width: 100%;" class="mdl-textfield mdl-js-textfield"><textarea onkeydown='if (event.keyCode == 13 && event.ctrlKey) { event.preventDefault(); event.stopPropagation(); tabNext(this); return false; }' class="mdl-textfield__input" rows="8" cols="80" name="note" id="note" ><?php echo htmlentities($data['note']); ?></textarea><label class="mdl-textfield__label" for="note"><?php echo(_('text')); ?></label><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div>
	</div>
	</div><?php if (((false)) && ($data['creation::canEdit'] == 1)) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_creation" id="column_creation">
		<!-- Feld "Erstellung": creation -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="creation"><?php echo(_('Erstellung')); ?>: </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 (_('datetimeformat_moment')); ?>' class="mdl-textfield__input picker_datetime" id="creation" type="text" name="creation" value="<?php echo ($data['creation']) ? strftime(_('datetimeformat_php2'), intval($data['creation'])) : ''; ?>"/><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div>
	</div>
	</div><?php } ?><?php if (((false)) && ($data['lastUpdate::canEdit'] == 1)) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_lastUpdate" id="column_lastUpdate">
		<!-- Feld "letzte Aktualisierung": lastUpdate -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="lastUpdate"><?php echo(_('letzte Aktualisierung')); ?>: </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 (_('datetimeformat_moment')); ?>' class="mdl-textfield__input picker_datetime" id="lastUpdate" type="text" name="lastUpdate" value="<?php echo ($data['lastUpdate']) ? strftime(_('datetimeformat_php2'), intval($data['lastUpdate'])) : ''; ?>"/><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></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_campaignTarget_edit').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-wf_campaignTarget_edit').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-wf_campaignTarget_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%3AcampaignTarget%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%3AcampaignTarget%3Aedit&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_campaignTarget_edit')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_campaignTarget_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>
							

							</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 sendMailDelayed($id, $delayed_start = 0 ) { 
    
    
    // --- BLOCK: main ---
    

	$parameterArray = [$id];
	$methodname = '\Tables\CampaignTarget::sendMail';
	$sql = 'INSERT INTO delayedmethods('.qi('lock').', method, parameter, start, '.qi('user').') VALUES (NULL, ' . \FOP\Database::quote($methodname) . ', ' . \FOP\Database::quote(json_encode($parameterArray)) . ', ' . intval($delayed_start) . ', ' . intval(\FOP\User::getID()) . ')';
	try {
		\FOP\Database::query($sql);
	} catch(PDOException $error){
		die(json_encode($error));
	}
	
    
  }

  public static function notify($recipient, $campaign, $target, $state) { 
    
    
    // --- BLOCK: main ---
    
		 $mail = \Mailer\Mails::getMailer();
		 // Recipients, ReplyTo
		 if (!($recipient)) return false; // exit when recipient dosent exist
		 $mail->AddAddress($recipient, $recipient);
		 $mail->Subject = ('CRM: ') . (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CONCAT('.qi('GuaPZc8A').'.'.qi('vorname').', \' \', '.qi('GuaPZc8A').'.'.qi('name').')) FROM '.qi('mitglied').' '.qi('GuaPZc8A').' WHERE '.qi('GuaPZc8A').'.'.qi('ID').' = ' . \FOP\Database::quote($target) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CONCAT('.qi('GuaPZc8A').'.'.qi('vorname').', \' \', '.qi('GuaPZc8A').'.'.qi('name').')) FROM '.qi('mitglied').' '.qi('GuaPZc8A').' WHERE '.qi('GuaPZc8A').'.'.qi('ID').' = ' . \FOP\Database::quote($target) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CONCAT('.qi('GuaPZc8A').'.'.qi('vorname').', \' \', '.qi('GuaPZc8A').'.'.qi('name').')) FROM '.qi('mitglied').' '.qi('GuaPZc8A').' WHERE '.qi('GuaPZc8A').'.'.qi('ID').' = ' . \FOP\Database::quote($target) . '')->fetchColumn()))) : (_(''))) . (' wechselt Zustand zu ') . (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.qi('tiMnru0W').'.'.qi('desc').') FROM '.qi('campaignState').' '.qi('tiMnru0W').' WHERE '.qi('tiMnru0W').'.'.qi('ID').' = ' . \FOP\Database::quote($state) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.qi('tiMnru0W').'.'.qi('desc').') FROM '.qi('campaignState').' '.qi('tiMnru0W').' WHERE '.qi('tiMnru0W').'.'.qi('ID').' = ' . \FOP\Database::quote($state) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.qi('tiMnru0W').'.'.qi('desc').') FROM '.qi('campaignState').' '.qi('tiMnru0W').' WHERE '.qi('tiMnru0W').'.'.qi('ID').' = ' . \FOP\Database::quote($state) . '')->fetchColumn()))) : (_('')));

		 // Body mit HTML, text oder beides
		 $mail->AltBody = ('der Zustand des Teilnehmers ') . (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CONCAT('.qi('5TAAa5s2').'.'.qi('vorname').', \' \', '.qi('5TAAa5s2').'.'.qi('name').')) FROM '.qi('mitglied').' '.qi('5TAAa5s2').' WHERE '.qi('5TAAa5s2').'.'.qi('ID').' = ' . \FOP\Database::quote($target) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CONCAT('.qi('5TAAa5s2').'.'.qi('vorname').', \' \', '.qi('5TAAa5s2').'.'.qi('name').')) FROM '.qi('mitglied').' '.qi('5TAAa5s2').' WHERE '.qi('5TAAa5s2').'.'.qi('ID').' = ' . \FOP\Database::quote($target) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (CONCAT('.qi('5TAAa5s2').'.'.qi('vorname').', \' \', '.qi('5TAAa5s2').'.'.qi('name').')) FROM '.qi('mitglied').' '.qi('5TAAa5s2').' WHERE '.qi('5TAAa5s2').'.'.qi('ID').' = ' . \FOP\Database::quote($target) . '')->fetchColumn()))) : (_(''))) . (' hat seinen Zustand zu ') . (((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.qi('KaYnLD8I').'.'.qi('desc').') FROM '.qi('campaignState').' '.qi('KaYnLD8I').' WHERE '.qi('KaYnLD8I').'.'.qi('ID').' = ' . \FOP\Database::quote($state) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.qi('KaYnLD8I').'.'.qi('desc').') FROM '.qi('campaignState').' '.qi('KaYnLD8I').' WHERE '.qi('KaYnLD8I').'.'.qi('ID').' = ' . \FOP\Database::quote($state) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT ('.qi('KaYnLD8I').'.'.qi('desc').') FROM '.qi('campaignState').' '.qi('KaYnLD8I').' WHERE '.qi('KaYnLD8I').'.'.qi('ID').' = ' . \FOP\Database::quote($state) . '')->fetchColumn()))) : (_(''))) . (' gewechselt.'); $mail->Body = nl2br(htmlentities($mail->AltBody));

		 
		 // CallToAction
		 if ($campaign) {
			 $mail->Body = $mail->Body . '<br><br><a href="' . htmlentities(\TablesRouter\Campaign::viewURL2(['id' => $campaign])) . '">' . nl2br(htmlentities('zur Kampagne')) . '</a>';
			 $mail->AltBody = $mail->AltBody . "\n\n" . 'zur Kampagne' . ': '. \TablesRouter\Campaign::viewURL2(['id' => $campaign]);
		 }

		 

		 // Attachments

		 return $mail->send();
	
    
  }

  public static function checkState($id) { 
    
    
    // --- BLOCK: main ---
    
	$item = \FOP\Database::query('SELECT '.qi('campaignFollow').'.'.qi('nextCampaign').', '.qi('campaignFollow').'.'.qi('nextState').', '.qi('campaignTarget').'.'.qi('target').', '.qi('campaignTarget').'.'.qi('note').'
	FROM '.qi('campaignFollow').', '.qi('campaignTarget').' WHERE
		'.qi('campaignFollow').'.'.qi('campaign').' = '.qi('campaignTarget').'.'.qi('campaign').' AND
		'.qi('campaignFollow').'.'.qi('state').' = '.qi('campaignTarget').'.'.qi('state').' AND
		'.qi('campaignFollow').'.'.qi('nextCampaign').' IS NOT NULL AND
		NOT EXISTS (SELECT * FROM '.qi('campaignTarget').' AS '.qi('t2').' WHERE '.qi('t2').'.'.qi('campaign').' = '.qi('campaignFollow').'.'.qi('nextCampaign').' AND '.qi('t2').'.'.qi('state').' = '.qi('campaignFollow').'.'.qi('nextState').' AND '.qi('t2').'.'.qi('target').' = '.qi('campaignTarget').'.'.qi('target').') AND
		'.qi('campaignTarget').'.'.qi('ID').' = ' . intval($id))->fetch(\PDO::FETCH_ASSOC);
	if ($item) {
		// Nachfolge-Zustand anlegen
		$data = self::getDefaults();
		$data['campaign'] = $item['nextCampaign'];
		$data['target'] = $item['target'];
		$data['state'] = $item['nextState'];
		$data['note'] = $item['note'];
		$data['creation'] = time();
		$data['lastUpdate'] = time();
		self::sanitizeDefaults($data, false);
		self::create($data, true, true);
	}

    
  }

  public static function interaction1Action($token) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
		if ($_SERVER['REQUEST_METHOD'] != 'HEAD') { // omit email sniffers
			// other side: openssl_encrypt($id, 'aes-128-ctr', \Types\Password::getEncryptKey());
			$id = openssl_decrypt($token, 'aes-128-ctr', \Types\Password::getEncryptKey());
			if (substr($id, 0, 7) != 'target-') {
				die('invalid token');
			} else {
				$id = substr($id, 7);
			}
			$campaignTarget = self::view($id, false, true);
			$campaign = \Tables\Campaign::view($campaignTarget['campaign'], false, true);
			self::edit($id, ['state' => $campaign['email_interact1_state']], false, true);
			if ($campaign['email_reply']) {
				self::notify($campaign['email_reply'], $campaign['ID'], $campaignTarget['target'], $campaign['email_interact1_state']);
			}
		}
		header('Location: ' . $campaign['email_interact1_url']);
	
    
  }

  public static function interaction2Action($token) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
		if ($_SERVER['REQUEST_METHOD'] != 'HEAD') { // omit email sniffers
			// other side: openssl_encrypt($id, 'aes-128-ctr', \Types\Password::getEncryptKey());
			$id = openssl_decrypt($token, 'aes-128-ctr', \Types\Password::getEncryptKey());
			if (substr($id, 0, 7) != 'target-') {
				die('invalid token');
			} else {
				$id = substr($id, 7);
			}
			$campaignTarget = self::view($id, false, true);
			$campaign = \Tables\Campaign::view($campaignTarget['campaign'], false, true);
			self::edit($id, ['state' => $campaign['email_interact2_state']], false, true);
			if ($campaign['email_reply']) {
				self::notify($campaign['email_reply'], $campaign['ID'], $campaignTarget['target'], $campaign['email_interact2_state']);
			}
		}
		header('Location: ' . $campaign['email_interact2_url']);
	
    
  }

  public static function sendMail($id) { 
    
    
    // --- BLOCK: main ---
    
/* Achtung! Weitere Code Duplication in Single */
$target = \FOP\Database::query('SELECT
	'.qi('campaignTarget').'.'.qi('ID').' AS '.qi('ID').',
	'.qi('campaignTarget').'.'.qi('target').' AS '.qi('target').',
	'.qi('campaignTarget').'.'.qi('state').',
	'.qi('campaignTarget').'.'.qi('campaign').',
	(SELECT ('.qi('pV9mqmMV').'.'.qi('email').') FROM '.qi('mitglied').' '.qi('pV9mqmMV').' WHERE '.qi('pV9mqmMV').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1) AS '.qi('campaignTargetEmail').',
	email_text AS '.qi('campaignEmailText').',
	email_subject AS '.qi('campaignEmailSubject').',
	email_interact1_title,
	email_interact2_title,
	email_reply AS '.qi('replyTo').'
FROM '.qi('campaignTarget').', '.qi('campaign').' WHERE '.qi('campaign').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' AND '.qi('campaignTarget').'.'.qi('ID').' = ' . intval($id))->fetch(\PDO::FETCH_ASSOC);

$mail = \Mailer\Mails::getMailer();
if ($target['replyTo']) {
	$mail->AddReplyTo($target['replyTo']);
}

if (!$target['campaignTargetEmail']) return;
$mail->addAddress($target['campaignTargetEmail']);


$mail->Subject = $target['campaignEmailSubject'];
$html = \Tables\Mitglied::applyTemplate($target['target'], $target['campaignEmailText']);
$html = \FOP\Util::SanitizeUserHtml($html, false, [
	'interaction1' => '<span><a href="'.htmlentities(\TablesRouter\CampaignTarget::interaction1URL(openssl_encrypt('target-'.$id, 'aes-128-ctr', \Types\Password::getEncryptKey()))).'">'.htmlentities($target['email_interact1_title']).'</a></span>',
	'interaction2' => '<span><a href="'.htmlentities(\TablesRouter\CampaignTarget::interaction2URL(openssl_encrypt('target-'.$id, 'aes-128-ctr', \Types\Password::getEncryptKey()))).'">'.htmlentities($target['email_interact2_title']).'</a></span>',
]);
$mail->msgHTML($html);
// Anhänge
\FOP\Files::attachFileToMail(\FOP\Database::query('SELECT '.qi('file').' FROM '.qi('campaignAttachment').' WHERE '.qi('campaign').' = ' . intval($target['campaign']))->fetchAll(\PDO::FETCH_COLUMN), $mail);

$mail->Timeout = 15; // tight timeout
if ($mail->send()) {
	\FOP\Database::query('UPDATE '.qi('campaignTarget').' SET '.qi('state').' = COALESCE((SELECT '.qi('campaignState').'.'.qi('aftercontact').' FROM '.qi('campaignState').' WHERE '.qi('ID').' = '.qi('campaignTarget').'.'.qi('state').'), '.qi('state').') WHERE '.qi('ID').' = '.intval($id));
} else {
	// sonst: nix
}

    
  }

  public static function massMailSendAction($idlist) { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && (!\FOP\User::getIsGuest()))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access-itemlist-campaignTarget-is_mail ---
    
		// ID-Liste neu aufbauen und nur die übrig lassen, die auch erlaubt sind
		$idlist_ = new \FOP\IDList($idlist);
		$idlist = new \FOP\IDList();
		foreach (\FOP\Database::query('SELECT '.qi('ID').' FROM '.qi('campaignTarget').' WHERE ('.(\FOP\User::getIsGuest() ? 'false' : 'true').') AND ' . $idlist_->toSQL(qi('ID')))->fetchAll(\PDO::FETCH_COLUMN) AS $idlist_sub) {
			$idlist->push($idlist_sub);
		}
	
    // --- BLOCK: access-itemlist-campaignTarget-view ---
    
		// ID-Liste neu aufbauen und nur die übrig lassen, die auch erlaubt sind
		$idlist_ = new \FOP\IDList($idlist);
		$idlist = new \FOP\IDList();
		foreach (\FOP\Database::query('SELECT '.qi('ID').' FROM '.qi('campaignTarget').' WHERE (('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('dHL279iX').' WHERE '.qi('dHL279iX').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('fbT2x3zb').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('fbT2x3zb').' WHERE '.qi('fbT2x3zb').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PmLIw5tN').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PmLIw5tN').'.'.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('PmLIw5tN').' WHERE '.qi('PmLIw5tN').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Ffzcl8KY').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Ffzcl8KY').' WHERE '.qi('Ffzcl8KY').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) AND ' . $idlist_->toSQL(qi('ID')))->fetchAll(\PDO::FETCH_COLUMN) AS $idlist_sub) {
			$idlist->push($idlist_sub);
		}
	
    // --- BLOCK: main ---
    
$idlist = new \FOP\IDList($idlist);


$send_at = time();
foreach ($idlist->all() as $id) {
	self::sendMailDelayed($id, $send_at);
	if (!isset($delay)) {
		$delay = \FOP\Database::query('SELECT email_delay FROM '.qi('campaign').' WHERE '.qi('ID').' = (SELECT campaign FROM '.qi('campaignTarget').' WHERE '.qi('ID').' = '.intval($id).')')->fetchColumn();
	}
	$send_at += $delay;
	$lastid = $id;
}

header('Location: ' . \TablesRouter\Campaign::viewURL(\FOP\Database::query('SELECT '.qi('campaign').' FROM '.qi('campaignTarget').' WHERE '.qi('ID').' = ' . intval($lastid))->fetchColumn()) . '#snack:' . _('campaignMassMailSnackSent'));
die();

    
  }

  public static function stateEditAction($id) { 
    
    
    // --- BLOCK: access ---
    if(!((!\FOP\User::getIsGuest()) && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access-item-campaignTarget-edit ---
    
		if (\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('vOljclgU').' WHERE '.qi('vOljclgU').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('XXDtdS61').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('XXDtdS61').' WHERE '.qi('XXDtdS61').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('YOWPvw9s').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('YOWPvw9s').'.'.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('YOWPvw9s').' WHERE '.qi('YOWPvw9s').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Z2wISAZD').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Z2wISAZD').' WHERE '.qi('Z2wISAZD').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) FROM '.qi('campaignTarget').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: main ---
    
		// abgespecktes CardForm
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			\Types\CampaignState::validate($_POST['value']);

			$_POST['value'] = \FOP\Sanitizers::null_filter($_POST['value']);

			self::edit($id, ['state' => $_POST['value']]);
			echo 'OK';
		} else {
			$frameid = 'temp_'.time();
			$data = self::view($id, false, true);
			?><form style="display: block; margin: 0px; padding: 0px;" method="POST" action="<?php echo \TablesRouter\CampaignTarget::stateEditURL($id); ?>" target="<?php echo $frameid; ?>" enctype="multipart/form-data"><div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\CampaignState::renderEditcampaignTarget_state_singleAction($data['state'], [], '');
?> &nbsp;	<?php if (\TablesRouter\CampaignState::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\CampaignState::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=campaignState%26colinsert=value%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\CampaignState::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=campaignState%26colinsert=value%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=campaignState", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div></form><iframe name="<?php echo $frameid; ?>" style="display: none;"></iframe><?php
		}
	
    
  }

  public static function noteEditAction($id) { 
    
    
    // --- BLOCK: access ---
    if(!((!\FOP\User::getIsGuest()) && ((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access-item-campaignTarget-edit ---
    
		if (\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('vOljclgU').' WHERE '.qi('vOljclgU').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('XXDtdS61').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('XXDtdS61').' WHERE '.qi('XXDtdS61').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('YOWPvw9s').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('YOWPvw9s').'.'.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('YOWPvw9s').' WHERE '.qi('YOWPvw9s').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Z2wISAZD').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Z2wISAZD').' WHERE '.qi('Z2wISAZD').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) FROM '.qi('campaignTarget').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: main ---
    
		// abgespecktes CardForm
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			

			

			self::edit($id, ['note' => $_POST['value']]);
			echo 'OK';
		} else {
			$frameid = 'temp_'.time();
			$data = self::view($id, false, true);
			?><form style="display: block; margin: 0px; padding: 0px;" method="POST" action="<?php echo \TablesRouter\CampaignTarget::noteEditURL($id); ?>" target="<?php echo $frameid; ?>" enctype="multipart/form-data"><div style="width: 100%;" class="mdl-textfield mdl-js-textfield"><textarea onkeydown='if (event.keyCode == 13 && event.ctrlKey) { event.preventDefault(); event.stopPropagation(); tabNext(this); return false; }' class="mdl-textfield__input" rows="8" cols="80" name="value" id="value" ><?php echo htmlentities($data['note']); ?></textarea><label class="mdl-textfield__label" for="value"><?php echo(_('text')); ?></label><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div></form><iframe name="<?php echo $frameid; ?>" style="display: none;"></iframe><?php
		}
	
    
  }

  public static function loadMultiaddFop_listItems($id) { 
    
    
    // --- BLOCK: main ---
    
		/* TODO: SQL Query bauen mit SQLQuery-Fakten */
		$items =
		\FOP\Database::query('SELECT '.qi('campaignTarget').'.'.qi('ID').' AS '.qi('ID').', '.qi('campaignTarget').'.'.qi('campaign').', '.qi('campaignTarget').'.'.qi('target').', '.qi('campaignTarget').'.'.qi('state').', '.qi('campaignTarget').'.'.qi('note').', '.qi('campaignTarget').'.'.qi('creation').', '.qi('campaignTarget').'.'.qi('lastUpdate').',
			(('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('hKxqI7xl').' WHERE '.qi('hKxqI7xl').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('qnAG6U6I').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('qnAG6U6I').' WHERE '.qi('qnAG6U6I').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('MQUST27S').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('MQUST27S').'.'.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('MQUST27S').' WHERE '.qi('MQUST27S').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('UZUFh6Y1').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('UZUFh6Y1').' WHERE '.qi('UZUFh6Y1').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) AS '.qi('canDelete').'
			FROM '.qi('campaignTarget').' 
			WHERE (('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('vOljclgU').' WHERE '.qi('vOljclgU').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('XXDtdS61').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('XXDtdS61').' WHERE '.qi('XXDtdS61').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('YOWPvw9s').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('YOWPvw9s').'.'.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('YOWPvw9s').' WHERE '.qi('YOWPvw9s').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Z2wISAZD').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Z2wISAZD').' WHERE '.qi('Z2wISAZD').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)))')->fetchAll(\PDO::FETCH_ASSOC);

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

  public static function loadMultistatusFop_listItems($id) { 
    
    
    // --- BLOCK: main ---
    
		/* TODO: SQL Query bauen mit SQLQuery-Fakten */
		$items =
		\FOP\Database::query('SELECT '.qi('campaignTarget').'.'.qi('ID').' AS '.qi('ID').', '.qi('campaignTarget').'.'.qi('campaign').', '.qi('campaignTarget').'.'.qi('target').', '.qi('campaignTarget').'.'.qi('state').', '.qi('campaignTarget').'.'.qi('note').', '.qi('campaignTarget').'.'.qi('creation').', '.qi('campaignTarget').'.'.qi('lastUpdate').',
			(('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('hKxqI7xl').' WHERE '.qi('hKxqI7xl').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('qnAG6U6I').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('qnAG6U6I').' WHERE '.qi('qnAG6U6I').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('MQUST27S').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('MQUST27S').'.'.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('MQUST27S').' WHERE '.qi('MQUST27S').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('UZUFh6Y1').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('UZUFh6Y1').' WHERE '.qi('UZUFh6Y1').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) AS '.qi('canDelete').'
			FROM '.qi('campaignTarget').' 
			WHERE (('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('vOljclgU').' WHERE '.qi('vOljclgU').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('XXDtdS61').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('XXDtdS61').' WHERE '.qi('XXDtdS61').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('YOWPvw9s').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('YOWPvw9s').'.'.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('YOWPvw9s').' WHERE '.qi('YOWPvw9s').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Z2wISAZD').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Z2wISAZD').' WHERE '.qi('Z2wISAZD').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) AND (' . (new \FOP\IDList($id))->toSQL(qi('campaignTarget').'.'.qi('ID')) . ')')->fetchAll(\PDO::FETCH_ASSOC);

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

  public static function loadMultistatus2Fop_listItems($id) { 
    
    
    // --- BLOCK: main ---
    
		/* TODO: SQL Query bauen mit SQLQuery-Fakten */
		$items =
		\FOP\Database::query('SELECT '.qi('campaignTarget').'.'.qi('ID').' AS '.qi('ID').', '.qi('campaignTarget').'.'.qi('campaign').', '.qi('campaignTarget').'.'.qi('target').', '.qi('campaignTarget').'.'.qi('state').', '.qi('campaignTarget').'.'.qi('note').', '.qi('campaignTarget').'.'.qi('creation').', '.qi('campaignTarget').'.'.qi('lastUpdate').',
			(('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('hKxqI7xl').' WHERE '.qi('hKxqI7xl').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('qnAG6U6I').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('qnAG6U6I').' WHERE '.qi('qnAG6U6I').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('MQUST27S').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('MQUST27S').'.'.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('MQUST27S').' WHERE '.qi('MQUST27S').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('UZUFh6Y1').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('UZUFh6Y1').' WHERE '.qi('UZUFh6Y1').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) AS '.qi('canDelete').'
			FROM '.qi('campaignTarget').' 
			WHERE (('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('vOljclgU').' WHERE '.qi('vOljclgU').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('XXDtdS61').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('XXDtdS61').' WHERE '.qi('XXDtdS61').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('YOWPvw9s').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('YOWPvw9s').'.'.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('YOWPvw9s').' WHERE '.qi('YOWPvw9s').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Z2wISAZD').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Z2wISAZD').' WHERE '.qi('Z2wISAZD').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) AND (' . (new \FOP\IDList($id))->toSQL(qi('campaignTarget').'.'.qi('ID')) . ')')->fetchAll(\PDO::FETCH_ASSOC);

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

  public static function pdfZipAction($ids) { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access-itemlist-campaignTarget-view ---
    
		// ID-Liste neu aufbauen und nur die übrig lassen, die auch erlaubt sind
		$ids_ = new \FOP\IDList($ids);
		$ids = new \FOP\IDList();
		foreach (\FOP\Database::query('SELECT '.qi('ID').' FROM '.qi('campaignTarget').' WHERE (('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('dHL279iX').' WHERE '.qi('dHL279iX').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('fbT2x3zb').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('fbT2x3zb').' WHERE '.qi('fbT2x3zb').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PmLIw5tN').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PmLIw5tN').'.'.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('PmLIw5tN').' WHERE '.qi('PmLIw5tN').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Ffzcl8KY').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Ffzcl8KY').' WHERE '.qi('Ffzcl8KY').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) AND ' . $ids_->toSQL(qi('ID')))->fetchAll(\PDO::FETCH_COLUMN) AS $ids_sub) {
			$ids->push($ids_sub);
		}
	
    // --- BLOCK: main ---
    
		$ids = new \FOP\IDList($ids);
		$zip = new \ZipArchive;
		$zipfilename = tempnam(sys_get_temp_dir(), 'fop-zip');
		$zip->open($zipfilename, \ZipArchive::CREATE);
		ini_set('memory_limit', '-1'); // wegen Bugs

		foreach($ids->all() AS $id) {
		\Tables\CampaignTarget::pdfAction($id, $zip);
		}
		$zip->close();

		header('Content-Type: application/zip');
		header('Content-Disposition: attachment; filename="pdfs.zip"');
		readfile($zipfilename);
		unlink($zipfilename);
		die();
	
    
  }

  public static function cloneCampaign($old_id, $id) { 
    
    
    // --- BLOCK: main ---
    
		$q = \FOP\Database::query('SELECT '.qi('ID').' AS '.qi('ID').' FROM '.qi('campaignTarget').' WHERE '.qi('campaignTarget').'.'.qi('campaign').' = ' . \FOP\Database::quote($old_id));
		while ($oldsubid = $q->fetch(\PDO::FETCH_COLUMN)) {
			\FOP\Database::query('INSERT INTO '.qi('campaignTarget').' ('.qi('lastUpdate').', '.qi('note').', '.qi('target').', '.qi('campaign').', '.qi('state').', '.qi('creation').') SELECT '.qi('lastUpdate').', '.qi('note').', '.qi('target').', ' . \FOP\Database::quote($id) . ', '.qi('state').', '.qi('creation').' FROM '.qi('campaignTarget').' fop_old_t WHERE fop_old_t.'.qi('ID').' = ' . \FOP\Database::quote($oldsubid));
			$newsubid = \FOP\Database::getLastInsertId();
			(function ($old_id, $id) {
				if (isset($_POST['child_state'])) {
	\FOP\Database::query('UPDATE '.qi('campaignTarget').' SET '.qi('state').' = '.\FOP\Database::quote($_POST['child_state']).' WHERE '.qi('ID').' = ' . intval($id));
}
			})($oldsubid, $newsubid);
		}
	
    
  }

  public static function delete($id, $disregardPermissions = false ) { 
    
    
    // --- BLOCK: main ---
    
			$sql = 'SELECT ' . ($disregardPermissions ? 1 : '('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('hKxqI7xl').' WHERE '.qi('hKxqI7xl').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('qnAG6U6I').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('qnAG6U6I').' WHERE '.qi('qnAG6U6I').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('MQUST27S').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('MQUST27S').'.'.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('MQUST27S').' WHERE '.qi('MQUST27S').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('UZUFh6Y1').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('UZUFh6Y1').' WHERE '.qi('UZUFh6Y1').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))') . ' FROM '.qi('campaignTarget').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id);
			if (\FOP\Database::query($sql)->fetchColumn() != 1) {
				return false;
			}
			
			$sql = 'DELETE FROM  '.qi('campaignTarget').'  WHERE '.qi('ID').' = ' . \FOP\Database::quote($id);
			$result = \FOP\Database::query($sql);
			
			return true;
	
    
  }

  public static function multiaddListFop_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\CampaignTarget::getDefaults();
			$row['ID'] = '';
			$row['canDelete'] = true;
			\Tables\CampaignTarget::sanitizeDefaults($row, true, 'campaignTarget', $parentrow);
		} else {
			
			$row['state'] = \FOP\Sanitizers::null_converter($row['state']);
			$row['target'] = \FOP\Sanitizers::null_converter($row['target']);			
			$row['canDelete'] = $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']); ?>'>
							<input type='hidden' name='fop_list_target[]' value='<?php echo htmlentities($row['target']); ?>'>
						</div>
					</td><?php
        // Unterscheidung Create/Edit
        if ($row['ID'] ? true : true) {
        	?><!-- Spalte "Ziel": target
			--><td class='mdl-data-table__cell--non-numeric'><span><?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($row['target']);
	$mitglied_result = \FOP\Database::query($sql);
	if ($mitglied_row = $mitglied_result->fetch(\PDO::FETCH_ASSOC)) {
		echo htmlentities($mitglied_row['description']);if ($mitglied_row['canView']) echo "<a tabindex=\"-1\" class=\"mdl-button mdl-button-small tbl-link\" data-tbl=\"mitglied\" data-id=\"".htmlentities($mitglied_row['ID'])."\" onclick=\"event.preventDefault(); open_url(this.href, true);\" href=\"" . \TablesRouter\Mitglied::viewURL($row['target'], ['from' => 'jscloser.php?action=popup']) . "\">(…)</a>";
	} else {
		echo htmlentities(_('') ?: '-');
	}
	
?>
</span>
			</td><?php } else if (/* Create aber nicht edit: leere Zelle
			*/true || true) { ?><td>&nbsp;</td><?php } ?><?php
        // Unterscheidung Create/Edit
        if ($row['ID'] ? (!\FOP\User::getIsGuest()) : true) {
        	?><!-- Spalte "Status": state
			--><td class='mdl-data-table__cell--non-numeric'><span><div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\CampaignState::renderEditformarray_wf_campaignTarget_multiadd_fop_list_stateAction($row['state'], [], '');
?> &nbsp;	<?php if (\TablesRouter\CampaignState::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\CampaignState::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=campaignState%26colinsert=fop_list_state[]%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\CampaignState::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=campaignState%26colinsert=fop_list_state[]%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=campaignState", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div></span>
			</td><?php } else if (/* Create aber nicht edit: leere Zelle
			*/true || !\FOP\User::getIsGuest()) { ?><td>&nbsp;</td><?php } ?><?php
        // Unterscheidung Create/Edit
        if ($row['ID'] ? (!\FOP\User::getIsGuest()) : true) {
        	?><!-- Spalte "Notiz": note
			--><td class='mdl-data-table__cell--non-numeric'><span><div style="width: 100%;" class="mdl-textfield mdl-js-textfield"><textarea onkeydown='if (event.keyCode == 13 && event.ctrlKey) { event.preventDefault(); event.stopPropagation(); tabNext(this); return false; }' class="mdl-textfield__input" rows="8" cols="80" name="fop_list_note[]" id="fop_list_note[]" ><?php echo htmlentities($row['note']); ?></textarea><label class="mdl-textfield__label" for="fop_list_note[]"><?php echo(_('text')); ?></label><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div></span>
			</td><?php } else if (/* Create aber nicht edit: leere Zelle
			*/true || !\FOP\User::getIsGuest()) { ?><td>&nbsp;</td><?php } ?></tr><?php
	
    
  }

  public static function multistatusListFop_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\CampaignTarget::getDefaults();
			$row['ID'] = '';
			$row['canDelete'] = true;
			\Tables\CampaignTarget::sanitizeDefaults($row, true, 'campaignTarget', $parentrow);
		} else {
			
			$row['state'] = \FOP\Sanitizers::null_converter($row['state']);
			$row['target'] = \FOP\Sanitizers::null_converter($row['target']);			
			$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 "Ziel": target
			--><td class='mdl-data-table__cell--non-numeric'><span><?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($row['target']);
	$mitglied_result = \FOP\Database::query($sql);
	if ($mitglied_row = $mitglied_result->fetch(\PDO::FETCH_ASSOC)) {
		echo htmlentities($mitglied_row['description']);if ($mitglied_row['canView']) echo "<a tabindex=\"-1\" class=\"mdl-button mdl-button-small tbl-link\" data-tbl=\"mitglied\" data-id=\"".htmlentities($mitglied_row['ID'])."\" onclick=\"event.preventDefault(); open_url(this.href, true);\" href=\"" . \TablesRouter\Mitglied::viewURL($row['target'], ['from' => 'jscloser.php?action=popup']) . "\">(…)</a>";
	} else {
		echo htmlentities(_('') ?: '-');
	}
	
?>
</span>
			</td><?php } else if (/* Create aber nicht edit: leere Zelle
			*/true || true) { ?><td>&nbsp;</td><?php } ?><?php
        // Unterscheidung Create/Edit
        if ($row['ID'] ? (!\FOP\User::getIsGuest()) : true) {
        	?><!-- Spalte "Status": state
			--><td class='mdl-data-table__cell--non-numeric'><span><div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\CampaignState::renderEditformarray_wf_campaignTarget_multistatus_fop_list_stateAction($row['state'], [], '');
?> &nbsp;	<?php if (\TablesRouter\CampaignState::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\CampaignState::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=campaignState%26colinsert=fop_list_state[]%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\CampaignState::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26type=campaignState%26colinsert=fop_list_state[]%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=campaignState", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div></span>
			</td><?php } else if (/* Create aber nicht edit: leere Zelle
			*/true || !\FOP\User::getIsGuest()) { ?><td>&nbsp;</td><?php } ?><?php
        // Unterscheidung Create/Edit
        if ($row['ID'] ? (!\FOP\User::getIsGuest()) : true) {
        	?><!-- Spalte "Notiz": note
			--><td class='mdl-data-table__cell--non-numeric'><span><div style="width: 100%;" class="mdl-textfield mdl-js-textfield"><textarea onkeydown='if (event.keyCode == 13 && event.ctrlKey) { event.preventDefault(); event.stopPropagation(); tabNext(this); return false; }' class="mdl-textfield__input" rows="8" cols="80" name="fop_list_note[]" id="fop_list_note[]" ><?php echo htmlentities($row['note']); ?></textarea><label class="mdl-textfield__label" for="fop_list_note[]"><?php echo(_('text')); ?></label><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div></span>
			</td><?php } else if (/* Create aber nicht edit: leere Zelle
			*/true || !\FOP\User::getIsGuest()) { ?><td>&nbsp;</td><?php } ?></tr><?php
	
    
  }

  public static function multistatus2ListFop_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\CampaignTarget::getDefaults();
			$row['ID'] = '';
			$row['canDelete'] = true;
			\Tables\CampaignTarget::sanitizeDefaults($row, true, 'campaignTarget', $parentrow);
		} else {
			
			$row['target'] = \FOP\Sanitizers::null_converter($row['target']);			
			$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 "Ziel": target
			--><td class='mdl-data-table__cell--non-numeric'><span><?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($row['target']);
	$mitglied_result = \FOP\Database::query($sql);
	if ($mitglied_row = $mitglied_result->fetch(\PDO::FETCH_ASSOC)) {
		echo htmlentities($mitglied_row['description']);if ($mitglied_row['canView']) echo "<a tabindex=\"-1\" class=\"mdl-button mdl-button-small tbl-link\" data-tbl=\"mitglied\" data-id=\"".htmlentities($mitglied_row['ID'])."\" onclick=\"event.preventDefault(); open_url(this.href, true);\" href=\"" . \TablesRouter\Mitglied::viewURL($row['target'], ['from' => 'jscloser.php?action=popup']) . "\">(…)</a>";
	} else {
		echo htmlentities(_('') ?: '-');
	}
	
?>
</span>
			</td><?php } else if (/* Create aber nicht edit: leere Zelle
			*/true || true) { ?><td>&nbsp;</td><?php } ?><?php
        // Unterscheidung Create/Edit
        if ($row['ID'] ? (!\FOP\User::getIsGuest()) : true) {
        	?><!-- Spalte "Notiz": note
			--><td class='mdl-data-table__cell--non-numeric'><span><div style="width: 100%;" class="mdl-textfield mdl-js-textfield"><textarea onkeydown='if (event.keyCode == 13 && event.ctrlKey) { event.preventDefault(); event.stopPropagation(); tabNext(this); return false; }' class="mdl-textfield__input" rows="8" cols="80" name="fop_list_note[]" id="fop_list_note[]" ><?php echo htmlentities($row['note']); ?></textarea><label class="mdl-textfield__label" for="fop_list_note[]"><?php echo(_('text')); ?></label><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div></span>
			</td><?php } else if (/* Create aber nicht edit: leere Zelle
			*/true || !\FOP\User::getIsGuest()) { ?><td>&nbsp;</td><?php } ?></tr><?php
	
    
  }

  public static function pdfAction($id, $attachTo = null ) { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access-item-campaignTarget-view ---
    
		if (\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('dHL279iX').' WHERE '.qi('dHL279iX').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('fbT2x3zb').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('fbT2x3zb').' WHERE '.qi('fbT2x3zb').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PmLIw5tN').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PmLIw5tN').'.'.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('PmLIw5tN').' WHERE '.qi('PmLIw5tN').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Ffzcl8KY').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Ffzcl8KY').' WHERE '.qi('Ffzcl8KY').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) FROM '.qi('campaignTarget').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: main ---
    self::pdf($id, $attachTo);
    
  }

  public static function create($data, $disregardPermissions = false , $updateOnDuplicate = false ) { 
    
    
    // --- BLOCK: main ---
    
				$sql = 'INSERT INTO '.qi('campaignTarget').'(';
				
				$set = [];
				
					
					$set[qi('campaign')] = \FOP\Database::quote($data['campaign']);
					
				
					if ($disregardPermissions || ((!\FOP\User::getIsGuest()))) {
					
					$set[qi('target')] = \FOP\Database::quote($data['target']);
					} else {
						$set[qi('target')] = \FOP\Database::quote(\FOP\Sanitizers::null_filter(null));
					}
				
					
					$set[qi('state')] = \FOP\Database::quote($data['state']);
					
				
					
					$set[qi('note')] = \FOP\Database::quote($data['note']);
					
				
					if ($disregardPermissions || (((false)))) {
					
					$set[qi('creation')] = \FOP\Database::quote($data['creation']);
					} else {
						$set[qi('creation')] = \FOP\Database::quote(\FOP\Sanitizers::convert_datetime_to_unix_timestamp(time()));
					}
				
					if ($disregardPermissions || (((false)))) {
					
					$set[qi('lastUpdate')] = \FOP\Database::quote($data['lastUpdate']);
					} else {
						$set[qi('lastUpdate')] = \FOP\Database::quote(\FOP\Sanitizers::convert_datetime_to_unix_timestamp(null));
					}
				
				$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 {
						$sql .= ' ON CONFLICT ('.qi('campaign').', '.qi('target').') UPDATE SET ' . implode(', ', $set2);
					}
				}

				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
				\FOP\ClassStaticMethodDelayed::worker(false);
				return $id;

    
  }

  public static function view($id, $snippet = false , $ignoreAccess = false ) { 
    
    
    // --- BLOCK: main ---
    
		$sql = 'SELECT /* ID */ '.qi('ID').' AS '.qi('ID').',
									/* ID */ '.qi('campaignTarget').'.'.qi('ID').' AS '.qi('ID').',
									/* campaign */ '.qi('campaignTarget').'.'.qi('campaign').' AS '.qi('campaign').',
									/* campaign::canView */ '.qi('ref:campaign').'.'.qi('campaign:canView').' AS '.qi('campaign::canView').',
									/* campaign::description */ '.qi('ref:campaign').'.'.qi('campaign:description').' AS '.qi('campaign::description').',
									/* creation */ '.qi('campaignTarget').'.'.qi('creation').' AS '.qi('creation').',
									/* creation::canEdit */ (FALSE) AS '.qi('creation::canEdit').',
									/* lastUpdate */ '.qi('campaignTarget').'.'.qi('lastUpdate').' AS '.qi('lastUpdate').',
									/* lastUpdate::canEdit */ (FALSE) AS '.qi('lastUpdate::canEdit').',
									/* note */ '.qi('campaignTarget').'.'.qi('note').' AS '.qi('note').',
									/* operation::create */ ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('CkHlp5PE').' WHERE '.qi('CkHlp5PE').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('gamUdXIr').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('gamUdXIr').' WHERE '.qi('gamUdXIr').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PW9rw6As').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PW9rw6As').'.'.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('PW9rw6As').' WHERE '.qi('PW9rw6As').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('CoxcrW6l').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('CoxcrW6l').' WHERE '.qi('CoxcrW6l').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AS '.qi('operation::create').',
									/* operation::delete */ ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('hKxqI7xl').' WHERE '.qi('hKxqI7xl').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('qnAG6U6I').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('qnAG6U6I').' WHERE '.qi('qnAG6U6I').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('MQUST27S').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('MQUST27S').'.'.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('MQUST27S').' WHERE '.qi('MQUST27S').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('UZUFh6Y1').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('UZUFh6Y1').' WHERE '.qi('UZUFh6Y1').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AS '.qi('operation::delete').',
									/* operation::edit */ ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('vOljclgU').' WHERE '.qi('vOljclgU').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('XXDtdS61').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('XXDtdS61').' WHERE '.qi('XXDtdS61').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('YOWPvw9s').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('YOWPvw9s').'.'.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('YOWPvw9s').' WHERE '.qi('YOWPvw9s').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Z2wISAZD').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Z2wISAZD').' WHERE '.qi('Z2wISAZD').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AS '.qi('operation::edit').',
									/* operation::index */ ' . (!\FOP\User::getIsGuest() ? 1 : 0) . ' AS '.qi('operation::index').',
									/* operation::is_mail */ '.(\FOP\User::getIsGuest() ? 'false' : 'true').' AS '.qi('operation::is_mail').',
									/* operation::view */ ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('dHL279iX').' WHERE '.qi('dHL279iX').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('fbT2x3zb').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('fbT2x3zb').' WHERE '.qi('fbT2x3zb').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PmLIw5tN').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PmLIw5tN').'.'.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('PmLIw5tN').' WHERE '.qi('PmLIw5tN').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Ffzcl8KY').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Ffzcl8KY').' WHERE '.qi('Ffzcl8KY').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AS '.qi('operation::view').',
									/* state */ '.qi('campaignTarget').'.'.qi('state').' AS '.qi('state').',
									/* state::canView */ '.qi('ref:state').'.'.qi('state:canView').' AS '.qi('state::canView').',
									/* state::description */ '.qi('ref:state').'.'.qi('state:description').' AS '.qi('state::description').',
									/* target */ '.qi('campaignTarget').'.'.qi('target').' AS '.qi('target').',
									/* target::canView */ '.qi('ref:target').'.'.qi('target:canView').' AS '.qi('target::canView').',
									/* target::description */ '.qi('ref:target').'.'.qi('target:description').' AS '.qi('target::description').',
									1
								FROM '.qi('campaignTarget').' '.qi('campaignTarget').'
								LEFT JOIN (SELECT '.qi('ID').' AS '.qi('campaign:ID').', '.qi('campaign').'.'.qi('name').' AS '.qi('campaign:description').', (('.\FOP\Database::quote(\FOP\User::getCampaign()).')) AS '.qi('campaign:canView').' FROM '.qi('campaign').') '.qi('ref:campaign').' ON '.qi('ref:campaign').'.'.qi('campaign:ID').' = '.qi('campaignTarget').'.'.qi('campaign').'
								LEFT JOIN (SELECT '.qi('ID').' AS '.qi('state:ID').', '.qi('campaignState').'.'.qi('desc').' AS '.qi('state:description').', (('.\FOP\Database::quote(\FOP\User::getCampaign()).')) AS '.qi('state:canView').' FROM '.qi('campaignState').') '.qi('ref:state').' ON '.qi('ref:state').'.'.qi('state:ID').' = '.qi('campaignTarget').'.'.qi('state').'
								LEFT JOIN (SELECT '.qi('ID').' AS '.qi('target:ID').', CONCAT('.qi('mitglied').'.'.qi('vorname').', \' \', '.qi('mitglied').'.'.qi('name').') AS '.qi('target: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('target:canView').' FROM '.qi('mitglied').') '.qi('ref:target').' ON '.qi('ref:target').'.'.qi('target:ID').' = '.qi('campaignTarget').'.'.qi('target').'
								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['campaign'] = \FOP\Sanitizers::null_converter($row['campaign']);
		$row['target'] = \FOP\Sanitizers::null_converter($row['target']);
		$row['state'] = \FOP\Sanitizers::null_converter($row['state']);
		$row['creation'] = intval($row['creation']);
		$row['lastUpdate'] = intval($row['lastUpdate']);
		

		if($snippet){
			$row['campaign'] = (
  \FOP\Database::query('SELECT '.qi('campaign').'.'.qi('name').' AS description FROM '.qi('campaign').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($row['campaign']))->fetchColumn() ?: _('')
);
			$row['target'] = (
  \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['target']))->fetchColumn() ?: _('')
);
			$row['state'] = (
  \FOP\Database::query('SELECT '.qi('campaignState').'.'.qi('desc').' AS description FROM '.qi('campaignState').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($row['state']))->fetchColumn() ?: _('')
);
			$row['note'] = ($row['note']);
			$row['creation'] = (($row['creation']) ? strftime(_('datetimeformat_php2'), intval($row['creation'])) : '');
			$row['lastUpdate'] = (($row['lastUpdate']) ? strftime(_('datetimeformat_php2'), intval($row['lastUpdate'])) : '');
			
		}


		return $row;

    
  }

  public static function campaigntargetUniqueAction($context, $value, $id) { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && (!\FOP\User::getIsGuest()))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: main ---
    
		$count = \FOP\Database::query('SELECT COUNT(*) FROM '.qi('campaignTarget').' WHERE '.qi('campaign').' = ' . \FOP\Database::quote($context) . ' AND '.qi('target').' = ' . \FOP\Database::quote($value) . ' AND '.qi('ID').' <> ' . \FOP\Database::quote($id))->fetchColumn();
		return !$count;
	
    
  }

  public static function sanitizeDefaults(&$data, $sanitizeForForms, $refcol = null , $parentdata = null ) { 
    
    
    // --- BLOCK: main ---
    
		$virginData = self::getDefaults();
		// column: campaign
			if (!$data['campaign']) {
				// replace forbidden NULL values
				$items = \Types\Campaign::getItems([], null);
				$best = -INF;
				foreach ($items as $item) /* TODO: InputFieldLoadCondition: if (!$condition || $item[$condition]) */ {
					if ($item['priority'] > $best) {
						$data['campaign'] = $item['ID'];
						$best = $item['priority'];
					}
				}
			}
		
		// column: creation
		
		// column: lastUpdate
		
		// column: note
		
		// column: state
			if (!$data['state']) {
				// replace forbidden NULL values
				$items = \Types\CampaignState::getItems([], null);
				$best = -INF;
				foreach ($items as $item) /* TODO: InputFieldLoadCondition: if (!$condition || $item[$condition]) */ {
					if ($item['priority'] > $best) {
						$data['state'] = $item['ID'];
						$best = $item['priority'];
					}
				}
			}
		
		// column: target
			if (!$data['target']) {
				// replace forbidden NULL values
				$items = \Types\Mitglied::getItems([], null);
				$best = -INF;
				foreach ($items as $item) /* TODO: InputFieldLoadCondition: if (!$condition || $item[$condition]) */ {
					if ($item['priority'] > $best) {
						$data['target'] = $item['ID'];
						$best = $item['priority'];
					}
				}
			}
		
		if ($sanitizeForForms) {
			
			$data['campaign'] = \FOP\Sanitizers::null_converter($data['campaign']);
			$data['target'] = \FOP\Sanitizers::null_converter($data['target']);
			$data['state'] = \FOP\Sanitizers::null_converter($data['state']);
			$data['creation'] = intval($data['creation']);
			$data['lastUpdate'] = intval($data['lastUpdate']);
		}
	
    
  }

  public static function edit($id, $data, $ignoreUniqueConstraints = false , $disregardPermissions = false ) { 
    
    
    // --- BLOCK: main ---
    
				
				$set = [];
				
					
					if (array_key_exists('campaign', $data)) {
						array_push($set, qi('campaign').' = ' . \FOP\Database::quote($data['campaign']));
					}
				
					
					if (array_key_exists('target', $data)) {
						array_push($set, qi('target').' = ' . \FOP\Database::quote($data['target']));
					}
				
					if ($disregardPermissions || (!\FOP\User::getIsGuest()))
					
					if (array_key_exists('state', $data)) {
						array_push($set, qi('state').' = ' . \FOP\Database::quote($data['state']));
					}
				
					if ($disregardPermissions || (!\FOP\User::getIsGuest()))
					
					if (array_key_exists('note', $data)) {
						array_push($set, qi('note').' = ' . \FOP\Database::quote($data['note']));
					}
				
					if ($disregardPermissions || ((false)))
					
					if (array_key_exists('creation', $data)) {
						array_push($set, qi('creation').' = ' . \FOP\Database::quote($data['creation']));
					}
				
					if ($disregardPermissions || ((false)))
					
					if (array_key_exists('lastUpdate', $data)) {
						array_push($set, qi('lastUpdate').' = ' . \FOP\Database::quote($data['lastUpdate']));
					}
				;
				
				if (count($set)) {
					try {
						\FOP\Database::query('UPDATE '.qi('campaignTarget').' 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
				\FOP\ClassStaticMethodDelayed::worker(false);
				return true;

    
  }

  public static function pdfMultiPdfAction($ids, $attachTo = null ) { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access-itemlist-campaignTarget-view ---
    
		// ID-Liste neu aufbauen und nur die übrig lassen, die auch erlaubt sind
		$ids_ = new \FOP\IDList($ids);
		$ids = new \FOP\IDList();
		foreach (\FOP\Database::query('SELECT '.qi('ID').' FROM '.qi('campaignTarget').' WHERE (('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('dHL279iX').' WHERE '.qi('dHL279iX').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('fbT2x3zb').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('fbT2x3zb').' WHERE '.qi('fbT2x3zb').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('PmLIw5tN').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('PmLIw5tN').'.'.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('PmLIw5tN').' WHERE '.qi('PmLIw5tN').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('Ffzcl8KY').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('Ffzcl8KY').' WHERE '.qi('Ffzcl8KY').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) AND ' . $ids_->toSQL(qi('ID')))->fetchAll(\PDO::FETCH_COLUMN) AS $ids_sub) {
			$ids->push($ids_sub);
		}
	
    // --- BLOCK: main-1 ---
    
		$ids = new \FOP\IDList($ids);
		
    // --- BLOCK: main-1-getImage ---
    
	$getImage = function ($file) {
		return htmlentities(\FOP\Files::getPDFURL($file));
	};
    // --- BLOCK: main-2 ---
    


	$mpdfconf = [
		'tempDir' => sys_get_temp_dir() . '/mpdf',
		'setAutoTopMargin' => 'stretch',
		'setAutoBottomMargin' => 'stretch'];

	ini_set('memory_limit', '-1');
	ini_set('pcre.backtrack_limit', '10000000');
	$mpdf = new \Mpdf\Mpdf($mpdfconf);
	$mpdf->use_kwt = true;
		
	$flush = function ($mode = null) use ($mpdf) {
		$html = mb_convert_encoding(ob_get_contents(), 'UTF-8', 'UTF-8');
		if($html) {
			switch ($mode) {
				case 'body': $mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY); break;
				case 'start': $mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY, true, false); break;
				case 'middle': $mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY, false, false); break;
				case 'end': $mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY, false, true); break;
				case 'style': $mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HEADER_CSS); break;
				case 'footer': $mpdf->DefHTMLFooterByName('footer', $html); break;
				case 'header': $mpdf->DefHTMLHeaderByName('header', $html); break;
				case 'headerFirst': $mpdf->DefHTMLHeaderByName('headerFirst', $html); break;
				default: $mpdf->WriteHTML($html);
			}
		}
		ob_clean();
	};
	
	ob_start();
	
    // --- BLOCK: main-2-style ---
    
	?>
	body, html, div, p, table { font-family: sans-serif; }
	
	/* pdf styles */
	<?php $flush('style'); 
    // --- BLOCK: main-4 ---
    ?>
		<?php
		foreach($ids->all() AS $id) {
			\Tables\CampaignTarget::pdfAction($id, $mpdf);
		}
	?>
	<?php $flush('body');
	
    // --- BLOCK: main-100 ---
    
	$filename = 'all.pdf';
	$filename = preg_replace('/[~"#%&\*:<>\?\/\\\{|\}]/', '_', $filename); // sanitize
    // --- BLOCK: main-120 ---
    
	ob_end_clean();
	if (!$attachTo) {
		$mpdf->Output($filename, \Mpdf\Output\Destination::INLINE);
	} else if ($attachTo instanceof \PHPMailer\PHPMailer\PHPMailer) {
		$attachTo->AddStringAttachment($mpdf->Output('', \Mpdf\Output\Destination::STRING_RETURN), $filename);
	} else if ($attachTo instanceof \Mpdf\Mpdf) {
		
	$tmp = tempnam(sys_get_temp_dir(), 'fop-pdf');
	$mpdf->Output($tmp, \Mpdf\Output\Destination::FILE);
	$pagecount = $attachTo->SetSourceFile($tmp);
	for ($i = 1; $i <= $pagecount; $i++) {
		$tplId = $attachTo->importPage($i);
		$attachTo->AddPage();
		$attachTo->UseTemplate($tplId);
	}
	unlink($tmp);
	} else if ($attachTo instanceof \ZipArchive) {
		$attachTo->addFromString($filename, $mpdf->Output('', \Mpdf\Output\Destination::STRING_RETURN));
	} else if ($attachTo === 'string') {
		return \Mpdf\Output\Destination::STRING_RETURN;
	} else if ($attachTo === 'file') {
		
		$tmp = tempnam(sys_get_temp_dir(), 'fop-pdf');
		$mpdf->Output($tmp, \Mpdf\Output\Destination::FILE);
		return \FOP\Files::uploadFromFile($tmp, $filename);
	} else {
		throw new \FOP\AccessDeniedException('unknown attachment object');
	}
	
    
  }

  public static function pdf($id, $attachTo = null ) { 
    
    
    // --- BLOCK: main-1 ---
    
		 $data = \FOP\Database::query('SELECT *,
		 	(SELECT (CONCAT('.qi('Z2xXMAwr').'.'.qi('vorname').', \' \', '.qi('Z2xXMAwr').'.'.qi('name').', \'
\', '.qi('Z2xXMAwr').'.'.qi('strasse').', \'
\', '.qi('Z2xXMAwr').'.'.qi('plz').', \' \', '.qi('Z2xXMAwr').'.'.qi('ort').')) FROM '.qi('mitglied').' '.qi('Z2xXMAwr').' WHERE '.qi('Z2xXMAwr').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1) AS recAddress,
			NULL AS '.qi('context').'
			FROM '.qi('campaignTarget').' WHERE ID = ' . intval($id))->fetch(\PDO::FETCH_ASSOC);
		 $campaign = \Tables\Campaign::view($data['campaign'], false, true);
		 $stammdaten = \Configuration\Stammdaten::getStammdaten($data['context']);
	
    // --- BLOCK: main-1-getImage ---
    
	$getImage = function ($file) {
		return htmlentities(\FOP\Files::getPDFURL($file));
	};
    // --- BLOCK: main-2 ---
    


	$mpdfconf = [
		'tempDir' => sys_get_temp_dir() . '/mpdf',
		'setAutoTopMargin' => 'stretch',
		'setAutoBottomMargin' => 'stretch'];

	ini_set('memory_limit', '-1');
	ini_set('pcre.backtrack_limit', '10000000');
	$mpdf = new \Mpdf\Mpdf($mpdfconf);
	$mpdf->use_kwt = true;
		
	$flush = function ($mode = null) use ($mpdf) {
		$html = mb_convert_encoding(ob_get_contents(), 'UTF-8', 'UTF-8');
		if($html) {
			switch ($mode) {
				case 'body': $mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY); break;
				case 'start': $mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY, true, false); break;
				case 'middle': $mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY, false, false); break;
				case 'end': $mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY, false, true); break;
				case 'style': $mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HEADER_CSS); break;
				case 'footer': $mpdf->DefHTMLFooterByName('footer', $html); break;
				case 'header': $mpdf->DefHTMLHeaderByName('header', $html); break;
				case 'headerFirst': $mpdf->DefHTMLHeaderByName('headerFirst', $html); break;
				default: $mpdf->WriteHTML($html);
			}
		}
		ob_clean();
	};
	
	ob_start();
	
    // --- BLOCK: main-2-style ---
    
	?>
	body, html, div, p, table { font-family: sans-serif; }
	
	/* pdf styles */
	
	/* header and footer */
	@page { 
	footer: html_footer; }
	@page :first { header: _blank; margin-top: 16mm; }

@page {
	margin-left: 25mm;
	margin-right: 15mm;
}

.address{
	float: left;
	margin-top: 30mm;
	position: absolute;
	width: 90mm;
}
.sender {
	white-space: nowrap;
	left: 25mm;
	top: 30mm;
	height: 5mm;
	font-size: 70%;
}
.recipient {
	left: 25mm;
	top: 44.7mm;
	height: 27.3mm;
}
.header {
	margin-collapse: none;
	float: right;
	width: 80mm;
	text-align: right;
	height: 60mm; /* 60mm ist das Minimum, da sonst die Überschrift ins Adressfeld ragt (5 Zeilen bei Adressliste (Name, Firma, Str, PLZOrt, Land) */
	font-size: 80%;
}

.footer {
	color: grey;
	font-size: 10px;
	width: 100%;
	vertical-align: top;
}

body {
	clear: both;
	padding-left: 25mm;
	/*padding-top: 20mm;*/
	padding-right: 20mm;
}

.content {
	clear: both;
}
body::before, .mark1 {
	/* Faltmarken */
	display: block;
	position: absolute;
	height: 105mm;
	top: 96mm;
	left: 0px;
	width: 5mm;
	border-top: 1px solid black;
	border-bottom: 1px solid black;
	content: '';
}

body::after, .mark2 {
	/* Lochmarke */
	display: block;
	position: absolute;
	top: 148.5mm;
	height: 1px;
	left: 0px;
	width: 8mm;
	border-top: 1px solid black;
	content: '';
}

.pdflettertable tbody td {
	vertical-align: top;
}
.pdflettertable th, .pdflettertable td {
    padding: 3px;
}

li {
	page-break-inside: avoid;
}


.pdf-logo {
	float: right;
	max-width: 100%;
	max-height: 30mm;
}

<?php $flush('style'); 
    // --- BLOCK: main-3-footer ---
    ?>
	
	<footer>
	<table class='footer'>
		<tr>
			<td><?php echo (htmlentities($stammdaten['firmenname']) . '<br>' .
				($stammdaten['firmenname2'] ? $stammdaten['firmenname2'] . '<br>' : '') .
				htmlentities($stammdaten['strasse']) . '<br>' .
				htmlentities($stammdaten['plz']) . ' ' . htmlentities($stammdaten['ort']) );
			?></td>
			<td><?php 
			$gesch_1= $stammdaten['geschaeftsfuehrer1'];
			$gesch_2= $stammdaten['geschaeftsfuehrer2'];
			if($gesch_1 != ""){
				echo ('Geschäftsführer' . '<br>' . htmlentities($gesch_1));
				if($gesch_2 != ""){
					echo ('<br>' . htmlentities($gesch_2));	 
				}
			} ?></td>
			<td><?php 
			$tel = $stammdaten['telefon'];
			$mobil = $stammdaten['mobil'];
			$fax = $stammdaten['fax'];
			$email = $stammdaten['email'];
			if($email != ""){
				echo 'E-Mail: ' . htmlentities($email) . '<br>';
			}
			if($tel != ""){
				echo 'Telefon: ' . htmlentities($tel) . '<br>';
			}
			if($mobil != ""){
				echo 'Mobil: ' . htmlentities($mobil) . '<br>';
			}
			if($fax != ""){
				echo 'Fax: ' . htmlentities($fax);
			} ?></td> 
			<td><?php 
			$reg = $stammdaten['registergericht'];
			$hga = $stammdaten['handelsregisternummer'];
			$ust = $stammdaten['umsatzsteuerid'];
			if ($reg != ""){
				echo (htmlentities($reg) . '<br>' );
			}
			if($hga != ""){
				echo	(htmlentities($hga) . '<br>');
			}
			if($ust != ""){
				echo (htmlentities($ust));
			} ?> </td>
			<td style='white-space: nowrap;'>Bankverbindung<br><?php echo $stammdaten['iban']; ?><br><?php echo $stammdaten['bic']; ?><br>
			<?php echo $stammdaten['bankname']; ?></td>
		</tr>
	</table>
	</footer>
	
	<?php $flush('footer'); 
    // --- BLOCK: main-3.9-before-4 ---
    
		if ($campaign['pdf_type'] == 1 || $campaign['pdf_type'] == 3) {
	
    // --- BLOCK: main-4 ---
    ?>
		

<div class='mark1'></div>
<div class='mark2'></div>
<div class='address'>
	<div class='sender'><?php echo str_replace("\n", '<br>', htmlentities($stammdaten['firmenname'] . ' ' . ($stammdaten['firmenname2'] ? stammdaten['firmenname2'] . ' ' : '') . $stammdaten['strasse'] . ' ' . $stammdaten['plz'] . ' ' . $stammdaten['ort'])); ?></div>
	<div class='recipient'><?php echo str_replace("\n", '<br>', htmlentities($data['recAddress'])); ?></div>
</div>
<?php if ($stammdaten['logo']) { ?><img class='pdf-logo' src="<?php echo $getImage($stammdaten['logo']); ?>"><div class='pdf-logo-spacer'></div><?php } ?>
<div class='header'><?php echo \FOP\Util::SanitizeUserHtml($stammdaten['headerText']); ?><div style='text-align: right;'><?php echo date('d.m.Y', time()); ?></div></div>
<div class='content'><?php $flush('start'); ?>
	
		 <b><?php echo htmlentities($campaign['email_subject']); ?></b>
		 <?php echo \Tables\Mitglied::applyTemplate($data['target'], $campaign['email_text']); ?>
	
	<?php $flush('end'); ?></div>

	<?php $flush('body');
	
    // --- BLOCK: main-4-after ---
    
		} // end if type in 1,3
		if ($campaign['pdf_type'] == 2 || $campaign['pdf_type'] == 3) {
			if ($campaign['post_template']) {
				$pagecount = $mpdf->SetSourceFile(\FOP\Files::getTempFile($campaign['post_template']));
				for ($i = 1; $i <= $pagecount; $i++) {
					$mpdf->AddPage();
					$mpdf->SetHTMLFooter('');
					if ($i == 1 && $campaign['pdf_type'] == 2) {
						$mpdf->WriteHTML('<div style="position: absolute; left: 22mm; top: 60.7mm; height: 27.3mm;">'.nl2br(htmlentities($data['recAddress'])).'</div>');
					}
					$mpdf->UseTemplate($mpdf->ImportPage($i));
				}
			} else if ($campaign['pdf_type'] == 2) {
				// no template
				$mpdf->SetHTMLFooter('');
				$mpdf->WriteHTML('<div style="position: absolute; left: 22mm; top: 60.7mm; height: 27.3mm;">'.nl2br(htmlentities($data['recAddress'])).'</div>');
			}
			$flush('body');
		}
	
    // --- BLOCK: main-100 ---
    
	$filename = 'brief-'.intval($id).'.pdf';
	$filename = preg_replace('/[~"#%&\*:<>\?\/\\\{|\}]/', '_', $filename); // sanitize
    // --- BLOCK: main-120 ---
    
	ob_end_clean();
	if (!$attachTo) {
		$mpdf->Output($filename, \Mpdf\Output\Destination::INLINE);
	} else if ($attachTo instanceof \PHPMailer\PHPMailer\PHPMailer) {
		$attachTo->AddStringAttachment($mpdf->Output('', \Mpdf\Output\Destination::STRING_RETURN), $filename);
	} else if ($attachTo instanceof \Mpdf\Mpdf) {
		
	$tmp = tempnam(sys_get_temp_dir(), 'fop-pdf');
	$mpdf->Output($tmp, \Mpdf\Output\Destination::FILE);
	$pagecount = $attachTo->SetSourceFile($tmp);
	for ($i = 1; $i <= $pagecount; $i++) {
		$tplId = $attachTo->importPage($i);
		$attachTo->AddPage();
		$attachTo->UseTemplate($tplId);
	}
	unlink($tmp);
	} else if ($attachTo instanceof \ZipArchive) {
		$attachTo->addFromString($filename, $mpdf->Output('', \Mpdf\Output\Destination::STRING_RETURN));
	} else if ($attachTo === 'string') {
		return \Mpdf\Output\Destination::STRING_RETURN;
	} else if ($attachTo === 'file') {
		
		$tmp = tempnam(sys_get_temp_dir(), 'fop-pdf');
		$mpdf->Output($tmp, \Mpdf\Output\Destination::FILE);
		return \FOP\Files::uploadFromFile($tmp, $filename);
	} else {
		throw new \FOP\AccessDeniedException('unknown attachment object');
	}
	
    
  }

  public static function deleteAction($id) { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access-itemlist-campaignTarget-delete ---
    
		// 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('campaignTarget').' WHERE (('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT ('.\FOP\Database::quote(\FOP\User::getCampaign()).') FROM '.qi('campaign').' '.qi('hKxqI7xl').' WHERE '.qi('hKxqI7xl').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('campaign').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getGruppe()).' THEN TRUE ELSE NOT (('.qi('qnAG6U6I').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('mitglied').' '.qi('qnAG6U6I').' WHERE '.qi('qnAG6U6I').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getMitglied()).' THEN TRUE ELSE NOT ((('.qi('MQUST27S').'.'.qi('ID').') <> ('.\FOP\Database::sessionVarSQL('user').')) AND (NOT (EXISTS (SELECT (TRUE) FROM '.qi('gruppeItem').' '.qi('7sncgH3z').' WHERE '.qi('7sncgH3z').'.'.qi('item').' = '.qi('MQUST27S').'.'.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('MQUST27S').' WHERE '.qi('MQUST27S').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE)) AND ('.\FOP\Database::quote(\FOP\User::getCampaign()).') AND (COALESCE((SELECT (CASE WHEN '.\FOP\Database::quote(\FOP\User::getSuperadmin()).' THEN TRUE ELSE NOT ('.qi('UZUFh6Y1').'.'.qi('superadmin').') END) FROM '.qi('mitglied').' '.qi('UZUFh6Y1').' WHERE '.qi('UZUFh6Y1').'.'.qi('ID').' = '.qi('campaignTarget').'.'.qi('target').' LIMIT 1), FALSE))) AND ' . $id_->toSQL(qi('ID')))->fetchAll(\PDO::FETCH_COLUMN) AS $id_sub) {
			$id->push($id_sub);
		}
	
    // --- BLOCK: main ---
    
		\FOP\Database::beginTransaction();
		$ids = new \FOP\IDList($id);
		foreach ($ids->all() AS $id) {
			try {
				$success = self::delete($id);
			} catch (\PDOException $e) {
				if (\FOP\Database::getDriver() == 'mysql' && $e->errorInfo[1] == 1451 /* mysql error code */ || \FOP\Database::getDriver() == 'pgsql' && $e->getCode() == 23503/* psql error code */) {
					// fail due to foreign key constraints (the GUI before should already handle this)
					\FOP\Database::rollbackTransaction();
					if (isset($_GET['ajax'])) {
						header('HTTP/1.0 403 Forbidden');
						die(\TablesRouter\CampaignTarget::deleteConfirmURL($ids->toString(), ['from' => $_GET['from'] ?? null])); // open delete confirm window when something went wrong
					}
					// TODO: I18n
					header('Location: ' . \TablesRouter\CampaignTarget::deleteConfirmURL($ids->toString(), ['from' => $_GET['from'] ?? null]) . '#snack:Eine Löschung ist noch nicht möglich'); // open delete confirm window when something went wrong
					die();
				}
				throw $e; // sonst: weiterwerfen
			}
			if (!$success) {
				// fail due to permission
				\FOP\Database::rollbackTransaction();
				if (isset($_GET['ajax'])) {
					header('HTTP/1.0 403 Forbidden');
					die(_('deletiondenied'));
				}
				throw new \FOP\AccessDeniedException('deletiondenied');
			}

			$addition = '#snack:' . _('delete successful');
		}
		\FOP\Database::commitTransaction();

		if (isset($_GET['ajax'])) die('');
		header("Location: " . (isset($_GET['from']) ? $_GET['from'] : \TablesRouter\CampaignTarget::indexURL()) . $addition);
		die();
	
    
  }

  public static function indexAction() { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getCampaign()) && (\FOP\User::getCampaign())) && (!\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(_('Empfänger')); ?></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(_('Empfänger')); ?></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(_('Empfänger')); ?></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-campaignTarget"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormCampaignTarget" ng-init="form = <?php echo htmlentities(json_encode([]));
									?>;"
								>
								<?php
								 ?>
								<div id='fop-upbar'></div>
								<?php \DataView\CampaignTarget::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 = \'campaignTarget\' 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::getCampaign()) && (\FOP\User::getCampaign())) && (!\FOP\User::getIsGuest())) { ?>
	<div id="campaignTarget-table" class="fop-dv"><?php
		if (\EasyEditor\FormFeature::isCollapsed()) {
			// #3198 lazy rendering:
			echo '<div class="fop-lazy-reload" onclick="reloadcampaignTarget()"></div>'; // CSS class .fop-lazy-reload will be clicked after being showed
		} else {
			\DataView\CampaignTarget::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-campaignTarget').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-campaignTarget').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-campaignTarget').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=campaignTarget&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=campaignTarget&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-campaignTarget')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-campaignTarget 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
    
  }


  
  

  
  
}



