rhsaas/Vue/Ajaxselectionretrait/index.php
2026-01-21 02:57:26 +00:00

80 lines
4.8 KiB
PHP

<?php
$taxLabel = (isset($_SESSION['composanteprime']['Taxes'])) ? _($_SESSION['composanteprime']['Taxes']) : _("Taxes");
?>
<div class="table-responsive">
<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") ?></th>
<th class="text-center">Type</th>
<th class="text-center">No</th>
<th class="text-center"><?= _("Entrée") ?></th>
<th class="text-center"><?= _("Durée") ?></th>
<th class="text-center"><?= _("Durée Rist") ?></th>
<th class="text-center"><?= _("Ratio") ?></th>
<th class="text-center"><?= _("S/P") ?></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 fw-bold text-primary"><?= _("Ttc Rist") ?></th>
<th class="text-center" width="8%">
<button id="toggleAll" class="btn btn-sm btn-outline-primary fw-bold">
<?= _("Tout") ?>
</button>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($beneficiaires as $beneficiaire): ?>
<tr class="text-nowrap">
<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 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"><?= $this->nettoyer($beneficiaire['ratioNonAcquise']) ?></td>
<td class="text-center"><?= $this->nettoyer($beneficiaire['rapportsp']) ?>%</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 beneficiaire-check" type="checkbox"
value="<?= ($beneficiaire['choix'] == '1') ? '1' : '0' ?>"
<?= ($beneficiaire['choix'] == '1') ? 'checked' : '' ?>
onchange="toggleBeneficiaireSelection(this, <?= $beneficiaire['idBeneficiaire_temp'] ?>);">
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<script>
// Quand on clique sur la case "Tout"
$(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', 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");
});
</script>