Merge pull request #23618 from ATM-Consulting/FIX_16.0_fieldvalue_emailtemplate

FIX : Empty FormSetup emailTemplate type IF empty fieldvalue
This commit is contained in:
Laurent Destailleur 2023-01-25 18:28:26 +01:00 committed by GitHub
commit 3aec1289f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1069,16 +1069,18 @@ class FormSetupItem
} elseif ($this->type == 'yesno') { } elseif ($this->type == 'yesno') {
$out.= ajax_constantonoff($this->confKey); $out.= ajax_constantonoff($this->confKey);
} elseif (preg_match('/emailtemplate:/', $this->type)) { } elseif (preg_match('/emailtemplate:/', $this->type)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; if ($this->fieldValue > 0) {
$formmail = new FormMail($this->db); include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($this->db);
$tmp = explode(':', $this->type); $tmp = explode(':', $this->type);
$template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $this->fieldValue); $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $this->fieldValue);
if ($template<0) { if ($template<0) {
$this->setErrors($formmail->errors); $this->setErrors($formmail->errors);
}
$out.= $this->langs->trans($template->label);
} }
$out.= $this->langs->trans($template->label);
} elseif (preg_match('/category:/', $this->type)) { } elseif (preg_match('/category:/', $this->type)) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$c = new Categorie($this->db); $c = new Categorie($this->db);