<?php
// Include database connection
require("../../includes/config.php");


// Set header for JSON response
header("Content-Type: application/json");
// Get the fee type ID from the request
$fee_type_id = $_GET['id'] ?? null;

$response = array('status' => '', 'message' => '', 'data' => null);

if ($fee_type_id) {
    try {
        // Prepare the SQL query to get the fee type amount
        $sql = "SELECT amount FROM fee_types WHERE id = :id";
        $stmt = $pdo->prepare($sql);
        $stmt->bindParam(':id', $fee_type_id, PDO::PARAM_INT);
        $stmt->execute();

        // Fetch the fee type amount
        $fee_type = $stmt->fetch(PDO::FETCH_ASSOC);

        if ($fee_type) {
            $response['status'] = 'success';
            $response['data'] = $fee_type;
        } else {
            $response['status'] = 'error';
            $response['message'] = 'Fee type not found.';
        }
    } catch (PDOException $e) {
        $response['status'] = 'error';
        $response['message'] = 'Database Error: ' . $e->getMessage();
    }
} else {
    $response['status'] = 'error';
    $response['message'] = 'Invalid fee type ID.';
}

// Return the response as JSON
echo json_encode($response);
?>
