# ═══════════════════════════════════════════════════════════════
# PHASE 11: COMMUNICATIONS & DOCUMENTS MODULE
# Module directory: /modules/communications/
# ═══════════════════════════════════════════════════════════════
# READ THE MASTER PROMPT FIRST.

## YOUR TABLES
notification_channels, notification_templates, notification_triggers,
notification_queue, notifications_sent, notification_preferences,
scheduled_notifications, bulk_communications, bulk_communication_recipients,
email_log, sms_log, announcements, announcement_reads,
document_templates, generated_documents

## PAGES TO BUILD

### 1. Notification Templates (`GET /communications/templates`)
- CRUD for notification_templates
- Channel selection, trigger mapping
- Template body with variable placeholders (shown with helper)
- Preview functionality
- Bilingual (EN + AR)

### 2. Notification Channels (`GET /communications/channels`)
- CRUD for channels with configuration

### 3. Notification Triggers (`GET /communications/triggers`)
- Map events to templates
- Condition configuration

### 4. Notification Queue (`GET /communications/queue`)
- DataTable of queued/sent/failed notifications
- Retry failed
- Cancel queued

### 5. Bulk Communications (`GET /communications/bulk`)
- Campaign creation: name, channel, template, target criteria
- Target criteria builder (by membership type, status, age, etc.)
- Preview recipients
- Schedule or send immediately
- Track delivery stats

### 6. Sent Notifications (`GET /communications/sent`)
- DataTable of all sent notifications
- Delivery status tracking

### 7. SMS Log & Email Log
- Dedicated views for SMS and email logs

### 8. Notification Preferences (member-facing, but admin can view)
- Per-member channel/trigger opt-in/opt-out

### 9. Announcements (`GET /communications/announcements`)
- CRUD: Title, body (EN+AR), category, priority, target audience
- Publish/unpublish toggle
- Pin toggle
- Expiry date
- Views/reads tracking

### 10. Document Templates (`GET /communications/document-templates`)
- CRUD for document_templates
- Template body editor (HTML with variable placeholders)
- Variables list per template
- Paper size, orientation settings

### 11. Generate Document (`POST /communications/documents/generate`)
- Select template, select member/reference
- Preview generated document
- Download PDF
- Track in generated_documents

## DASHBOARD WIDGETS
1. **Notifications Sent Today** — Count by channel
2. **Failed Notifications** — Recent failures

## PERMISSIONS
notifications.view, notifications.send, notifications.bulk,
documents.view, documents.manage