498 lines
32 KiB
PHP
498 lines
32 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
// Fetch settings
|
|
$settings_stmt = db()->query('SELECT setting_key, setting_value FROM settings');
|
|
$settings = $settings_stmt->fetchAll(PDO::FETCH_KEY_PAIR);
|
|
$coach_mode = $settings['coach_mode'] ?? 'multi';
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
$user_id = $_SESSION['user_id'];
|
|
$user_role = $_SESSION['user_role'];
|
|
$bookings = [];
|
|
$existing_reviews = [];
|
|
$subscription = null;
|
|
|
|
// Update status of past bookings to 'completed'
|
|
$update_stmt = db()->prepare("UPDATE bookings SET status = 'completed' WHERE status = 'confirmed' AND booking_time < NOW()");
|
|
$update_stmt->execute();
|
|
|
|
if ($user_role === 'client') {
|
|
$stmt = db()->prepare("SELECT b.*, c.name as coach_name FROM bookings b JOIN coaches c ON b.coach_id = c.id WHERE b.client_id = ? ORDER BY b.booking_time DESC");
|
|
$stmt->execute([$user_id]);
|
|
$bookings = $stmt->fetchAll();
|
|
|
|
$review_stmt = db()->prepare("SELECT booking_id FROM reviews WHERE client_id = ?");
|
|
$review_stmt->execute([$user_id]);
|
|
$existing_reviews = $review_stmt->fetchAll(PDO::FETCH_COLUMN);
|
|
|
|
$sub_stmt = db()->prepare("SELECT * FROM client_subscriptions WHERE client_id = ? AND (status = 'active' OR status = 'trialing') ORDER BY created_at DESC LIMIT 1");
|
|
$sub_stmt->execute([$user_id]);
|
|
$subscription = $sub_stmt->fetch();
|
|
|
|
$client_stmt = db()->prepare("SELECT timezone FROM clients WHERE id = ?");
|
|
$client_stmt->execute([$user_id]);
|
|
$client = $client_stmt->fetch();
|
|
|
|
} elseif ($user_role === 'coach') {
|
|
$stmt = db()->prepare("SELECT b.*, c.name as client_name FROM bookings b JOIN clients c ON b.client_id = c.id WHERE b.coach_id = ? ORDER BY b.booking_time DESC");
|
|
$stmt->execute([$user_id]);
|
|
$bookings = $stmt->fetchAll();
|
|
|
|
$coach_stmt = db()->prepare("SELECT buffer_time, timezone FROM coaches WHERE id = ?");
|
|
$coach_stmt->execute([$user_id]);
|
|
$coach = $coach_stmt->fetch();
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Dashboard - CoachConnect</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
</head>
|
|
<body class="bg-gray-50">
|
|
|
|
<header class="bg-white shadow-md">
|
|
<nav class="container mx-auto px-6 py-4 flex justify-between items-center">
|
|
<a href="index.php" class="text-2xl font-bold text-gray-800">CoachConnect</a>
|
|
<div class="flex space-x-4">
|
|
<a href="index.php" class="text-gray-600 hover:text-blue-500">Home</a>
|
|
<?php if ($coach_mode === 'multi'): ?>
|
|
<a href="coaches.php" class="text-gray-600 hover:text-blue-500">Coaches</a>
|
|
<?php endif; ?>
|
|
<?php if (isset($_SESSION['user_id'])): ?>
|
|
<a href="dashboard.php" class="text-gray-600 hover:text-blue-500">Dashboard</a>
|
|
<a href="messages.php" class="text-gray-600 hover:text-blue-500">Messages</a>
|
|
<a href="logout.php" class="text-gray-600 hover:text-blue-500">Logout</a>
|
|
<?php else: ?>
|
|
<a href="login.php" class="text-gray-600 hover:text-blue-500">Login</a>
|
|
<a href="register-client.php" class="text-gray-600 hover:text-blue-500">Sign Up</a>
|
|
<a href="register-coach.php" class="text-gray-600 hover:text-blue-500">Become a Coach</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
</nav>
|
|
</header>
|
|
|
|
<main class="container mx-auto px-6 py-12">
|
|
<?php if ($user_role === 'client' && isset($_GET['booking']) && $_GET['booking'] === 'pending'): ?>
|
|
<div class="bg-blue-100 border-t-4 border-blue-500 rounded-b text-blue-900 px-4 py-3 shadow-md mb-8" role="alert">
|
|
<div class="flex">
|
|
<div class="py-1"><svg class="fill-current h-6 w-6 text-blue-500 mr-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm12.73-1.41A8 8 0 1 0 4.34 4.34a8 8 0 0 0 11.32 11.32zM9 11V9h2v6H9v-4zm0-6h2v2H9V5z"/></svg></div>
|
|
<div>
|
|
<p class="font-bold">Your booking is pending approval.</p>
|
|
<p class="text-sm">You will be notified once the coach confirms the booking.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if ($user_role === 'coach'): ?>
|
|
<div class="bg-white shadow-md rounded-lg p-6 mb-8">
|
|
<h2 class="text-2xl font-bold text-gray-800 mb-4">Manage Your One-Off Availability</h2>
|
|
<form action="add-availability.php" method="post">
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<div>
|
|
<label for="date" class="block text-sm font-medium text-gray-700">Date</label>
|
|
<input type="date" name="date" id="date" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
|
|
</div>
|
|
<div>
|
|
<label for="start_time" class="block text-sm font-medium text-gray-700">Start Time</label>
|
|
<input type="time" name="start_time" id="start_time" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
|
|
</div>
|
|
<div>
|
|
<label for="end_time" class="block text-sm font-medium text-gray-700">End Time</label>
|
|
<input type="time" name="end_time" id="end_time" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
|
|
</div>
|
|
</div>
|
|
<div class="mt-4">
|
|
<button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
Add Availability
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="bg-white shadow-md rounded-lg p-6 mb-8">
|
|
<h2 class="text-2xl font-bold text-gray-800 mb-4">Manage Your Recurring Weekly Availability</h2>
|
|
<form action="add-recurring-availability.php" method="post">
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<div>
|
|
<label for="day_of_week" class="block text-sm font-medium text-gray-700">Day of Week</label>
|
|
<select name="day_of_week" id="day_of_week" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
|
|
<option value="1">Monday</option>
|
|
<option value="2">Tuesday</option>
|
|
<option value="3">Wednesday</option>
|
|
<option value="4">Thursday</option>
|
|
<option value="5">Friday</option>
|
|
<option value="6">Saturday</option>
|
|
<option value="0">Sunday</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label for="recurring_start_time" class="block text-sm font-medium text-gray-700">Start Time</label>
|
|
<input type="time" name="start_time" id="recurring_start_time" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
|
|
</div>
|
|
<div>
|
|
<label for="recurring_end_time" class="block text-sm font-medium text-gray-700">End Time</label>
|
|
<input type="time" name="end_time" id="recurring_end_time" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
|
|
</div>
|
|
</div>
|
|
<div class="mt-4">
|
|
<button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
Add Recurring Availability
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="bg-white shadow-md rounded-lg p-6 mb-8">
|
|
<h2 class="text-2xl font-bold text-gray-800 mb-4">Manage Your Settings</h2>
|
|
<form action="update-coach-settings.php" method="post">
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<div>
|
|
<label for="buffer_time" class="block text-sm font-medium text-gray-700">Buffer Time (minutes)</label>
|
|
<input type="number" name="buffer_time" id="buffer_time" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" value="<?php echo htmlspecialchars($coach['buffer_time'] ?? 0); ?>" required>
|
|
</div>
|
|
<div>
|
|
<label for="timezone" class="block text-sm font-medium text-gray-700">Timezone</label>
|
|
<select id="timezone" name="timezone" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
|
|
<?php
|
|
$timezones = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
|
|
foreach ($timezones as $tz) {
|
|
$selected = ($coach['timezone'] ?? 'UTC') === $tz ? 'selected' : '';
|
|
echo '<option value="' . htmlspecialchars($tz) . '" ' . $selected . '>' . htmlspecialchars($tz) . '</option>';
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="mt-4">
|
|
<button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
Update Settings
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="bg-white shadow-md rounded-lg p-6 mb-8">
|
|
<h2 class="text-2xl font-bold text-gray-800 mb-4">Manage Service Packages</h2>
|
|
<p class="text-gray-600 mb-4">Create, view, and manage your coaching packages.</p>
|
|
<a href="manage-packages.php" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700">Manage Packages</a>
|
|
</div>
|
|
<div class="bg-white shadow-md rounded-lg p-6 mb-8">
|
|
<h2 class="text-2xl font-bold text-gray-800 mb-4">Manage Your Portfolio</h2>
|
|
<p class="text-gray-600 mb-4">Update your bio, specialties, and upload media to showcase your work.</p>
|
|
<a href="edit-portfolio.php" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700">Edit Portfolio</a>
|
|
</div>
|
|
<div class="bg-white shadow-md rounded-lg p-6 mb-8">
|
|
<h2 class="text-2xl font-bold text-gray-800 mb-4">Admin Settings</h2>
|
|
<p class="text-gray-600 mb-4">Configure site-wide settings and modes.</p>
|
|
<a href="admin/settings.php" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-gray-700 hover:bg-gray-800">Go to Settings</a>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if ($user_role === 'client'): ?>
|
|
<div class="bg-white shadow-md rounded-lg p-6 mb-8">
|
|
<h2 class="text-2xl font-bold text-gray-800 mb-4">Manage Your Settings</h2>
|
|
<form action="update-client-settings.php" method="post">
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<div>
|
|
<label for="timezone" class="block text-sm font-medium text-gray-700">Timezone</label>
|
|
<select id="timezone" name="timezone" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
|
|
<?php
|
|
$timezones = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
|
|
foreach ($timezones as $tz) {
|
|
$selected = ($client['timezone'] ?? 'UTC') === $tz ? 'selected' : '';
|
|
echo '<option value="' . htmlspecialchars($tz) . '" ' . $selected . '>' . htmlspecialchars($tz) . '</option>';
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="mt-4">
|
|
<button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
Update Settings
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="bg-white shadow-md rounded-lg p-6 mb-8">
|
|
<h2 class="text-2xl font-bold text-gray-800 mb-4">Your Packages</h2>
|
|
<?php
|
|
$packages_stmt = db()->prepare("SELECT cp.sessions_remaining, sp.name FROM client_packages cp JOIN service_packages sp ON cp.package_id = sp.id WHERE cp.client_id = ?");
|
|
$packages_stmt->execute([$user_id]);
|
|
$client_packages = $packages_stmt->fetchAll();
|
|
?>
|
|
<?php if ($client_packages): ?>
|
|
<ul class="list-disc list-inside space-y-2">
|
|
<?php foreach ($client_packages as $pkg): ?>
|
|
<li><strong><?= htmlspecialchars($pkg['name']) ?>:</strong> <?= htmlspecialchars($pkg['sessions_remaining']) ?> sessions remaining</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php else: ?>
|
|
<p class="text-gray-600 mb-4">You have not purchased any packages yet.</p>
|
|
<a href="coaches.php" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700">Browse Packages</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="bg-white shadow-md rounded-lg p-6 mb-8">
|
|
<h2 class="text-2xl font-bold text-gray-800 mb-4">Your Subscriptions</h2>
|
|
<?php
|
|
$subs_stmt = db()->prepare("SELECT cs.*, sp.name FROM client_subscriptions cs JOIN service_packages sp ON cs.package_id = sp.id WHERE cs.client_id = ? ORDER BY cs.created_at DESC");
|
|
$subs_stmt->execute([$user_id]);
|
|
$subscriptions = $subs_stmt->fetchAll();
|
|
?>
|
|
<?php if ($subscriptions): ?>
|
|
<ul class="list-disc list-inside space-y-2">
|
|
<?php foreach ($subscriptions as $sub): ?>
|
|
<li><strong><?= htmlspecialchars($sub['name']) ?>:</strong> <span class="font-semibold text-green-600"><?= htmlspecialchars(ucfirst($sub['status'])) ?></span></li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<a href="manage-subscription.php" class="mt-4 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700">Manage Subscriptions</a>
|
|
<?php else: ?>
|
|
<p class="text-gray-600 mb-4">You do not have any active subscriptions.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<h1 class="text-3xl font-bold text-gray-800 mb-8">Your Bookings</h1>
|
|
|
|
<?php if (isset($_GET['status'])):
|
|
$status = $_GET['status'];
|
|
$message = '';
|
|
$alert_type = '';
|
|
|
|
switch ($status) {
|
|
case 'approved':
|
|
$message = 'Booking approved successfully.';
|
|
$alert_type = 'green';
|
|
break;
|
|
case 'declined':
|
|
$message = 'Booking declined successfully.';
|
|
$alert_type = 'yellow';
|
|
break;
|
|
case 'cancelled':
|
|
$message = 'Booking cancelled successfully.';
|
|
$alert_type = 'yellow';
|
|
break;
|
|
case 'review_success':
|
|
$message = 'Thank you for your review!';
|
|
$alert_type = 'green';
|
|
break;
|
|
case 'already_reviewed':
|
|
$message = 'You have already reviewed this booking.';
|
|
$alert_type = 'yellow';
|
|
break;
|
|
case 'buffer_updated':
|
|
$message = 'Buffer time updated successfully.';
|
|
$alert_type = 'green';
|
|
break;
|
|
case 'settings_updated':
|
|
$message = 'Settings updated successfully.';
|
|
$alert_type = 'green';
|
|
break;
|
|
case 'error':
|
|
$message = 'An error occurred. Please try again.';
|
|
$alert_type = 'red';
|
|
break;
|
|
}
|
|
?>
|
|
<div class="bg-<?php echo $alert_type; ?>-100 border border-<?php echo $alert_type; ?>-400 text-<?php echo $alert_type; ?>-700 px-4 py-3 rounded relative mb-4" role="alert">
|
|
<span class="block sm:inline"><?php echo $message; ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (isset($_GET['booking']) && $_GET['booking'] === 'success'): ?>
|
|
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4" role="alert">
|
|
<strong class="font-bold">Success!</strong>
|
|
<span class="block sm:inline">Your booking request has been sent.</span>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="flex flex-col gap-8">
|
|
<div class="bg-white shadow-md rounded-lg overflow-x-auto">
|
|
<table class="min-w-full leading-normal">
|
|
<thead>
|
|
<tr>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
|
Start Time
|
|
</th>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
|
End Time
|
|
</th>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$availability = [];
|
|
if ($user_role === 'coach') {
|
|
$stmt = db()->prepare("SELECT * FROM coach_availability WHERE coach_id = ? ORDER BY start_time DESC");
|
|
$stmt->execute([$user_id]);
|
|
$availability = $stmt->fetchAll();
|
|
}
|
|
|
|
if (empty($availability)):
|
|
?>
|
|
<tr>
|
|
<td colspan="3" class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-center">No availability set.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($availability as $slot): ?>
|
|
<tr>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
|
<p class="text-gray-900 whitespace-no-wrap"><?php echo htmlspecialchars(date('F j, Y, g:i a', strtotime($slot['start_time']))); ?></p>
|
|
</td>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
|
<p class="text-gray-900 whitespace-no-wrap"><?php echo htmlspecialchars(date('F j, Y, g:i a', strtotime($slot['end_time']))); ?></p>
|
|
</td>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-right">
|
|
<a href="delete-availability.php?id=<?php echo $slot['id']; ?>" class="text-red-600 hover:text-red-900">Delete</a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="bg-white shadow-md rounded-lg overflow-x-auto">
|
|
<h3 class="text-xl font-bold text-gray-800 p-4">Your Recurring Weekly Availability</h3>
|
|
<table class="min-w-full leading-normal">
|
|
<thead>
|
|
<tr>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
|
Day of Week
|
|
</th>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
|
Start Time
|
|
</th>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
|
End Time
|
|
</th>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$recurring_availability = [];
|
|
if ($user_role === 'coach') {
|
|
$stmt = db()->prepare("SELECT * FROM coach_recurring_availability WHERE coach_id = ? ORDER BY day_of_week, start_time");
|
|
$stmt->execute([$user_id]);
|
|
$recurring_availability = $stmt->fetchAll();
|
|
$days_of_week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
}
|
|
|
|
if (empty($recurring_availability)):
|
|
?>
|
|
<tr>
|
|
<td colspan="4" class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-center">No recurring availability set.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($recurring_availability as $slot): ?>
|
|
<tr>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
|
<p class="text-gray-900 whitespace-no-wrap"><?php echo htmlspecialchars($days_of_week[$slot['day_of_week']]); ?></p>
|
|
</td>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
|
<p class="text-gray-900 whitespace-no-wrap"><?php echo htmlspecialchars(date('g:i a', strtotime($slot['start_time']))); ?></p>
|
|
</td>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
|
<p class="text-gray-900 whitespace-no-wrap"><?php echo htmlspecialchars(date('g:i a', strtotime($slot['end_time']))); ?></p>
|
|
</td>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-right">
|
|
<a href="delete-recurring-availability.php?id=<?php echo $slot['id']; ?>" class="text-red-600 hover:text-red-900">Delete</a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="bg-white shadow-md rounded-lg overflow-x-auto">
|
|
<table class="min-w-full leading-normal">
|
|
<thead>
|
|
<tr>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
|
<?php echo $user_role === 'client' ? 'Coach' : 'Client'; ?>
|
|
</th>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
|
Booking Time
|
|
</th>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
|
Status
|
|
</th>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($bookings)): ?>
|
|
<tr>
|
|
<td colspan="4" class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-center">No bookings found.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($bookings as $booking): ?>
|
|
<tr>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
|
<p class="text-gray-900 whitespace-no-wrap">
|
|
<?php echo htmlspecialchars($user_role === 'client' ? $booking['coach_name'] : $booking['client_name']); ?>
|
|
</p>
|
|
</td>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
|
<p class="text-gray-900 whitespace-no-wrap"><?php echo htmlspecialchars(date('F j, Y, g:i a', strtotime($booking['booking_time']))); ?></p>
|
|
</td>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
|
<span class="relative inline-block px-3 py-1 font-semibold text-green-900 leading-tight">
|
|
<span aria-hidden class="absolute inset-0 <?php
|
|
switch ($booking['status']) {
|
|
case 'pending':
|
|
echo 'bg-yellow-200';
|
|
break;
|
|
case 'confirmed':
|
|
echo 'bg-green-200';
|
|
break;
|
|
case 'completed':
|
|
echo 'bg-blue-200';
|
|
break;
|
|
case 'cancelled':
|
|
case 'declined':
|
|
echo 'bg-red-200';
|
|
break;
|
|
}
|
|
?> opacity-50 rounded-full"></span>
|
|
<span class="relative"><?php echo htmlspecialchars(ucfirst($booking['status'])); ?></span>
|
|
</span>
|
|
</td>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-right">
|
|
<?php if ($user_role === 'coach' && $booking['status'] === 'pending'): ?>
|
|
<a href="approve-booking.php?id=<?php echo $booking['id']; ?>" class="text-green-600 hover:text-green-900 mr-3">Approve</a>
|
|
<a href="decline-booking.php?id=<?php echo $booking['id']; ?>" class="text-red-600 hover:text-red-900">Decline</a>
|
|
<?php elseif ($user_role === 'client' && ($booking['status'] === 'pending' || $booking['status'] === 'confirmed')): ?>
|
|
<a href="cancel-booking.php?id=<?php echo $booking['id']; ?>" class="text-red-600 hover:text-red-900">Cancel</a>
|
|
<?php elseif ($user_role === 'client' && $booking['status'] === 'completed' && !in_array($booking['id'], $existing_reviews)): ?>
|
|
<a href="review-booking.php?id=<?php echo $booking['id']; ?>" class="text-blue-600 hover:text-blue-900">Review</a>
|
|
<?php elseif ($user_role === 'coach' && ($booking['status'] === 'confirmed' || $booking['status'] === 'completed') && !empty($booking['stripe_payment_intent_id'])): ?>
|
|
<a href="refund.php?booking_id=<?php echo $booking['id']; ?>" class="text-blue-600 hover:text-blue-900">Refund</a>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<footer class="bg-gray-800 text-white py-6 mt-12">
|
|
<div class="container mx-auto px-6 text-center">
|
|
<p>© <?php echo date("Y"); ?> CoachConnect. All rights reserved.</p>
|
|
</div>
|
|
</footer>
|
|
|
|
</body>
|
|
</html>
|