{% extends "maraudes/base.html" %}

{% block title %} {{ block.super }} Tableau de bord {% endblock %}

{% block breadcrumbs %}
  <h6 class="navbar-text text-white my-2">Tableau de bord</h6>
  <p class="navbar-text my-2 pl-2">{{ date }}</p>
{% endblock %}

{% block page_content %}
{% load tables %}
<div class="col-lg-7 col-md-12">
    <div class="card rounded-bottom">
      <h6 class="card-header rounded-0 py-2 bg-dark text-white">Planning</h6>
      <div class="card-body">
        <h6 class="card-title">Prochaine maraude</h6>
	<p class="card-text">
        {% if prochaine_maraude %}
        Le <strong class="text-dark">{{ prochaine_maraude.date }} à {{ prochaine_maraude.heure_debut }}</strong>
          avec {% if user == prochaine_maraude.referent %}
                   {{prochaine_maraude.binome}}
               {% else %}
                   {{prochaine_maraude.referent}}
               {% endif %}.
	{% else %}
          Aucune maraude prévue.
        {% endif %}
        </p>
        <a href="{% url 'maraudes:planning' %}" class="card-link text-primary">Voir le planning</a>
        <a href="{% url 'notes:liste-maraude' %}" class="card-link text-primary">Toutes les maraudes</a>
      </div>
    </div>
    <div class="row">
    {% if derniers_sujets_rencontres %}
    <div class="col">
    <div class="card rounded-bottom my-3">
        <div class="card-header rounded-0 py-1 text-white bg-dark">En ce moment nous croisons...</div>
        <div class="card-body">
          {% for sujet in derniers_sujets_rencontres %}
             {{ sujet }},
          {% endfor %}
        </div>
    </div>
    </div>
    {% endif %}
    {% if derniers_sujets_signales %}
    <div class="col">
    <div class="card rounded-bottom my-3">
      <div class="card-header rounded-0 py-1 text-white bg-dark">
          Signalements récents
      </div>
      <div class="card-body">
        {% for sjt in derniers_sujets_signales %}
            {{ sjt }}
        {% endfor %}
      </div>
    </div>
    </div>
    {% endif %}
    </div>
{% if user.is_superuser and missing_cr %}
    <div class="card border-warning rounded-bottom my-3">
      <div class="card-header py-2 bg-dark text-warning rounded-0">
        Compte-rendus en retard
      </div>
      {% table missing_cr cols=2 cell_template="maraudes/table_cell_missing_cr.html" %}
    </div>
{% endif %}
</div>
<div class="col-md-12 col-lg-5">
  <div class="card shadow">
    <div class="card-header bg-dark text-white">
        <ul class="nav nav-tabs card-header-tabs" id="addNote" role="tablist">
            <li class="nav-item my-2"><strong class="nav-text pr-2">Ajouter </strong></li>
            <li class="nav-item">
              <a class="nav-link" role="tab" data-toggle="tab" href="#noteNote" aria-expanded="false" aria-controls="noteNote">Note</a></li>
            <li class="nav-item"><a class="nav-link active" role="tab" data-toggle="tab" href="#noteAppel" aria-expanded="false" aria-controls="noteAppel">Appel</a></li>
            <li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#noteSignalement" aria-expanded="false" aria-controls="noteSignalement">Signalement</a></li>
        </ul>
    </div>
    <div class="card-body tab-content">
        <div class="tab-pane fade" id="noteNote"><div class="card card-body">Note</div></div>
        <div class="tab-pane fade show active" id="noteAppel" role="tabpanel">
         {% include "notes/form_appel_inner.html" with form=appel_form %}
        </div>
        <div class="tab-pane fade" id="noteSignalement">
         {% include "notes/form_signalement_inner.html" with form=signalement_form %}
        </div>
    </div>
  </div>
</div>
{% endblock %}
