diff --git a/charity-settings.php b/charity-settings.php index 60f6533..62354a6 100644 --- a/charity-settings.php +++ b/charity-settings.php @@ -1,6 +1,6 @@ fetchColumn(); $total_pages = ceil($total_records / $limit); // Fetch paginated results -$query = "SELECT m.*, s.name as status_name, s.color as status_color, u.full_name as assigned_to_name +$query = "SELECT m.*, s.name as status_name, s.color as status_color, u.full_name as assigned_to_name, + (SELECT GROUP_CONCAT(display_name SEPARATOR '|||') FROM inbound_attachments WHERE mail_id = m.id) as attachment_names FROM inbound_mail m LEFT JOIN mailbox_statuses s ON m.status_id = s.id LEFT JOIN users u ON m.assigned_to = u.id @@ -214,7 +215,7 @@ $users_list = db()->query("SELECT id, full_name FROM users ORDER BY full_name")- $deepLinkData = null; if (isset($_GET['action']) && $_GET['action'] === 'edit' && isset($_GET['id'])) { if (canEdit('inbound')) { - $stmt = db()->prepare("SELECT * FROM inbound_mail WHERE id = ? "); + $stmt = db()->prepare("SELECT m.*, (SELECT GROUP_CONCAT(display_name SEPARATOR '|||') FROM inbound_attachments WHERE mail_id = m.id) as attachment_names FROM inbound_mail m WHERE m.id = ? "); $stmt->execute([$_GET['id']]); $deepLinkData = $stmt->fetch(); } @@ -289,6 +290,7 @@ function getStatusBadgeInList($mail) { الموعد النهائي الموضوع المرسل + المرفقات المسؤول الحالة الإجراءات @@ -313,6 +315,13 @@ function getStatusBadgeInList($mail) { + + + + + - + + @@ -338,7 +347,7 @@ function getStatusBadgeInList($mail) { - لا يوجد بريد وارد مسجل حالياً + لا يوجد بريد وارد مسجل حالياً @@ -415,7 +424,8 @@ function getStatusBadgeInList($mail) {
- + +
@@ -487,6 +497,7 @@ function openMailModal(action, data = null) { const label = document.getElementById('mailModalLabel'); const modalAction = document.getElementById('modalAction'); const modalId = document.getElementById('modalId'); + const existingAttachmentsDiv = document.getElementById('modalExistingAttachments'); const fields = { ref_no: document.getElementById('modalRefNo'), @@ -500,6 +511,7 @@ function openMailModal(action, data = null) { }; modalAction.value = action; + existingAttachmentsDiv.innerHTML = ''; if (action === 'add') { label.textContent = 'إضافة بريد وارد جديد'; @@ -524,6 +536,17 @@ function openMailModal(action, data = null) { if (descriptionEditor) descriptionEditor.setData(data.description || ''); else document.getElementById('modalDescription').value = data.description || ''; + + // Display existing attachments + if (data.attachment_names) { + const names = data.attachment_names.split('|||'); + let html = '

المرفقات الحالية:

'; + existingAttachmentsDiv.innerHTML = html; + } } mailModal.show(); @@ -544,7 +567,8 @@ document.addEventListener('DOMContentLoaded', function() { 'subject' => $_POST['subject'] ?? '', 'description' => $_POST['description'] ?? '', 'status_id' => $_POST['status_id'] ?? $default_status_id, - 'assigned_to' => $_POST['assigned_to'] ?? '' + 'assigned_to' => $_POST['assigned_to'] ?? '', + 'attachment_names' => $_POST['attachment_names'] ?? '' ]) ?>; openMailModal('', errorData); @@ -597,4 +621,4 @@ function confirmDelete(id) { } - + \ No newline at end of file diff --git a/internal_inbox.php b/internal_inbox.php index 10f3f9d..f4ae24a 100644 --- a/internal_inbox.php +++ b/internal_inbox.php @@ -33,7 +33,8 @@ $total_records = $count_stmt->fetchColumn(); $total_pages = ceil($total_records / $limit); // Fetch messages -$query = "SELECT m.*, u_sender.full_name as sender_name, u_sender.profile_image as sender_image, s.name as status_name, s.color as status_color +$query = "SELECT m.*, u_sender.full_name as sender_name, u_sender.profile_image as sender_image, s.name as status_name, s.color as status_color, + (SELECT GROUP_CONCAT(display_name SEPARATOR ', ') FROM internal_attachments WHERE mail_id = m.id) as attachment_names FROM internal_mail m LEFT JOIN users u_sender ON m.created_by = u_sender.id LEFT JOIN mailbox_statuses s ON m.status_id = s.id @@ -100,6 +101,7 @@ function getStatusBadgeInternal($mail) { المرسل الموضوع + المرفقات التاريخ الحالة الإجراء @@ -127,6 +129,13 @@ function getStatusBadgeInternal($mail) { + + + + + - + + @@ -138,7 +147,7 @@ function getStatusBadgeInternal($mail) { - +

لا توجد رسائل واردة حالياً

diff --git a/internal_outbox.php b/internal_outbox.php index 074ce8d..040967f 100644 --- a/internal_outbox.php +++ b/internal_outbox.php @@ -1,6 +1,6 @@ fetchColumn(); $total_pages = ceil($total_records / $limit); // Fetch messages -$query = "SELECT m.*, u_recp.full_name as recipient_name, u_recp.profile_image as recipient_image, s.name as status_name, s.color as status_color +$query = "SELECT m.*, u_recp.full_name as recipient_name, u_recp.profile_image as recipient_image, s.name as status_name, s.color as status_color, + (SELECT GROUP_CONCAT(display_name SEPARATOR ', ') FROM internal_attachments WHERE mail_id = m.id) as attachment_names FROM internal_mail m LEFT JOIN users u_recp ON m.assigned_to = u_recp.id LEFT JOIN mailbox_statuses s ON m.status_id = s.id @@ -202,6 +203,7 @@ function getStatusBadgeInternal($mail) { المستلم الموضوع + المرفقات التاريخ الحالة الإجراء @@ -229,6 +231,13 @@ function getStatusBadgeInternal($mail) { + + + + + - + + @@ -240,7 +249,7 @@ function getStatusBadgeInternal($mail) { - +

لم يتم إرسال أي رسائل حالياً

@@ -296,7 +305,7 @@ function getStatusBadgeInternal($mail) {
- +
diff --git a/mail/MailService.php b/m_services/MailService.php similarity index 100% rename from mail/MailService.php rename to m_services/MailService.php diff --git a/mail/config.php b/m_services/config.php similarity index 100% rename from mail/config.php rename to m_services/config.php diff --git a/mail/index.php b/m_services/index.php similarity index 100% rename from mail/index.php rename to m_services/index.php diff --git a/mail/install.php b/m_services/install.php similarity index 100% rename from mail/install.php rename to m_services/install.php diff --git a/outbound.php b/outbound.php index 11525fc..f61d506 100644 --- a/outbound.php +++ b/outbound.php @@ -1,6 +1,6 @@ fetchColumn(); $total_pages = ceil($total_records / $limit); // Fetch paginated results -$query = "SELECT m.*, s.name as status_name, s.color as status_color, u.full_name as assigned_to_name +$query = "SELECT m.*, s.name as status_name, s.color as status_color, u.full_name as assigned_to_name, + (SELECT GROUP_CONCAT(display_name SEPARATOR '|||') FROM outbound_attachments WHERE mail_id = m.id) as attachment_names FROM outbound_mail m LEFT JOIN mailbox_statuses s ON m.status_id = s.id LEFT JOIN users u ON m.assigned_to = u.id @@ -227,7 +228,7 @@ $users_list = db()->query("SELECT id, full_name FROM users ORDER BY full_name")- $deepLinkData = null; if (isset($_GET['action']) && $_GET['action'] === 'edit' && isset($_GET['id'])) { if (canEdit('outbound')) { - $stmt = db()->prepare("SELECT * FROM outbound_mail WHERE id = ? "); + $stmt = db()->prepare("SELECT m.*, (SELECT GROUP_CONCAT(display_name SEPARATOR '|||') FROM outbound_attachments WHERE mail_id = m.id) as attachment_names FROM outbound_mail m WHERE m.id = ? "); $stmt->execute([$_GET['id']]); $deepLinkData = $stmt->fetch(); } @@ -302,6 +303,7 @@ function getStatusBadgeInList($mail) { الموعد النهائي الموضوع المستلم + المرفقات المسؤول الحالة الإجراءات @@ -326,6 +328,13 @@ function getStatusBadgeInList($mail) { + + + + + - + + @@ -351,7 +360,7 @@ function getStatusBadgeInList($mail) { - لا يوجد بريد صادر مسجل حالياً + لا يوجد بريد صادر مسجل حالياً @@ -428,7 +437,8 @@ function getStatusBadgeInList($mail) {
- + +
@@ -500,6 +510,7 @@ function openMailModal(action, data = null) { const label = document.getElementById('mailModalLabel'); const modalAction = document.getElementById('modalAction'); const modalId = document.getElementById('modalId'); + const existingAttachmentsDiv = document.getElementById('modalExistingAttachments'); const fields = { ref_no: document.getElementById('modalRefNo'), @@ -513,6 +524,7 @@ function openMailModal(action, data = null) { }; modalAction.value = action; + existingAttachmentsDiv.innerHTML = ''; if (action === 'add') { label.textContent = 'إضافة بريد صادر جديد'; @@ -537,6 +549,17 @@ function openMailModal(action, data = null) { if (descriptionEditor) descriptionEditor.setData(data.description || ''); else document.getElementById('description_editor').value = data.description || ''; + + // Display existing attachments + if (data.attachment_names) { + const names = data.attachment_names.split('|||'); + let html = '

المرفقات الحالية:

'; + existingAttachmentsDiv.innerHTML = html; + } } mailModal.show(); @@ -557,7 +580,8 @@ document.addEventListener('DOMContentLoaded', function() { 'subject' => $_POST['subject'] ?? '', 'description' => $_POST['description'] ?? '', 'status_id' => $_POST['status_id'] ?? $default_status_id, - 'assigned_to' => $_POST['assigned_to'] ?? '' + 'assigned_to' => $_POST['assigned_to'] ?? '', + 'attachment_names' => $_POST['attachment_names'] ?? '' ]) ?>; openMailModal('', errorData); diff --git a/scripts/send_reminders.php b/scripts/send_reminders.php index 5dec34c..ae90fa9 100644 --- a/scripts/send_reminders.php +++ b/scripts/send_reminders.php @@ -3,7 +3,7 @@ // Should be run as a cron job daily: php scripts/send_reminders.php require_once __DIR__ . '/../db/config.php'; -require_once __DIR__ . '/../mail/MailService.php'; +require_once __DIR__ . '/../m_services/MailService.php'; echo "[" . date('Y-m-d H:i:s') . "] Starting reminder process..." . PHP_EOL; diff --git a/view_mail.php b/view_mail.php index afbddaf..5d09a79 100644 --- a/view_mail.php +++ b/view_mail.php @@ -1,6 +1,6 @@