diff --git a/admin_dashboard.php b/admin_dashboard.php new file mode 100644 index 0000000..eef1e60 --- /dev/null +++ b/admin_dashboard.php @@ -0,0 +1,70 @@ +prepare("SELECT events.*, users.name as manager_name FROM events JOIN users ON events.created_by = users.id WHERE events.status = 'pending' ORDER BY events.created_at DESC"); +$stmt->execute(); +$events = $stmt->fetchAll(PDO::FETCH_ASSOC); + +?> + + + + + + Admin Dashboard - EventPlatform + + + + + + + +
+

Admin Dashboard

+ +
+
+ Pending Events +
+
+ + + + + + + + + + + + + + + + + + + + + +
Event NameManagerDateLocationActions
+ Approve + Reject +
+
+
+
+ + + + diff --git a/buy_ticket.php b/buy_ticket.php new file mode 100644 index 0000000..0c8b157 --- /dev/null +++ b/buy_ticket.php @@ -0,0 +1,32 @@ +prepare("INSERT INTO tickets (user_id, event_id) VALUES (:user_id, :event_id)"); + $stmt->bindParam(':user_id', $user_id, PDO::PARAM_INT); + $stmt->bindParam(':event_id', $event_id, PDO::PARAM_INT); + $stmt->execute(); + + header('Location: my_tickets.php?success=ticket_purchased'); + exit(); +} catch (PDOException $e) { + // Handle database error + header('Location: event_details.php?id=' . $event_id . '&error=db_error'); + exit(); +} diff --git a/create_event.php b/create_event.php new file mode 100644 index 0000000..388a407 --- /dev/null +++ b/create_event.php @@ -0,0 +1,41 @@ +prepare("INSERT INTO events (name, description, date, location, status, created_by) VALUES (:name, :description, :date, :location, 'pending', :created_by)"); + $stmt->bindParam(':name', $name); + $stmt->bindParam(':description', $description); + $stmt->bindParam(':date', $date); + $stmt->bindParam(':location', $location); + $stmt->bindParam(':created_by', $manager_id, PDO::PARAM_INT); + $stmt->execute(); + + header('Location: manager_dashboard.php?success=event_created'); + exit(); + } catch (PDOException $e) { + // Handle database error + header('Location: manager_dashboard.php?error=db_error'); + exit(); + } +} diff --git a/db/migrations/002_create_users_table.php b/db/migrations/002_create_users_table.php new file mode 100644 index 0000000..f2faa5d --- /dev/null +++ b/db/migrations/002_create_users_table.php @@ -0,0 +1,25 @@ +exec($sql); + + echo "Migration 002 completed successfully: 'users' table created." . PHP_EOL; + +} catch (PDOException $e) { + die("Migration 002 failed: " . $e->getMessage()); +} +?> \ No newline at end of file diff --git a/db/migrations/003_add_role_to_users.php b/db/migrations/003_add_role_to_users.php new file mode 100644 index 0000000..3eb9554 --- /dev/null +++ b/db/migrations/003_add_role_to_users.php @@ -0,0 +1,17 @@ +exec($sql); + // Set user with id 1 to be an admin + $sql_admin = "UPDATE users SET role = 'admin' WHERE id = 1"; + $conn->exec($sql_admin); + // Set user with id 2 to be a manager + $sql_manager = "UPDATE users SET role = 'manager' WHERE id = 2"; + $conn->exec($sql_manager); + echo "Migration successful: 'role' column added to 'users' table and default users updated." . PHP_EOL; +} catch (PDOException $e) { + echo "Migration failed: " . $e->getMessage() . PHP_EOL; +} diff --git a/db/migrations/004_add_created_by_to_events.php b/db/migrations/004_add_created_by_to_events.php new file mode 100644 index 0000000..989929c --- /dev/null +++ b/db/migrations/004_add_created_by_to_events.php @@ -0,0 +1,11 @@ +exec($sql); + echo "Migration successful: 'created_by' column added to 'events' table." . PHP_EOL; +} catch (PDOException $e) { + echo "Migration failed: " . $e->getMessage() . PHP_EOL; +} diff --git a/db/migrations/005_create_tickets_table.php b/db/migrations/005_create_tickets_table.php new file mode 100644 index 0000000..cff4c50 --- /dev/null +++ b/db/migrations/005_create_tickets_table.php @@ -0,0 +1,18 @@ +exec($sql); + echo "Migration successful: 'tickets' table created." . PHP_EOL; +} catch (PDOException $e) { + echo "Migration failed: " . $e->getMessage() . PHP_EOL; +} diff --git a/event_details.php b/event_details.php new file mode 100644 index 0000000..db8d2de --- /dev/null +++ b/event_details.php @@ -0,0 +1,59 @@ +prepare("SELECT * FROM events WHERE id = :id AND status = 'accepted'"); +$stmt->bindParam(':id', $event_id, PDO::PARAM_INT); +$stmt->execute(); +$event = $stmt->fetch(PDO::FETCH_ASSOC); + +if (!$event) { + header('Location: index.php'); + exit(); +} + +$event_date = new DateTime($event['date']); + +?> + + + + + + <?php echo htmlspecialchars($event['name']); ?> - EventPlatform + + + + + + + +
+
+
+
+
+

+
format('l, F j, Y'); ?>
+

+

+ Buy Ticket +
+
+
+
+
+ + + + diff --git a/includes/header.php b/includes/header.php new file mode 100644 index 0000000..b62e307 --- /dev/null +++ b/includes/header.php @@ -0,0 +1,45 @@ + + diff --git a/index.php b/index.php index 9bb1731..0235179 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ - EventJet - Your Gateway to Exclusive Events + EventPlatform - Your Gateway to Exclusive Events @@ -18,25 +18,9 @@ - + + +
@@ -55,7 +39,7 @@ try { require_once __DIR__ . '/db/config.php'; $pdo = db(); - $stmt = $pdo->prepare("SELECT * FROM events WHERE status = 'accepted' ORDER BY event_date ASC"); + $stmt = $pdo->prepare("SELECT * FROM events WHERE status = 'accepted' ORDER BY date ASC"); $stmt->execute(); $events = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -63,19 +47,15 @@ echo "

No upcoming events found. Please check back later!

"; } else { foreach ($events as $event) { - $event_date = new DateTime($event['event_date']); - $price = floatval($event['price']); - $price_display = $price > 0 ? '$' . number_format($price, 2) : 'FREE'; - $price_class = $price > 0 ? '' : 'free'; + $event_date = new DateTime($event['date']); echo '
-
' . $price_display . '
-
' . $event_date->format('M d, Y \a\t h:i A') . '
-

' . htmlspecialchars($event['title']) . '

+
' . $event_date->format('M d, Y') . '
+

' . htmlspecialchars($event['name']) . '

' . htmlspecialchars($event['location']) . '

- View Details + View Details
'; @@ -90,7 +70,6 @@
-