Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/portal/modules/directory/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/portal/modules/directory/README.md

# Directory Module

A comprehensive directory management system for managing member directories and standalone directory entries.

## Features

### Members Directory
- **Quick Search**: Search members by name, phone, email, or member ID
- **Complete List View**: View all members with advanced filtering
- **Filters**: Filter by District and Assembly (dynamic loading)
- **Sort**: Click column headers to sort data
- **Export**: Export to CSV format
- **Print**: Print-friendly view with proper formatting
- **Display Fields**: Member ID, Full Name, Phone, Email, Location

### Standalone Directory
- **CRUD Operations**: Add, Edit, Delete directory entries
- **Bulk Upload**: Import multiple entries via CSV or Excel (.xlsx, .xls)
- **Advanced Filters**: Filter by search term, district, and assembly
- **Export & Print**: Same export and print capabilities as Members Directory
- **Rich Data Fields**: 
  - Personal: Title, Names, Gender, Occupation
  - Contact: Phone, Email, Address, City
  - Location: Area, District, Assembly
  - Additional: Position, Notes

## Installation

1. Run the installation script as a superuser:
   ```
   http://your-domain/install_directory_module.php
   ```

2. The installer will:
   - Create `standalone_directory` database table
   - Create `core_management` table (if not exists)
   - Register the module in `module_management`
   - Add module to `core_management` for enable/disable control

## File Structure

```
modules/directory/
├── index.php                  # Members Directory - Search page
├── members-list.php          # Members Directory - List view with filters
├── standalone.php            # Standalone Directory - List view
├── standalone-add.php        # Standalone Directory - Add/Edit form
├── standalone-upload.php     # Standalone Directory - Bulk upload
└── README.md                 # This file

classes/
└── DirectoryManager.php      # Data access layer for directory operations

sql/
└── directory.sql             # Database schema
```

## Database Schema

### standalone_directory Table
- `id` - Primary key
- `title` - Optional title (Rev., Mr., Mrs., etc.)
- `first_name` - Required
- `middle_name` - Optional
- `last_name` - Required
- `gender` - Male/Female (required)
- `phone` - Contact number
- `email` - Email address
- `address_line` - Street address
- `city` - City name
- `area_id` - Foreign key to areas
- `district_id` - Foreign key to districts
- `assembly_id` - Foreign key to assemblies
- `occupation` - Job/profession
- `position` - Role/position
- `notes` - Additional information
- `photo` - Profile photo path (future use)
- `is_active` - Soft delete flag
- `created_at` - Timestamp
- `updated_at` - Timestamp
- `created_by` - User who created entry

### core_management Table
- Controls module enable/disable functionality
- Accessible from Settings > Core Management
- Superuser only

## Usage

### Members Directory Search
1. Navigate to **Directory** module
2. Enter search term in the search box
3. View results with member details
4. Click "View All Members" for complete list

### Members List View
1. Click "View All Members" button
2. Use filters to narrow results:
   - Search by name/phone/email
   - Select District (assemblies load dynamically)
   - Select Assembly
3. Sort by clicking column headers
4. Export to CSV or Print

### Standalone Directory Management

#### Add New Entry
1. Go to Standalone Directory page
2. Click "Add New Entry"
3. Fill in the form (First Name and Last Name required)
4. Select Area, District, and Assembly (optional)
5. Click "Add Entry"

#### Edit Entry
1. Find entry in the list
2. Click the edit icon (pencil)
3. Modify fields
4. Click "Update Entry"

#### Delete Entry
1. Find entry in the list
2. Click the delete icon (trash)
3. Confirm deletion

#### Bulk Upload
1. Click "Bulk Upload" button
2. Download CSV or Excel template
3. Fill in the data (remove sample row)
4. Upload the completed file
5. Review upload results

## Bulk Upload Template

### CSV/Excel Columns
1. Title
2. First Name (required)
3. Middle Name
4. Last Name (required)
5. Gender (Male/Female, required)
6. Phone
7. Email
8. Address Line
9. City
10. Area ID
11. District ID
12. Assembly ID
13. Occupation
14. Position
15. Notes

### Notes
- First Name and Last Name are mandatory
- Gender must be exactly "Male" or "Female"
- IDs (Area, District, Assembly) must match existing database records
- Both CSV and Excel formats supported
- Remove sample data before uploading

## Permissions

- **Module Access**: User level and above
- **Core Management**: Superuser only
- All logged-in users can access the directory features

## Export Features

### CSV Export
- Generates downloadable CSV file
- Includes all visible data
- Filename format: `members_directory_YYYY-MM-DD.csv` or `standalone_directory_YYYY-MM-DD.csv`

### Print
- Browser-based printing
- Clean formatting optimized for print
- Removes navigation and action buttons
- Table borders for clarity

## API Endpoints Used

- `../membership/get-assemblies.php` - Dynamic assembly loading based on district

## Dependencies

- **PhpSpreadsheet** (optional, for Excel support)
  - Install via: `composer require phpoffice/phpspreadsheet`
  - Required only for Excel upload/download features
  - CSV features work without this dependency

## Styling

- Uses application's gradient theme (blue, orange, mauve)
- Responsive design (mobile, tablet, desktop)
- Tailwind CSS classes
- Professional card-based UI
- Smooth transitions and hover effects

## Core Management Integration

The module can be enabled/disabled from:
1. Navigate to **Settings** > **Core Management**
2. Find "Directory" module
3. Toggle enable/disable
4. Changes take effect immediately

## Technical Details

### DirectoryManager Class Methods

#### For Standalone Directory
- `addEntry($data)` - Create new entry
- `updateEntry($id, $data)` - Update existing entry
- `deleteEntry($id)` - Delete entry (permanent)
- `getEntryById($id)` - Get single entry with location details
- `getAllEntries($filters)` - Get all entries with optional filters

#### For Members Directory
- `searchMembers($search, $filters)` - Search members with filters
- `getStats()` - Get directory statistics

### Security
- Session-based authentication required
- SQL injection prevention via prepared statements
- XSS prevention via htmlspecialchars()
- Input validation on all forms
- Foreign key constraints on database level

## Future Enhancements

- Photo upload functionality
- Advanced search with more criteria
- PDF export with custom layouts
- Email integration for directory entries
- QR code generation for contact cards
- Directory groups/categories
- Import from external sources
- API endpoints for mobile apps

## Support

For issues or feature requests, contact the system administrator.

## Version

Version: 1.0.0
Release Date: 2024

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