<?php
include '../includes/auth.php';
include '../includes/functions.php';

header('Content-Type: application/json');

if (!isset($_GET['id_event'])) {
    echo json_encode(['success' => false, 'message' => 'ID Event tidak valid']);
    exit;
}

$id_event = (int)$_GET['id_event'];

try {
    $stmt = $conn->prepare("SELECT pembuat, jabatan, nip, isi_notulen FROM dafdir_event_notulen WHERE id_event = ?");
    $stmt->bind_param("i", $id_event);
    $stmt->execute();
    $result = $stmt->get_result();
    
    if ($result->num_rows > 0) {
        $data = $result->fetch_assoc();
        echo json_encode([
            'success' => true,
            'pembuat' => $data['pembuat'],
            'jabatan' => $data['jabatan'],
            'nip' => $data['nip'],
            'isi_notulen' => $data['isi_notulen']
        ]);
    } else {
        echo json_encode([
            'success' => true,
            'pembuat' => '',
            'jabatan' => '',
            'nip' => '',
            'isi_notulen' => ''
        ]);
    }
} catch (Exception $e) {
    echo json_encode(['success' => false, 'message' => $e->getMessage()]);
}
?>