<?php
session_start();
header('Content-Type: application/json');
if(!isset($_SESSION['user_id']) || $_SESSION['role']!= 'admin_dpw') die(json_encode(['status'=>false]));

include '../config/database.php';
$db = new Database();
$conn = $db->getConnection();

$gereja_id = $_GET['gereja_id'] ?? 0;
$data = $conn->prepare("SELECT id, nama_lengkap, no_hp FROM jemaat WHERE gereja_id=? AND status='Aktif' ORDER BY nama_lengkap");
$data->execute([$gereja_id]);
echo json_encode(['status'=>true, 'data'=>$data->fetchAll(PDO::FETCH_ASSOC)]);
?>