{% extends 'backend/base.html.twig' %}
{% block title %}Accueil{% endblock %}
{% block content %}
<div class="row justify-content-md-center">
<div class="col-12 col-lg-8 mb-4 mb-lg-0">
<div class="card h-100">
<div class="card-header">
<div class="row">
<div class="col-12 col-lg-6">
<h4>Adhérents par régions {{ mapSelectedYear }}</h4>
<div class="text-sm"><i>Cliquez sur les numéros pour voir le détails</i></div>
</div>
<div class="col-12 col-lg-6 text-end">
<a href="{{ path('app_homepage', {year: (nowYear - 2)}) }}" class="btn {{ (nowYear - 2) == mapSelectedYear ? 'btn-success' : 'btn-outline-secondary' }} btn-sm">{{ nowYear - 2 }}</a>
<a href="{{ path('app_homepage', {year: (nowYear - 1)}) }}" class="btn {{ (nowYear - 1) == mapSelectedYear ? 'btn-success' : 'btn-outline-secondary' }} btn-sm">{{ nowYear - 1 }}</a>
<a href="{{ path('app_homepage', {year: (nowYear)}) }}" class="btn {{ nowYear == mapSelectedYear ? 'btn-success' : 'btn-outline-secondary' }} btn-sm">{{ nowYear }}</a>
</div>
</div>
</div>
<div class="card-body">
<div
class="map mx-auto"
data-controller="region-details-modal"
data-region-details-modal-id-value="#regionDetail"
data-region-details-modal-year-value="{{ mapSelectedYear }}"
data-region-details-modal-display-value="{{ is_granted('ROLE_BOARD_DIRECTOR') or is_granted('ROLE_REGIONAL_AGENT') or is_granted('ROLE_UNION_PRESIDENT') ? 'false' : 'true' }}"
>
{% set color = '#000000' %}
{% if memberPerRegion is not empty %}
<span class="map-value" data-region-id="{{ memberPerRegion[6].id }}" style="top: 115px; right: -335px;" title="{{ memberPerRegion[6].name ~ '(' ~ memberPerRegion[6].id ~')' }}">
{{ memberPerRegion[6].countMember }}
</span>
<span class="map-value" data-region-id="{{ memberPerRegion[8].id }}" style="top: 163px;right: -203px;" title="{{ memberPerRegion[8].name ~ '(' ~ memberPerRegion[8].id ~')' }}">
{{ memberPerRegion[8].countMember }}
</span>
<span class="map-value" data-region-id="{{ memberPerRegion[7].id }}" style="top: 189px; right: -308px;" title="{{ memberPerRegion[7].name ~ '(' ~ memberPerRegion[7].id ~')' }}">
{{ memberPerRegion[7].countMember }}
</span>
<span class="map-value" data-region-id="{{ memberPerRegion[5].id }}" style="top: 189px; right: -421px;" title="{{ memberPerRegion[5].name ~ '(' ~ memberPerRegion[5].id ~')' }}">
{{ memberPerRegion[5].countMember }}
</span>
<span class="map-value" data-region-id="{{ memberPerRegion[1].id }}" style="top: 296px; right: -374px;" title="{{ memberPerRegion[1].name ~ '(' ~ memberPerRegion[1].id ~')' }}">
{{ memberPerRegion[1].countMember }}
</span>
<span class="map-value" data-region-id="{{ memberPerRegion[0].id }}" style="top: 416px;right: -347px;" title="{{ memberPerRegion[0].name ~ '(' ~ memberPerRegion[0].id ~')' }}">
{{ memberPerRegion[0].countMember }}
</span>
<span class="map-value" data-region-id="{{ memberPerRegion[12].id }}" style="top: 509px; right: -388px;" title="{{ memberPerRegion[12].name ~ '(' ~ memberPerRegion[12].id ~')' }}">
{{ memberPerRegion[12].countMember }}
</span>
<span class="map-value" data-region-id="{{ memberPerRegion[10].id }}" style="top: 505px; right: -204px;" title="{{ memberPerRegion[10].name ~ '(' ~ memberPerRegion[10].id ~')' }}">
{{ memberPerRegion[10].countMember }}
</span>
<span class="map-value" data-region-id="{{ memberPerRegion[9].id }}" style="top: 400px; right: -103px;" title="{{ memberPerRegion[9].name ~ '(' ~ memberPerRegion[9].id ~')' }}">
{{ memberPerRegion[9].countMember }}
</span>
<span class="map-value" data-region-id="{{ memberPerRegion[3].id }}" style="top: 285px; right: -142px;" title="{{ memberPerRegion[3].name ~ '(' ~ memberPerRegion[3].id ~')' }}">
{{ memberPerRegion[3].countMember }}
</span>
<span class="map-value" data-region-id="{{ memberPerRegion[2].id }}" style="top: 222px; right: 67px;" title="{{ memberPerRegion[2].name ~ '(' ~ memberPerRegion[2].id ~')' }}">
{{ memberPerRegion[2].countMember }}
</span>
<span class="map-value" data-region-id="{{ memberPerRegion[11].id }}" style="top: 222px; right: -19px;" title="{{ memberPerRegion[11].name ~ '(' ~ memberPerRegion[11].id ~')' }}">
{{ memberPerRegion[11].countMember }}
</span>
<span class="map-value" data-region-id="{{ memberPerRegion[4].id }}" style="top: 596px; right: -409px;" title="{{ memberPerRegion[4].name ~ '(' ~ memberPerRegion[4].id ~')' }}">
{{ memberPerRegion[4].countMember }}
</span>
{% endif %}
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-4">
<div class="card">
<div class="card-header"><h4>Adhésion sur les 3 dernières années</h4></div>
<div class="card-body">
{{ render_chart(chartMemberPerYear) }}
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="regionDetail" tabindex="-1" aria-labelledby="regionDetailLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="regionDetailLabel"></h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th>Raison sociale</th>
<th class="text-center">Action(s)</th>
</tr>
</thead>
<tbody id="region-details">
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}