<!-- To change the layout of the detail view form, we recommend using JS code in hooks/flugbuch_verein-dv.js rather than editing this file -->

<div id="detail-view"></div>
<div class="panel-heading"><h3 class="panel-title"><strong><%%DETAIL_VIEW_TITLE%%></strong></h3></div>

<div id="flugbuch_verein_dv_container-loading" class="text-center text-info text-bold vspacer-lg"><i class="glyphicon glyphicon-refresh loop-rotate"></i> <%%TRANSLATION(Loading ...)%%></div>

<div class="panel-body hidden" id="flugbuch_verein_dv_container">
	<!-- child links -->
	<div class="row vspacer-md">
		<div class="col-xs-12 children-links">
			<div class="clearfix"></div>
		</div>
	</div>

	<div class="row">
		<!-- form inputs -->
		<div class="col-md-8 col-lg-10" id="flugbuch_verein_dv_form">
			<fieldset class="form-horizontal">

				<!-- Field: Datum -->
				<div class="form-group flugbuch_verein-datum">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="datum-dd">Datum<span class="text-danger"><%%TRANSLATION(*)%%></span> <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#datum-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="datum-description"><div class="alert alert-info bspacer-xs">Datum des Fluges</div></span>
						<%%COMBO(datum)%%>
					</div>
				</div>

				<!-- Field: Beginn -->
				<div class="form-group flugbuch_verein-beginn">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="beginn">Beginn<span class="text-danger"><%%TRANSLATION(*)%%></span> <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#beginn-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="beginn-description"><div class="alert alert-info bspacer-xs">Uhrzeit der ersten Flugaktivit&#228;t </div></span>
						<input maxlength="11" type="text" class="form-control" name="beginn" id="beginn" value="<%%VALUE(beginn)%%>" required>
					</div>
				</div>

				<!-- Field: Ende -->
				<div class="form-group flugbuch_verein-ende">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="ende">Ende<span class="text-danger"><%%TRANSLATION(*)%%></span> <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#ende-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="ende-description"><div class="alert alert-info bspacer-xs">Uhrzeit der letzten Flugaktivit&#228;t</div></span>
						<input maxlength="11" type="text" class="form-control" name="ende" id="ende" value="<%%VALUE(ende)%%>" required>
					</div>
				</div>

				<!-- Field: Pilot -->
				<div class="form-group flugbuch_verein-pilot">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3">Pilot <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#pilot-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="pilot-description"><div class="alert alert-info bspacer-xs">Name des Fernflugpiloten - wird automatisch aus dem Anmeldenamen generiert und kann nicht ver&#228;ndert werden.</div></span>
						<div class="form-control-static" id="pilot"><%%VALUE(pilot)%%></div>
					</div>
				</div>

				<!-- Field: Anzahl der Fl&#252;ge -->
				<div class="form-group flugbuch_verein-anzahl_fluege">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="anzahl_fluege">Anzahl der Fl&#252;ge<span class="text-danger"><%%TRANSLATION(*)%%></span> <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#anzahl_fluege-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="anzahl_fluege-description"><div class="alert alert-info bspacer-xs">Anzahl der Fl&#252;ge im angegebenen Zeitraum</div></span>
						<input maxlength="11" type="text" class="form-control" name="anzahl_fluege" id="anzahl_fluege" value="<%%VALUE(anzahl_fluege)%%>" required>
					</div>
				</div>

				<!-- Field: maximale Flugh&#246;he -->
				<div class="form-group flugbuch_verein-max_flughoehe">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="max_flughoehe">maximale Flugh&#246;he<span class="text-danger"><%%TRANSLATION(*)%%></span> <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#max_flughoehe-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="max_flughoehe-description"><div class="alert alert-info bspacer-xs">In manchen Artikel 16 Bescheiden ist die Erfassung der max. Flugh&#246;he gefordert. Hier besteht die M&#246;glichkeit dazu.</div></span>
						<input maxlength="11" type="text" class="form-control" name="max_flughoehe" id="max_flughoehe" value="<%%VALUE(max_flughoehe)%%>" required>
					</div>
				</div>

				<!-- Field: Flugplatz -->
				<div class="form-group flugbuch_verein-flugplatz">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="flugplatz" data-parent_link="view_parent_hidden">Flugplatz <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#flugplatz-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="flugplatz-description"><div class="alert alert-info bspacer-xs">F&#252;r den Fall, dass der Verein mehrere Flugpl&#228;tze betreibt, kann hier der betreffende Platz angegeben werden.<br>Sofern hier KEIN Flugplatz ausgew&#228;hlt wird, gilt der Eintrag f&#252;r den Stammflugplatz des Vereines !</div></span>
						<div class="lookup-flex"><%%COMBO(flugplatz)%%><%%ADDNEW(flugplaetze_oe)%%></div>
					</div>
				</div>

				<!-- Field: Einsatz eines Luftraumbeobachters -->
				<div class="form-group flugbuch_verein-luftraumbeobachter_anwesend">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3">Einsatz eines Luftraumbeobachters</label>
					<div class="col-lg-9">
						<div class="form-control-static" id="luftraumbeobachter_anwesend"><%%VALUE(luftraumbeobachter_anwesend)%%></div>
					</div>
				</div>

				<!-- Field: Modell -->
				<div class="form-group flugbuch_verein-modell">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="modell">Modell <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#modell-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="modell-description"><div class="alert alert-info bspacer-xs">Gib hier dein Modell ein</div></span>
						<input maxlength="40" type="text" class="form-control" name="modell" id="modell" value="<%%VALUE(modell)%%>">
					</div>
				</div>

				<!-- Field: Besonderheiten -->
				<div class="form-group flugbuch_verein-besonderheiten">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="besonderheiten">Besonderheiten <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#besonderheiten-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="besonderheiten-description"><div class="alert alert-info bspacer-xs">Vorf&#228;lle, Absinken auf eine Flugh&#246;he unter 120 m oder Landung wegen Ann&#228;herung eines manntragenden Luftfahrzeuges, Kollisionen in der Luft zwischen UAS, Absturz eines UAS, flyaway eines UAS, ..</div></span>
						<textarea maxlength="65500" class="form-control" name="besonderheiten" id="besonderheiten" rows=" 5"><%%VALUE(besonderheiten)%%></textarea>
					</div>
				</div>

				<!-- Field: Gastpilot -->
				<div class="form-group flugbuch_verein-gastpilot">
					<hr class="hidden-md hidden-lg">
					<div class="col-lg-offset-3 col-lg-9">
						<div class="checkbox">
							<label for="gastpilot"><input type="checkbox" name="gastpilot" id="gastpilot" value="1" <%%CHECKED(gastpilot)%%>> Gastpilot</label>
						</div>
					</div>
				</div>

				<!-- Field: Name des Gastpiloten -->
				<div class="form-group flugbuch_verein-name_gastpilot">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="name_gastpilot">Name des Gastpiloten <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#name_gastpilot-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="name_gastpilot-description"><div class="alert alert-info bspacer-xs">Gib hier den Vor- und Zunamen des Gastpiloten ein</div></span>
						<input maxlength="200" type="text" class="form-control" name="name_gastpilot" id="name_gastpilot" value="<%%VALUE(name_gastpilot)%%>">
					</div>
				</div>

				<!-- Field: MFBO gelesen JA/NEIN -->
				<div class="form-group flugbuch_verein-mfbo">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="mfbo" data-parent_link="view_parent_hidden">MFBO gelesen JA/NEIN <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#mfbo-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="mfbo-description"><div class="alert alert-info bspacer-xs">Der Gastpilot hat die MFBO des Modellflugplatzes anerkannt JA oder NEIN eingeben!</div></span>
						<div class="lookup-flex"><%%COMBO(mfbo)%%><%%ADDNEW(mfbo)%%></div>
					</div>
				</div>

				<!-- Field: Registriernummer -->
				<div class="form-group flugbuch_verein-reg_nr">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="reg_nr">Registriernummer <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#reg_nr-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="reg_nr-description"><div class="alert alert-info bspacer-xs">Gib hier die Registriernummer des Gastpiloten ein (Austrocontrolnummer! - zb. AUTabc1defg2hij3)</div></span>
						<input maxlength="200" type="text" class="form-control" name="reg_nr" id="reg_nr" value="<%%VALUE(reg_nr)%%>">
					</div>
				</div>

				<!-- Field: Fl&#252;ge Gastpilot -->
				<div class="form-group flugbuch_verein-fluege">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="fluege">Fl&#252;ge Gastpilot <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#fluege-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="fluege-description"><div class="alert alert-info bspacer-xs">Trage hier die Gesamtzahl der Fl&#252;ge ein</div></span>
						<input maxlength="200" type="text" class="form-control" name="fluege" id="fluege" value="<%%VALUE(fluege)%%>">
					</div>
				</div>

				<!-- Field: Lutraumbeobachter anwesend -->
				<div class="form-group flugbuch_verein-lrb">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3">Lutraumbeobachter anwesend</label>
					<div class="col-lg-9">
						<div class="form-control-static" id="lrb"><%%VALUE(lrb)%%></div>
					</div>
				</div>

				<!-- Field: geflogene H&#246;he -->
				<div class="form-group flugbuch_verein-hoehe">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3" for="hoehe">geflogene H&#246;he <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#hoehe-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="hoehe-description"><div class="alert alert-info bspacer-xs">Trasge hier die geflogene H&#246;he des Gastpiloten ein</div></span>
						<input maxlength="200" type="text" class="form-control" name="hoehe" id="hoehe" value="<%%VALUE(hoehe)%%>">
					</div>
				</div>

				<!-- Field: Dokument / Datei 1 -->
				<div class="form-group flugbuch_verein-datei">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3">Dokument / Datei 1 <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#datei-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="datei-description"><div class="alert alert-info bspacer-xs">beliebige Datei (Bild, pdf, ...) z.B. Tagescheckliste f&#252;r 25 kg, Teilnehmerliste bei Bewerben damit nicht alle Piloten einzeln erfasst werden m&#252;ssen.<br><br>Maximale Dateigr&#246;&#223;e: 2500 KB (2,5 MB)<br>Zul&#228;ssige Dateitypen: doc, docx, docm, odt, pdf, xls, xlsx, zip, jpg, jpeg, gif, png</div></span>
						<div class="form-control-static well well-sm">
							<div class="row" style="margin-right: 0; margin-left: 0;">
								<div class="col-lg-8 col-md-6" style="padding-left: 0;"><a id="datei-link" href="link.php?t=flugbuch_verein&f=datei&i=<%%VALUE(id)%%>" target="_blank" class="rspacer-lg"><i class="glyphicon glyphicon-picture" title="<%%VALUE(datei)%%>" style="font-size: 4em;"></i></a></div>
								<div class="hidden-md hidden-lg vspacer-lg"></div>
								<div class="col-lg-4 col-md-6 well upload-toolbox">
									<%%REMOVEFILE(datei)%%>
									<%%UPLOADFILE(datei)%%>
									<div class="text-bold text-danger file-type-error hidden"><%%TRANSLATION(invalid file type)%%></div>
									<div class="text-bold text-danger file-size-error hidden"><%%TRANSLATION(file too large)%%></div>
								</div>
							</div>
						</div>
						<script>/* disable empty links */ $j(() => { const e_datei = '<%%VALUE(datei)%%>'; if(e_datei == '' || e_datei == '&nbsp;' || e_datei == 'blank.gif') { $j('#datei-link').hide(); $j('#datei-image').parents('a').attr('href', '').on('click', (e) => e.preventDefault()); } });</script>
					</div>
				</div>

				<!-- Field: Dokument / Datei 2 -->
				<div class="form-group flugbuch_verein-datei_1">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3">Dokument / Datei 2 <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#datei_1-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block bspacer-xs collapse" id="datei_1-description"><div class="alert alert-info bspacer-xs">beliebige Datei (Bild, pdf, ...) z.B. Tagescheckliste f&#252;r 25 kg, Teilnehmerliste bei Bewerben damit nicht alle Piloten einzeln erfasst werden m&#252;ssen.<br><br>Maximale Dateigr&#246;&#223;e: 2500 KB (2,5 MB)<br>Zul&#228;ssige Dateitypen: doc, docx, docm, odt, pdf, xls, xlsx, zip, jpg, jpeg, gif, png</div></span>
						<div class="form-control-static well well-sm">
							<div class="row" style="margin-right: 0; margin-left: 0;">
								<div class="col-lg-8 col-md-6" style="padding-left: 0;"><a id="datei_1-link" href="link.php?t=flugbuch_verein&f=datei_1&i=<%%VALUE(id)%%>" target="_blank" class="rspacer-lg"><i class="glyphicon glyphicon-picture" title="<%%VALUE(datei_1)%%>" style="font-size: 4em;"></i></a></div>
								<div class="hidden-md hidden-lg vspacer-lg"></div>
								<div class="col-lg-4 col-md-6 well upload-toolbox">
									<%%REMOVEFILE(datei_1)%%>
									<%%UPLOADFILE(datei_1)%%>
									<div class="text-bold text-danger file-type-error hidden"><%%TRANSLATION(invalid file type)%%></div>
									<div class="text-bold text-danger file-size-error hidden"><%%TRANSLATION(file too large)%%></div>
								</div>
							</div>
						</div>
						<script>/* disable empty links */ $j(() => { const e_datei_1 = '<%%VALUE(datei_1)%%>'; if(e_datei_1 == '' || e_datei_1 == '&nbsp;' || e_datei_1 == 'blank.gif') { $j('#datei_1-link').hide(); $j('#datei_1-image').parents('a').attr('href', '').on('click', (e) => e.preventDefault()); } });</script>
					</div>
				</div>

			</fieldset>
		</div>

		<!-- DV action buttons -->
		<hr class="hidden-md hidden-lg">
		<div class="col-md-4 col-lg-2 dv-action-buttons" id="flugbuch_verein_dv_action_buttons">
			<div class="btn-toolbar">
				<div class="btn-group-vertical btn-group-lg" style="width: 100%;">
					<%%UPDATE_BUTTON%%>
				</div><p></p>
				<div class="btn-group-vertical btn-group-lg" style="width: 100%;">
					<%%DESELECT_BUTTON%%>
					<%%DVPRINT_BUTTON%%>
					<%%DELETE_BUTTON%%>
				</div><p></p>
				<div class="btn-group-vertical btn-group-lg" style="width: 100%;">
					<%%INSERT_BUTTON%%>
				</div>
			</div>
		</div>
	</div>


</div><!-- /div class="panel-body" -->
	<script>
		$j(function() {
			var add_new_mode = (!$j('input[name=SelectedID]').val());
			var embedded_mode = ($j('input[name=Embedded]').val() == 1);

			/* auto-close embedded page? */
			var autoclose_mode = ($j('input[name=AutoClose]').val() == 1);
			var record_added_ok = (location.search.split('record-added-ok=').length == 2);
			var record_updated_ok = (location.search.split('record-updated-ok=').length == 2);
			if((record_added_ok || record_updated_ok) && embedded_mode && autoclose_mode) {
				setTimeout(AppGini.closeParentModal, 2000);
			}


			/* enable DV action buttons to float on scrolling down the form */
			enable_dvab_floating();

			$j('#flugbuch_verein_dv_container-loading').addClass('hidden');
			$j('#flugbuch_verein_dv_container').removeClass('hidden');
			if(!$j('.table_view').length || $j('[name=SelectedID]').val().length) AppGini.focusFormElement('flugbuch_verein', 'datum');

			$j('a[href="<%%BASE_UPLOAD_PATH%%>"]').click(function() { return false; });


			if(true /* !embedded_mode */) {
				$j('.add_new_parent').click(function() {
					const fieldId = $j(this).prevAll('input:hidden').eq(0).attr('id');
					const pt = $j(this).attr('id').replace(/_add_new$/, '');

					modal_window({
						url: `${pt}_view.php?addNew_x=1&Embedded=1`,
						close: function() {
							$j(`#${fieldId}-container`).select2('focus').select2('focus');

							/* if a new parent was added, select it */
							var new_id = AppGini.localStorage.getItem(`${pt}_last_added_id`);
							if(new_id === null) return;

							AppGini.localStorage.removeItem(`${pt}_last_added_id`);
							AppGini.lookupText({
								id: new_id,
								table: AppGini.currentTableName(),
								field: fieldId,
								callback: function(data) {
									$j(`#${fieldId}-container`).select2('data', data, true);
								}
							});
						},
						beforeClose: AppGini.confirmBeforeClosingModal,
						size: 'full',
						title: $j(this).attr('title')
					});
				});
			}

			AppGini.hideViewParentLinks();

			$j('form').on('click', '.view_parent', function() {
				const pt = $j(this).attr('id').replace(/_view_parent$/, '');
				const fieldId = $j(this).prevAll('input:hidden').eq(0).attr('id');

				let parent_id = '{empty_value}';
				if(fieldId) {
					parent_id = $j(`#${fieldId}`).val();
				} else if($j(this).prevAll('[type=radio]').length) { /* handle radio lookups */
					parent_id = $j(this).prevAll('[type=radio]').eq(0).val();
				} else {
					parent_id = $j(this).prevAll().children('input:hidden').eq(0).val();
				}

				if(parent_id != '{empty_value}' && parent_id !== undefined && parent_id !== '') {
					const parent_link = $j(this).parents('.form-group').children('label').data('parent_link');
					switch(parent_link) {
						case 'view_parent_hidden':
							break;
						case 'view_parent_modal':
							modal_window({
								url: `${pt}_view.php?Embedded=1&SelectedID=${encodeURIComponent(parent_id)}`,
								close: function() {
									$j(`#${fieldId}-container`).select2('focus').select2('focus');

									// update lookup text in case the parent record was updated
									AppGini.lookupText({
										id: parent_id,
										table: AppGini.currentTableName(),
										field: fieldId,
										cache: false,
										callback: function(data) {
											$j(`#${fieldId}-container`).select2('data', data, true);

											// update auto-fills
											const updaterName = `${fieldId}_update_autofills`;
											if(typeof(window[updaterName]) == 'function')
												window[updaterName]();
										}
									});
								},
								beforeClose: AppGini.confirmBeforeClosingModal,
								size: 'full',
								title: $j(this).attr('title')
							});
							break;
						case 'view_parent_same_window':
							window.location = `${pt}_view.php?Embedded=${embedded_mode ? '1' : ''}&SelectedID=${encodeURIComponent(parent_id)}`;
							break;
						case 'view_parent_new_window':
							window.open(`${pt}_view.php?SelectedID=${encodeURIComponent(parent_id)}`);
							break;
					}

				}
			});

			flugbuch_vereinUniqueFields.forEach(fieldName => enforce_uniqueness('flugbuch_verein', fieldName));

			/* load admin tools for admin user */
			if(!add_new_mode) {
				$j('body').append('<div id="admin-tools-appendix"></div>');
				$j('#admin-tools-appendix').load(
					'ajax_admin_tools.php?table=flugbuch_verein&id=<%%URLVALUE(id)%%>',
					function(resp) {
						if(!resp.length) return;
						$j.ajax('ajax_admin_tools.php?action=get_admin_tools_js&table=flugbuch_verein&id=<%%URLVALUE(id)%%>');
					}
				);
			}
		});

		var flugbuch_vereinUniqueFields = [
		];
	</script>