From c6cb25129c14368aeda53056d25d05789260964e Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sat, 28 Feb 2026 07:59:16 +0000 Subject: [PATCH] installation --- inbound.php | 90 ++++++++++++++++++++++++++++++++------------ includes/footer.php | 6 +++ internal_outbox.php | 25 +++++++++--- mail/MailService.php | 6 ++- outbound.php | 13 +++++-- 5 files changed, 107 insertions(+), 33 deletions(-) diff --git a/inbound.php b/inbound.php index 605747e..bbd4575 100644 --- a/inbound.php +++ b/inbound.php @@ -70,6 +70,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $id = $_POST['id'] ?? 0; if ($ref_no && $subject) { + $should_notify = false; try { db()->beginTransaction(); if ($action === 'add') { @@ -78,7 +79,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $mail_id = db()->lastInsertId(); if ($assigned_to) { - sendAssignmentNotification($assigned_to, $ref_no, $subject); + $should_notify = true; } $_SESSION['success'] = 'تمت إضافة البريد بنجاح'; @@ -93,7 +94,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $stmt->execute([$ref_no, $date_registered, $due_date, $sender, $recipient, $subject, $description, $status_id, $assigned_to, $id]); if ($assigned_to && $assigned_to != $old_assigned_to) { - sendAssignmentNotification($assigned_to, $ref_no, $subject); + $should_notify = true; } $_SESSION['success'] = 'تم تحديث البيانات بنجاح'; @@ -117,9 +118,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } db()->commit(); + + // Notify after commit to avoid holding locks during email sending + if ($should_notify) { + sendAssignmentNotification($assigned_to, $ref_no, $subject); + } + redirect('inbound.php'); } catch (PDOException $e) { - db()->rollBack(); + if (db()->inTransaction()) db()->rollBack(); if ($e->getCode() == 23000) { $error = 'رقم القيد مستخدم مسبقاً'; } else { @@ -404,7 +411,7 @@ function getStatusBadgeInList($mail) {
- +
@@ -445,8 +452,27 @@ function getStatusBadgeInList($mail) {
+ + + + +