Autosave: 20260228-102254

This commit is contained in:
Flatlogic Bot 2026-02-28 10:22:54 +00:00
parent dcb1aa0c6b
commit 6ddb4f9f37
12 changed files with 89 additions and 23 deletions

View File

@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/includes/header.php';
require_once __DIR__ . '/mail/MailService.php';
require_once __DIR__ . '/m_services/MailService.php';
// Only users with settings view permission can access this page
if (!canView('settings')) {

View File

@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/includes/header.php';
require_once __DIR__ . '/mail/MailService.php';
require_once __DIR__ . '/m_services/MailService.php';
if (isLoggedIn()) {
redirect('index.php');

View File

@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/includes/header.php';
require_once __DIR__ . '/mail/MailService.php';
require_once __DIR__ . '/m_services/MailService.php';
// Check if user has view permission
if (!canView('inbound')) {
@ -196,7 +196,8 @@ $total_records = $stmt_count->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) {
<th>الموعد النهائي</th>
<th>الموضوع</th>
<th>المرسل</th>
<th>المرفقات</th>
<th>المسؤول</th>
<th>الحالة</th>
<th class="pe-4 text-center">الإجراءات</th>
@ -313,6 +315,13 @@ function getStatusBadgeInList($mail) {
</td>
<td><?= htmlspecialchars($mail['subject']) ?></td>
<td><?= htmlspecialchars($mail['sender']) ?></td>
<td>
<?php if (!empty($mail['attachment_names'])): ?>
<small class="text-muted"><i class="fas fa-paperclip me-1"></i> <?= htmlspecialchars(str_replace('|||', ', ', $mail['attachment_names'])) ?></small>
<?php else: ?>
<span class="text-muted">-</span>
<?php endif; ?>
</td>
<td>
<?php if ($mail['assigned_to_name']): ?>
<span class="text-nowrap"><i class="fas fa-user-tag me-1 text-muted"></i> <?= htmlspecialchars($mail['assigned_to_name']) ?></span>
@ -338,7 +347,7 @@ function getStatusBadgeInList($mail) {
</tr>
<?php endforeach; else: ?>
<tr>
<td colspan="8" class="text-center py-4 text-muted">لا يوجد بريد وارد مسجل حالياً</td>
<td colspan="9" class="text-center py-4 text-muted">لا يوجد بريد وارد مسجل حالياً</td>
</tr>
<?php endif; ?>
</tbody>
@ -415,7 +424,8 @@ function getStatusBadgeInList($mail) {
</div>
<div class="col-12">
<label class="form-label fw-bold">المرفقات</label>
<input type="file" name="inbound_attachments[]" class="form-control" multiple>
<input type="file" name="attachments[]" class="form-control" multiple>
<div id="modalExistingAttachments" class="mt-2"></div>
</div>
<div class="col-md-6">
<label class="form-label fw-bold">الحالة</label>
@ -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 = '<div class="mt-2"><p class="mb-1 fw-bold small">المرفقات الحالية:</p><ul class="list-unstyled small">';
names.forEach(name => {
html += `<li><i class="fas fa-file-alt me-1 text-muted"></i> ${name}</li>`;
});
html += '</ul></div>';
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('<?= $_POST['action'] ?>', errorData);
<?php elseif (isset($_GET['action']) && $_GET['action'] === 'add'): ?>
@ -597,4 +621,4 @@ function confirmDelete(id) {
}
</style>
<?php require_once __DIR__ . '/includes/footer.php'; ?>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

View File

@ -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) {
<tr>
<th class="ps-4">المرسل</th>
<th>الموضوع</th>
<th>المرفقات</th>
<th>التاريخ</th>
<th>الحالة</th>
<th class="pe-4 text-center">الإجراء</th>
@ -127,6 +129,13 @@ function getStatusBadgeInternal($mail) {
<?= strip_tags($msg['description']) ?>
</small>
</td>
<td>
<?php if (!empty($msg['attachment_names'])): ?>
<small class="text-muted"><i class="fas fa-paperclip me-1"></i> <?= htmlspecialchars($msg['attachment_names']) ?></small>
<?php else: ?>
<span class="text-muted">-</span>
<?php endif; ?>
</td>
<td>
<small class="text-muted"><?= date('Y-m-d H:i', strtotime($msg['created_at'])) ?></small>
</td>
@ -138,7 +147,7 @@ function getStatusBadgeInternal($mail) {
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="5" class="text-center py-5 text-muted">
<td colspan="6" class="text-center py-5 text-muted">
<i class="fas fa-envelope-open fa-3x mb-3 opacity-25"></i>
<p>لا توجد رسائل واردة حالياً</p>
</td>

View File

@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/includes/header.php';
require_once __DIR__ . '/mail/MailService.php';
require_once __DIR__ . '/m_services/MailService.php';
if (!canView('internal')) {
redirect('index.php');
@ -123,7 +123,8 @@ $total_records = $count_stmt->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) {
<tr>
<th class="ps-4">المستلم</th>
<th>الموضوع</th>
<th>المرفقات</th>
<th>التاريخ</th>
<th>الحالة</th>
<th class="pe-4 text-center">الإجراء</th>
@ -229,6 +231,13 @@ function getStatusBadgeInternal($mail) {
<?= strip_tags($msg['description']) ?>
</small>
</td>
<td>
<?php if (!empty($msg['attachment_names'])): ?>
<small class="text-muted"><i class="fas fa-paperclip me-1"></i> <?= htmlspecialchars($msg['attachment_names']) ?></small>
<?php else: ?>
<span class="text-muted">-</span>
<?php endif; ?>
</td>
<td>
<small class="text-muted"><?= date('Y-m-d H:i', strtotime($msg['created_at'])) ?></small>
</td>
@ -240,7 +249,7 @@ function getStatusBadgeInternal($mail) {
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="5" class="text-center py-5 text-muted">
<td colspan="6" class="text-center py-5 text-muted">
<i class="fas fa-paper-plane fa-3x mb-3 opacity-25"></i>
<p>لم يتم إرسال أي رسائل حالياً</p>
</td>
@ -296,7 +305,7 @@ function getStatusBadgeInternal($mail) {
</div>
<div class="col-md-12">
<label class="form-label fw-bold">المرفقات</label>
<input type="file" name="internal_attachments[]" class="form-control border-2" multiple>
<input type="file" name="attachments[]" class="form-control border-2" multiple>
</div>
</div>
</div>

View File

@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/includes/header.php';
require_once __DIR__ . '/mail/MailService.php';
require_once __DIR__ . '/m_services/MailService.php';
// Check if user has view permission
if (!canView('outbound')) {
@ -209,7 +209,8 @@ $total_records = $stmt_count->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) {
<th>الموعد النهائي</th>
<th>الموضوع</th>
<th>المستلم</th>
<th>المرفقات</th>
<th>المسؤول</th>
<th>الحالة</th>
<th class="pe-4 text-center">الإجراءات</th>
@ -326,6 +328,13 @@ function getStatusBadgeInList($mail) {
</td>
<td><?= truncate_text($mail['subject'], 80) ?></td>
<td><?= htmlspecialchars($mail['recipient']) ?></td>
<td>
<?php if (!empty($mail['attachment_names'])): ?>
<small class="text-muted"><i class="fas fa-paperclip me-1"></i> <?= htmlspecialchars(str_replace('|||', ', ', $mail['attachment_names'])) ?></small>
<?php else: ?>
<span class="text-muted">-</span>
<?php endif; ?>
</td>
<td>
<?php if ($mail['assigned_to_name']): ?>
<span class="text-nowrap"><i class="fas fa-user-tag me-1 text-muted"></i> <?= htmlspecialchars($mail['assigned_to_name']) ?></span>
@ -351,7 +360,7 @@ function getStatusBadgeInList($mail) {
</tr>
<?php endforeach; else: ?>
<tr>
<td colspan="8" class="text-center py-4 text-muted">لا يوجد بريد صادر مسجل حالياً</td>
<td colspan="9" class="text-center py-4 text-muted">لا يوجد بريد صادر مسجل حالياً</td>
</tr>
<?php endif; ?>
</tbody>
@ -428,7 +437,8 @@ function getStatusBadgeInList($mail) {
</div>
<div class="col-12">
<label class="form-label fw-bold">المرفقات</label>
<input type="file" name="outbound_attachments[]" class="form-control" multiple>
<input type="file" name="attachments[]" class="form-control" multiple>
<div id="modalExistingAttachments" class="mt-2"></div>
</div>
<div class="col-md-6">
<label class="form-label fw-bold">الحالة</label>
@ -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 = '<div class="mt-2"><p class="mb-1 fw-bold small">المرفقات الحالية:</p><ul class="list-unstyled small">';
names.forEach(name => {
html += `<li><i class="fas fa-file-alt me-1 text-muted"></i> ${name}</li>`;
});
html += '</ul></div>';
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('<?= $_POST['action'] ?>', errorData);
<?php elseif (isset($_GET['action']) && $_GET['action'] === 'add'): ?>

View File

@ -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;

View File

@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/includes/header.php';
require_once __DIR__ . '/mail/MailService.php';
require_once __DIR__ . '/m_services/MailService.php';
$id = $_GET['id'] ?? 0;
$type = $_GET['type'] ?? '';