<?php
require_once 'includes/config.php';

header('Content-Type: application/json');

if(isset($_GET['car_id'], $_GET['start'], $_GET['end'])) {
    $car_id = (int)$_GET['car_id'];
    $start_date = $_GET['start'];
    $end_date = $_GET['end'];
    $pickup_time = isset($_GET['pickup_time']) ? $_GET['pickup_time'] : '10:00';
    $dropoff_time = isset($_GET['dropoff_time']) ? $_GET['dropoff_time'] : '10:00';
    
    // Përdor funksionin e ri me orë
    $result = calculateDynamicPrice($car_id, $start_date, $pickup_time, $end_date, $dropoff_time, $pdo);
    
    echo json_encode($result);
    exit;
}

echo json_encode(['error' => 'Missing parameters']);
?>