Compare commits

..

1 Commits

Author SHA1 Message Date
Flatlogic Bot
0a0873a371 v2 2025-09-09 15:57:31 +00:00
8 changed files with 847 additions and 126 deletions

66
assets/css/custom.css Normal file
View File

@ -0,0 +1,66 @@
/* --- custom.css --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap');
body {
font-family: 'Poppins', sans-serif;
background-color: #f8f9fa;
color: #333;
}
:root {
--primary-gradient: linear-gradient(45deg, #6f42c1, #007bff);
--primary-gradient-hover: linear-gradient(45deg, #007bff, #6f42c1);
}
.navbar-brand {
font-weight: 700;
}
.hero {
padding: 6rem 1rem;
text-align: center;
background: #fff;
border-bottom: 1px solid #dee2e6;
}
.hero h1 {
font-size: 3rem;
font-weight: 700;
}
.hero p {
font-size: 1.25rem;
font-weight: 300;
max-width: 600px;
margin: 1rem auto;
}
.btn-primary {
background: var(--primary-gradient);
border: none;
padding: 0.75rem 1.5rem;
font-weight: 600;
transition: background 0.3s ease;
}
.btn-primary:hover {
background: var(--primary-gradient-hover);
}
.interactive-widget {
background: #ffffff;
padding: 3rem 1rem;
margin-top: 2rem;
border-radius: 0.5rem;
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.05);
text-align: center;
max-width: 500px;
margin-left: auto;
margin-right: auto;
}
.interactive-widget h3 {
font-weight: 600;
margin-bottom: 1.5rem;
}

27
db/migrate.php Normal file
View File

@ -0,0 +1,27 @@
<?php
// Simple migration script
// 1. Load DB configuration
require_once 'config.php';
try {
// 2. Get a PDO database connection
$pdo = db();
// 3. Read the initial schema
$sql = file_get_contents(__DIR__ . '/migrations/001_initial_schema.sql');
if ($sql === false) {
throw new Exception("Error: Could not read the migration file.");
}
// 4. Execute the SQL
$pdo->exec($sql);
echo "Success: Database schema applied successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Error: Database connection failed: " . $e->getMessage());
} catch (Exception $e) {
die($e->getMessage());
}

View File

@ -0,0 +1,32 @@
-- Initial Schema for Event Management App
-- Venues Table: Stores information about event locations.
CREATE TABLE IF NOT EXISTS `venues` (
`id` INT PRIMARY KEY AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`description` TEXT,
`capacity` INT,
`address` VARCHAR(255),
`is_available` BOOLEAN DEFAULT TRUE,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Vendors Table: Stores information about service providers.
CREATE TABLE IF NOT EXISTS `vendors` (
`id` INT PRIMARY KEY AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`service_type` VARCHAR(100) COMMENT '''e.g., Catering, Decor, Entertainment''',
`contact_email` VARCHAR(255),
`contact_phone` VARCHAR(20),
`rating` DECIMAL(3, 2) COMMENT '''Rating from 1.00 to 5.00''',
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Users Table: For authentication and roles.
CREATE TABLE IF NOT EXISTS `users` (
`id` INT PRIMARY KEY AUTO_INCREMENT,
`email` VARCHAR(255) NOT NULL UNIQUE,
`password_hash` VARCHAR(255) NOT NULL,
`role` VARCHAR(50) NOT NULL DEFAULT '''event_manager''' COMMENT '''e.g., event_manager, admin''',
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

125
edit-vendor.php Normal file
View File

@ -0,0 +1,125 @@
<?php
require_once 'db/config.php';
$errorMessage = null;
$successMessage = null;
$vendor_id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
if (!$vendor_id) {
header("Location: vendors.php");
exit;
}
// Handle form submission for editing the vendor
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_vendor'])) {
$name = trim($_POST['name'] ?? '');
$service_type = trim($_POST['service_type'] ?? '');
$contact_email = filter_input(INPUT_POST, 'contact_email', FILTER_VALIDATE_EMAIL);
$contact_phone = trim($_POST['contact_phone'] ?? '');
$rating = filter_input(INPUT_POST, 'rating', FILTER_VALIDATE_FLOAT);
if (empty($name) || empty($service_type) || !$contact_email) {
$errorMessage = "Error: Vendor name, service type, and a valid email are required.";
} else {
try {
$pdo = db();
$stmt = $pdo->prepare('UPDATE vendors SET name = ?, service_type = ?, contact_email = ?, contact_phone = ?, rating = ? WHERE id = ?');
$stmt->execute([$name, $service_type, $contact_email, $contact_phone, $rating, $vendor_id]);
header("Location: vendors.php?success=3");
exit;
} catch (PDOException $e) {
$errorMessage = "Error: Could not update the vendor. " . $e->getMessage();
}
}
}
// Fetch the vendor to edit
$vendor = null;
try {
$pdo = db();
$stmt = $pdo->prepare('SELECT * FROM vendors WHERE id = ?');
$stmt->execute([$vendor_id]);
$vendor = $stmt->fetch(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
$errorMessage = "Error: Could not fetch vendor details.";
}
if (!$vendor) {
header("Location: vendors.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Vendor - The Best Events</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="index.php">The Best Events</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="venues.php">Venues</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="vendors.php">Vendors</a>
</li>
</ul>
</div>
</div>
</nav>
<main class="container mt-4">
<h1 class="mb-4">Edit Vendor</h1>
<?php if ($errorMessage): ?>
<div class="alert alert-danger">
<?= htmlspecialchars($errorMessage) ?>
</div>
<?php endif; ?>
<form action="edit-vendor.php?id=<?= $vendor_id ?>" method="POST">
<input type="hidden" name="edit_vendor" value="1">
<div class="mb-3">
<label for="name" class="form-label">Vendor Name</label>
<input type="text" class="form-control" id="name" name="name" value="<?= htmlspecialchars($vendor['name']) ?>" required>
</div>
<div class="mb-3">
<label for="service_type" class="form-label">Service Type</label>
<input type="text" class="form-control" id="service_type" name="service_type" value="<?= htmlspecialchars($vendor['service_type']) ?>" placeholder="e.g., Catering, Photography" required>
</div>
<div class="mb-3">
<label for="contact_email" class="form-label">Contact Email</label>
<input type="email" class="form-control" id="contact_email" name="contact_email" value="<?= htmlspecialchars($vendor['contact_email']) ?>" required>
</div>
<div class="mb-3">
<label for="contact_phone" class="form-label">Contact Phone</label>
<input type="tel" class="form-control" id="contact_phone" name="contact_phone" value="<?= htmlspecialchars($vendor['contact_phone']) ?>">
</div>
<div class="mb-3">
<label for="rating" class="form-label">Rating (1-5)</label>
<input type="number" step="0.1" min="1" max="5" class="form-control" id="rating" name="rating" value="<?= htmlspecialchars($vendor['rating']) ?>">
</div>
<button type="submit" class="btn btn-success">Save Changes</button>
<a href="vendors.php" class="btn btn-secondary">Cancel</a>
</form>
</main>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

120
edit-venue.php Normal file
View File

@ -0,0 +1,120 @@
<?php
require_once 'db/config.php';
$errorMessage = null;
$successMessage = null;
$venue_id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
if (!$venue_id) {
header("Location: venues.php");
exit;
}
// Handle form submission for editing the venue
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_venue'])) {
$name = trim($_POST['name'] ?? '');
$description = trim($_POST['description'] ?? '');
$capacity = filter_input(INPUT_POST, 'capacity', FILTER_VALIDATE_INT);
$features = trim($_POST['features'] ?? '');
if (empty($name) || $capacity === false || $capacity <= 0) {
$errorMessage = "Error: Venue name and a valid capacity are required.";
} else {
try {
$pdo = db();
$stmt = $pdo->prepare('UPDATE venues SET name = ?, description = ?, capacity = ?, features = ? WHERE id = ?');
$stmt->execute([$name, $description, $capacity, $features, $venue_id]);
header("Location: venues.php?success=3");
exit;
} catch (PDOException $e) {
$errorMessage = "Error: Could not update the venue. " . $e->getMessage();
}
}
}
// Fetch the venue to edit
$venue = null;
try {
$pdo = db();
$stmt = $pdo->prepare('SELECT * FROM venues WHERE id = ?');
$stmt->execute([$venue_id]);
$venue = $stmt->fetch(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
$errorMessage = "Error: Could not fetch venue details.";
}
if (!$venue) {
header("Location: venues.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Venue - The Best Events</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="index.php">The Best Events</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="venues.php">Venues</a>
</li>
<li class="nav-item">
<a class="nav-link" href="vendors.php">Vendors</a>
</li>
</ul>
</div>
</div>
</nav>
<main class="container mt-4">
<h1 class="mb-4">Edit Venue</h1>
<?php if ($errorMessage): ?>
<div class="alert alert-danger">
<?= htmlspecialchars($errorMessage) ?>
</div>
<?php endif; ?>
<form action="edit-venue.php?id=<?= $venue_id ?>" method="POST">
<input type="hidden" name="edit_venue" value="1">
<div class="mb-3">
<label for="name" class="form-label">Venue Name</label>
<input type="text" class="form-control" id="name" name="name" value="<?= htmlspecialchars($venue['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"><?= htmlspecialchars($venue['description']) ?></textarea>
</div>
<div class="mb-3">
<label for="capacity" class="form-label">Capacity</label>
<input type="number" class="form-control" id="capacity" name="capacity" value="<?= htmlspecialchars($venue['capacity']) ?>" required>
</div>
<div class="mb-3">
<label for="features" class="form-label">Features</label>
<input type="text" class="form-control" id="features" name="features" value="<?= htmlspecialchars($venue['features']) ?>" placeholder="e.g., WiFi, Projector, Catering Available">
</div>
<button type="submit" class="btn btn-success">Save Changes</button>
<a href="venues.php" class="btn btn-secondary">Cancel</a>
</form>
</main>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

205
index.php
View File

@ -1,131 +1,84 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?>
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}
.loader {
margin: 1.25rem auto 1.25rem;
width: 48px;
height: 48px;
border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hint {
opacity: 0.9;
}
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap; border: 0;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Title</title>
<!-- Bootstrap 5 CDN -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<main>
<div class="card">
<h1>Analyzing your requirements and generating your website…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
</div>
<p class="hint">Flatlogic AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will update automatically as the plan is implemented.</p>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
<div class="container">
<a class="navbar-brand" href="index.php">EventFlow</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="venues.php">Venues</a>
</li>
<li class="nav-item">
<a class="nav-link" href="vendors.php">Vendors</a>
</li>
<li class="nav-item">
<a class="nav-link" href="login.php">Login</a>
</li>
<li class="nav-item">
<a class="btn btn-primary ms-2" href="register.php">Get Started</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Hero Section -->
<header class="hero">
<div class="container">
<h1>Effortless Events, Perfectly Planned.</h1>
<p class="lead">Your all-in-one solution for managing venues, vendors, guests, and budgets from a single, easy-to-use dashboard.</p>
<a href="venues.php" class="btn btn-primary btn-lg">Discover Your Dream Venue</a>
</div>
</header>
<!-- Main Content -->
<main class="container mt-5">
<!-- Interactive Widget -->
<section class="interactive-widget">
<h3>Venue Availability Checker</h3>
<form id="availability-form">
<div class="mb-3">
<input type="date" class="form-control" id="event-date" required>
</div>
<button type="submit" class="btn btn-primary">Check Availability</button>
</form>
</section>
</main>
<!-- Footer -->
<footer class="text-center py-4 mt-5 bg-white border-top">
<p>&copy; 2025 EventFlow. All rights reserved.</p>
</footer>
<!-- Bootstrap 5 JS Bundle -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<!-- Custom JS -->
<script>
document.getElementById('availability-form').addEventListener('submit', function(e) {
e.preventDefault();
const eventDate = document.getElementById('event-date').value;
if (eventDate) {
alert('Feature coming soon! We will check availability for ' + eventDate);
} else {
alert('Please select a date.');
}
});
</script>
</body>
</html>
</html>

191
vendors.php Normal file
View File

@ -0,0 +1,191 @@
<?php
require_once 'db/config.php';
$errorMessage = null;
$successMessage = null;
// Handle form submission for deleting a vendor
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_vendor'])) {
$vendor_id = filter_input(INPUT_POST, 'vendor_id', FILTER_VALIDATE_INT);
if ($vendor_id) {
try {
$pdo = db();
$stmt = $pdo->prepare('DELETE FROM vendors WHERE id = ?');
$stmt->execute([$vendor_id]);
header("Location: vendors.php?success=2");
exit;
} catch (PDOException $e) {
$errorMessage = "Error: Could not delete the vendor. " . $e->getMessage();
}
}
}
// Handle form submission for adding a new vendor
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_vendor'])) {
$name = trim($_POST['name'] ?? '');
$service_type = trim($_POST['service_type'] ?? '');
$contact_email = filter_input(INPUT_POST, 'contact_email', FILTER_VALIDATE_EMAIL);
$contact_phone = trim($_POST['contact_phone'] ?? '');
$rating = filter_input(INPUT_POST, 'rating', FILTER_VALIDATE_FLOAT);
if (empty($name) || empty($service_type) || !$contact_email) {
$errorMessage = "Error: Vendor name, service type, and a valid email are required.";
} else {
try {
$pdo = db();
$stmt = $pdo->prepare('INSERT INTO vendors (name, service_type, contact_email, contact_phone, rating) VALUES (?, ?, ?, ?, ?)');
$stmt->execute([$name, $service_type, $contact_email, $contact_phone, $rating]);
header("Location: vendors.php?success=1");
exit;
} catch (PDOException $e) {
$errorMessage = "Error: Could not add the vendor. " . $e->getMessage();
}
}
}
// Handle success messages
if (isset($_GET['success'])) {
if ($_GET['success'] == 1) $successMessage = "Vendor added successfully!";
if ($_GET['success'] == 2) $successMessage = "Vendor deleted successfully!";
if ($_GET['success'] == 3) $successMessage = "Vendor updated successfully!";
}
// Fetch vendors from the database
$vendors = [];
try {
$pdo = db();
$stmt = $pdo->query('SELECT * FROM vendors ORDER BY name');
$vendors = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
$errorMessage = "Error: Could not connect to the database.";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vendors - The Best Events</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="index.php">The Best Events</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="venues.php">Venues</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="vendors.php">Vendors</a>
</li>
</ul>
</div>
</div>
</nav>
<main class="container mt-4">
<h1 class="mb-4">Manage Vendors</h1>
<?php if ($successMessage): ?>
<div class="alert alert-success"><?= htmlspecialchars($successMessage) ?></div>
<?php endif; ?>
<?php if ($errorMessage): ?>
<div class="alert alert-danger"><?= htmlspecialchars($errorMessage) ?></div>
<?php endif; ?>
<p>
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#add-vendor-form" aria-expanded="false" aria-controls="add-vendor-form">
Add New Vendor
</button>
</p>
<div class="collapse mb-4" id="add-vendor-form">
<div class="card card-body">
<form action="vendors.php" method="POST">
<input type="hidden" name="add_vendor" value="1">
<div class="mb-3">
<label for="name" class="form-label">Vendor Name</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="mb-3">
<label for="service_type" class="form-label">Service Type</label>
<input type="text" class="form-control" id="service_type" name="service_type" placeholder="e.g., Catering, Photography" required>
</div>
<div class="mb-3">
<label for="contact_email" class="form-label">Contact Email</label>
<input type="email" class="form-control" id="contact_email" name="contact_email" required>
</div>
<div class="mb-3">
<label for="contact_phone" class="form-label">Contact Phone</label>
<input type="tel" class="form-control" id="contact_phone" name="contact_phone">
</div>
<div class="mb-3">
<label for="rating" class="form-label">Rating (1-5)</label>
<input type="number" step="0.1" min="1" max="5" class="form-control" id="rating" name="rating">
</div>
<button type="submit" class="btn btn-success">Save Vendor</button>
</form>
</div>
</div>
<?php if (empty($vendors) && !$errorMessage): ?>
<div class="alert alert-info">
No vendors found. Get started by adding one!
</div>
<?php elseif (!$errorMessage): ?>
<div class="list-group">
<?php foreach ($vendors as $vendor): ?>
<div class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1"><?= htmlspecialchars($vendor['name']) ?></h5>
<small>Service: <?= htmlspecialchars($vendor['service_type']) ?></small>
</div>
<p class="mb-1">Contact: <?= htmlspecialchars($vendor['contact_email']) ?> | <?= htmlspecialchars($vendor['contact_phone']) ?></p>
<small class="d-block mb-2">Rating: <?= htmlspecialchars($vendor['rating']) ?> / 5</small>
<div>
<a href="edit-vendor.php?id=<?= $vendor['id'] ?>" class="btn btn-sm btn-outline-secondary">Edit</a>
<button type="button" class="btn btn-sm btn-outline-danger" data-bs-toggle="modal" data-bs-target="#delete-modal-<?= $vendor['id'] ?>">
Delete
</button>
</div>
</div>
<!-- Delete Confirmation Modal -->
<div class="modal fade" id="delete-modal-<?= $vendor['id'] ?>" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Confirm Deletion</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Are you sure you want to delete the vendor "<?= htmlspecialchars($vendor['name']) ?>"?
</div>
<div class="modal-footer">
<form action="vendors.php" method="POST" class="d-inline">
<input type="hidden" name="delete_vendor" value="1">
<input type="hidden" name="vendor_id" value="<?= $vendor['id'] ?>">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

207
venues.php Normal file
View File

@ -0,0 +1,207 @@
<?php
require_once 'db/config.php';
$errorMessage = null;
$successMessage = null;
// Handle form submission for deleting a venue
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_venue'])) {
$venue_id = filter_input(INPUT_POST, 'venue_id', FILTER_VALIDATE_INT);
if ($venue_id) {
try {
$pdo = db();
$stmt = $pdo->prepare('DELETE FROM venues WHERE id = ?');
$stmt->execute([$venue_id]);
$successMessage = "Success: Venue deleted successfully!";
header("Location: venues.php?success=2");
exit;
} catch (PDOException $e) {
$errorMessage = "Error: Could not delete the venue. " . $e->getMessage();
}
}
}
// Handle form submission for adding a new venue
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_venue'])) {
$name = trim($_POST['name'] ?? '');
$description = trim($_POST['description'] ?? '');
$capacity = filter_input(INPUT_POST, 'capacity', FILTER_VALIDATE_INT);
$features = trim($_POST['features'] ?? '');
if (empty($name) || $capacity === false || $capacity <= 0) {
$errorMessage = "Error: Venue name and a valid capacity are required.";
} else {
try {
$pdo = db();
$stmt = $pdo->prepare('INSERT INTO venues (name, description, capacity, features) VALUES (?, ?, ?, ?)');
$stmt->execute([$name, $description, $capacity, $features]);
$successMessage = "Success: Venue added successfully!";
// Redirect to avoid form resubmission
header("Location: venues.php?success=1");
exit;
} catch (PDOException $e) {
$errorMessage = "Error: Could not add the venue. " . $e->getMessage();
}
}
}
// Handle success message from redirect
if (isset($_GET['success'])) {
if ($_GET['success'] == '1') {
$successMessage = "Success: Venue added successfully!";
}
if ($_GET['success'] == '2') {
$successMessage = "Success: Venue deleted successfully!";
}
if ($_GET['success'] == '3') {
$successMessage = "Success: Venue updated successfully!";
}
}
// Fetch venues from the database
$venues = [];
try {
$pdo = db();
$stmt = $pdo->query('SELECT * FROM venues ORDER BY name');
$venues = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
// Handle DB error gracefully
$errorMessage = "Error: Could not connect to the database.";
// In a real app, you'd log this error.
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Venues - The Best Events</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="index.php">The Best Events</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="venues.php">Venues</a>
</li>
<li class="nav-item">
<a class="nav-link" href="vendors.php">Vendors</a>
</li>
</ul>
</div>
</div>
</nav>
<main class="container mt-4">
<h1 class="mb-4">Manage Venues</h1>
<?php if ($successMessage): ?>
<div class="alert alert-success">
<?= htmlspecialchars($successMessage) ?>
</div>
<?php endif; ?>
<?php if ($errorMessage): ?>
<div class="alert alert-danger">
<?= htmlspecialchars($errorMessage) ?>
</div>
<?php endif; ?>
<p>
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#add-venue-form" aria-expanded="false" aria-controls="add-venue-form">
Add New Venue
</button>
</p>
<div class="collapse mb-4" id="add-venue-form">
<div class="card card-body">
<form action="venues.php" method="POST">
<input type="hidden" name="add_venue" value="1">
<div class="mb-3">
<label for="name" class="form-label">Venue 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"></textarea>
</div>
<div class="mb-3">
<label for="capacity" class="form-label">Capacity</label>
<input type="number" class="form-control" id="capacity" name="capacity" required>
</div>
<div class="mb-3">
<label for="features" class="form-label">Features</label>
<input type="text" class="form-control" id="features" name="features" placeholder="e.g., WiFi, Projector, Catering Available">
</div>
<button type="submit" class="btn btn-success">Save Venue</button>
</form>
</div>
</div>
<?php if (isset($errorMessage)): ?>
<div class="alert alert-danger">
<?= htmlspecialchars($errorMessage) ?>
</div>
<?php elseif (empty($venues)): ?>
<div class="alert alert-info">
No venues found. Get started by adding one!
</div>
<?php else: ?>
<div class="list-group">
<?php foreach ($venues as $venue): ?>
<div class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1"><?= htmlspecialchars($venue['name']) ?></h5>
<small>Capacity: <?= htmlspecialchars($venue['capacity']) ?></small>
</div>
<p class="mb-1"><?= htmlspecialchars($venue['description']) ?></p>
<small class="d-block mb-2">Features: <?= htmlspecialchars($venue['features']) ?></small>
<div>
<a href="edit-venue.php?id=<?= $venue['id'] ?>" class="btn btn-sm btn-outline-secondary">Edit</a>
<button type="button" class="btn btn-sm btn-outline-danger" data-bs-toggle="modal" data-bs-target="#delete-modal-<?= $venue['id'] ?>">
Delete
</button>
</div>
</div>
<!-- Delete Confirmation Modal -->
<div class="modal fade" id="delete-modal-<?= $venue['id'] ?>" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteModalLabel">Confirm Deletion</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Are you sure you want to delete the venue "<?= htmlspecialchars($venue['name']) ?>"?
</div>
<div class="modal-footer">
<form action="venues.php" method="POST" class="d-inline">
<input type="hidden" name="delete_venue" value="1">
<input type="hidden" name="venue_id" value="<?= $venue['id'] ?>">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</main>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>