Ajaxfichepolice améliorée
This commit is contained in:
parent
d03a252db0
commit
ea775d6cdd
33
Controleur/ControleurAjaxfichepolice.php
Normal file
33
Controleur/ControleurAjaxfichepolice.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
require_once 'Framework/Controleur.php';
|
||||
require_once 'Modele/Quittance.php';
|
||||
require_once 'Modele/Police.php';
|
||||
|
||||
class ControleurAjaxfichepolice extends Controleur {
|
||||
private $quittance;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->quittance = new Quittance();
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// $idPolice = $this->requete->getParametreFormulaire("idPolice");
|
||||
$idPolice = $_SESSION['idPolice_C'] ;
|
||||
$debut = $this->requete->getParametreDate("debut");
|
||||
$fin = $this->requete->getParametreDate("fin");
|
||||
|
||||
$quittances = $this->quittance->getQuittancesPolicePeriode($idPolice, $debut, $fin);
|
||||
$totalquittanceperiode = $this->quittance->getTotalQuittancePeriode($idPolice, $debut, $fin);
|
||||
|
||||
$this->genererVueAjax(
|
||||
array(
|
||||
'quittances' => $quittances,
|
||||
'totalquittanceperiode' => $totalquittanceperiode
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -497,4 +497,56 @@ function ajax_context_police_afficher(idPolice) {
|
|||
window.location.assign(racine + "Fichepolice/");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge la liste des quittances pour une police sur une période donnée.
|
||||
*/
|
||||
function afficher_quittances_police_periode() {
|
||||
// 1. Récupération des paramètres
|
||||
const racine = $("#racineWeb").val() || "/";
|
||||
const idPolice = $("#idPolice_C").val();
|
||||
const debut = $("#debut").val();
|
||||
const fin = $("#fin").val();
|
||||
const $conteneur = $("#div_quittancepolice");
|
||||
|
||||
// 2. Vérification de l'ID Police (Correction du bug numeroPolice)
|
||||
if (!idPolice || idPolice.trim() === "") {
|
||||
console.warn("Affichage quittances impossible : ID Police manquant.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. Préparation de l'interface (Loader)
|
||||
$conteneur.html(`
|
||||
<div class="text-center my-5 py-5">
|
||||
<div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
|
||||
<span class="visually-hidden">Chargement...</span>
|
||||
</div>
|
||||
<p class="mt-2 text-primary fw-bold">${_("Chargement des quittances...")}</p>
|
||||
</div>
|
||||
`);
|
||||
|
||||
// 4. Appel AJAX
|
||||
$.ajax({
|
||||
url: racine + "Ajaxfichepolice/",
|
||||
type: 'POST',
|
||||
data: {
|
||||
idPolice: idPolice,
|
||||
debut: debut,
|
||||
fin: fin
|
||||
},
|
||||
success: function(data) {
|
||||
// Injection du résultat
|
||||
$conteneur.hide().html(data).fadeIn();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
$conteneur.html(`
|
||||
<div class="alert alert-danger shadow-sm m-3">
|
||||
<i class="bi bi-exclamation-triangle-fill me-2"></i>
|
||||
${_("Erreur lors du chargement des quittances.")}
|
||||
</div>
|
||||
`);
|
||||
console.error("Erreur AJAX Quittances:", status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -14,4 +14,22 @@ class Quittance extends Modele {
|
|||
|
||||
}
|
||||
|
||||
public function getQuittancesPolicePeriode($idPolice, $debut, $fin)
|
||||
{
|
||||
$sql = 'call sp_emissions_police_periode(?, ?, ?)';
|
||||
|
||||
$quittances = $this->executerRequete($sql, array($idPolice, $debut, $fin));
|
||||
|
||||
return $quittances->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
public function getTotalQuittancePeriode($idPolice, $debut, $fin)
|
||||
{
|
||||
$sql = 'call sp_emissions_total_police_periode(?, ?, ?)';
|
||||
|
||||
$totalquittance = $this->executerRequete($sql, array($idPolice, $debut, $fin));
|
||||
|
||||
return $totalquittance->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
}
|
||||
}
|
||||
98
Vue/Ajaxfichepolice/index.php
Normal file
98
Vue/Ajaxfichepolice/index.php
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<div id="div_quittancepolice" class="mt-3">
|
||||
<div class="table-responsive shadow-sm rounded">
|
||||
<table class="table table-hover align-middle bg-white mb-0" style="font-size: 0.9rem;">
|
||||
<thead class="table-light text-nowrap">
|
||||
<tr>
|
||||
<th class="text-center" width="5%"><?= _("ID") ?></th>
|
||||
<th class="text-center"><?= _("Émission") ?></th>
|
||||
<th class="text-center"><?= _("Date") ?></th>
|
||||
<th><?= _("Libellé") ?></th>
|
||||
<th class="text-center"><?= _("Échéance") ?></th>
|
||||
<th class="text-end"><?= _("Prime TTC") ?></th>
|
||||
<th class="text-end"><?= _("Encaissé") ?></th>
|
||||
<th class="text-end"><?= _("Solde") ?></th>
|
||||
<th class="text-center" width="15%"><?= _("Actions") ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($quittances as $quittance):
|
||||
$idQuittance = $quittance['id'];
|
||||
$solde = (float)$this->nettoyer($quittance['solde']);
|
||||
// Badge de couleur pour le solde
|
||||
$soldeClass = ($solde <= 0) ? 'bg-success-soft text-success' : 'bg-danger-soft text-danger';
|
||||
?>
|
||||
<tr>
|
||||
<td class="text-center text-muted fw-bold"><?= $idQuittance ?></td>
|
||||
|
||||
<td class="text-center">
|
||||
<button class="btn btn-sm btn-outline-info px-2 py-0"
|
||||
onclick="afficher_emission(<?= $quittance['idEmission'] ?>);">
|
||||
<?= $quittance['numeroEmission'] ?>
|
||||
</button>
|
||||
</td>
|
||||
|
||||
<td class="text-center text-nowrap">
|
||||
<?= dateLang($this->nettoyer($quittance['dateEmission']), $_SESSION['lang']) ?>
|
||||
</td>
|
||||
|
||||
<td><small class="fw-semibold"><?= $this->nettoyer($quittance['libelleQuittance']) ?></small></td>
|
||||
|
||||
<td class="text-center text-nowrap">
|
||||
<span class="text-muted"><?= dateLang($this->nettoyer($quittance['datePaiement']), $_SESSION['lang']) ?></span>
|
||||
</td>
|
||||
|
||||
<td class="text-end fw-bold"><?= format_N($this->nettoyer($quittance['primeTtc'])) ?></td>
|
||||
|
||||
<td class="text-end text-success"><?= format_N($this->nettoyer($quittance['encaisse'])) ?></td>
|
||||
|
||||
<td class="text-end fw-bold <?= $soldeClass ?>">
|
||||
<?= format_N($solde) ?>
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
<div class="btn-group shadow-sm">
|
||||
<button title="<?= _("Assureur") ?>" class="btn btn-sm btn-primary" onclick="imprimer_quittance(<?= $idQuittance ?>);">
|
||||
<i class="bi bi-printer"></i>
|
||||
</button>
|
||||
<button title="<?= _("Client") ?>" class="btn btn-sm btn-outline-primary" onclick="imprimer_quittance_client(<?= $idQuittance ?>);">
|
||||
<i class="bi bi-person-badge"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
||||
<tfoot class="table-secondary fw-bold border-top-2">
|
||||
<tr>
|
||||
<td colspan="5" class="text-center text-uppercase small"><?= _("Total Période") ?></td>
|
||||
<td class="text-end"><?= format_N($totalquittanceperiode['primeTtc']) ?></td>
|
||||
<td class="text-end text-success"><?= format_N($totalquittanceperiode['encaisse']) ?></td>
|
||||
<td class="text-end text-danger"><?= format_N($totalquittanceperiode['solde']) ?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="pop_export_quittance" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-lg modal-dialog-centered">
|
||||
<div class="modal-content border-0 shadow-lg">
|
||||
<div class="modal-header bg-primary text-white">
|
||||
<h5 class="modal-title">
|
||||
<i class="bi bi-printer-fill me-2"></i><?= _("Impression de Quittance") ?>
|
||||
</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body p-0">
|
||||
<div id="div_export_quittance" class="p-3 text-center">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-light">
|
||||
<button type="button" class="btn btn-secondary px-4" data-bs-dismiss="modal"><?= _("Fermer") ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -616,7 +616,7 @@ console.groupEnd();
|
|||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
<!-- Application Scripts -->
|
||||
<script src="/Js/fonctions.js?ver=2025.12.25.16"></script>
|
||||
<script src="/Js/fonctions.js?ver=2025.12.25.17"></script>
|
||||
|
||||
<?php if (est_anglophone()): ?>
|
||||
<script src="/Js/datepicker-eng.js"></script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user