diff --git a/modules/budget/includes/api/save-budget.php b/modules/budget/includes/api/save-budget.php index 17aca21..d1eef34 100644 --- a/modules/budget/includes/api/save-budget.php +++ b/modules/budget/includes/api/save-budget.php @@ -7,6 +7,28 @@ require_login(); $action = $_POST['action'] ?? ''; +// ================================================================= +// LECTURE D'UNE NOTE (AJAX) +// ================================================================= +if ($action === 'get_note') { + $noteType = $_POST['note_type'] ?? ''; + $refId = $_POST['reference_id'] ?? ''; + + try { + $stmt = $pdo->prepare("SELECT content FROM pf_notes WHERE note_type = ? AND reference_id = ?"); + $stmt->execute([$noteType, $refId]); + + // fetchColumn() renvoie false si aucune ligne n'est trouvée, on sécurise avec un coalesce (?? '') + $content = $stmt->fetchColumn(); + $content = $content !== false ? $content : ''; + + echo json_encode(['success' => true, 'content' => $content]); + } catch (Exception $e) { + echo json_encode(['success' => false, 'error' => $e->getMessage()]); + } + exit; +} + // ================================================================= // 7. SAUVEGARDE D'UNE NOTE GÉNÉRIQUE (pf_notes) // ================================================================= diff --git a/modules/budget/views/budget_prev.php b/modules/budget/views/budget_prev.php index b7f50a2..1d51310 100644 --- a/modules/budget/views/budget_prev.php +++ b/modules/budget/views/budget_prev.php @@ -333,14 +333,41 @@ if (count($parentMapping) >= 2) {