{% load combo %}

{% if json.data.individu_1 %}

<div id="doublon">

<div class="newline grid-5-6">
<h2>Doublon {{json.data.individu_1.id}}+{{json.data.individu_2.id}}</h2>
</div>
<div class="grid-1-6">
<p><a class="mini-ts" href="?limit={{ limit }}&cookie={{ cookie|urlencode }}">Retour à la liste</a></p>
</div>

<div class="newline">
<p>
{% if json.data.state == "nouveau" %}
{% if request.user|has_role:parameters.role_traitement %}
  <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-rsu-faux-positif/?session_var_rsu_adult={{ json.data.individu_1.id }}&session_var_rsu_duplicate={{ json.data.individu_2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Déclarer comme faux positif</a>
  <em>si les deux fiches sont deux personnes différentes.</em>
{% endif %}
{% else %}
  <ul class="messages">
    <li class="error">
      Ce doublon est déclaré « {{ json.data.state }} »
    </li>
  </ul>
{% endif %}
</div>

{% with user=json.data.individu_1 %}
<div class="grid-1-2 bloc-rsu bloc-rsu-no-border">
<h3>
  <a href="../?rsu_adult={{ user.id }}"><strong>{{ user.nom_de_naissance }}
  {% if user.nom_d_usage %}({{ user.nom_d_usage }}){% endif %}
  </strong> {{ user.prenoms }}
  <small>— individu {{ user.statut_legal }}</small>
  <small>— #{{ user.id }}</a></small>
  {% if user.date_de_deces %}— décès le {{ user.date_de_deces|strptime:"%Y-%m-%d"|date:"j F Y" }}{% endif %}
  </a>
</h3>
<p>
  <em>Créée le {{ user.date_de_creation|parse_datetime }}</em><br />
  <em>Modifiée le {{ user.date_de_modification|parse_datetime }}</em>
</p>
</div>
{% endwith %}

{% with user=json.data.individu_2 %}
<div class="grid-1-2 bloc-rsu bloc-rsu-no-border">
<h3>
  <a href="../?rsu_adult={{ user.id }}"><strong>{{ user.nom_de_naissance }}
  {% if user.nom_d_usage %}({{ user.nom_d_usage }}){% endif %}
  </strong> {{ user.prenoms }}
  <small>— individu {{ user.statut_legal }}</small>
  <small>— #{{ user.id }}</a></small>
  {% if user.date_de_deces %}— décès le {{ user.date_de_deces|strptime:"%Y-%m-%d"|date:"j F Y" }}{% endif %}
  </a>
</h3>
<p>
  <em>Créée le {{ user.date_de_creation|parse_datetime }}</em><br />
  <em>Modifiée le {{ user.date_de_modification|parse_datetime }}</em>
</p>
</div>
{% endwith %}

{% if json.data.individu_1.statut_legal != json.data.individu_2.statut_legal %}
<div class="newline grid-1-1 bloc-rsu bloc-rsu-no-border">
    <ul class="messages"><li class="warning">
       Attention, les deux individus n’ont pas le même statut légal.
    </li></ul>
</div>
{% endif %}


{% if json.data.individu_1.cles_de_federation and json.data.individu_2.cles_de_federation and json.data.state == "nouveau" %}
<div class="newline grid-1-1 bloc-rsu bloc-rsu-no-border">
    <ul class="messages"><li class="warning">
      Transférer les fédérations vers la fiche à conserver.
    </li></ul>
</div>
{% endif %}

{% if json.data.state == "nouveau" %}

  {% with user=json.data.individu_1 user2=json.data.individu_2 %}
  <div class="newline grid-1-2 bloc-rsu bloc-rsu-no-border">
  <ul class="messages">
  {% if not user.cles_de_federation %}
    <li class="info">
      <strong>Fiche à supprimer (doublon)</strong>, n’est plus reliée à aucun système tiers.
    {% if user.parents or user.enfants or user.union %}
      </li>
      <li class="warning">
	Pour pouvoir la supprimer, supprimer ses liens (conjoint, parents, enfants).
    {% else %}
      {% if request.user|has_role:parameters.role_traitement %}
      <br />
      <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/suppression-fiche-rsu/?session_var_rsu_adult={{ user.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Supprimer cette fiche</a>
      {% endif %}
    {% endif %}
    </li>
  {% elif not user2.cles_de_federation %}
    <li class="info">
      <strong>Fiche à conserver.</strong>
      Vérifier que toutes <a href="../?rsu_adult={{ user.id }}">les données de cette
      fiche #{{ user.id }}</a> sont bien à jour.
    </li>
  {% endif %}
  </ul>
  </div>
  {% endwith %}

  {% with user=json.data.individu_2 user2=json.data.individu_1 %}
  <div class="grid-1-2 bloc-rsu bloc-rsu-no-border">
  <ul class="messages">
  {% if not user.cles_de_federation %}
    <li class="info">
      <strong>Fiche à supprimer (doublon)</strong>, n’est plus reliée à aucun système tiers.
    {% if user.parents or user.enfants or user.union %}
      </li>
      <li class="warning">
	Pour pouvoir la supprimer, supprimer ses liens (conjoint, parents, enfants).
    {% else %}
      {% if request.user|has_role:parameters.role_traitement %}
      <br />
      <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/suppression-fiche-rsu/?session_var_rsu_adult={{ user.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Supprimer cette fiche</a>
      {% endif %}
    {% endif %}
    </li>
  {% elif not user2.cles_de_federation %}
    <li class="info">
      <strong>Fiche à conserver.</strong>
      Vérifier que toutes <a href="../?rsu_adult={{ user.id }}">les données de cette
      fiche #{{ user.id }}</a> sont bien à jour.
    </li>
  {% endif %}
  </ul>
  </div>
  {% endwith %}

{% endif %}


<div class="newline grid-1-2 bloc-rsu">
  {% with user=json.data.individu_1 user2=json.data.individu_2 %}
  <h3>
    Fédérations
  </h3>
  <table class="federations"><tbody>
    <tr>
      <td>Technocarte (Famille) :</td>
      <td class="federation-key" title="{{ user.cles_de_federation.technocarte }}">{{ user.cles_de_federation.technocarte|default:"×" }}</td>
      {% if json.data.state == "nouveau" %}
      <td class="federation-action-left">
      {% if request.user|has_role:parameters.role_traitement %}
        {% if user.cles_de_federation.technocarte and user2.cles_de_federation.technocarte %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult=&session_var_rsu_application=technocarte&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Effacer</a>
        {% elif user.cles_de_federation.technocarte and not user2.cles_de_federation.technocarte %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult={{ user2.id }}&session_var_rsu_application=technocarte&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Transférer →</a>
        {% endif %}
      {% endif %}
      </td>
      {% endif %}
    </tr>
    <tr>
      <td>Implicit (QF) :</td>
      <td class="federation-key" title="{{ user.cles_de_federation.implicit }}">{{ user.cles_de_federation.implicit|default:"×" }}</td>
      {% if json.data.state == "nouveau" %}
      <td class="federation-action-left">
      {% if request.user|has_role:parameters.role_traitement %}
        {% if user.cles_de_federation.implicit and user2.cles_de_federation.implicit %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult=&session_var_rsu_application=implicit&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Effacer</a>
        {% elif user.cles_de_federation.implicit and not user2.cles_de_federation.implicit %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult={{ user2.id }}&session_var_rsu_application=implicit&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Transférer →</a>
        {% endif %}
      {% endif %}
      </td>
      {% endif %}
    </tr>
    <tr>
      <td>SAGA (factures) :</td>
      <td class="federation-key" title="{{ user.cles_de_federation.saga }}">{{ user.cles_de_federation.saga|default:"×" }}</td>
      {% if json.data.state == "nouveau" %}
      <td class="federation-action-left">
      {% if request.user|has_role:parameters.role_traitement %}
        {% if user.cles_de_federation.saga %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult=&session_var_rsu_application=saga&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Effacer</a>
        {% endif %}
      {% endif %}
      </td>
      {% endif %}
    </tr>
    <tr>
      <td>Tiers SAGA (factures) :</td>
      <td class="federation-key" title="{{ user.cles_de_federation.saga_tiers }}">{{ user.cles_de_federation.saga_tiers|default:"×" }}</td>
      {% if json.data.state == "nouveau" %}
      <td class="federation-action-left">
      {% if request.user|has_role:parameters.role_traitement %}
        {% if user.cles_de_federation.saga_tiers %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult=&session_var_rsu_application=saga_tiers&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Effacer</a>
        {% endif %}
      {% endif %}
      </td>
      {% endif %}
    </tr>
    <tr>
      <td>Infor (Médiathèque) :</td>
      <td class="federation-key" title="{{ user.cles_de_federation.infor }}">{{ user.cles_de_federation.infor|default:"×" }}</td>
      {% if json.data.state == "nouveau" %}
      <td class="federation-action-left">
      {% if request.user|has_role:parameters.role_traitement %}
        {% if user.cles_de_federation.infor and user2.cles_de_federation.infor %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult=&session_var_rsu_application=infor&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Effacer</a>
        {% elif user.cles_de_federation.infor and not user2.cles_de_federation.infor %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult={{ user2.id }}&session_var_rsu_application=infor&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Transférer →</a>
        {% endif %}
      {% endif %}
      </td>
      {% endif %}
    </tr>
    <tr>
      <td>Compte internaute :</td>
      <td class="federation-key" title="{{ user.cles_de_federation.authentic }}">{{ user.cles_de_federation.authentic|default:"×" }}</td>
      {% if json.data.state == "nouveau" %}
      <td class="federation-action-left">
      {% if request.user|has_role:parameters.role_traitement %}
        {% if user.cles_de_federation.authentic and user2.cles_de_federation.authentic %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult=&session_var_rsu_application=authentic&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Effacer</a>
        {% elif user.cles_de_federation.authentic and not user2.cles_de_federation.authentic %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult={{ user2.id }}&session_var_rsu_application=authentic&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Transférer →</a>
        {% endif %}
      {% endif %}
      </td>
      {% endif %}
    </tr>
  </tbody></table>

  {% endwith %}
</div>

<div class="grid-1-2 bloc-rsu">
  {% with user=json.data.individu_2 user2=json.data.individu_1 %}
  <h3>
    Fédérations
  </h3>
  <table class="federations"><tbody>
    <tr>
      {% if json.data.state == "nouveau" %}
      <td>
      {% if request.user|has_role:parameters.role_traitement %}
        {% if user.cles_de_federation.technocarte and user2.cles_de_federation.technocarte %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult=&session_var_rsu_application=technocarte&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Effacer</a>
        {% elif user.cles_de_federation.technocarte and not user2.cles_de_federation.technocarte %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult={{ user2.id }}&session_var_rsu_application=technocarte&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">← Transférer</a>
        {% endif %}
      {% endif %}
      </td>
      {% endif %}
      <td>Technocarte (Famille) :</td>
      <td class="federation-key" title="{{ user.cles_de_federation.technocarte }}">{{ user.cles_de_federation.technocarte|default:"×" }}</td>
    </tr>
    <tr>
      {% if json.data.state == "nouveau" %}
      <td>
      {% if request.user|has_role:parameters.role_traitement %}
        {% if user.cles_de_federation.implicit and user2.cles_de_federation.implicit %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult=&session_var_rsu_application=implicit&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Effacer</a>
        {% elif user.cles_de_federation.implicit and not user2.cles_de_federation.implicit %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult={{ user2.id }}&session_var_rsu_application=implicit&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">← Transférer</a>
        {% endif %}
      {% endif %}
      </td>
      {% endif %}
      <td>Implicit (QF) :</td>
      <td class="federation-key" title="{{ user.cles_de_federation.implicit }}">{{ user.cles_de_federation.implicit|default:"×" }}</td>
    </tr>
    <tr>
      {% if json.data.state == "nouveau" %}
      <td>
      {% if request.user|has_role:parameters.role_traitement %}
        {% if user.cles_de_federation.saga %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult=&session_var_rsu_application=saga&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Effacer</a>
        {% endif %}
      {% endif %}
      </td>
      {% endif %}
      <td>SAGA (factures) :</td>
      <td class="federation-key" title="{{ user.cles_de_federation.saga }}">{{ user.cles_de_federation.saga|default:"×" }}</td>
    </tr>
    <tr>
      {% if json.data.state == "nouveau" %}
      <td>
      {% if request.user|has_role:parameters.role_traitement %}
        {% if user.cles_de_federation.saga_tiers %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult=&session_var_rsu_application=saga_tiers&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Effacer</a>
        {% endif %}
      {% endif %}
      </td>
      {% endif %}
      <td>Tiers SAGA (factures) :</td>
      <td class="federation-key" title="{{ user.cles_de_federation.saga_tiers }}">{{ user.cles_de_federation.saga_tiers|default:"×" }}</td>
    </tr>
    <tr>
      {% if json.data.state == "nouveau" %}
      <td>
      {% if request.user|has_role:parameters.role_traitement %}
        {% if user.cles_de_federation.infor and user2.cles_de_federation.infor %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult=&session_var_rsu_application=infor&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Effacer</a>
        {% elif user.cles_de_federation.infor and not user2.cles_de_federation.infor %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult={{ user2.id }}&session_var_rsu_application=infor&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">← Transférer</a>
        {% endif %}
      {% endif %}
      </td>
      {% endif %}
      <td>Infor (Médiathèque) :</td>
      <td class="federation-key" title="{{ user.cles_de_federation.infor }}">{{ user.cles_de_federation.infor|default:"×" }}</td>
    </tr>
    <tr>
      {% if json.data.state == "nouveau" %}
      <td>
      {% if request.user|has_role:parameters.role_traitement %}
        {% if user.cles_de_federation.authentic and user2.cles_de_federation.authentic %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult=&session_var_rsu_application=authentic&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">Effacer</a>
        {% elif user.cles_de_federation.authentic and not user2.cles_de_federation.authentic %}
          <a class="mini-ts" href="{{ eservices_url }}backoffice/submission/doublon-federation/?session_var_rsu_duplicate={{ user.id }}&session_var_rsu_adult={{ user2.id }}&session_var_rsu_application=authentic&session_var_rsu_duplicate_ids={{ user.id }} {{ user2.id }}&cancelurl={{ portal_agent_url }}doublons/?{{ request.META.QUERY_STRING|urlencode:"" }}">← Transférer</a>
        {% endif %}
      {% endif %}
      </td>
      {% endif %}
      <td>Compte internaute :</td>
      <td class="federation-key" title="{{ user.cles_de_federation.authentic }}">{{ user.cles_de_federation.authentic|default:"×" }}</td>
    </tr>
  </tbody></table>

  {% endwith %}
</div>

<div class="newline grid-1-2 bloc-rsu">
  <h3>Identité</h3>
  {% include "rsu/identite.html" with user=json.data.individu_1 %}
</div>
<div class="grid-1-2 bloc-rsu">
  <h3>Identité</h3>
  {% include "rsu/identite.html" with user=json.data.individu_2 %}
</div>

<div class="newline grid-1-2 bloc-rsu">
  <h3>Adresse</h3>
  {% include "rsu/adresses.html" with adresses=json.data.individu_1.adresses %}
</div>
<div class="grid-1-2 bloc-rsu">
  <h3>Adresse</h3>
  {% include "rsu/adresses.html" with adresses=json.data.individu_2.adresses %}
</div>

<div class="newline grid-1-2 newline bloc-rsu">
  <h3>Informations de contact</h3>
  {% include "rsu/contacts.html" with email=json.data.individu_1.email telephones=json.data.individu_1.telephones %}
</div>
<div class="grid-1-2 bloc-rsu">
  <h3>Informations de contact</h3>
  {% include "rsu/contacts.html" with email=json.data.individu_2.email telephones=json.data.individu_2.telephones %}
</div>

{% if json.data.individu_1.enfants or json.data.individu_2.enfants %}
<div class="newline grid-1-2 bloc-rsu">
  <h3>Enfants</h3>
  {% for enfant in json.data.individu_1.enfants|dictsort:"date_de_naissance" %}
    <div class="newline grid-1-1">
    {% include "rsu/identite-mini.html" with user=enfant root="../" %}
    </div>
  {% empty %}
  <p>Pas d’enfant</p>
  {% endfor %}
</div>
<div class="grid-1-2 bloc-rsu">
  <h3>Enfants</h3>
  {% for enfant in json.data.individu_2.enfants|dictsort:"date_de_naissance" %}
    <div class="newline grid-1-1">
    {% include "rsu/identite-mini.html" with user=enfant root="../" %}
    </div>
  {% empty %}
  <p>Pas d’enfant</p>
  {% endfor %}
</div>
{% endif %}

{% if json.data.individu_1.union or json.data.individu_2.union %}
<div class="newline grid-1-2 bloc-rsu">
  {% if json.data.individu_1.union %}
  <h3>Conjoint — {% include "rsu/union_statut.html" with union_statut=json.data.individu_1.union_statut %}</h3>
  {% include "rsu/identite-mini.html" with user=json.data.individu_1.union root="../" %}
  {% else %}
  <h3>Conjoint</h3><p>Pas de conjoint</p>
  {% endif %}
</div>
<div class="grid-1-2 bloc-rsu">
  {% if json.data.individu_2.union %}
  <h3>Conjoint — {% include "rsu/union_statut.html" with union_statut=json.data.individu_2.union_statut %}</h3>
  {% include "rsu/identite-mini.html" with user=json.data.individu_2.union root="../" %}
  {% else %}
  <h3>Conjoint</h3><p>Pas de conjoint</p>
  {% endif %}
</div>
{% endif %}

{% if json.data.individu_1.parents or json.data.individu_2.parents %}
<div class="newline grid-1-2 bloc-rsu">
  <h3>Parents</h3>
  {% for parent in json.data.individu_1.parents|dictsort:"date_de_naissance" %}
    <div class="newline grid-1-1">
    {% include "rsu/identite-mini.html" with user=parent root="../" %}
    </div>
  {% empty %}
  <p>Pas de parent</p>
  {% endfor %}
</div>
<div class="grid-1-2 bloc-rsu">
  <h3>Parents</h3>
  {% for parent in json.data.individu_2.parents|dictsort:"date_de_naissance" %}
    <div class="newline grid-1-1 bloc-rsu">
    {% include "rsu/identite-mini.html" with user=parent root="../" %}
    </div>
  {% empty %}
  <p>Pas de parent</p>
  {% endfor %}
</div>
{% endif %}

<p>
<a href="?limit={{ limit }}&cookie={{ cookie|urlencode }}">Retour à la liste</a>
</p>

</div>
</div>

{% else %}

<div id="doublons">

<p align="right">
{% if cookie %}<a href="?limit={{ limit }}&cookie=">Première page</a> |{% endif %}
<a href="?limit={{ limit }}&cookie={{ json.cookie|urlencode }}">Page suivante</a>
</p>

{% for doublon in json.data %}
<p>

<a href="?ids={{ doublon.individu_1.id }} {{ doublon.individu_2.id }}&cookie={{ cookie|urlencode }}&limit={{ limit }}">{{ doublon.individu_1.id }}+{{ doublon.individu_2.id }}</a>
    — <strong>{{ doublon.score }}&nbsp;%</strong>
    — <small>détecté le {{ doublon.created|parse_datetime }} ({{doublon.state}})</small>

<ul>
{% with user=doublon.individu_1 %}
<li><strong>{{ user.nom_de_naissance }}
  {% if user.nom_d_usage %}({{ user.nom_d_usage }}){% endif %}
  </strong> {{ user.prenoms }}
  <small>— naissance le {{ user.date_de_naissance|strptime:"%Y-%m-%d"|date:"j F Y" }}</small>
  <small>— individu {{ user.statut_legal }}</small>
  <small>— RSU <a href="../?rsu_adult={{ user.id }}">#{{ user.id }}</a></small>
  {% if user.date_de_deces %}— décès le {{ user.date_de_deces|strptime:"%Y-%m-%d"|date:"j F Y" }}{% endif %}
{% endwith %}
{% with user=doublon.individu_2 %}
<li><strong>{{ user.nom_de_naissance }}
  {% if user.nom_d_usage %}({{ user.nom_d_usage }}){% endif %}
  </strong> {{ user.prenoms }}
  <small>— naissance le {{ user.date_de_naissance|strptime:"%Y-%m-%d"|date:"j F Y" }}</small>
  <small>— individu {{ user.statut_legal }}</small>
  <small>— RSU <a href="../?rsu_adult={{ user.id }}">#{{ user.id }}</a></small>
  {% if user.date_de_deces %}— décès le {{ user.date_de_deces|strptime:"%Y-%m-%d"|date:"j F Y" }}{% endif %}
{% endwith %}
</ul>

</p>
{% endfor %}

<p align="right">
{% if cookie %}<a href="?limit={{ limit }}&cookie=">Première page</a> |{% endif %}
<a href="?limit={{ limit }}&cookie={{ json.cookie|urlencode }}">Page suivante</a>
</p>

</div>

{% endif %}
