prepare("SELECT * FROM pf_salary_config WHERE year = ?"); $stmt->execute([$currentYear]); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $salaryConfig[$row['person']] = $row; } foreach (['Alex', 'Laia'] as $p) { if (!isset($salaryConfig[$p])) { $salaryConfig[$p] = ['salary'=>0, 'mensualite'=>0, 'frais_func'=>0, 'eco_perso'=>0, 'eco_family'=>0]; } } // 2. Récupération Catégories $cats = $pdo->query("SELECT * FROM pf_alloc_categories ORDER BY sort_order ASC, id ASC")->fetchAll(PDO::FETCH_ASSOC); // 3. Gestion du mois FOCUS et Navigation $focusDate = isset($_GET['focus_date']) ? $_GET['focus_date'] : date('Y-m-01'); $focusTs = strtotime($focusDate); $months = []; for ($i = 0; $i < 6; $i++) { $months[] = date('Y-m-01', strtotime("-$i months", $focusTs)); } $prevMonthLink = date('Y-m-01', strtotime("-1 month", $focusTs)); $nextMonthLink = date('Y-m-01', strtotime("+1 month", $focusTs)); // NOUVEAU : Récupération des Cycles configurés dans pf_notes $cycleConfigs = []; $stmtNotes = $pdo->query("SELECT reference_id, content FROM pf_notes WHERE note_type = 'month_config'"); while ($row = $stmtNotes->fetch(PDO::FETCH_ASSOC)) { $parts = explode('-', $row['reference_id']); if (count($parts) == 2) { $mKey = $parts[1] . '-' . $parts[0] . '-01'; $cycleConfigs[$mKey] = json_decode($row['content'], true); } } // 4. Récupération Valeurs Répartition $inQuery = implode(',', array_fill(0, count($months), '?')); $stmt = $pdo->prepare("SELECT * FROM pf_alloc_values WHERE month_date IN ($inQuery)"); $stmt->execute($months); $allocs = []; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $allocs[$row['month_date']][$row['cat_id']] = $row; } // 5. Récupération de l'ID de la catégorie système $sysCatId = null; foreach ($cats as $key => $c) { if ($c['name'] === 'SYSTEM_VALIDATION') { $sysCatId = $c['id']; unset($cats[$key]); break; } } // 6. Lecture des statuts de validation $focusDate = $months[0]; $isValidatedAlex = false; $isValidatedLaia = false; if ($sysCatId && isset($allocs[$focusDate][$sysCatId])) { $row = $allocs[$focusDate][$sysCatId]; $isValidatedAlex = ($row['amount_alex'] == 1); $isValidatedLaia = ($row['amount_laia'] == 1); } $stmtNote = $pdo->prepare("SELECT content FROM pf_notes WHERE note_type = 'budget_prev' AND reference_id = ?"); $stmtNote->execute([$focusDate]); $currentNote = $stmtNote->fetchColumn(); // 7. Récupération des vacances actives $activeHolidays = $pdo->query("SELECT id, title FROM pf_holidays WHERE status IN ('draft', 'planned', 'booked') ORDER BY start_date ASC")->fetchAll(PDO::FETCH_ASSOC); // Helper function pour les mois function getTranslatedMonthName($dateString) { $m = date('m', strtotime($dateString)); $y = date('Y', strtotime($dateString)); return tr('month_' . $m) . ' ' . $y; } ?>

'Alex', ID_LAIA => 'Laia']; foreach ($family_members as $id => $p): $d = $salaryConfig[$p]; $restant = $d['salary'] - ($d['mensualite'] + $d['frais_func'] + $d['eco_perso'] + $d['eco_family']); $borderColor = ($id === ID_ALEX) ? '#0891b2' : '#f59e0b'; ?>

()

()

0, 'amount_laia'=>0]; ?>
" . sprintf(tr('bud_sav_from_date'), $cStart) . ""; } ?>
Global Alex Laia
Total 0 0 0
(Eco Family) - 0 0
Info
0

📝

0, 'Laia' => 0]; foreach ($cats as $cat) { $t = trim($cat['target']); if (empty($t)) continue; $val = $allocs[$focusMonth][$cat['id']] ?? ['amount_alex'=>0, 'amount_laia'=>0]; if (!isset($summaryData[$t])) { $summaryData[$t] = ['Alex' => 0, 'Laia' => 0]; } $summaryData[$t]['Alex'] += $val['amount_alex']; $summaryData[$t]['Laia'] += $val['amount_laia']; } $grandTotalAlex = 0; $grandTotalLaia = 0; $grandTotalGlobal = 0; ?>
-
ALEX
LAIA
Global
0 € 0 € 0 €
0 € 0 € 0 €

0 €