% Student template

\clearpage
\checkoddpage

\sectionmark{Steckbrief - \stdname}

% Returns a default file if not found
\providecommand\dfincludegraphics[2][]{
	\IfFileExists{#2}
	{
		\includegraphics[#1]{#2}
	}
	{
		%\fbox{File not found}
	}
}

\providecommand\studentbackground[2]{
	% Ring
	\def\ringx{20pt}
	\def\ringy{250pt}
	\def\ringwidth{250pt}
	\def\ringimgwidth{180pt}
	\def\ringoffset{(\ringwidth - \ringimgwidth) / 2}
	\ifoddpage\else
		\def\ringx{-\paperwidth - 325pt} % ringwidth + 2 * ringx % Nope, idk anymore
	\fi

	% Frame and QR-Code
	\def\framex{160pt}
	\def\framey{20pt}
	\def\framewidth{180pt}
	\def\frameimgwidth{160pt}
	\def\frameoffset{(\framewidth - \frameimgwidth) / 2}
	\def\qrcodex{90pt}
	\ifoddpage\else
		\def\framex{540pt} % paperwidth - framewidth / 2 % Nope, idk anymore
		\def\qrcodex{470pt}
	\fi

	\AddToShipoutPictureBG*{
		\AtTextUpperLeft{
			\put(-\ringx + \ringoffset, -\ringy + \ringoffset){
				\def\imgpath{parts/generated/students/figures/36_#1.jpg}
				\IfFileExists{\imgpath}{}
				{
					\def\imgpath{placeholder/#1.jpg}
				}
				\includegraphics[keepaspectratio=true, width=\frameimgwidth]{\imgpath}
			}
			\put(-\ringx, -\ringy){
				\includegraphics[keepaspectratio=true, width=\ringwidth]{ring.png}
			}
		}
		\AtTextLowerLeft{
			\put(\textwidth - \framex + \frameoffset, \framey + \frameoffset + 8pt){
				\dfincludegraphics[keepaspectratio=true, width=\frameimgwidth]{parts/generated/students/figures/11_#1.jpg}
			}
			\put(\textwidth - \framex, \framey){
				\oddflip[keepaspectratio=true, width=\framewidth]{rahmen.png}
			}
			\put(\textwidth - \qrcodex, \framey - 25pt){
				\ifdefempty{\stdqrcode}{}{
					\qrcode[nolink, height=0.7in]{\stdqrcode}
				}
			}
		}
	}
}

% Steckbrief Tabelle
\ifoddpage
	\def\tablex{0.5\linewidth}
	\def\tablewidth{0.55\linewidth} % Left side
\else
	\def\tablex{-0cm}
	\def\tablewidth{0.55\linewidth} % Right side
\fi

\hspace*{\tablex}\large\begin{minipage}{\tablewidth}
	\begin{tabular}{@{}ll@{}}
		\textbf{Name:}          & \stdname                                                  \\
		\textbf{Geburtstag:}    & \multicolumn{1}{p{\tablewidth}}{\RaggedRight\stdbirthday} \\
		\textbf{Lieblingsfach:} & \multicolumn{1}{p{\tablewidth}}{\RaggedRight\stdfavsub}   \\
		\textbf{Hassfach:}      & \multicolumn{1}{p{\tablewidth}}{\RaggedRight\stdhatesub}  \\
		\textbf{Hobbies:}       & \multicolumn{1}{p{\tablewidth}}{\RaggedRight\stdhobbies}  \\
		\textbf{Musik:}         & \multicolumn{1}{p{\tablewidth}}{\RaggedRight\stdmusic}    \\
	\end{tabular}\\~\\
	\textbf{Das werde ich am meisten vermissen:}\\\stdmissing\\~\\
	\textbf{Ohne das hätte ich die Oberstufe nicht geschafft:}\\\stdmotivation\\~\\
	\textbf{Lebensmotto:}\\\stdquote\\~\\
	\textbf{Zukunftspläne:}\\\stdfuture\\~\\
	%\textbf{Erkennungsmerkmale:}\\\stdidk\\~\\
\end{minipage}

% Characteristics
\providecommand\studentchar[1]{
	\textbf{#1}
}

% Divider
\providecommand\divider{
	\begin{figure}[H]
		\ifoddpage
			\hspace*{-1.5cm}\includegraphics[keepaspectratio=true, width=\paperwidth]{mittelwelle.png}
		\else
			\hspace*{-1.5cm}\includegraphics[keepaspectratio=true, width=\paperwidth]{mittelwelle_r.png}
		\fi
	\end{figure}
}

% Comments
\def\commentswidth{0.7\linewidth}
\ifoddpage
	\def\commentsx{-0cm}
\else
	\def\commentsx{\framewidth}
\fi
