From 92898c9562da57f2fa7ccbe2c6a1bd7118674bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 1 May 2020 11:27:11 +0200 Subject: [PATCH 1/8] enable free emails with select2 --- htdocs/core/actions_sendmails.inc.php | 9 ++++-- htdocs/core/class/html.form.class.php | 39 +++++++++++++++++++---- htdocs/core/class/html.formmail.class.php | 22 ++++++------- htdocs/langs/en_US/mails.lang | 1 + 4 files changed, 52 insertions(+), 19 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index e23d2ce01a9..f647bd5418e 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -190,10 +190,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST { $tmparray[] = dol_string_nospecial($contact->getFullName($langs), ' ', array(",")).' <'.$contact->email.'>'; } - elseif ($val) // $val is the Id of a contact + elseif ((int) $val > 0) // $val is the Id of a contact { $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); $sendtoid[] = $val; + } else { + $tmparray[] = $val; } } } @@ -240,10 +242,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST { $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; } - elseif ($val) // $val is the Id of a contact + elseif ((int) $val > 0) // $val is the Id of a contact { $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); //$sendtoid[] = $val; TODO Add also id of contact in CC ? + } else { + $tmparray[] = $val; } } } @@ -261,6 +265,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST } } $sendtocc = implode(',', $tmparray); + //var_dump($sendto, $sendtocc);exit; if (dol_strlen($sendto)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b2c677ed29d..bc605d286c1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6617,10 +6617,11 @@ class Form * @param string $elemtype Type of element we show ('category', ...). Will execute a formating function on it. To use in readonly mode if js component support HTML formatting. * @param string $placeholder String to use as placeholder * @param int $addjscombo Add js combo + * @param int $enablefreetag 0 no free tag, 1 enable free tag for elemtype * @return string HTML multiselect string * @see selectarray(), selectArrayAjax(), selectArrayFilter() */ - public static function multiselectarray($htmlname, $array, $selected = array(), $key_in_label = 0, $value_as_key = 0, $morecss = '', $translate = 0, $width = 0, $moreattrib = '', $elemtype = '', $placeholder = '', $addjscombo = -1) + public static function multiselectarray($htmlname, $array, $selected = array(), $key_in_label = 0, $value_as_key = 0, $morecss = '', $translate = 0, $width = 0, $moreattrib = '', $elemtype = '', $placeholder = '', $addjscombo = -1, $enablefreetag = 0) { global $conf, $langs; @@ -6634,11 +6635,11 @@ class Form // Add code for jquery to use multiselect if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) { - $out .= "\n".' -