From 8c4c402f5b62c334a6fee08f54ee24585a4ff9f2 Mon Sep 17 00:00:00 2001 From: "fefe.clochette" Date: Mon, 4 May 2026 12:52:48 +0200 Subject: [PATCH] modale csv --- includes/lang/ca.php | 15 + includes/lang/fr.php | 14 + modules/budget/budget.css | 29 +- modules/budget/includes/api/manage-item.php | 14 +- modules/budget/views/budget_prev.php | 82 ----- modules/budget/views/recap.php | 123 +++++-- modules/budget/views/suivi.php | 349 +++++++++++++------- 7 files changed, 391 insertions(+), 235 deletions(-) diff --git a/includes/lang/ca.php b/includes/lang/ca.php index 51691ca..0a5c6d4 100644 --- a/includes/lang/ca.php +++ b/includes/lang/ca.php @@ -360,6 +360,21 @@ return [ 'bud_add_title' => 'Afegir', 'bud_edit_title' => 'Modificar la transacció', 'bud_to_define_js' => 'per definir', + 'bud_bar_actual' => "Actual", + 'bud_bar_theoretical' => "Teòric", + 'bud_bar_max_cap' => "Capacitat Màx.", + // --- MODULE BUDGET : IMPORT CSV --- + 'bud_import_csv' => "Importar CSV", + 'bud_csv_file' => "Seleccioneu el fitxer del vostre banc (.csv)", + 'bud_preview' => "Previsualitzar", + 'bud_validate_import' => "Si us plau, comproveu i categoritzeu les línies abans de validar.", + 'bud_assign_month' => "Mes de gestió", + 'bud_op_date' => "Data", + 'bud_amount' => "Import", + 'bud_ignore' => "Ignorar (Crèdit)", + 'bud_to_define' => "Per definir", + 'bud_is_charge' => "És un càrrec fix...", + 'bud_is_income' => "És un ingrés...", // --- BUDGET : RECAP --- 'bud_recap_monthly_title' => 'Resum Mensual', diff --git a/includes/lang/fr.php b/includes/lang/fr.php index f811541..13b28d6 100644 --- a/includes/lang/fr.php +++ b/includes/lang/fr.php @@ -361,6 +361,20 @@ return [ 'bud_add_title' => 'Ajouter', 'bud_edit_title' => 'Modifier la transaction', 'bud_to_define_js' => 'à définir', + 'bud_bar_actual' => "Actuel", + 'bud_bar_theoretical' => "Théorique", + 'bud_bar_max_cap' => "Capacité Max", + 'bud_import_csv' => "Importer CSV", + 'bud_csv_file' => "Sélectionnez le fichier de votre banque (.csv)", + 'bud_preview' => "Prévisualiser", + 'bud_validate_import' => "Veuillez vérifier et catégoriser les lignes avant validation.", + 'bud_assign_month' => "Mois de gestion", + 'bud_op_date' => "Date", + 'bud_amount' => "Montant", + 'bud_ignore' => "Ignorer (Crédit)", + 'bud_to_define' => "À définir", + 'bud_is_charge' => "Est une charge fixe...", + 'bud_is_income' => "Est un revenu...", // --- BUDGET : RECAP --- 'bud_recap_monthly_title' => 'Récapitulatif Mensuel', diff --git a/modules/budget/budget.css b/modules/budget/budget.css index e21ea7f..d273099 100644 --- a/modules/budget/budget.css +++ b/modules/budget/budget.css @@ -472,6 +472,33 @@ input[type="number"] { flex-direction: column; gap: 10px; } +/* Modale étendue pour les grands tableaux (ex: Import CSV) */ +.pf-modal-content.modal-large { + max-width: 900px; + transition: max-width 0.3s ease; +} + +/* Conteneur de tableau scrollable pour la modale */ +.import-table-wrapper { + max-height: 45vh; + overflow-y: auto; + overflow-x: auto; + -webkit-overflow-scrolling: touch; /* Fluidité sur iOS */ + background: white; + border: 1px solid #e2e8f0; + border-radius: 8px; + box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02); +} + +/* Zone de dépôt (Upload CSV) */ +.import-dropzone { + border: 2px dashed #cbd5e1; + padding: 40px 20px; + text-align: center; + border-radius: 12px; + background: #f8fafc; +} + @keyframes modalPop { from { transform: scale(0.95) translateY(10px); @@ -683,7 +710,7 @@ input[type="number"] { font-size: 0.9rem; } .prev-alloc-table td { - padding: 3px 14px; + padding: 3px 10px; border-bottom: 1px solid #f1f5f9; border-right: 1px solid #f1f5f9; white-space: nowrap; diff --git a/modules/budget/includes/api/manage-item.php b/modules/budget/includes/api/manage-item.php index 88fb6c5..a267387 100644 --- a/modules/budget/includes/api/manage-item.php +++ b/modules/budget/includes/api/manage-item.php @@ -83,9 +83,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $amount = floatval($_POST['amount'] ?? 0); $date = $_POST['date'] ?? date('Y-m-d'); - // Format attendu pour gestion_month (qui vient de input type="month") : YYYY-MM. On ajoute le jour. - $gestionMonth = $_POST['gestion_month'] ?? ''; - if (strlen($gestionMonth) === 7) $gestionMonth .= '-01'; + // 🛡️ SÉCURITÉ : Format attendu pour gestion_month (qui vient de input type="month") : YYYY-MM. + $gestionMonthRaw = $_POST['gestion_month'] ?? ''; + + // Si la valeur est vide ou '0000-00-00' + if (empty($gestionMonthRaw) || strpos($gestionMonthRaw, '0000') !== false) { + // On force le mois de gestion au 1er jour de la date de la dépense + $gestionMonth = date('Y-m-01', strtotime($date)); + } else { + // Si la valeur vient d'un input "month" (ex: "2026-04"), on rajoute "-01" + $gestionMonth = (strlen($gestionMonthRaw) === 7) ? $gestionMonthRaw . '-01' : $gestionMonthRaw; + } $label = trim($_POST['label'] ?? ''); $budgetItemId = null; diff --git a/modules/budget/views/budget_prev.php b/modules/budget/views/budget_prev.php index 4f94c1c..841ba82 100644 --- a/modules/budget/views/budget_prev.php +++ b/modules/budget/views/budget_prev.php @@ -478,88 +478,6 @@ function getTranslatedMonthName($dateString) { - -
+ @@ -275,7 +275,6 @@ $totalRevenus = 0; $m) { if($index == 0) continue; - // On injecte la valeur en français (pour la DB) mais on affiche la version traduite echo ""; } ?> @@ -292,17 +291,21 @@ $totalRevenus = 0; \ No newline at end of file diff --git a/modules/budget/views/suivi.php b/modules/budget/views/suivi.php index e1fe792..17561b3 100644 --- a/modules/budget/views/suivi.php +++ b/modules/budget/views/suivi.php @@ -100,10 +100,10 @@ if (isset($_POST['action']) && $_POST['action'] === 'save_snapshot') { exit; } -if (isset($_GET['delete_expense'])) { - $pdo->prepare("DELETE FROM pf_expenses WHERE id = ?")->execute([(int)$_GET['delete_expense']]); - - echo ""; +if (isset($_POST['action']) && $_POST['action'] === 'delete_expense') { + $pdo->prepare("DELETE FROM pf_expenses WHERE id = ?")->execute([(int)$_POST['id']]); + header('Content-Type: application/json'); + echo json_encode(['success' => true]); exit; } @@ -343,6 +343,10 @@ $monthName = $monthNames[(int)$viewM] . ' ' . $viewY;
+ + @@ -358,7 +362,7 @@ $monthName = $monthNames[(int)$viewM] . ' ' . $viewY; - +
@@ -408,107 +412,68 @@ $monthName = $monthNames[(int)$viewM] . ' ' . $viewY;
-
-
0 €
+ = 0 ? $posZero : $posActuel; + + $widthDanger = 0; $leftDanger = $posZero; + if ($solde_theorique < 0) { + $widthDanger = (abs($solde_theorique) / $range) * 100; + $leftDanger = $posTheorique; + } + ?> + +
-
- : € ℹ️ +
+ 0): ?> +
+ + +
+ + +
+
-
-
-
-
-
-
-
-
-
-
-
+
+
0 €
+ +
+
+ +
+
+ + +
+ +
+ : € ℹ️
+
- -
- -
- -
- -
-
- - -
- -
- -
- -
-

- -
- -
- - - - - - $row): - $dup = $row['is_duplicate']; $isCrd = $row['is_credit']; $dis = $dup?'disabled':''; - $bgCol = $dup ? 'opacity:0.5' : (empty($row['cat']) && !$isCrd ? 'background:#fff1f2' : ''); - ?> - - - - - - - - - - -
- onchange="checkValidation()"> - - - - - - - > - -
- - - -
-
-
-
- - -
-
- -
-
$conf): ?> @@ -547,8 +512,7 @@ $monthName = $monthNames[(int)$viewM] . ' ' . $viewY; - × - + @@ -655,7 +619,115 @@ $monthName = $monthNames[(int)$viewM] . ' ' . $viewY;
+
+
+
+

+ +
+ + +
+
+
📄
+ + +
+ +
+ + +
+ + +
+

+ +
+ +
+ + + + + + + + + + + + + $row): + $dup = $row['is_duplicate']; $isCrd = $row['is_credit']; $dis = $dup?'disabled':''; + $bgCol = $dup ? 'opacity:0.5' : (empty($row['cat']) && !$isCrd ? 'background:#fff1f2' : ''); + ?> + + + + + + + + + + +
+ onchange="checkValidation()"> + + + + + + + > + +
+ + + +
+
+
+ +
+ +
+
+ \ No newline at end of file