<?php
// Quick fix - Create an active offer immediately
$host = 'localhost';
$username = 'kongutourist_offers';
$password = 'Uq$yrK527t(d.@7[';
$database = 'kongutourist_offers';

$conn = new mysqli($host, $username, $password, $database);

if ($conn->connect_error) {
    die(json_encode(['success' => false, 'message' => 'Database connection failed']));
}

// Create an active offer that starts now and ends in 7 days
$startDate = date('Y-m-d H:i:s');
$endDate = date('Y-m-d H:i:s', strtotime('+7 days'));

$sql = "INSERT INTO offers (title, image_url, start_date, end_date) VALUES (?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ssss", 'Opening Offer', 'images/offers/offer_1772097193_69a00ea9d4e80.png', $startDate, $endDate);

if ($stmt->execute()) {
    echo json_encode(['success' => true, 'message' => 'Active offer created']);
} else {
    echo json_encode(['success' => false, 'message' => 'Failed to create offer']);
}

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