# Edumacflow Feature User Manual

This manual provides instructions on how to use the newly enhanced features in your Edumacflow system.

---

## 1. Database Management Module
**How to Access**: **School Settings** > **Database Management**

### 🗳️ Features:
1.  **Full Database Backup**:
    *   Click the **Generate & Download** button.
    *   The system will automatically download a `.sql` file containing all school data (Students, Results, Fees, etc.).
    *   Keep this file safely in an external storage device for security.
2.  **Run Optimization**:
    *   Click the **Run Optimization** button.
    *   This is recommended after large deletions or once a month to keep the system fast and responsive.
3.  **Database Restoration**:
    *   Click the **Upload & Restore** button.
    *   ⚠️ **Warning**: This will overwrite all your current data with the contents of the chosen backup file. Use ONLY when recovering from a system crash or data corruption.

---

## 2. Synchronization Hub
**How to Access**: **School Settings** > **Synchronization Hub**

### 🔄 How to Sync to Online Server:
1.  **Initial Setup**:
    *   Input your **Remote Server URL** (e.g., `https://hikimahschools.com/portal`).
    *   Input your **Sync API Secret Key** (Must be shared between offline and online systems).
2.  **Operating the Sync**:
    *   Click **Start Sync Operation**.
    *   The system will loop through all **Unsynced** records (Results, Students, Invoices) and push them over to your online portal.
    *   Wait for the notification summary at the top of the page.
    *   Once a record is successfully synced, it will not be sent again unless updated.

### ⚠️ Prerequisite Step:
Before using the Sync Hub for the first time, you MUST visit this URL in your browser:  
`http://localhost/Edumacflow/eduflow/db_update_sync.php`  
This script will upgrade your database schema to support tracking for synced items.

---

## 3. Adding Permissions
If features are not visible in your sidebar:
1.  Login as Super Admin.
2.  Go to **Role and Permission** > **Permission**.
3.  Add the following permission entries, one at a time:
    *   `db_management` → assign to **Admin**
    *   `sync_manager` → assign to **Admin**
    *   `elibrary` → assign to **Admin, Teachers, Students**
4.  Apply these permissions to the appropriate **Roles**.

---

## 4. Digital Library (E-Library)
**How to Access**: Click **Digital Library** in the sidebar (available to Admin, Teachers, and Students).

### 📤 Uploading a Material (Admin / Teacher):
1.  Click the **Upload New Material** button (top right).
2.  Fill in the upload form:
    *   **Title**: e.g., "Physics Final Exam Notes"
    *   **Category**: Choose from `E-Book`, `Class Note`, or `Assignment`
    *   **Subject**: Select relevant subject
    *   **For Class**: Select the class this material is for
    *   **Description**: Brief summary of the content
    *   **Select File**: Supports PDF, Word (.doc/.docx), PowerPoint, and ZIP files
3.  Click **Start Upload**. The file will appear in the library table.

### 📥 Downloading a Material (Student / Teacher):
1.  Navigate to **Digital Library** in the sidebar.
2.  Use the **Filters** at the top to narrow by Class or Category.
3.  Click the **blue Download button** (⬇) next to any material.
4.  The file will automatically download to your device.

### 🗑️ Deleting a Material (Admin only):
1.  Find the material in the table.
2.  Click the **red Delete button** (🗑️).
3.  Confirm the deletion prompt. The file on disk is also permanently removed.

### ⚠️ Prerequisite Step (First-Time Setup):
Before accessing the E-Library for the first time, visit this URL in your browser:  
`http://localhost/Edumacflow/eduflow/db_update_elibrary.php`  
This upgrades your database to support categories and descriptions for library materials.

### 📖 Student Digital Library Access:
Students see a **personalised** card-based view showing only materials uploaded for their class.

1.  Login as a **Student**.
2.  Click **Digital Library** in the left sidebar.
3.  The library automatically shows materials for your enrolled class.
4.  Use the **Category** and **Subject** dropdowns to filter materials.
5.  Click the **Download** button on any card to save the file to your device.

> **Note**: Students cannot upload or delete materials — those actions are reserved for Admin and Teachers.

---

---

## 5. Internal Mailbox System
**How to Access**: Click **Mailbox** in the main sidebar.

### ✉️ Features:
1.  **View Inbox**: See all messages sent to you or broadcast to your role (e.g., "Everyone").
2.  **Broadcast (Admin Only)**: Send a single message to all staff and students simultaneously.
3.  **Direct Messaging**: Teachers can message specific students, and students can message their teachers.
4.  **Message Status**: "New" messages are highlighted. Once clicked, they are marked as "Read".
5.  **Compose Modal**: Click **Compose Message** to start a new thread. Select the recipient type (Admin, Teacher, or Student) to load the context-specific list.

---

## 6. Smart Defaulters Tracker
**How to Access**: **Invoice Management** > **Defaulters Tracker**

### 📊 Features:
1.  **Real-Time Balances**: No more manual spreadsheets. This list is automatically generated by comparing **Invoices** against **Fee Payments**.
2.  **Live Filters**: Instantly see who owes money for a specific **Class**, **Session**, or **Term**.
3.  **Financial Health Summary**: Cards at the top show the total count of defaulters, total debt amount, and total revenue collected.
4.  **Urgency Tracking**: Records are highlighted based on the amount owed (Red for high debt, Yellow for moderate).
5.  **Send Reminders**: Click the **yellow Envelope icon** next to any student to jump directly to the Mailbox with their details pre-filled for a quick payment reminder.
6.  **Export Records**: Use the **Export CSV** button to download the list for offline analysis or school board meetings.

---

## 7. Configuration & Permissions

### ⚠️ Prerequisite Step (Phase 4):
Before using the Mailbox for the first time, visit this URL in your browser:  
`http://localhost/Edumacflow/eduflow/db_update_mail.php`  
This script creates the `internal_mail` table in your database.

### 📋 Full Permissions Table
Ensure these are added under **Role & Permission > Permission** and assigned to ensure the modules appear in the sidebar:

| Permission Key      | Module                        | Recommended Access               |
|---------------------|-------------------------------|----------------------------------|
| `db_management`     | Database Utilities            | Admin only                       |
| `sync_manager`      | Online Sync Hub               | Admin only                       |
| `elibrary`          | Digital Library (Admin/Staff) | Admin, Teachers                  |
| `student_elibrary`  | Digital Library (Students)    | Students                         |
| `mailbox`           | Internal Messaging            | Admin, Teachers, Students        |
| `defaulters_tracker`| Defaulters Tracking           | Admin, Accountants, Principals   |
| `qr_attendance`     | QR-Code Scanner               | Admin, Teachers                  |

---

## 8. Smart Attendance System
The attendance tracking process has been significantly modernized.

### 📲 QR-Code Scanning
**How to Access**: **Attendance** > **QR-Code Scanner**
1. Ensure your device has a working camera (Laptop webcam or Mobile device).
2. Configure the Session correctly (Class, Term, Current Session, Date).
3. The Camera will launch automatically. Give permission if asked.
4. Scan a student's **ID Card QR Code**; the reader will capture their unique Regisration Number instantly and record them as Present. All unscanned students automatically fall back to **Absent**.
5. Once all present students are scanned, click **Save Attendance Record**.

### 💼 CSV Import and Export
**How to Access**: **Attendance** > **Record Attendance**
- To backup or analyze attendance, click **Export CSV**.
- To bulk load attendance offline, download the CSV, edit it securely offline (do not alter headers or registration numbers structure), then upload via the **Import CSV** form. It will immediately synchronize with the database tracking for that day.

---
*Created by Antigravity AI*
