25 lines
665 B
PHP
25 lines
665 B
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'coach') {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
if (isset($_GET['id'])) {
|
|
$coach_id = $_SESSION['user_id'];
|
|
$availability_id = $_GET['id'];
|
|
|
|
try {
|
|
$stmt = db()->prepare("DELETE FROM coach_recurring_availability WHERE id = ? AND coach_id = ?");
|
|
$stmt->execute([$availability_id, $coach_id]);
|
|
header('Location: dashboard.php?status=recurring_deleted');
|
|
} catch (PDOException $e) {
|
|
header('Location: dashboard.php?status=error');
|
|
}
|
|
} else {
|
|
header('Location: dashboard.php');
|
|
}
|
|
exit;
|