From fb12a515ac5ed47927608b62dabe9c659651bfe7 Mon Sep 17 00:00:00 2001 From: KONE SOREL Date: Wed, 31 Dec 2025 08:06:35 +0000 Subject: [PATCH] Modif --- Js/fonctions.js | 86 ++++++++++-- Vue/Accueil/index.php | 5 +- Vue/Ajaxgraphiquesinistres/index.php | 192 +-------------------------- Vue/gabarit.php | 2 +- 4 files changed, 83 insertions(+), 202 deletions(-) diff --git a/Js/fonctions.js b/Js/fonctions.js index b7c6316..ecf5cc0 100755 --- a/Js/fonctions.js +++ b/Js/fonctions.js @@ -810,6 +810,7 @@ function afficher_adherents_police() function graphique_sinistre() { + // Spinner pendant le chargement $("#div_graphique").html(`
@@ -824,20 +825,46 @@ function graphique_sinistre() { type: 'get', dataType: 'json', success: function(data) { - $("#div_graphique").empty(); + console.log("Réponse JSON reçue:", data); - // Construis ton layout HTML ici - $("#div_graphique").append(` + // Layout HTML + $("#div_graphique").html(` +
+ +
-
-
-
+
+
+
+
Répartition des sinistres
+ +
+
+
+
+
+
+
Évolution mensuelle
+ +
+
+
+
+
+
+
Ratio de sinistralité
+ +
+
+
`); + // --- Graphiques Chart.js --- - // Initialise les graphiques avec Chart.js - // Graphique 1 : répartition des sinistres + // 1. Répartition new Chart(document.getElementById('claimsChart'), { type: 'bar', data: { @@ -850,7 +877,7 @@ function graphique_sinistre() { } }); - // Graphique 2 : évolution mensuelle + // 2. Évolution mensuelle new Chart(document.getElementById('claimsMonthChart'), { type: 'line', data: { @@ -872,7 +899,7 @@ function graphique_sinistre() { } }); - // Graphique 3 : ratio de sinistralité + // 3. Ratio de sinistralité new Chart(document.getElementById('lossRatioChart'), { type: 'line', data: { @@ -886,9 +913,46 @@ function graphique_sinistre() { } }); + // --- Export PDF --- + $("#exportPdfBtn").on("click", function() { + if (!window.jspdf) { + alert("Erreur : jsPDF n'est pas chargé."); + return; + } + + const { jsPDF } = window.jspdf; + const pdf = new jsPDF('p', 'mm', 'a4'); + + pdf.setFontSize(18); + pdf.text("Tableau de bord - Synthèse", 10, 20); + + // Ajout des graphiques + addChartToPdf(pdf, 'claimsChart', 'Répartition des sinistres', 40); + addChartToPdf(pdf, 'claimsMonthChart', 'Évolution mensuelle', 120); + + pdf.addPage(); + addChartToPdf(pdf, 'lossRatioChart', 'Ratio de sinistralité', 40); + + pdf.save('Tableau_de_bord.pdf'); + }); + + function addChartToPdf(pdf, canvasId, title, startY) { + const canvas = document.getElementById(canvasId); + if (canvas) { + const imgData = canvas.toDataURL('image/png', 1.0); + pdf.setFontSize(14); + pdf.text(title, 10, startY); + pdf.addImage(imgData, 'PNG', 10, startY + 5, 180, 60); + } + } }, error: function(err) { - $("#div_graphique").html(`
Impossible de charger les graphiques.
`); + console.error("Erreur AJAX:", err); + $("#div_graphique").html(` +
+ Impossible de charger les graphiques. +
+ `); } }); } \ No newline at end of file diff --git a/Vue/Accueil/index.php b/Vue/Accueil/index.php index 5520ba4..3a678aa 100644 --- a/Vue/Accueil/index.php +++ b/Vue/Accueil/index.php @@ -138,10 +138,13 @@
-
+ + +
diff --git a/Vue/Ajaxgraphiquesinistres/index.php b/Vue/Ajaxgraphiquesinistres/index.php index a79bb97..cd2e6f0 100644 --- a/Vue/Ajaxgraphiquesinistres/index.php +++ b/Vue/Ajaxgraphiquesinistres/index.php @@ -5,7 +5,7 @@
- +

@@ -17,7 +17,7 @@
-

+

@@ -29,190 +29,4 @@
-
- - - - \ No newline at end of file +
\ No newline at end of file diff --git a/Vue/gabarit.php b/Vue/gabarit.php index d967484..fbf5fe1 100755 --- a/Vue/gabarit.php +++ b/Vue/gabarit.php @@ -599,7 +599,7 @@ $activeChildId = $menuData['child']; - +