Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/portal/sql/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/portal/sql/event_system_tables.sql

-- Event Registration and Attendance System Tables

-- Event Registrations Table
CREATE TABLE IF NOT EXISTS event_registrations (
    id INT AUTO_INCREMENT PRIMARY KEY,
    event_id INT NOT NULL,
    member_id INT NULL,
    user_id INT NULL,
    first_name VARCHAR(100) NOT NULL,
    last_name VARCHAR(100) NOT NULL,
    email VARCHAR(255) NOT NULL,
    phone VARCHAR(20) NULL,
    registration_type ENUM('member', 'guest') DEFAULT 'guest',
    tracking_code VARCHAR(100) UNIQUE NOT NULL,
    registration_data JSON NULL,
    status ENUM('pending', 'confirmed', 'cancelled', 'attended') DEFAULT 'pending',
    registered_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    confirmed_at TIMESTAMP NULL,
    attended_at TIMESTAMP NULL,
    notes TEXT NULL,
    
    FOREIGN KEY (event_id) REFERENCES events(id) ON DELETE CASCADE,
    FOREIGN KEY (member_id) REFERENCES members(id) ON DELETE SET NULL,
    FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL,
    
    INDEX idx_event_id (event_id),
    INDEX idx_member_id (member_id),
    INDEX idx_user_id (user_id),
    INDEX idx_tracking_code (tracking_code),
    INDEX idx_status (status),
    INDEX idx_registration_type (registration_type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Event Attendance Table
CREATE TABLE IF NOT EXISTS event_attendance (
    id INT AUTO_INCREMENT PRIMARY KEY,
    event_id INT NOT NULL,
    registration_id INT NULL,
    member_id INT NULL,
    user_id INT NULL,
    first_name VARCHAR(100) NOT NULL,
    last_name VARCHAR(100) NOT NULL,
    attendance_type ENUM('registered', 'walk_in') DEFAULT 'registered',
    check_in_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    check_out_time TIMESTAMP NULL,
    notes TEXT NULL,
    recorded_by INT NULL,
    
    FOREIGN KEY (event_id) REFERENCES events(id) ON DELETE CASCADE,
    FOREIGN KEY (registration_id) REFERENCES event_registrations(id) ON DELETE SET NULL,
    FOREIGN KEY (member_id) REFERENCES members(id) ON DELETE SET NULL,
    FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL,
    FOREIGN KEY (recorded_by) REFERENCES users(id) ON DELETE SET NULL,
    
    INDEX idx_event_id (event_id),
    INDEX idx_registration_id (registration_id),
    INDEX idx_member_id (member_id),
    INDEX idx_user_id (user_id),
    INDEX idx_attendance_type (attendance_type),
    INDEX idx_check_in_time (check_in_time)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Event Forms Table (for dynamic registration forms)
CREATE TABLE IF NOT EXISTS event_forms (
    id INT AUTO_INCREMENT PRIMARY KEY,
    event_id INT NOT NULL,
    form_name VARCHAR(255) NOT NULL,
    form_fields JSON NOT NULL,
    is_active BOOLEAN DEFAULT TRUE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    
    FOREIGN KEY (event_id) REFERENCES events(id) ON DELETE CASCADE,
    INDEX idx_event_id (event_id),
    INDEX idx_is_active (is_active)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Update events table with additional fields for public display
ALTER TABLE events 
ADD COLUMN IF NOT EXISTS featured BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS image_url VARCHAR(500) NULL,
ADD COLUMN IF NOT EXISTS max_attendees INT NULL,
ADD COLUMN IF NOT EXISTS registration_fee DECIMAL(10,2) DEFAULT 0.00,
ADD COLUMN IF NOT EXISTS event_type ENUM('conference', 'workshop', 'rally', 'service', 'program', 'fellowship', 'other') DEFAULT 'other',
ADD COLUMN IF NOT EXISTS public_registration BOOLEAN DEFAULT TRUE,
ADD COLUMN IF NOT EXISTS require_approval BOOLEAN DEFAULT FALSE;

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists