From c4dc8b9276fe9bd4e5010449e0f87dcaf49f766d Mon Sep 17 00:00:00 2001 From: ThomasNgr-OpenDSI Date: Wed, 7 Jan 2026 18:30:16 +0100 Subject: [PATCH] NEW : Add global MAIL_MASS_ACTION_SEARCH_MOST_RECENT_FILE_IF_NOT_FOUND for search and attach the most recent file if none file found when send email in mass action (#36813) Co-authored-by: Kamel Khelifa --- htdocs/core/actions_massactions.inc.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 1ebe5c9ca5e..4ec19e70f5f 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -429,6 +429,14 @@ if (!$error && $massaction == 'confirm_presend') { $filepath = $fileparams['fullname']; } + if (getDolGlobalInt('MAIL_MASS_ACTION_SEARCH_MOST_RECENT_FILE_IF_NOT_FOUND') && isset($filepath) && !dol_is_file($filepath)) { + $fileparams = dol_most_recent_file($filedir, preg_quote($objectobj->ref, '/') . '([^\-])+' . (getDolGlobalInt('MAIN_ODT_AS_PDF') ? '\.pdf$' : '')); + if (isset($fileparams)) { + $filepath = $fileparams['fullname']; + $filename = $fileparams['name']; + } + } + // try to find other files generated for this object (last_main_doc) $filename_found = ''; $filepath_found = '';