refactor: align events admin pages with trips layout and add publish functionality

- Remove checkbox from manage_events.php form (publish via admin table instead)
- Redesign admin_events.php to match admin_trips.php layout exactly
- Add table-based actions with icon buttons (Edit, Publish/Unpublish, Delete)
- Change button styling to match trips (btn classes with colors)
- Add publish/unpublish toggle button with eye icon
- Create toggle_event_published.php endpoint for publish status switching
- Create delete_event.php endpoint for event deletion
- Add AJAX functionality for instant publish/delete without page reload
- Update .htaccess with new endpoint rewrite rules
- Badge styling updated to match trips (bg-success, bg-warning)
- Consistent sorting and filtering functionality
This commit is contained in:
twotalesanimation
2025-12-04 21:40:11 +02:00
parent 2b136c4b06
commit f522b84fc1
6 changed files with 290 additions and 128 deletions

View File

@@ -0,0 +1,44 @@
<?php
$rootPath = dirname(dirname(__DIR__));
include_once($rootPath . '/header.php');
checkAdmin();
header('Content-Type: application/json');
$event_id = $_POST['event_id'] ?? null;
if (!$event_id) {
echo json_encode(['status' => 'error', 'message' => 'Event ID is required']);
exit;
}
// Get current published status
$stmt = $conn->prepare("SELECT published FROM events WHERE event_id = ?");
$stmt->bind_param("i", $event_id);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows === 0) {
echo json_encode(['status' => 'error', 'message' => 'Event not found']);
exit;
}
$event = $result->fetch_assoc();
$new_status = $event['published'] == 1 ? 0 : 1;
// Update published status
$update_stmt = $conn->prepare("UPDATE events SET published = ? WHERE event_id = ?");
$update_stmt->bind_param("ii", $new_status, $event_id);
if ($update_stmt->execute()) {
echo json_encode([
'status' => 'success',
'message' => $new_status == 1 ? 'Event published' : 'Event unpublished',
'published' => $new_status
]);
} else {
echo json_encode(['status' => 'error', 'message' => 'Failed to update event status']);
}
$stmt->close();
$update_stmt->close();