query("SELECT * FROM pf_budget_items ORDER BY category DESC, sort_order ASC, name ASC"); $items = $stmt->fetchAll(); // 2. Déterminer quel est le mois de gestion "ouvert" par défaut $stmtActive = $pdo->query("SELECT content FROM pf_notes WHERE note_type = 'active_gestion_month' LIMIT 1"); $defaultActiveMonth = $stmtActive->fetchColumn(); if (!$defaultActiveMonth) { $defaultActiveMonth = date('Y-m-01'); } // 3. Assigner le mois et l'année en fonction du mois ouvert $currentMonth = isset($_GET['m']) ? str_pad((int)$_GET['m'], 2, '0', STR_PAD_LEFT) : date('m', strtotime($defaultActiveMonth)); $currentYear = isset($_GET['y']) ? (int)$_GET['y'] : date('Y', strtotime($defaultActiveMonth)); $viewMonthDate = "$currentYear-$currentMonth-01"; $sqlReal = "SELECT budget_item_id, SUM(amount) as total_real FROM pf_expenses WHERE gestion_month = ? AND budget_item_id IS NOT NULL GROUP BY budget_item_id"; $stmtReal = $pdo->prepare($sqlReal); $stmtReal->execute([$viewMonthDate]); $realTotals = $stmtReal->fetchAll(PDO::FETCH_KEY_PAIR); // Retourne un tableau [id => total] $sqlCatReal = "SELECT category, SUM(amount) as total_real FROM pf_expenses WHERE gestion_month = ? AND budget_item_id IS NULL GROUP BY category"; $stmtCatReal = $pdo->prepare($sqlCatReal); $stmtCatReal->execute([$viewMonthDate]); $catTotals = $stmtCatReal->fetchAll(PDO::FETCH_KEY_PAIR); $stmtLabels = $pdo->prepare("SELECT label, amount FROM pf_expenses WHERE gestion_month = ? AND budget_item_id IS NULL"); $stmtLabels->execute([$viewMonthDate]); $unlinkedExpenses = $stmtLabels->fetchAll(PDO::FETCH_ASSOC); $moisFr = ['', 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre']; $monthTranslationKey = 'month_' . str_pad((int)$currentMonth, 2, '0', STR_PAD_LEFT); $currentMonthName = tr($monthTranslationKey) . ' ' . $currentYear; $totalDepenses = 0; $totalRevenus = 0; ?>

= ($targetAbs - 0.10))); $rowClass = ($item['category'] === 'income') ? 'row-income' : 'row-expense'; if ($item['is_estimate']) $rowClass .= ' row-estimate'; ?>
()
('.tr('bud_est_short').')' : '' ?> 🔗
📅
0.05): ?>
: +
:
/
+
-
€ /

*