-
-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Describe the bug
File attachments don't work when sending emails from patient documents page after upgrading to Dolibarr 21.0.1. Documents that should be attached to emails are not included in the email form.
To Reproduce
Steps to reproduce the behavior:
- Go to patient documents:
/custom/cabinetmed/documents.php?socid=XXXX - Upload a document (e.g., consultation report, medical report)
- Click on "Send by email" on the uploaded document
- See that the email form opens without the document attached
Expected behavior
The document should appear in the "Attached files" section of the email form, ready to be sent to the patient.
Desktop (please complete the following information):
- OS: Windows 10
- Browser: Chrome
- Dolibarr Version: 21.0.1
- DOLIMED Version: 10.0.1
Additional context
This worked correctly in Dolibarr 16.0 + DOLIMED 10.0. After upgrading to Dolibarr 21.0.1, the issue appeared.
Possible root cause:
Dolibarr 21's card_presend.tpl.php may be overwriting the $file variable when object->element = 'societe' and object->last_main_doc is empty (normal for Patient objects).
Proposed fix:
// In documents.php, action presend, add before template include:
if (!empty(GETPOST('urlfile')) && file_exists($fullpathfile)) {
$file = $fullpathfile;
$original_last_main_doc = $object->last_main_doc ?? '';
$object->last_main_doc = str_replace(DOL_DATA_ROOT.'/', '', $fullpathfile);
}
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
// Restore original value
if (!empty(GETPOST('urlfile')) && file_exists($fullpathfile)) {
$object->last_main_doc = $original_last_main_doc;
}