<?php
session_start();
header('Content-Type: application/json');
require_once '../config/auth.php';
require_once '../config/database.php';

$db = new Database();
$conn = $db->getConnection();

$stmt = $conn->query("
    SELECT u.*, g.nama_gereja 
    FROM users u 
    LEFT JOIN gereja g ON g.gembala_id = u.id 
    WHERE u.role = 'gembala' 
    ORDER BY u.id DESC
");
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);

echo json_encode(['status'=>'success','data'=>$data]);
?>