{% extends 'base.html' %}

{% load static %}
{% load stud_tags %}

{% block title %} 
  {{ block.super }} {{title}}
{% endblock title %} Студенты

{% block content %}
     {% comment %} <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
      <h1 class="h2">Dashboard</h1>
      <div class="btn-toolbar mb-2 mb-md-0">
        <div class="btn-group me-2">
          <button type="button" class="btn btn-sm btn-outline-secondary">Share</button>
          <button type="button" class="btn btn-sm btn-outline-secondary">Export</button>
        </div>
        <button type="button" class="btn btn-sm btn-outline-secondary dropdown-toggle">
          <span data-feather="calendar" class="align-text-bottom"></span>
          This week
        </button>
      </div>
    </div> {% endcomment %}

    <h2 class="text-center">{{t_title}}:</h2>
    <div class="table-responsive">
      <table class="table table-striped table-sm table-hover table-bordered">
        <thead class="text-center table-secondary">
          <tr>
            <th scope="col" class="text-end">№</th>
            <th scope="col">Фото</th>
            <th scope="col">ФИО</th>
            <th scope="col">Пол</th>
            <th scope="col">Телефон</th>
            <th scope="col" class="text-end">Группа</th>
            <th scope="col">Добавлен</th>
            <th scope="col">Обучается</th>
            <th scope="col">Возраст</th>
          </tr>
        </thead>
        <tbody class="text-center">
          {% for item in objects %}
          <tr>
            <td class="text-end align-item-bottom">{{ forloop.counter }}.</td>
            <td>
              {% if item.photo %}
              <img src="{{ item.photo.url }}" height="75" />
              {% else %}
              <img src="{% static 'img/blank.png' %}" height="75" />
              {% endif %}
            </td>
            {% comment %} <td><a href=" {% url 'student' item.pk  %} ">{{ item.surname }} {{ item.name }} {{item.patronymic}}</td> {% endcomment %}
            <td><a href=" {{ item.get_absolute_url }} ">{{ item.surname }} {{ item.name }} {{item.patronymic}}</td>
            <td>{{item.gender}}</td>
            <td>{{item.phone}}</td>
            <td class="text-end"><a href=" {{item.group.get_absolute_url}} "> {{item.group}}</a></td>
            <td>{{ item.added_at|date:"d-m-Y" }}</td>
            <td>
              {% get_cbs item.id as contracts %} 
              {% for item in contracts%}
              {% if forloop.counter > 1 %}
              <br>
              {% endif %}
              <a href=" {{ item.get_absolute_url }} "> Договор № {{ item.number }} </a> <br>
              с {{item.start_date|date:"SHORT_DATE_FORMAT"}} по {{item.end_date|date:"SHORT_DATE_FORMAT"}}
              {% endfor %}
            </td>
            <td>{{ item.birthdate|timesince }}</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
{% endblock content %}

