diff --git a/.htaccess b/.htaccess index e90ec28e..aba56657 100644 --- a/.htaccess +++ b/.htaccess @@ -37,6 +37,7 @@ RewriteRule ^member_info$ src/pages/memberships/member_info.php [L] RewriteRule ^bookings$ src/pages/bookings/bookings.php [L] RewriteRule ^campsites$ src/pages/bookings/campsites.php [L] RewriteRule ^campsite_booking$ src/pages/bookings/campsite_booking.php [L] +RewriteRule ^add_campsite$ src/pages/add_campsite.php [L] RewriteRule ^trips$ src/pages/bookings/trips.php [L] RewriteRule ^trip-details$ src/pages/bookings/trip-details.php [L] RewriteRule ^course_details$ src/pages/bookings/course_details.php [L] @@ -81,7 +82,6 @@ RewriteRule ^admin_camp_bookings$ src/admin/admin_camp_bookings.php [L] RewriteRule ^admin_trip_bookings$ src/admin/admin_trip_bookings.php [L] RewriteRule ^admin_visitors$ src/admin/admin_visitors.php [L] RewriteRule ^admin_efts$ src/admin/admin_efts.php [L] -RewriteRule ^add_campsite$ src/admin/add_campsite.php [L] RewriteRule ^admin_trips$ src/admin/admin_trips.php [L] RewriteRule ^manage_trips$ src/admin/manage_trips.php [L] diff --git a/assets/uploads/campsites/274d8e71982307bc5a699125966d5731.jpg b/assets/uploads/campsites/274d8e71982307bc5a699125966d5731.jpg new file mode 100644 index 00000000..3cbb8f26 Binary files /dev/null and b/assets/uploads/campsites/274d8e71982307bc5a699125966d5731.jpg differ diff --git a/assets/uploads/campsites/3dd0636b3ed6926e10f0387a747d58c1.jpg b/assets/uploads/campsites/3dd0636b3ed6926e10f0387a747d58c1.jpg new file mode 100644 index 00000000..3018e71c Binary files /dev/null and b/assets/uploads/campsites/3dd0636b3ed6926e10f0387a747d58c1.jpg differ diff --git a/assets/uploads/campsites/ae16ea8e89bb83dc3b85c54aa0e3fcec.jpg b/assets/uploads/campsites/ae16ea8e89bb83dc3b85c54aa0e3fcec.jpg new file mode 100644 index 00000000..45c308c2 Binary files /dev/null and b/assets/uploads/campsites/ae16ea8e89bb83dc3b85c54aa0e3fcec.jpg differ diff --git a/assets/uploads/campsites/c613066cd83537a874355671e0213539.jpg b/assets/uploads/campsites/c613066cd83537a874355671e0213539.jpg new file mode 100644 index 00000000..3018e71c Binary files /dev/null and b/assets/uploads/campsites/c613066cd83537a874355671e0213539.jpg differ diff --git a/assets/uploads/campsites/d21ae51aec635de07883d9586a1542df.jpg b/assets/uploads/campsites/d21ae51aec635de07883d9586a1542df.jpg new file mode 100644 index 00000000..3018e71c Binary files /dev/null and b/assets/uploads/campsites/d21ae51aec635de07883d9586a1542df.jpg differ diff --git a/src/api/get_campsites.php b/src/api/get_campsites.php index 5daef5e9..2a04864b 100644 --- a/src/api/get_campsites.php +++ b/src/api/get_campsites.php @@ -6,7 +6,16 @@ include_once('../config/functions.php'); $conn = openDatabaseConnection(); $stmt = $conn->prepare("SELECT - c.*, + c.id, + c.name, + c.description, + c.website, + c.telephone, + c.latitude, + c.longitude, + c.thumbnail, + c.country, + c.province, u.first_name, u.last_name, u.profile_pic @@ -26,6 +35,8 @@ while ($row = $result->fetch_assoc()) { 'latitude' => $row['latitude'], 'longitude' => $row['longitude'], 'thumbnail' => $row['thumbnail'], + 'country' => $row['country'], + 'province' => $row['province'], 'user' => [ 'first_name' => $row['first_name'], 'last_name' => $row['last_name'], diff --git a/src/pages/add_campsite.php b/src/pages/add_campsite.php new file mode 100644 index 00000000..fef686ca --- /dev/null +++ b/src/pages/add_campsite.php @@ -0,0 +1,118 @@ + 0) { + // Verify ownership - check if the campsite belongs to the current user + $ownerCheckStmt = $conn->prepare("SELECT user_id FROM campsites WHERE id = ?"); + $ownerCheckStmt->bind_param("i", $id); + $ownerCheckStmt->execute(); + $ownerResult = $ownerCheckStmt->get_result(); + + if ($ownerResult->num_rows === 0) { + http_response_code(404); + die('Campsite not found.'); + } + + $ownerRow = $ownerResult->fetch_assoc(); + if ($ownerRow['user_id'] != $user_id) { + http_response_code(403); + die('You do not have permission to edit this campsite. Only the owner can make changes.'); + } + + $ownerCheckStmt->close(); + + // UPDATE + if ($thumbnailPath) { + $stmt = $conn->prepare("UPDATE campsites SET name=?, description=?, country=?, province=?, latitude=?, longitude=?, website=?, telephone=?, thumbnail=? WHERE id=?"); + $stmt->bind_param("ssssddsssi", $name, $desc, $country, $province, $lat, $lng, $website, $telephone, $thumbnailPath, $id); + } else { + $stmt = $conn->prepare("UPDATE campsites SET name=?, description=?, country=?, province=?, latitude=?, longitude=?, website=?, telephone=? WHERE id=?"); + $stmt->bind_param("ssssddssi", $name, $desc, $country, $province, $lat, $lng, $website, $telephone, $id); + } + + // Log the action + auditLog($user_id, 'CAMPSITE_UPDATE', 'campsites', $id, ['name' => $name]); +} else { + // INSERT + $stmt = $conn->prepare("INSERT INTO campsites (name, description, country, province, latitude, longitude, website, telephone, thumbnail, user_id) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + $stmt->bind_param("ssssddsssi", $name, $desc, $country, $province, $lat, $lng, $website, $telephone, $thumbnailPath, $user_id); + + // Log the action + auditLog($user_id, 'CAMPSITE_CREATE', 'campsites', 0, ['name' => $name]); +} + +if (!$stmt->execute()) { + http_response_code(500); + die('Database error: ' . $stmt->error); +} + +$stmt->close(); + +header("Location: campsites"); +?> diff --git a/src/pages/bookings/campsites.php b/src/pages/bookings/campsites.php index ce4926d6..be021371 100644 --- a/src/pages/bookings/campsites.php +++ b/src/pages/bookings/campsites.php @@ -25,74 +25,303 @@ while ($row = $result->fetch_assoc()) { .info-box img { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); - + } + + /* Form styling to match manage_trips */ + .campsite-form-container { + background: #f9f9f7; + border: 1px solid #d8d8d8; + border-radius: 10px; + padding: 30px; + margin: 20px 0; + display: none; + } + + .campsite-form-container h5 { + color: #2c3e50; + font-weight: 600; + margin-bottom: 30px; + font-size: 1.5rem; + } + + .campsite-form-container .form-group { + margin-bottom: 20px; + } + + .campsite-form-container label { + font-weight: 500; + color: #34495e; + margin-bottom: 8px; + display: block; + } + + .campsite-form-container .form-control { + width: 100%; + padding: 10px; + border: 1px solid #ddd; + border-radius: 6px; + font-size: 14px; + } + + .campsite-form-container .form-control:focus { + border-color: #4CAF50; + box-shadow: 0 0 0 0.2rem rgba(76, 175, 80, 0.25); + outline: none; + } + + .campsite-form-container .form-control select { + cursor: pointer; + } + + .campsite-form-container .btn { + border-radius: 6px; + font-weight: 500; + padding: 10px 20px; + } + + /* Table styling to match admin trips */ + .campsites-table { + width: 100%; + border-collapse: separate; + border-spacing: 0; + margin: 10px 0; + } + + .campsites-table thead th { + cursor: pointer; + text-align: left; + padding: 10px; + font-weight: bold; + position: relative; + } + + .campsites-table thead th::after { + content: '\25B2'; + font-size: 0.8em; + position: absolute; + right: 10px; + opacity: 0; + transition: opacity 0.2s; + } + + .campsites-table thead th.asc::after { + content: '\25B2'; + opacity: 1; + } + + .campsites-table thead th.desc::after { + content: '\25BC'; + opacity: 1; + } + + .campsites-table tbody tr:nth-child(odd) { + background-color: transparent; + } + + .campsites-table tbody tr:nth-child(even) { + background-color: rgb(255, 255, 255); + border-radius: 10px; + } + + .campsites-table tbody td { + padding: 10px; + } + + .campsites-table tbody tr:nth-child(even) td:first-child { + border-top-left-radius: 10px; + border-bottom-left-radius: 10px; + } + + .campsites-table tbody tr:nth-child(even) td:last-child { + border-top-right-radius: 10px; + border-bottom-right-radius: 10px; + } + + .filter-input { + width: 100%; + padding: 10px; + font-size: 16px; + background-color: rgb(255, 255, 255); + border-radius: 25px; + margin-bottom: 20px; + border: 1px solid #ddd; + } + + .campsite-group { + color: #484848; + background: #f9f9f7; + border: 1px solid #d8d8d8; + border-radius: 10px; + margin-top: 15px; + margin-bottom: 15px; + padding: 10px; + } 'index.php']]; - require_once($rootPath . '/components/banner.php'); +$pageTitle = 'Campsites'; +$breadcrumbs = [['Home' => 'index.php']]; +require_once($rootPath . '/components/banner.php'); ?> - -
+
+
+

Campsites Map

+ +
+

Click on the map to add a new campsite, or click on a marker to view details.

+ + +
+
Add New Campsite
+
+ + + + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
- - + + +
+

All Campsites

+ +
+ + + + + + + + + + + + + + +
NameDescriptionWebsitePhoneAdded ByActions
+
+
+
- - - + \ No newline at end of file