feat: improve campsites and events management UX

- Add map-based location picker with centered pin for campsites (two-step process)
- Hide edit buttons for campsites not owned by current user
- Allow numbers in campsite names (fix validateName function)
- Prepopulate edit form with existing campsite data
- Preserve country/province selection when confirming location
- Add real-time filter functionality to campsites table
- Fix events publish button error handling (use output buffering cleanup)
- Improve AJAX response handling with complete callback

Changes:
- src/pages/bookings/campsites.php: Location mode UI, filter, edit form improvements
- src/config/functions.php: Allow numbers in validateName regex
- src/admin/toggle_event_published.php: Clean output buffers before JSON response
- src/admin/admin_events.php: Use complete callback instead of success/error handlers
This commit is contained in:
twotalesanimation
2025-12-05 09:20:48 +02:00
parent b52c46b67c
commit 9133b7bbc6
14 changed files with 350 additions and 75 deletions

View File

@@ -1,9 +1,21 @@
<?php
// Set JSON header FIRST before any includes that might output
header('Content-Type: application/json');
header('Cache-Control: no-cache, no-store, must-revalidate');
header('Pragma: no-cache');
header('Expires: 0');
// Clean any output buffers before including header
while (ob_get_level() > 0) {
ob_end_clean();
}
$rootPath = dirname(dirname(__DIR__));
include_once($rootPath . '/header.php');
checkAdmin();
header('Content-Type: application/json');
// Clean output buffer again in case header.php added content
ob_clean();
$event_id = $_POST['event_id'] ?? null;
@@ -44,6 +56,7 @@ try {
$update_stmt->bind_param("ii", $new_status, $event_id);
if ($update_stmt->execute()) {
ob_clean(); // Clean any buffered output before sending JSON
http_response_code(200);
echo json_encode([
'status' => 'success',
@@ -55,6 +68,7 @@ try {
}
$update_stmt->close();
} catch (Exception $e) {
ob_clean(); // Clean any buffered output before sending JSON
http_response_code(500);
echo json_encode(['status' => 'error', 'message' => 'Database error: ' . $e->getMessage()]);
}