{% extends "members/tex_base.tex" %}
{% load static common tex_extras %}

{% block headline %}{% endblock %}
{% block contact %}{% endblock %}

{% block extra-preamble %}
\usepackage{rotating}
\usepackage[code=Code39,X=.48mm,ratio=3.5,H=0.5cm]{makebarcode}
\geometry{reset,margin=1cm, bottom=1.5cm}
\renewcommand{\arraystretch}{1}
{% endblock %}

{% block content %}
{% settings_value 'DEFAULT_STATIC_PATH' as static_root %}

{% for group in groups %}
\picpos{2.5cm}{16cm}{-0.4cm}{%
{{ static_root }}/general/img/dav_logo_sektion.png%
}
% HEADLINE

{\noindent\Large{Gruppenliste {{ group.name }} }}\\[1mm]
{% if group.has_time_info %} \noindent {{ weekdays|index:group.weekday|esc_all }}, {{ group.start_time }} - {{ group.end_time }} Uhr\\ {% endif %}
\noindent {{ header_text }}
\begin{table}[H]
  \centering
%\begin{tabularx}{\textwidth}{lYY|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l}
\begin{tabularx}{\textwidth}{X{% for i in week_range %}|l{% endfor%}}
\toprule
  \textbf{Name} {% for i in week_range %}
  & \begin{sideways} {{ dates|index:i|add:group.weekday|date_vs }} \end{sideways}
{% endfor %} \\

  {% for j in member_range %}
  {% with m=group.sorted_members|index:j %}
  {% with codelength=m.ticket_tag|length %}
  \midrule
      \begin{tabular}{@{}l}
         {% if codelength > 2 %}
          \barcode[
            X=\dimexpr 3.5mm / \numexpr {{ codelength }} \relax \relax
          ]{{ m.ticket_tag }}
        {% else %}
          \rule{0pt}{5mm}
        {% endif %} 
        \vspace{-0.8ex} \\
        {\small {{ j|plus:1 }} {% if m in group.leiters.all %}\textbf{JL}{% endif %}
        {{ m.name|esc_all }} {% if codelength > 2 %} - {{ m.ticket_tag }}{% endif %} 
        \vspace{-3ex} }
    \end{tabular} 
      
  {% for i in week_range %} & {% endfor %}\\
  {% endwith %}
  {% endwith %}
  {% endfor %}

  \bottomrule
\end{tabularx}
\end{table}

\clearpage
{% endfor %}

{% endblock content %}
