feat: implement global pricing model, optional equipment contribution, and bulk save for dotations

This commit is contained in:
2026-05-20 19:00:10 +02:00
parent 2a116b1e02
commit 1af0e177d5
12 changed files with 247 additions and 50 deletions
@@ -156,32 +156,39 @@
<th class="py-3 px-4 font-medium">Catégorie</th>
<th class="py-3 px-4 font-medium">N° Licence</th>
<th class="py-3 px-4 font-medium">État</th>
<th class="py-3 px-4 font-medium">Tarif Global</th>
<th class="py-3 px-4 font-medium">Reste à Payer</th>
<th class="py-3 px-4 font-medium text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 text-sm">
<tr th:if="${#lists.isEmpty(licences)}">
<td colspan="6" class="py-4 px-4 text-center text-gray-500">Aucune licence enregistrée.</td>
<td colspan="7" class="py-4 px-4 text-center text-gray-500">Aucune licence enregistrée.</td>
</tr>
<th:block th:each="lic : ${licences}">
<tr class="hover:bg-gray-50 border-b border-gray-100">
<td class="py-4 px-4 font-medium text-gray-900" th:text="${lic.saison}">2024-2025</td>
<td class="py-4 px-4 text-gray-600" th:text="${lic.categorie.nom}">U15</td>
<td class="py-4 px-4 text-gray-600">
<span th:text="${lic.categorie.nom}">U15</span>
<span class="text-[10px] text-gray-400 block" th:text="${(lic.adherent != null && lic.adherent.residentTalange ? lic.categorie.tarifBase : lic.categorie.tarifExterieur) + ' € (Catégorie)'}">100.00 € (Catégorie)</span>
</td>
<td class="py-4 px-4 text-gray-600 font-mono text-xs" th:text="${lic.numeroLicence != null and !lic.numeroLicence.isEmpty() ? lic.numeroLicence : '-'}">-</td>
<td class="py-4 px-4">
<span class="px-2 py-1 text-xs font-semibold rounded-full"
th:classappend="${lic.etat == 'Validée' ? 'bg-blue-100 text-blue-800' : (lic.etat == 'Payée' ? 'bg-green-100 text-green-800' : 'bg-yellow-100 text-yellow-800')}"
th:text="${lic.etat}">Brouillon</span>
</td>
<td class="py-4 px-4 text-gray-600 font-medium" th:text="${lic.getResteAPayer() + ' €'}">100.00 €</td>
<td class="py-4 px-4 text-gray-900 font-medium" th:text="${lic.getPrixTotal() + ' €'}">130.00 €</td>
<td class="py-4 px-4 font-semibold"
th:classappend="${lic.getResteAPayer() == 0 ? 'text-green-600' : 'text-red-600'}"
th:text="${lic.getResteAPayer() + ' €'}">30.00 €</td>
<td class="py-4 px-4 text-right">
<button th:if="${lic.getResteAPayer() > 0}" th:onclick="'openPaiementModal(' + ${lic.id} + ', ' + ${lic.getResteAPayer()} + ')'"
class="text-green-600 hover:text-green-800 font-medium bg-green-50 px-3 py-1 rounded-lg">Payer</button>
</td>
</tr>
<tr th:if="${!#lists.isEmpty(lic.paiements)}" class="bg-gray-50/50">
<td colspan="6" class="py-2 px-4">
<td colspan="7" class="py-2 px-4">
<div class="text-xs text-gray-500 mb-1 font-medium uppercase tracking-wider">Historique des paiements</div>
<div class="flex flex-wrap gap-2">
<span th:each="paiement : ${lic.paiements}" class="inline-flex items-center px-2.5 py-0.5 rounded-md text-xs font-medium bg-white border border-gray-200 text-gray-700">
@@ -195,48 +202,74 @@
</td>
</tr>
<tr class="bg-gray-50/30">
<td colspan="6" class="py-3 px-4 border-t border-gray-100">
<div class="text-xs text-gray-500 font-medium uppercase tracking-wider mb-2">Dotations Équipements</div>
<div th:if="${#lists.isEmpty(lic.dotations)}" class="text-xs text-gray-500 italic">Aucune dotation pour cette licence.</div>
<div th:if="${!#lists.isEmpty(lic.dotations)}" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4">
<div th:each="dot : ${lic.dotations}" class="bg-white p-3 rounded-lg border border-gray-200 shadow-sm flex flex-col justify-between">
<div>
<div class="flex justify-between items-start mb-1 gap-1">
<span class="font-semibold text-xs text-gray-800 truncate" th:text="${dot.equipement.nom}">Maillot</span>
<span class="text-[9px] px-1.5 py-0.5 rounded-full font-bold flex-shrink-0"
th:classappend="${dot.equipement.obligatoire ? 'bg-red-50 text-red-700 border border-red-100' : 'bg-gray-50 text-gray-600 border border-gray-100'}"
th:text="${dot.equipement.obligatoire ? 'Obligatoire' : 'Facultatif'}">Obligatoire</span>
<td colspan="7" class="py-3 px-4 border-t border-gray-100">
<form th:action="@{/dotations/bulk}" method="post">
<input type="hidden" name="adherentId" th:value="${adherent.id}">
<div class="flex justify-between items-center mb-3">
<div class="text-xs text-gray-500 font-medium uppercase tracking-wider">Dotations Équipements</div>
<button th:if="${!#lists.isEmpty(lic.dotations)}" type="submit"
class="bg-blue-600 hover:bg-blue-700 text-white text-xs px-3 py-1.5 rounded-lg font-semibold shadow-sm transition-colors flex items-center space-x-1">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
</svg>
<span>Enregistrer les dotations</span>
</button>
</div>
<div th:if="${#lists.isEmpty(lic.dotations)}" class="text-xs text-gray-500 italic">Aucune dotation pour cette licence.</div>
<div th:if="${!#lists.isEmpty(lic.dotations)}" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4">
<div th:each="dot : ${lic.dotations}" class="bg-white p-3 rounded-lg border border-gray-200 shadow-sm flex flex-col justify-between">
<input type="hidden" name="dotationIds" th:value="${dot.id}">
<div>
<div class="flex justify-between items-start mb-1 gap-1">
<span class="font-semibold text-xs text-gray-800 truncate" th:text="${dot.equipement.nom}">Maillot</span>
<span class="text-[9px] px-1.5 py-0.5 rounded-full font-bold flex-shrink-0"
th:classappend="${dot.equipement.obligatoire ? 'bg-red-50 text-red-700 border border-red-100' : 'bg-gray-50 text-gray-600 border border-gray-100'}"
th:text="${dot.equipement.obligatoire ? 'Obligatoire' : 'Facultatif'}">Obligatoire</span>
</div>
<div class="text-[10px] text-gray-400 mb-2 truncate" th:title="${dot.equipement.description}" th:text="${dot.equipement.description != null and !dot.equipement.description.isEmpty() ? dot.equipement.description : 'Pas de description'}">Description</div>
</div>
<div class="text-[10px] text-gray-400 mb-2 truncate" th:title="${dot.equipement.description}" th:text="${dot.equipement.description != null and !dot.equipement.description.isEmpty() ? dot.equipement.description : 'Pas de description'}">Description</div>
</div>
<!-- Formulaire pour mettre à jour la Dotation -->
<form th:action="@{/dotations/{id}(id=${dot.id})}" method="post" class="space-y-2 pt-2 border-t border-gray-100">
<input type="hidden" name="adherentId" th:value="${adherent.id}">
<div class="grid grid-cols-2 gap-1.5">
<div>
<label class="block text-[9px] uppercase font-bold text-gray-400">Taille</label>
<input type="text" name="taille" th:value="${dot.taille}" placeholder="S, M, L..."
class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 focus:ring-1 focus:ring-blue-500 outline-none">
<!-- Form inputs for bulk updating -->
<div class="space-y-2 pt-2 border-t border-gray-100">
<!-- Choisi checkbox for optional equipment -->
<div class="flex items-center mb-1.5 bg-blue-50/50 p-1.5 rounded border border-blue-100/50" th:if="${!dot.equipement.obligatoire}">
<label class="flex items-center space-x-1.5 cursor-pointer select-none">
<input type="checkbox" th:name="'choisi_' + ${dot.id}" th:checked="${dot.choisi}" class="w-3.5 h-3.5 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
<span class="text-[10px] font-bold text-blue-800 uppercase tracking-wide" th:text="'Commander (+ ' + ${dot.equipement.prixContribution} + ' €)'">Commander (+ 30 €)</span>
</label>
</div>
<div class="grid grid-cols-2 gap-1.5 mb-1.5">
<div>
<label class="block text-[9px] uppercase font-bold text-gray-400">Taille</label>
<input type="text" th:name="'taille_' + ${dot.id}" th:value="${dot.taille}" placeholder="S, M, L..."
class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 focus:ring-1 focus:ring-blue-500 outline-none">
</div>
<div>
<label class="block text-[9px] uppercase font-bold text-gray-400">Numéro</label>
<input type="text" th:name="'numero_' + ${dot.id}" th:value="${dot.numero}" placeholder="Ex: 10"
class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 focus:ring-1 focus:ring-blue-500 outline-none">
</div>
</div>
<div>
<label class="block text-[9px] uppercase font-bold text-gray-400">Flocage</label>
<input type="text" name="flocage" th:value="${dot.flocage}" placeholder="N°/Nom"
<input type="text" th:name="'flocage_' + ${dot.id}" th:value="${dot.flocage}" placeholder="Nom du joueur"
class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 focus:ring-1 focus:ring-blue-500 outline-none">
</div>
<div class="flex items-center pt-1.5">
<label class="flex items-center space-x-1 cursor-pointer select-none">
<input type="checkbox" th:name="'fourni_' + ${dot.id}" th:checked="${dot.fourni}" class="w-3.5 h-3.5 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
<span class="text-[11px] text-gray-700">Fourni</span>
</label>
</div>
</div>
<div class="flex justify-between items-center pt-1.5">
<label class="flex items-center space-x-1 cursor-pointer select-none">
<input type="checkbox" name="fourni" th:checked="${dot.fourni}" class="w-3.5 h-3.5 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
<span class="text-[11px] text-gray-700">Fourni</span>
</label>
<button type="submit" class="bg-blue-50 text-blue-600 hover:bg-blue-100 text-[10px] px-2 py-0.5 rounded font-bold transition-colors">
Sauver
</button>
</div>
</form>
</div>
</div>
</div>
</form>
</td>
</tr>
</th:block>
@@ -257,7 +290,7 @@
<label class="block text-sm font-medium text-gray-700 mb-1">Catégorie</label>
<select name="categorieId" required class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none">
<option value="">Sélectionnez une catégorie...</option>
<option th:each="cat : ${categories}" th:value="${cat.id}" th:text="${cat.nom} + ' (' + ${cat.tarifBase} + ' €)'"></option>
<option th:each="cat : ${categories}" th:value="${cat.id}" th:text="${cat.nom} + ' (Talange: ' + ${cat.tarifBase} + ' € / Ext: ' + ${cat.tarifExterieur} + ' €)'"></option>
</select>
</div>
<div>
@@ -44,6 +44,12 @@
<textarea th:field="*{description}" rows="3" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none"></textarea>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Prix de contribution (€) - Pour équipement facultatif</label>
<input type="number" step="0.01" th:field="*{prixContribution}" required class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none">
<p class="text-xs text-gray-500 mt-1">Si l'équipement est facultatif, ce montant sera ajouté au tarif global de la licence s'il est commandé.</p>
</div>
<div class="flex items-center space-x-3">
<input type="checkbox" id="obligatoire" th:field="*{obligatoire}" class="w-5 h-5 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
<label for="obligatoire" class="text-sm font-medium text-gray-700">
@@ -44,12 +44,13 @@
<th class="py-3 px-6 font-medium text-left">Nom de l'équipement</th>
<th class="py-3 px-6 font-medium text-left">Description</th>
<th class="py-3 px-6 font-medium text-center">Obligatoire</th>
<th class="py-3 px-6 font-medium text-center">Prix Contribution</th>
<th class="py-3 px-6 font-medium text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 text-sm">
<tr th:if="${#lists.isEmpty(equipements)}">
<td colspan="4" class="py-8 text-center text-gray-500">Aucun équipement n'est paramétré.</td>
<td colspan="5" class="py-8 text-center text-gray-500">Aucun équipement n'est paramétré.</td>
</tr>
<tr th:each="equip : ${equipements}" class="hover:bg-gray-50 transition-colors">
<td class="py-4 px-6 font-medium text-gray-900" th:text="${equip.nom}">Maillot</td>
@@ -59,6 +60,7 @@
th:classappend="${equip.obligatoire ? 'bg-red-100 text-red-800' : 'bg-gray-100 text-gray-800'}"
th:text="${equip.obligatoire ? 'Oui' : 'Non'}">Oui</span>
</td>
<td class="py-4 px-6 text-center font-medium text-gray-700" th:text="${equip.obligatoire ? 'Inclus' : (equip.prixContribution + ' €')}">30 €</td>
<td class="py-4 px-6 text-right flex justify-end space-x-3 items-center">
<a th:href="@{/equipements/{id}/edit(id=${equip.id})}" class="text-indigo-600 hover:text-indigo-900 font-medium bg-indigo-50 px-3 py-1 rounded-lg">Modifier</a>
<form th:action="@{/equipements/{id}/delete(id=${equip.id})}" method="post" onsubmit="return confirm('Supprimer cet équipement ? Cela supprimera également les dotations associées de toutes les licences.');">