Sindbad~EG File Manager
<?php
require_once '../config/config.php';
// Check if user is logged in and has admin privileges
if (!isLoggedIn() || !hasRole('admin')) {
redirect('../login.php');
}
$db = new Database();
$conn = $db->getConnection();
$success_message = '';
$error_message = '';
try {
// Check if columns already exist
$check_query = "SHOW COLUMNS FROM programs LIKE 'registration_status'";
$stmt = $conn->prepare($check_query);
$stmt->execute();
$column_exists = $stmt->fetch();
if (!$column_exists) {
// Read and execute the SQL file
$sql_file = '../database/add_form_registration_status.sql';
if (file_exists($sql_file)) {
$sql_content = file_get_contents($sql_file);
// Split SQL statements and execute them
$statements = array_filter(array_map('trim', explode(';', $sql_content)));
foreach ($statements as $statement) {
if (!empty($statement) && !str_starts_with(trim($statement), '--')) {
$stmt = $conn->prepare($statement);
$stmt->execute();
}
}
$success_message = 'Form registration status system has been successfully set up!';
// Log the activity
logActivity($_SESSION['user_id'], 'setup_form_registration', 'Set up form registration status system');
} else {
$error_message = 'SQL file not found.';
}
} else {
$success_message = 'Form registration status system is already set up.';
}
} catch (Exception $e) {
$error_message = 'Error setting up form registration status system: ' . $e->getMessage();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Setup Form Registration Status - Admin Panel</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
</head>
<body class="bg-gray-50">
<!-- Include Sidebar -->
<?php include 'includes/sidebar.php'; ?>
<!-- Main Content -->
<div class="md:ml-64">
<!-- Header -->
<header class="bg-white shadow-sm border-b">
<div class="px-6 py-4">
<div class="flex items-center justify-between">
<h1 class="text-2xl font-bold text-gray-900">Setup Form Registration Status</h1>
<a href="forms.php" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 transition duration-300">
<i class="fas fa-arrow-left mr-2"></i>
Back to Forms
</a>
</div>
</div>
</header>
<!-- Content -->
<main class="p-6">
<div class="max-w-4xl mx-auto">
<!-- Success/Error Messages -->
<?php if ($success_message): ?>
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-6">
<div class="flex items-center">
<i class="fas fa-check-circle mr-2"></i>
<span><?php echo $success_message; ?></span>
</div>
</div>
<?php endif; ?>
<?php if ($error_message): ?>
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-6">
<div class="flex items-center">
<i class="fas fa-exclamation-circle mr-2"></i>
<span><?php echo $error_message; ?></span>
</div>
</div>
<?php endif; ?>
<!-- Setup Information -->
<div class="bg-white rounded-lg shadow p-6 mb-6">
<h2 class="text-xl font-semibold text-gray-900 mb-4">Form Registration Status System</h2>
<div class="prose max-w-none">
<p class="text-gray-600 mb-4">
This setup adds form registration status management to your attendance system.
It allows administrators to control when users can register for programs.
</p>
<h3 class="text-lg font-semibold text-gray-900 mb-3">Features Added:</h3>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-4">
<li><strong>Registration Status Control:</strong> Open, Closed, or Scheduled registration</li>
<li><strong>Date-based Scheduling:</strong> Set specific open and close dates for registration</li>
<li><strong>Custom Messages:</strong> Display custom messages to users when registration is closed</li>
<li><strong>Admin Interface:</strong> Easy-to-use controls in the forms management page</li>
<li><strong>User Notifications:</strong> Clear status messages on attendance forms</li>
</ul>
<h3 class="text-lg font-semibold text-gray-900 mb-3">Registration Status Options:</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-4">
<div class="border rounded-lg p-4">
<div class="flex items-center mb-2">
<i class="fas fa-check-circle text-green-600 mr-2"></i>
<h4 class="font-semibold text-green-800">Open</h4>
</div>
<p class="text-sm text-gray-600">Registration is open and users can submit attendance forms</p>
</div>
<div class="border rounded-lg p-4">
<div class="flex items-center mb-2">
<i class="fas fa-times-circle text-red-600 mr-2"></i>
<h4 class="font-semibold text-red-800">Closed</h4>
</div>
<p class="text-sm text-gray-600">Registration is closed and users cannot submit forms</p>
</div>
<div class="border rounded-lg p-4">
<div class="flex items-center mb-2">
<i class="fas fa-clock text-blue-600 mr-2"></i>
<h4 class="font-semibold text-blue-800">Scheduled</h4>
</div>
<p class="text-sm text-gray-600">Registration opens/closes automatically based on set dates</p>
</div>
</div>
</div>
</div>
<!-- Next Steps -->
<div class="bg-blue-50 border border-blue-200 rounded-lg p-6">
<h3 class="text-lg font-semibold text-blue-900 mb-3">
<i class="fas fa-info-circle mr-2"></i>
Next Steps
</h3>
<div class="space-y-2 text-blue-800">
<p>1. Go to <a href="forms.php" class="font-semibold underline">Form Management</a> to configure registration status for your programs</p>
<p>2. Set registration dates and custom messages as needed</p>
<p>3. Test the functionality by visiting your attendance forms</p>
<p>4. Users will now see registration status messages on attendance forms</p>
</div>
</div>
</div>
</main>
</div>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists