Auto commit: 2025-10-03T00:08:51.683Z

This commit is contained in:
Flatlogic Bot 2025-10-03 00:08:51 +00:00
parent fa09637699
commit 10404549fd
3 changed files with 36 additions and 9 deletions

View File

@ -19,9 +19,17 @@ document.addEventListener('DOMContentLoaded', function() {
slotMaxTime: '22:00:00', slotMaxTime: '22:00:00',
allDaySlot: false, allDaySlot: false,
slotDuration: '00:15:00', slotDuration: '00:15:00',
slotLabelInterval: '00:15:00',
snapDuration: '00:15:00',
selectable: true, selectable: true,
editable: true, editable: true,
selectLongPressDelay: 200,
longPressDelay: 200,
select: function(info) { select: function(info) {
// Force 1-hour selection
info.end = new Date(info.start.getTime() + 60 * 60 * 1000);
info.endStr = info.end.toISOString();
currentSelectionInfo = info; currentSelectionInfo = info;
modal.style.display = 'block'; modal.style.display = 'block';
document.getElementById('organizer-name').focus(); document.getElementById('organizer-name').focus();

View File

@ -9,6 +9,7 @@ $data = json_decode(file_get_contents('php://input'), true);
if ($data) { if ($data) {
try { try {
$pdo = db(); $pdo = db();
// Main booking
$stmt = $pdo->prepare("INSERT INTO bookings (title, sport, start_time, end_time) VALUES (?, ?, ?, ?)"); $stmt = $pdo->prepare("INSERT INTO bookings (title, sport, start_time, end_time) VALUES (?, ?, ?, ?)");
$stmt->execute([ $stmt->execute([
$data['title'], $data['title'],
@ -16,9 +17,24 @@ if ($data) {
$data['start'], $data['start'],
$data['end'] $data['end']
]); ]);
// Buffer booking
$buffer_start = $data['end'];
$buffer_end_dt = new DateTime($buffer_start);
$buffer_end_dt->modify('+15 minutes');
$buffer_end = $buffer_end_dt->format('Y-m-d H:i:s');
$stmt_buffer = $pdo->prepare("INSERT INTO bookings (title, sport, start_time, end_time) VALUES (?, ?, ?, ?)");
$stmt_buffer->execute([
'Buffer',
'Buffer',
$buffer_start,
$buffer_end
]);
$response['status'] = 'success'; $response['status'] = 'success';
$response['message'] = 'Booking created successfully'; $response['message'] = 'Booking created successfully';
} catch (PDOException $e) { } catch (Exception $e) { // Catch generic Exception
$response['message'] = 'Database error: ' . $e->getMessage(); $response['message'] = 'Database error: ' . $e->getMessage();
} }
} }

View File

@ -4,18 +4,21 @@ require_once 'db/config.php';
try { try {
$pdo = db(); $pdo = db();
// Insert sample data if the table is empty
$stmt = $pdo->query('SELECT COUNT(*) FROM bookings');
if ($stmt->fetchColumn() == 0) {
$pdo->exec("INSERT INTO bookings (title, start_time, end_time) VALUES ('Booking 1', '2025-10-02 10:00:00', '2025-10-02 11:00:00')");
$pdo->exec("INSERT INTO bookings (title, start_time, end_time) VALUES ('Booking 2', '2025-10-02 14:00:00', '2025-10-02 15:00:00')");
}
$stmt = $pdo->query('SELECT title, start_time AS start, end_time AS end FROM bookings'); $stmt = $pdo->query('SELECT title, start_time AS start, end_time AS end FROM bookings');
$bookings = $stmt->fetchAll(PDO::FETCH_ASSOC); $bookings = $stmt->fetchAll(PDO::FETCH_ASSOC);
$events = [];
foreach ($bookings as $booking) {
if ($booking['title'] === 'Buffer') {
$booking['color'] = 'red';
} else {
$booking['color'] = '#3788d8'; // FullCalendar default blue
}
$events[] = $booking;
}
header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($bookings); echo json_encode($events);
} catch (PDOException $e) { } catch (PDOException $e) {
http_response_code(500); http_response_code(500);