% !TEX root = ../../../../Main.tex

\newcommand{\createdon}[1]{\gdef\@createdon{#1}}

\newcommand{\isReadOnlyVariant}{false}

\DeclareRobustCommand{\CustomTextField}[7]{\raisebox{#3}[#4][#5]{\TextField[
			print,
			name=#1,
			width=1.7cm,
			color=black,
			backgroundcolor=white,
			bordercolor=white,
			value=#2,
			align=1,
			readonly=\isReadOnlyVariant,
			% On Hover show the altname as Tooltip (#6)
			altname={#6},
			onmouseover={if (event.target.display == display.hidden) event.target.display = display.visible;},
			#7
		]{}}}

\DeclareRobustCommand{\CustomChoiceMenu}[7]{\raisebox{#3}[#4][#5]{\ChoiceMenu[
			name=#1,
			color=black,
			backgroundcolor=white,
			value=#2,
			align=1,
			combo,
			print,
			readonly=\isReadOnlyVariant,
			#6
		]{}{#7}}}

\DeclareRobustCommand{\CustomTextFieldThuge}[4]{\CustomTextField{#1}{#2}{-5pt}{0pt}{0pt}{#3}{
		charsize=16pt,
		height=1em,
		width=3.6cm,
		backgroundcolor=black!5!white,
		borderwidth=2pt,
		color=black,
		#4
	}}

\DeclareRobustCommand{\CustomTextFieldDefault}[4]{\CustomTextField{#1}{#2}{-4pt}{2pt}{2pt}{#3}{
		charsize=12pt,
		height=1.4em,
		width=5cm,
		bordercolor=black,
		align=0,
		#4
	}}

\DeclareRobustCommand{\CustomChoiceMenuDefault}[4]{\CustomChoiceMenu{#1}{#2}{-4pt}{2pt}{2pt}{
		charsize=12pt,
		height=1.4em,
		width=5cm,
		bordercolor=black,
		align=0,
		#3
	}{#4}}

% Command für einen Abschnitt – graue Box rund um den Abschnitt; Abschnittsname in der oberen linken Ecke
% #1: Abschnittsname
% #2: Abschnittsinhalt
\DeclareRobustCommand{\FormSection}[2]{
	\color{black}
	{\hspace{-1em}\small\textbf{#1}}\vspace{0.2em}
	% Create Box using mdframed
	\begin{mdframed}[
			backgroundcolor=white,
			hidealllines=true,
			skipabove=0,
			skipbelow=0.7\baselineskip,
			splitbottomskip=2pt,
			splittopskip=4pt,
			roundcorner=0pt,
			topline=true,
			bottomline=true,
			leftline=true,
			rightline=true,
			linecolor=black
		]
		\begin{minipage}[t]{0.95\textwidth}
			\color{black}#2
		\end{minipage}
	\end{mdframed}
}

\newcommand{\paPage}[2]{
	\newpage
	\setlength{\imageHeight}{2cm*\real{\mainLogoScale}*\real{\logosScale}}
	\begin{tikzpicture}[overlay, remember picture]
		\node[anchor=north west, inner sep=0pt, xshift=0.85cm, yshift=-1.5cm, opacity=0] (logo0) at (current page.north west) {
			\includegraphics[height=\imageHeight]{\imagesPath/DUMMY_FOOT.png}
		};
		\foreach \i in {1,...,\value{logoCounter}} {
				% Calculate name for i-1
				\pgfmathtruncatemacro{\prev}{\i-1}
				\node[anchor=west, inner sep=0pt, xshift=-0.1cm, opacity=0.3] (logo\i) at (logo\prev.east) {
					\makeatletter
					\testarray{LogosScales}(\i)
					\setlength{\imageHeight}{1.5cm*\real{\temp@macro}*\real{\logosScale}}
					\testarray{LogosExtensions}(\i)
					\let\extension\temp@macro
					\testarray{LogosOpacities}(\i)
					\let\opacity\temp@macro
					\testarray{LogosPaths}(\i)
					\ifthenelse{\equal{\extension}{svg}}{
						\begin{tikzpicture}
							\node[opacity=\opacity] {
								\includesvg[height=\imageHeight]{\classPath/Assets/Images/\temp@macro.\extension}
							};
						\end{tikzpicture}
					}{
						\begin{tikzpicture}
							\node[opacity=\opacity] {
								\includegraphics[height=\imageHeight]{\classPath/Assets/Images/\temp@macro.\extension}
							};
						\end{tikzpicture}
					}
					\makeatother
				};
			}
		% Address of the Student Parliament on the right:
		% Verfasste Studierendenschaft ▪ Hochschule Reutlingen ▪ Alteburgstraße 150 ▪ 72762 Reutlingen stupa.reutlingen.university ▪ T. +49 (0)7121 271-1099 ▪ asta@reutlingen-university.de
		\node[anchor=north east, inner sep=0pt, xshift=-0.85cm, yshift=-2cm, opacity=0.7] (logo\the\numexpr\value{logoCounter}+1) at (current page.north east) {
			\hspace*{\fill}\begin{minipage}{0.3\textwidth}
				\color{black}
				\blenderfont
				\footnotesize
				\textbf{Verfasste Studierendenschaft} \\
				\setstretch{1.0}
				Hochschule Reutlingen \\
				Alteburgstraße 150 \\
				72762 Reutlingen \\
				\href{https://stupa.reutlingen.university}{stupa.reutlingen.university} \\
				T. \href{tel:+4971212711099}{+49 (0)7121 271-1099} \\
				\href{mailto:asta@reutlingen-university.de}{asta@reutlingen-university.de}
			\end{minipage}
		};
		%
		\node[anchor=north east, inner sep=0pt, xshift=-2cm, yshift=-5.5cm, opacity=0.3] (logo\the\numexpr\value{logoCounter}+1) at (current page.north east) {
			\huge
			\iffalse
				\CustomTextFieldThuge{pa-id}{}{Jahr/Antragsnummer}{width=3.8cm}
				\CustomTextFieldThuge{pa-key}{}{}{
					name=pa-key,
					width=0.1pt,
					readonly=true,
					bordercolor=white,
					backgroundcolor=white,
					maxlen=16
				}
			\fi
		};

		\node[anchor=north, inner sep=0pt, xshift=0cm, yshift=-0.5cm, opacity=0.3] (logo\the\numexpr\value{logoCounter}+2) at (current page.north) {
		\ifnum1=\value{page}
			\CustomTextFieldThuge{warning-not-supported}{}{}{
			default={Warning: JavaScript is not supported! Please a supported Editor (e.g. Chrome, Firefox, Safari, Edge)},
			width=21cm,
			height=0.75cm,
			borderwidth=0pt,
			backgroundcolor=yellow,
			readonly,
			align=1,
			charsize=12pt,
			color=red,
			format={\detokenize{
			console.println(this);
			var f = this.getField('warning-not-supported');
			f.fillColor = ['T'];
			f.textColor = ['T'];
			f.disabled = true;
			f.display = display.hidden;
			}}
			}
		\fi
		};
	\end{tikzpicture}

	\vskip 5em

	% title
	\begin{flushleft}
		{
			\noindent
			\color{black}\textbf{
				\blenderfont\huge\hspace*{-2.5pt}Projektantrag: #1
			}\\\vspace*{-0.5em}
			{
				\blenderfont Antrag auf finanzielle Förderung durch das STUPA
			}\\
		}
		\color{black}
		\vspace{-.8em}
		\rule{\textwidth}{0.5mm}
	\end{flushleft}

	#2
}
