<?php
/**
 * SISPENRA - API: Get Siswa by Kelas
 */
require_once '../includes/functions.php';
requireLogin();
header('Content-Type: application/json');

$kelasId = intval($_GET['kelas_id'] ?? 0);
if (!$kelasId) { echo json_encode(['error' => 'kelas_id required']); exit; }

$siswas = db_fetchAll("SELECT id, nis, nama, jenis_kelamin FROM siswa WHERE kelas_id = ? AND status = 'aktif' ORDER BY nama", [$kelasId]);
echo json_encode(['data' => $siswas, 'total' => count($siswas)]);
