Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/attendance/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/attendance/DEPLOYMENT.md

# Church Attendance Management System - Deployment Guide

## Quick Start (XAMPP)

### 1. Download and Setup
1. Ensure XAMPP is installed and running
2. Place all files in `C:\xampp\htdocs\copattendance\`
3. Start Apache and MySQL services

### 2. Database Installation
**Option A: Using the Installation Wizard (Recommended)**
1. Open browser and go to `http://localhost/copattendance/install.php`
2. Follow the step-by-step installation wizard
3. Enter database credentials (default: host=localhost, user=root, password=empty)
4. The wizard will create the database and tables automatically

**Option B: Manual Installation**
1. Open phpMyAdmin (`http://localhost/phpmyadmin`)
2. Create a new database named `church_attendance`
3. Import the SQL file: `database/schema.sql`
4. Update database credentials in `config/database.php` if needed

### 3. Access the System
1. **Homepage**: `http://localhost/copattendance/`
2. **Admin Login**: `http://localhost/copattendance/admin/login.php`

### 4. Default Login Credentials
- **Email**: nabibo2@yahoo.co.uk
- **Username**: nabibo  
- **Password**: password123

**⚠️ IMPORTANT: Change the default password immediately after first login!**

## Production Deployment

### Prerequisites
- Web server (Apache/Nginx)
- PHP 7.4 or higher
- MySQL 5.7 or higher
- SSL certificate (recommended)

### Security Checklist
- [ ] Change default superuser password
- [ ] Update database credentials
- [ ] Enable HTTPS/SSL
- [ ] Set proper file permissions (755 for directories, 644 for files)
- [ ] Remove `install.php` after installation
- [ ] Configure regular database backups
- [ ] Enable PHP error logging (disable display_errors in production)

### File Permissions
```bash
# Set directory permissions
find /path/to/copattendance -type d -exec chmod 755 {} \;

# Set file permissions  
find /path/to/copattendance -type f -exec chmod 644 {} \;

# Make config directory writable for settings
chmod 755 /path/to/copattendance/config/

# Create and secure backups directory
mkdir /path/to/copattendance/backups/
chmod 755 /path/to/copattendance/backups/
```

### Apache Configuration (.htaccess)
The system includes `.htaccess` files for security. Ensure mod_rewrite is enabled.

### Database Configuration
Update `config/database.php` with production credentials:
```php
private $host = 'your-db-host';
private $db_name = 'your-db-name';
private $username = 'your-db-user';
private $password = 'your-secure-password';
```

## System Architecture

### Directory Structure
```
copattendance/
├── admin/                  # Admin panel
│   ├── includes/          # Shared components
│   ├── dashboard.php      # Main dashboard
│   ├── login.php         # Authentication
│   ├── programs.php      # Program management
│   ├── attendance.php    # Attendance records
│   ├── reports.php       # Analytics & reports
│   ├── locations.php     # Location management
│   ├── forms.php         # Form templates
│   ├── users.php         # User management
│   ├── settings.php      # System settings
│   └── audit.php         # Audit logs
├── assets/               # Static files
│   ├── css/             # Stylesheets
│   ├── js/              # JavaScript
│   └── images/          # Images & logos
├── attendance/          # Public forms
│   └── form.php        # Attendance submission
├── config/             # Configuration
│   ├── config.php     # Main config
│   └── database.php   # DB connection
├── database/          # Database files
│   └── schema.sql    # Database schema
├── index.php         # Landing page
├── install.php       # Installation wizard
└── README.md        # Documentation
```

### Database Tables
- **users**: System users (superuser, admin, regular)
- **locations**: Districts and assemblies
- **programs**: Church programs/events
- **form_templates**: Customizable form layouts
- **attendance_records**: Submitted attendance data
- **settings**: System configuration
- **notifications**: User notifications
- **audit_logs**: Activity tracking
- **backups**: Backup management

## Features Overview

### Public Features
- **Landing Page**: Program selection interface
- **Attendance Forms**: Mobile-optimized submission forms
- **Thank You Pages**: Confirmation after submission

### Admin Features
- **Dashboard**: Analytics and overview
- **Program Management**: Create/edit church programs
- **Attendance Records**: View and export data
- **Reports**: PDF/CSV/Excel export with charts
- **Location Management**: Districts and assemblies
- **Form Builder**: Customize attendance forms
- **User Management**: Role-based access control
- **Settings**: Site configuration
- **Audit Logs**: Security and activity tracking

### Security Features
- Password hashing (PHP password_hash)
- CSRF protection
- SQL injection prevention
- XSS protection
- Session security
- Activity logging
- Role-based permissions

## Customization

### Theme Colors
Edit `assets/css/style.css` to change the gradient colors:
```css
.gradient-bg {
    background: linear-gradient(135deg, #3B82F6 0%, #F59E0B 50%, #6B7280 100%);
}
```

### Site Branding
1. Login as superuser
2. Go to Settings > General
3. Update site title, logo, and footer
4. Upload custom logo to `assets/images/`

### Form Fields
1. Go to Admin > Form Management
2. Create custom form templates
3. Add fields like age groups, ministries, etc.
4. Set required/optional fields

## Backup & Maintenance

### Automatic Backups
1. Go to Settings > Backup & Restore
2. Set backup frequency (daily/weekly/monthly)
3. Backups stored in `/backups/` directory

### Manual Backup
1. Admin panel > Settings > Backup
2. Click "Create Backup Now"
3. Download generated SQL file

### Database Maintenance
```sql
-- Optimize tables monthly
OPTIMIZE TABLE attendance_records, audit_logs, users, programs;

-- Clean old audit logs (optional, keep 1 year)
DELETE FROM audit_logs WHERE created_at < DATE_SUB(NOW(), INTERVAL 1 YEAR);
```

## Troubleshooting

### Common Issues

**"Database connection failed"**
- Check MySQL service is running
- Verify credentials in `config/database.php`
- Ensure database exists

**"Permission denied" errors**
- Check file permissions (755/644)
- Ensure web server can write to config directory

**Forms not submitting**
- Check JavaScript is enabled
- Verify CSRF tokens
- Check browser console for errors

**Login issues**
- Clear browser cache/cookies
- Check user is active in database
- Verify password (default: password123)

### Performance Optimization
- Enable PHP OPcache
- Use CDN for static assets
- Enable gzip compression
- Optimize MySQL queries
- Regular database maintenance

## Support

### System Requirements
- **PHP**: 7.4+ (8.0+ recommended)
- **MySQL**: 5.7+ (8.0+ recommended)
- **Web Server**: Apache 2.4+ or Nginx 1.18+
- **Memory**: 256MB minimum
- **Storage**: 100MB minimum

### Browser Support
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
- Mobile browsers (iOS Safari, Chrome Mobile)

### Updates
1. Backup current system and database
2. Replace files (keep config directory)
3. Run any database migrations
4. Test functionality
5. Update documentation

---

**Version**: 1.0  
**Last Updated**: 2024  
**Support**: Contact your system administrator

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