<?php
require_once 'config.php';

$category = $_POST['category'];
$chamber_id = intval($_POST['chamber_id']);
$date = $_POST['date'];
$day = date('w', strtotime($date));

// Check if this is a free medicine camp day for this chamber
$free_camp = $conn->query("SELECT is_free_camp FROM chamber_schedules 
                           WHERE chamber_id = $chamber_id AND day_of_week = $day AND is_free_camp = 1");
$is_free_camp_day = $free_camp->num_rows > 0;

// Determine fee
if ($is_free_camp_day && $category == 'free_medicine') {
    echo 0; // Free for eligible patients on camp days
} else {
    switch ($category) {
        case 'special': echo 500; break;
        case 'regular': echo 200; break;
        case 'free_medicine': echo 100; break;
        default: echo 200;
    }
}
?>