This commit is contained in:
KONE SOREL 2026-01-19 19:03:31 +00:00
parent a62bc10dfb
commit d5d5df3664
2 changed files with 46 additions and 38 deletions

View File

@ -5382,23 +5382,3 @@ function ControlerEcheanceRen()
}
}
}
/**
* Gère le changement d'état du switch dans le tableau
*/
function toggleBeneficiaireSelection(checkbox, id) {
// On met à jour la valeur interne
const newValue = checkbox.checked ? '1' : '0';
checkbox.value = newValue;
// Appel de votre fonction métier existante
beneficiaire_a_retirer(newValue, id);
// Optionnel : On peut ajouter un effet visuel sur la ligne
const row = $(checkbox).closest('tr');
if (checkbox.checked) {
row.addClass('table-info');
} else {
row.removeClass('table-info');
}
}

View File

@ -3,11 +3,11 @@
?>
<div class="table-responsive">
<table class="table table-striped table-hover align-middle border tabspeciale compact" style="width:100%; font-size:8pt;">
<table class="table table-striped table-bordered table-hover align-middle mb-0 tabspeciale compact" style="font-size:8pt; width:100%;">
<thead class="text-nowrap">
<tr>
<th class="text-center small"><?= _("Cat") ?></th>
<th class="text-start"><?= _("Nom & Prénoms") ?></th>
<th class="text-start"><?= _("Nom") ?></th>
<th class="text-center">Type</th>
<th class="text-center">No</th>
<th class="text-center"><?= _("Entrée") ?></th>
@ -15,40 +15,68 @@
<th class="text-center"><?= _("Dur Rist") ?></th>
<th class="text-center"><?= _("Ratio") ?></th>
<th class="text-center"><?= _("S/P") ?></th>
<th class="text-center"><?= _("P. Non Acquise") ?></th>
<th class="text-center"><?= _("P. Nette Rist") ?></th>
<th class="text-center"><?= _("P Nette An") ?></th>
<th class="text-center"><?= _("Ttc An") ?></th>
<th class="text-center fw-bold text-danger"><?= _("P Non Acquise") ?></th>
<th class="text-center"><?= _("P Nette Rist") ?></th>
<th class="text-center"><?= $taxLabel ?></th>
<th class="text-center"><?= _("Ttc Rist") ?></th>
<th class="text-center no-export" width="5%"><?= _("Choix") ?></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>
</tr>
</thead>
<tbody>
<?php foreach ($beneficiaires as $beneficiaire): ?>
<tr class="text-nowrap">
<td class="text-center"><?= $this->nettoyer($beneficiaire['codeProduit']) ?></td>
<td class="text-center small"><?= $this->nettoyer($beneficiaire['codeProduit']) ?></td>
<td class="text-start fw-bold"><?= $this->nettoyer($beneficiaire['nomBeneficiaire']) ?></td>
<td class="text-center"><?= $this->nettoyer($beneficiaire['codeLienParente']) ?></td>
<td class="text-center text-muted small"><?= $this->nettoyer($beneficiaire['numeroBeneficiaire']) ?></td>
<td class="text-center small"><?= $this->nettoyer($beneficiaire['codeLienParente']) ?></td>
<td class="text-center text-muted"><?= $this->nettoyer($beneficiaire['numeroBeneficiaire']) ?></td>
<td class="text-center"><?= dateLang($this->nettoyer($beneficiaire['dateEntree']), $_SESSION['lang']) ?></td>
<td class="text-center"><?= $this->nettoyer($beneficiaire['duree']) ?></td>
<td class="text-center"><?= $this->nettoyer($beneficiaire['duree_non_acquise']) ?></td>
<td class="text-center small"><?= $this->nettoyer($beneficiaire['ratioNonAcquise']) ?></td>
<td class="text-center"><?= $this->nettoyer($beneficiaire['ratioNonAcquise']) ?></td>
<td class="text-center"><?= $this->nettoyer($beneficiaire['rapportsp']) ?>%</td>
<td class="text-center fw-bold text-danger"><?= format_N($this->nettoyer($beneficiaire['primeNonAcquise'])) ?></td>
<td class="text-center"><?= format_N($this->nettoyer($beneficiaire['primeNetteStat_an'])) ?></td>
<td class="text-center"><?= format_N($this->nettoyer($beneficiaire['primeTtc_an'])) ?></td>
<td class="text-center fw-bold text-danger"><?= format_N($this->nettoyer($beneficiaire['primeNonAcquise'])) ?></td>
<td class="text-center"><?= format_N($this->nettoyer($beneficiaire['primeHt'])) ?></td>
<td class="text-center"><?= format_N($this->nettoyer($beneficiaire['taxe'])) ?></td>
<td class="text-center fw-bold text-primary"><?= format_N($this->nettoyer($beneficiaire['primeTtc'])) ?></td>
<td class="text-center">
<div class="form-check form-switch d-inline-block">
<input class="form-check-input" type="checkbox"
value="<?= ($beneficiaire['choix'] == '1') ? '1' : '0' ?>"
<?= ($beneficiaire['choix'] == '1') ? 'checked' : '' ?>
onchange="toggleBeneficiaireSelection(this, <?= $beneficiaire['idBeneficiaire_temp'] ?>);">
</div>
<input type="checkbox"
class="beneficiaire-check"
data-id="<?= $beneficiaire['idBeneficiaire_temp'] ?>"
style="transform: scale(1.2); cursor:pointer;"
<?= ($beneficiaire['choix'] == '1') ? 'checked' : '' ?>
value="<?= ($beneficiaire['choix'] == '1') ? '1' : '0' ?>"
onClick="javascript:if(this.value=='1'){this.value='0'}else{this.value='1'}; beneficiaire_a_retirer(this.value, <?= $beneficiaire['idBeneficiaire_temp'] ?>);">
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<script>
// Quand on clique sur la case "Tout"
$(document).on('change', '#checkAll', function() {
const isChecked = $(this).is(':checked');
$('.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
beneficiaire_a_retirer(this.value, $(this).data('id'));
});
});
// 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>