Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/attendance/database/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/attendance/database/add_tracking_code.sql

-- Add tracking code field to attendance_records table
ALTER TABLE attendance_records 
ADD COLUMN tracking_code VARCHAR(20) UNIQUE NOT NULL AFTER id;

-- Add index for faster lookups
CREATE INDEX idx_attendance_tracking ON attendance_records(tracking_code);

-- Add email settings table for email management
CREATE TABLE email_settings (
    id INT AUTO_INCREMENT PRIMARY KEY,
    smtp_host VARCHAR(255) NOT NULL,
    smtp_port INT NOT NULL DEFAULT 587,
    smtp_username VARCHAR(255) NOT NULL,
    smtp_password VARCHAR(255) NOT NULL,
    smtp_encryption ENUM('tls', 'ssl', 'none') DEFAULT 'tls',
    from_email VARCHAR(255) NOT NULL,
    from_name VARCHAR(255) NOT NULL,
    is_active BOOLEAN DEFAULT TRUE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

-- Insert default email settings
INSERT INTO email_settings (smtp_host, smtp_port, smtp_username, smtp_password, from_email, from_name) 
VALUES ('smtp.gmail.com', 587, 'your-email@gmail.com', 'your-app-password', 'your-email@gmail.com', 'Church Attendance System');

-- Add email templates table
CREATE TABLE email_templates (
    id INT AUTO_INCREMENT PRIMARY KEY,
    template_name VARCHAR(100) NOT NULL,
    subject VARCHAR(255) NOT NULL,
    body TEXT NOT NULL,
    is_active BOOLEAN DEFAULT TRUE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

-- Insert default welcome email template
INSERT INTO email_templates (template_name, subject, body) VALUES 
('attendance_confirmation', 
'Welcome to {{program_name}} - Attendance Confirmed', 
'Dear {{full_name}},

Thank you for registering your attendance for {{program_name}}.

Your attendance has been successfully recorded with the following details:
- Tracking Code: {{tracking_code}}
- Program: {{program_name}}
- District: {{district_name}}
- Assembly: {{assembly_name}}
- Date: {{submission_date}}

You can use your tracking code ({{tracking_code}}) to check your attendance details anytime by visiting our status check page.

Thank you for your participation!

Best regards,
Church Attendance Management Team');

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