% !TEX root = ../Main.tex
% ========================================================
% Vereinfachung zur Darstellung von Tagesordnungspunkten
% (TOP) in einem Sitzungsprotokoll.
% ========================================================

\NewEnviron{TOP}[1]{
    \goodbreak
    \chapter{#1}
    \BODY
    \vspace{1.5em}
}

% tok for the committee members
\newtoks\committeeMembers

% counters for: STUPA, AStA, Präsent, Online
\newcounter{stupaCounter}
\newcounter{astaCounter}
\newcounter{presentCounter}
\newcounter{onlineCounter}

% Command to count based on flags: STUPA, AStA, Präsent, Online
\DeclareRobustCommand{\CountPresence}[4]{
    \ifthenelse{#1=1}{\stepcounter{stupaCounter}}{}
    \ifthenelse{#2=1}{\stepcounter{astaCounter}}{}
    \ifthenelse{#3=1}{\stepcounter{presentCounter}}{}
    \ifthenelse{#4=1}{\stepcounter{onlineCounter}}{}
}

% Command to add a line to the presence table
%                       Online ┑
%                   Präsent ┑  │
%                   ASTA ┑  │  │                                 ┍ Bis*
%               STUPA ┑  │  │  │  ┍ Name      ┍ Rolle(n)   ┍ Ab* │
% \AddCommitteeMember{1}{1}{1}{0}{Max Muster}{Musterrolle}{4:20}{6:09}
\DeclareRobustCommand{\AddCommitteeMember}[8]{
    \CountPresence{#1}{#2}{#3}{#4}
    \committeeMembers=\expandafter{\the\committeeMembers
        \PresenceTableLine{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}
    }
}

\DeclareRobustCommand{\AddPresenceSeparator}[0]{
    \committeeMembers=\expandafter{\the\committeeMembers
        \hdashline\addlinespace[1ex]
    }
}

% Command to make the final table
\DeclareRobustCommand{\MakePresenceTable}{
    \begin{CustomBox}{\faIcon{user}}{eggplant}
        \chapter*{Anwesenheitsliste}
        \PresenceTable{
            \the\committeeMembers
            \specialrule{.2em}{.05em}{.05em}\addlinespace[1ex]
            \PresenceTableSums{\thestupaCounter}{\theastaCounter}{\thepresentCounter}{\theonlineCounter}
            \specialrule{.2em}{.05em}{.05em}
        }
    \end{CustomBox}
}

% Task-Box pointing to Nextcloud-Deck-Cards under https://cloud.reutlingen.university/apps/deck/card/<deck-card-id>
\newcommand{\urlOfCard}[1]{https://cloud.reutlingen.university/apps/deck/card/#1}

\NewEnviron{TaskBox}[1]{
    \let\tbBODY=\BODY
    \vspace{1em}
    \begin{CustomBox}{\faIcon{tasks}}{eggplant}
        \section*{Aufgabe}
        \tbBODY
        \ifthenelse{\equal{#1}{}}{}{
            \begin{center}
                \vspace{1em}
                \textbf{Link zur Karte:} \url{\urlOfCard{#1}}
            \end{center}
        }
    \end{CustomBox}
    \vspace{1em}
}