{% 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 shadow">
      <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>
        {% if prochaine_maraude.date == date %}
        <a href="{% url 'maraudes:create' pk=prochaine_maraude.pk %}" class="card-link text-success">
            <span class="oi oi-pencil" title="Rédiger" aria-hidden="true"></span>
            <strong>Rédiger le compte-rendu</strong></a>
        {% endif %}
        <a href="{% url 'maraudes:planning' %}" class="card-link text-primary">
            <span class="oi oi-calendar" title="Calendar" aria-hidden="true"></span> 
            Voir le planning</a>
        <a href="{% url 'notes:liste-maraude' %}" class="card-link text-primary">
            <span class="oi oi-list" title="Liste" aria-hidden="true"></span> 
            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 }}<br />
          {% 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>
      <div class="card-body">
      {% for cr in missing_cr %}
         <a href="{% url "maraudes:create" pk=cr.pk %}" class="btn btn-warning mx-2">
             <span class="oi oi-pencil" aria-hidden="true"></span>
             {{cr}}
         </a>
      {% endfor %}
      </div>
    </div>
{% endif %}
</div>
<div class="col-md-12 col-lg-5">
  <div class="card">
    <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">
                <span class="oi oi-plus" title="+" aria-hidden="true"></span>
                Ajouter</strong></li>
            <li class="nav-item">
              <a class="nav-link" role="tab" data-toggle="tab" href="#noteNote" aria-expanded="false" aria-controls="noteNote">
                  <span class="oi oi-file" title="Phone" aria-hidden="true"></span>
                  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">
                  <span class="oi oi-phone" title="Phone" aria-hidden="true"></span>
                  Appel</a></li>
            <li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#noteSignalement" aria-expanded="false" aria-controls="noteSignalement">
                  <span class="oi oi-warning" title="Phone" aria-hidden="true"></span>
                  Signalement</a></li>
        </ul>
    </div>
    <div class="card-body tab-content">
        <div class="tab-pane fade" id="noteNote" role="tabpanel">
         {% include "notes/form_note_inner.html" with form=note_form %}
        </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 %}
