query("SELECT code, label, icon, type FROM pf_budget_categories ORDER BY type DESC, label ASC"); $dbCategories = $stmtCats->fetchAll(PDO::FETCH_ASSOC); // 2. Récupération des Salaires/Mensualités configurés (Revenus automatiques) $currentYear = isset($_GET['y']) ? (int)$_GET['y'] : date('Y'); $stmtSalaries = $pdo->prepare("SELECT person, mensualite FROM pf_salary_config WHERE year = ?"); $stmtSalaries->execute([$currentYear]); $salaries = $stmtSalaries->fetchAll(PDO::FETCH_ASSOC); // 3. Récupération des Items du Budget (Charges Fixes et Estimations) $stmt = $pdo->query("SELECT * FROM pf_budget_items ORDER BY is_estimate ASC, sort_order ASC, name ASC"); $items = $stmt->fetchAll(PDO::FETCH_ASSOC); // 4. Gestion du mois actif $stmtActive = $pdo->query("SELECT content FROM pf_notes WHERE note_type = 'active_gestion_month' LIMIT 1"); $defaultActiveMonth = $stmtActive->fetchColumn() ?: date('Y-m-01'); $currentMonth = isset($_GET['m']) ? str_pad((int)$_GET['m'], 2, '0', STR_PAD_LEFT) : date('m', strtotime($defaultActiveMonth)); $viewMonthDate = "$currentYear-$currentMonth-01"; // 5. Récupération du Réel (Dépenses) $stmtReal = $pdo->prepare("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->execute([$viewMonthDate]); $realTotals = $stmtReal->fetchAll(PDO::FETCH_KEY_PAIR); $stmtCatReal = $pdo->prepare("SELECT category, SUM(amount) as total_real FROM pf_expenses WHERE gestion_month = ? AND budget_item_id IS NULL GROUP BY category"); $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']; $currentMonthName = tr('month_' . str_pad((int)$currentMonth, 2, '0', STR_PAD_LEFT)) . ' ' . $currentYear; $totalDepenses = 0; $totalRevenus = 0; ?>

= ($targetAbs - 0.10))); $rowClass = 'row-expense' . ($item['is_estimate'] ? ' row-estimate' : ''); ?>
()
Apport ⚙️ + Fixe (Auto) -
Auto
Via Paramètres
(Variable)' : '' ?> 🔗 - 0.05): ?>
Dépassé : +
Reste :
Atteint ✓
/mois
Validé
Partiel
En attente
Total Revenus Lissés +
Total Dépenses & Estimations -
Reste à Vivre (Équilibre) € / mois