<?php
/**
 * PRODIGY NOTES Item #5: Get service pricing details
 */
session_start();
header('Content-Type: application/json');
include '../layouts/dbconn.php';

if (!isset($_SESSION['user_id'])) {
    echo json_encode(['success' => false, 'message' => 'Unauthorized']);
    exit();
}

$pricing_id = isset($_GET['pricing_id']) ? intval($_GET['pricing_id']) : 0;

if (!$pricing_id) {
    echo json_encode(['success' => false, 'message' => 'Invalid pricing ID']);
    exit();
}

$sql = "SELECT pricing_id, service_name, service_type, base_price, insurance_price, is_active
        FROM service_pricing
        WHERE pricing_id = ?";

$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $pricing_id);
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows > 0) {
    $service = $result->fetch_assoc();
    echo json_encode([
        'success' => true,
        'service' => $service
    ]);
} else {
    echo json_encode(['success' => false, 'message' => 'Service not found']);
}

$stmt->close();
$conn->close();
?>
