newdesigngestionnaire/Vue/Ajaxfiltretabproduit/index.php
2026-04-04 17:09:35 +00:00

113 lines
6.8 KiB
PHP
Executable File

<?php
$superUser = $_SESSION['superUser'];
$nbreTotal = count($produits);
$displayTotal = ($nbreTotal < 10) ? '0'.$nbreTotal : format_N($nbreTotal);
?>
<div class="animate__animated animate__fadeIn">
<div class="d-flex justify-content-end mb-3">
<span class="badge bg-white border text-primary rounded-pill px-3 py-2 shadow-xs">
<i class="fas fa-layer-group me-2"></i><?= _("Total enregistré :") ?> <span class="fw-bold"><?= $displayTotal ?></span>
</span>
</div>
<input type="hidden" id="total" value="<?= $displayTotal ?>">
<div class="card border-0 shadow-sm">
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover align-middle mb-0 datatable-produits" style="width:100%; font-size: 9.5pt;">
<thead class="bg-light">
<tr>
<th class="py-3 ps-3" width="10%"><?= _("Code") ?></th>
<th class="py-3"><?= _("Libellé du Produit") ?></th>
<th class="py-3 text-center"><?= _("Mode Calcul Prime") ?></th>
<th class="py-3 text-center" width="200px"><?= _("Actions") ?></th>
<th class="py-3 text-center" width="120px"><?= _("Garanties") ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($produits as $produit):
$idProduit = $this->nettoyer($produit['id']);
$codeModecalculPrime = $this->nettoyer($produit['codeModecalculPrime']);
$libelleProduit = est_anglophone() ? $this->nettoyer($produit['libelleEng']) : $this->nettoyer($produit['libelle']);
$modeprime = est_anglophone() ? $this->nettoyer($produit['modeprimeEng']) : $this->nettoyer($produit['modeprime']);
$isArchive = ($this->nettoyer($produit['produitArchive']) == '1');
$dansBareme = $this->nettoyer($produit['dansBareme']);
$aGarantie = ($this->nettoyer($produit['aGarantie']) == '1');
// Style spécifique pour les types 'TA'
$rowClass = ($codeModecalculPrime == 'TA') ? 'bg-warning-ghost' : '';
?>
<tr class="<?= $rowClass ?>">
<td class="ps-3 fw-bold text-primary"><?= $this->nettoyer($produit['codeProduit']) ?></td>
<td>
<div class="fw-bold"><?= $libelleProduit ?></div>
<?php if($isArchive): ?>
<span class="badge bg-danger-light text-danger" style="font-size: 7pt;"><?= _("ARCHIVÉ") ?></span>
<?php endif; ?>
</td>
<td class="text-center">
<span class="badge bg-light text-dark border fw-normal px-2"><?= $modeprime ?></span>
</td>
<td class="text-center">
<div class="btn-group shadow-xs rounded-pill bg-white border p-1">
<?php if($isArchive): ?>
<button class="btn btn-link btn-sm text-info p-1 mx-2 action-icon" title="<?= _("Consulter") ?>" onclick="consulter_produit(<?= $idProduit ?>);">
<i class="fas fa-search"></i>
</button>
<?php if ($superUser == "1"): ?>
<button class="btn btn-link btn-sm text-danger p-1 mx-2 action-icon" title="<?= _("Désarchiver") ?>" onclick="de_archiver_produit('<?= $idProduit ?>', '<?= $dansBareme ?>');">
<i class="fas fa-box-open"></i>
</button>
<?php endif; ?>
<?php else: ?>
<button class="btn btn-link btn-sm text-warning p-1 mx-2 action-icon" title="<?= _("Modifier") ?>" onclick="modifier_produit(<?= $idProduit ?>);">
<i class="fas fa-edit"></i>
</button>
<?php if($aGarantie == '1'): ?>
<button class="btn btn-link btn-sm text-primary p-1 mx-2 action-icon" title="<?= _("Archiver") ?>" onclick="archiver_produit('<?= $idProduit ?>');">
<i class="fas fa-archive"></i>
</button>
<?php endif; ?>
<?php endif; ?>
</div>
</td>
<td class="text-center">
<?php if($isArchive): ?>
<button class="btn btn-info btn-sm rounded-pill shadow-xs w-100" style="font-size: 8pt;" onclick="garanties_produit(<?= $idProduit ?>);">
<i class="fas fa-list-check me-1"></i> <?= _("Consulter") ?>
</button>
<?php else: ?>
<button class="btn btn-warning btn-sm rounded-pill shadow-xs w-100" style="font-size: 8pt;" onclick="garanties_produit(<?= $idProduit ?>);">
<i class="fas fa-list-check me-1"></i> <?= _("Gérer") ?>
</button>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<style>
.bg-warning-ghost { background-color: rgba(255, 239, 213, 0.4) !important; }
.bg-danger-light { background-color: rgba(220, 53, 69, 0.1); }
.btn-link { text-decoration: none; border: none; background: transparent; transition: all 0.2s; }
.action-icon:hover { transform: scale(1.2); }
</style>
<script>
var checkDTProd = setInterval(function() {
if (typeof initSmartTable === 'function') {
initSmartTable('.datatable-produits', 'Liste_Produits_Garant', false);
clearInterval(checkDTProd);
}
}, 100);
</script>