<?php
require_once 'config.php';
require_once 'functions.php';

$center_id = isset($_GET['center_id']) ? (int)$_GET['center_id'] : 0;

if ($center_id > 0) {
    $stmt = $conn->prepare("SELECT teacher_id, first_name, last_name FROM teachers WHERE center_id = ? AND status = 'active' ORDER BY first_name, last_name");
    $stmt->bind_param("i", $center_id);
    $stmt->execute();
    $result = $stmt->get_result();
    
    $teachers = [];
    while ($row = $result->fetch_assoc()) {
        $teachers[] = $row;
    }
    
    header('Content-Type: application/json');
    echo json_encode($teachers);
} else {
    header('Content-Type: application/json');
    echo json_encode([]);
}
?>