98 lines
3.6 KiB
PHP
98 lines
3.6 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'manager') {
|
|
header('Location: login.php');
|
|
exit();
|
|
}
|
|
|
|
require_once 'db/config.php';
|
|
$conn = db();
|
|
|
|
$manager_id = $_SESSION['user_id'];
|
|
|
|
// Fetch events created by the manager
|
|
$stmt = $conn->prepare("SELECT * FROM events WHERE created_by = :manager_id ORDER BY created_at DESC");
|
|
$stmt->bindParam(':manager_id', $manager_id, PDO::PARAM_INT);
|
|
$stmt->execute();
|
|
$events = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Manager Dashboard - EventPlatform</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
|
|
<?php require_once './includes/header.php'; ?>
|
|
|
|
<div class="container mt-5">
|
|
<h1 class="mb-4">Manager Dashboard</h1>
|
|
|
|
<div class="card mb-4">
|
|
<div class="card-header">
|
|
Create New Event
|
|
</div>
|
|
<div class="card-body">
|
|
<form action="create_event.php" method="POST">
|
|
<div class="mb-3">
|
|
<label for="name" class="form-label">Event Name</label>
|
|
<input type="text" class="form-control" id="name" name="name" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="description" class="form-label">Description</label>
|
|
<textarea class="form-control" id="description" name="description" rows="3" required></textarea>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-6 mb-3">
|
|
<label for="date" class="form-label">Date</label>
|
|
<input type="date" class="form-control" id="date" name="date" required>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="location" class="form-label">Location</label>
|
|
<input type="text" class="form-control" id="location" name="location" required>
|
|
</div>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Create Event</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-header">
|
|
Your Events
|
|
</div>
|
|
<div class="card-body">
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Date</th>
|
|
<th>Location</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($events as $event): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($event['name']); ?></td>
|
|
<td><?php echo htmlspecialchars($event['date']); ?></td>
|
|
<td><?php echo htmlspecialchars($event['location']); ?></td>
|
|
<td><span class="badge bg-<?php echo $event['status'] === 'accepted' ? 'success' : ($event['status'] === 'rejected' ? 'danger' : 'warning'); ?>"><?php echo htmlspecialchars(ucfirst($event['status'] ?? '')); ?></span></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|