diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 064acb0b1c6..34ba465ebff 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -257,9 +257,20 @@ if (! $error && $massaction == 'confirm_presend') { // TODO Use future field $objectobj->fullpathdoc to know where is stored default file // TODO If not defined, use $objectobj->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc. - $filename=dol_sanitizeFileName($objectobj->ref).'.pdf'; - $filedir=$uploaddir . '/' . dol_sanitizeFileName($objectobj->ref); + $filename = dol_sanitizeFileName($objectobj->ref).'.pdf'; + $subdir = ''; + // TODO Set subdir to be compatible with multi levels dir trees + // $subdir = get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element) + $filedir = $uploaddir . '/' . $subdir . dol_sanitizeFileName($objectobj->ref); $file = $filedir . '/' . $filename; + + // For supplier invoices, we use the file provided by supplier, not the one we generate + if ($objectobj->element == 'invoice_supplier') + { + $fileparams = dol_most_recent_file($uploaddir . '/' . get_exdir($objectobj->id,2,0,0,$objectobj,$objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,'/').'([^\-])+'); + $file = $fileparams['fullname']; + } + $mime = dol_mimetype($file); if (dol_is_file($file)) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index e8693af943a..ac742f0dbb7 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -359,6 +359,7 @@ class FormMail extends Form if ($this->param['models'] != 'none') { $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); + if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 4b208a99af7..c14c037dc97 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -496,7 +496,7 @@ if ($resql) print_barre_liste($langs->trans("BillsSuppliers").($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); $topicmail="SendBillRef"; - $modelmail="supplier_invoice_send"; + $modelmail="invoice_supplier_send"; $objecttmp=new FactureFournisseur($db); $trackid='sinv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';