{% extends 'layout.twig' %}

{% block body %}

	<div class="contenu clearfix">

		<h1>{{ 'Gestion des délégations' | trad }}</h1>

		{% include '@Delegation/Common/SubNavbar.twig' 
            with {
                absenceDelegations: absenceDelegations, 
                permanentDelegations: permanentDelegations, 
                items: []
            } only
        %}


		<h2>{{ 'Déléguer votre signature' | trad }}</h2>

		<div id="genetableau">
			<center>
				<div>
					<form method="POST" id='listeDelegations'>
						<table class="table" id="tableau">
							<thead class="thead-dark">
								<tr>
									<th>{{ triTable('DELEG', post.tri_DELEG, 'Délégataire' | trad, 'genetableau', 
                                        path('Delegation.AbsenceDelegation.index'), 'listeDelegations') }}</th>
									<th>{{ triTable('DTE_DEB', post.tri_DTE_DEB, 'Date de début' | trad, 'genetableau', 
                                        path('Delegation.AbsenceDelegation.index'), 'listeDelegations') }}</th>
									<th>{{ triTable('DTE_FIN', post.tri_DTE_FIN, 'Date de fin' | trad, 'genetableau', 
                                        path('Delegation.AbsenceDelegation.index'), 'listeDelegations') }}</th>
									<th width='60px'>
										<a class="ajouter_blanc_v2" href="{{ path('Delegation.AbsenceDelegation.create') }}" style="float: right;">
                                        </a>
									</th>
								</tr>
							</thead>
							<tbody>
								{% for delegation in absenceDelegations %}
									<tr id="delegation{{ loop.index }}">
										<td>{{ convertLibelleGlobal('Hastutil', '', delegation.DELEG, true) }}</td>
										<td>{{ delegation.DTE_DEB | dateTrad }}</td>
										<td>{{ delegation.DTE_FIN | dateTrad }}</td>
										<td class="no_parametrage">
											<a
												href="javascript:void(0)"
												class="action-hover Supprimer_v2"
												onclick="deleteItem('{{ path( 'Delegation.AbsenceDelegation.delete', 
                                                    {deleg: delegation.DELEG, debut: delegation.DTE_DEB} ) }}');">
                                            </a>
											<a class="action-hover modifier_v2" 
                                                href="{{ path( 'Delegation.AbsenceDelegation.edit', 
                                                    {deleg: delegation.DELEG, debut: delegation.DTE_DEB} ) }}">
                                            </a>
										</td>
									</tr>
								{% endfor %}
							</tbody>
						</table>
					</form>
				</div>
			</center>
		</div>
	</div>
    <script>
        function deleteItem(urlConfirm) {
            activeLoader();
            var urlPopup = {{ path(
                'Ajax.Erreur.popupConfirmationSuppresion'
            ) | json }};
            var alert = {{ 'Confirmez-vous la suppression de la délégation ?' | trad | json }};

            popupConfirmation(
                urlPopup, 
                '', 
                urlConfirm, 
                alert, 
                'page'
            )
        }
    </script>
{% endblock %}
