FIX broken pdf preview when multicompany sharing (#30188)

* FIX broken pdf preview when multicompany sharing

* Update html.formmail.class.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Regis Houssin 2024-06-29 19:28:30 +02:00 committed by GitHub
parent 4f5f7ea209
commit fdf5fe0f26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -844,8 +844,9 @@ class FormMail extends Form
foreach ($listofpaths as $key => $val) {
$relativepathtofile = substr($val, (strlen(DOL_DATA_ROOT) - strlen($val)));
if ($conf->entity > 1) {
$relativepathtofile = str_replace('/'.$conf->entity.'/', '/', $relativepathtofile);
$entity = (isset($this->param['object_entity']) ? $this->param['object_entity'] : $conf->entity);
if ($entity > 1) {
$relativepathtofile = str_replace('/'.$entity.'/', '/', $relativepathtofile);
}
// Try to extract data from full path
$formfile_params = array();
@ -855,7 +856,7 @@ class FormMail extends Form
// Preview of attachment
$out .= img_mime($listofnames[$key]).' '.$listofnames[$key];
$out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]);
$out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4], 0, ($entity == 1 ? '' : 'entity='.((int) $entity));
if (!$this->withfilereadonly) {
$out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
//$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>';

View file

@ -387,6 +387,7 @@ if ($action == 'presend') {
$formmail->param['id'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"].'?id='.$object->id;
$formmail->param['fileinit'] = array($file);
$formmail->param['object_entity'] = $object->entity;
// Show form
print $formmail->get_form();