This commit is contained in:
KONE SOREL 2026-01-19 19:21:29 +00:00
parent ccb9934a1c
commit 374be79929

View File

@ -21,9 +21,10 @@
<th class="text-center"><?= _("P Nette Rist") ?></th>
<th class="text-center"><?= $taxLabel ?></th>
<th class="text-center fw-bold text-primary"><?= _("Ttc Rist") ?></th>
<th class="text-center" width="5%">
<div class="mb-1 small"><?= _("Tout") ?></div>
<input type="checkbox" id="checkAll" style="transform: scale(1.2); cursor:pointer;">
<th class="text-center" width="8%">
<button id="toggleAll" class="btn btn-sm btn-outline-primary fw-bold">
<?= _("Tout") ?>
</button>
</th>
</tr>
</thead>
@ -48,7 +49,7 @@
<td class="text-center">
<div class="form-check form-switch d-inline-block">
<input class="form-check-input" type="checkbox"
<input class="form-check-input beneficiaire-check" type="checkbox"
value="<?= ($beneficiaire['choix'] == '1') ? '1' : '0' ?>"
<?= ($beneficiaire['choix'] == '1') ? 'checked' : '' ?>
onchange="toggleBeneficiaireSelection(this, <?= $beneficiaire['idBeneficiaire_temp'] ?>);">
@ -62,20 +63,18 @@
<script>
// Quand on clique sur la case "Tout"
$(document).on('change', '#checkAll', function() {
const isChecked = $(this).is(':checked');
$(document).on('click', '#toggleAll', function() {
const allChecked = $('.beneficiaire-check').length === $('.beneficiaire-check:checked').length;
const newState = !allChecked; // si tout est coché, on décoche; sinon on coche
$('.beneficiaire-check').each(function() {
$(this).prop('checked', isChecked);
// Mettre à jour la valeur (0/1) comme dans ton onClick
this.value = isChecked ? '1' : '0';
// Appeler ta fonction métier
$(this).prop('checked', newState);
this.value = newState ? '1' : '0';
beneficiaire_a_retirer(this.value, $(this).data('id'));
});
// Mettre à jour le texte du bouton
$(this).text(newState ? "Tout désélectionner" : "Tout sélectionner");
});
// Synchroniser l'état du "Tout" si on décoche une case individuelle
$(document).on('change', '.beneficiaire-check', function() {
const allChecked = $('.beneficiaire-check').length === $('.beneficiaire-check:checked').length;
$('#checkAll').prop('checked', allChecked);
});
</script>