enable free emails with select2
This commit is contained in:
parent
5948d385a3
commit
92898c9562
@ -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))
|
||||
{
|
||||
|
||||
@ -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".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
|
||||
<script>'."\n";
|
||||
if ($addjscombo == 1)
|
||||
{
|
||||
$tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
|
||||
$out .= "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->'."\n";
|
||||
$out .= '<script>'."\n";
|
||||
$out .= 'function formatResult(record) {'."\n";
|
||||
if ($elemtype == 'category')
|
||||
{
|
||||
@ -6662,13 +6663,37 @@ class Form
|
||||
$out .= '$(document).ready(function () {
|
||||
$(\'#'.$htmlname.'\').'.$tmpplugin.'({
|
||||
dir: \'ltr\',
|
||||
tags: '.($enablefreetag?'true':'false').',
|
||||
// Specify format function for dropdown item
|
||||
formatResult: formatResult,
|
||||
templateResult: formatResult, /* For 4.0 */
|
||||
/* For 4.0 */
|
||||
templateResult: formatResult,
|
||||
// Specify format function for selected item
|
||||
formatSelection: formatSelection,
|
||||
templateSelection: formatSelection /* For 4.0 */
|
||||
});
|
||||
/* For 4.0 */
|
||||
templateSelection: formatSelection';
|
||||
if ($enablefreetag && $elemtype == 'email') {
|
||||
$out .= ',
|
||||
createTag: function (params) {
|
||||
var REGEX_EMAIL = "([a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@" +
|
||||
"(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)";
|
||||
// Dont offset to create a tag if there is no @ symbol
|
||||
if (params.term.indexOf("@") === -1) {
|
||||
// Return null to disable tag creation
|
||||
return null;
|
||||
}
|
||||
var match = params.term.match(new RegExp("^([^<]*)\<" + REGEX_EMAIL + "\>$", "i"));
|
||||
// console.log(match);
|
||||
if (match !== null) {
|
||||
return {
|
||||
id: $.trim(match[1]) + " <" + match[2] + ">",
|
||||
text: $.trim(match[1]) + " <" + match[2] + ">"
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}';
|
||||
}
|
||||
$out .= ' });
|
||||
});'."\n";
|
||||
}
|
||||
elseif ($addjscombo == 2)
|
||||
@ -6676,6 +6701,8 @@ class Form
|
||||
// Add other js lib
|
||||
// TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
|
||||
// ...
|
||||
$out .= "\n".'<!-- JS CODE TO ENABLE external lib for id '.$htmlname.' -->'."\n";
|
||||
$out .= '<script>'."\n";
|
||||
$out .= '$(document).ready(function () {
|
||||
$(\'#'.$htmlname.'\').multiSelect({
|
||||
containerHTML: \'<div class="multi-select-container">\',
|
||||
|
||||
@ -630,7 +630,7 @@ class FormMail extends Form
|
||||
if (!empty($this->withto) || is_array($this->withto))
|
||||
{
|
||||
$out .= '<tr><td class="fieldrequired">';
|
||||
if ($this->withtofree) $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
|
||||
if ($this->withtofree) $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseFreeEmailsForRecipients"));
|
||||
else $out .= $langs->trans("MailTo");
|
||||
$out .= '</td><td>';
|
||||
if ($this->withtoreadonly)
|
||||
@ -670,14 +670,14 @@ class FormMail extends Form
|
||||
else
|
||||
{
|
||||
// The free input of email
|
||||
if (!empty($this->withtofree))
|
||||
{
|
||||
$out .= '<input class="minwidth200" id="sendto" name="sendto" value="'.(($this->withtofree && !is_numeric($this->withtofree)) ? $this->withtofree : (!is_array($this->withto) && !is_numeric($this->withto) ? (isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto) : "")).'" />';
|
||||
}
|
||||
// if (!empty($this->withtofree))
|
||||
// {
|
||||
// $out .= '<input class="minwidth200" id="sendto" name="sendto" value="'.(($this->withtofree && !is_numeric($this->withtofree)) ? $this->withtofree : (!is_array($this->withto) && !is_numeric($this->withto) ? (isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto) : "")).'" />';
|
||||
// }
|
||||
// The select combo
|
||||
if (!empty($this->withto) && is_array($this->withto))
|
||||
{
|
||||
if (!empty($this->withtofree)) $out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
|
||||
//if (!empty($this->withtofree)) $out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
|
||||
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
|
||||
$tmparray = $this->withto;
|
||||
foreach ($tmparray as $key => $val)
|
||||
@ -689,7 +689,7 @@ class FormMail extends Form
|
||||
{
|
||||
$withtoselected = array_keys($tmparray);
|
||||
}
|
||||
$out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, "");
|
||||
$out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', 0, '', '', 'email', '', -1, !empty($this->withtofree)?1:0);
|
||||
}
|
||||
}
|
||||
$out .= "</td></tr>\n";
|
||||
@ -736,7 +736,7 @@ class FormMail extends Form
|
||||
if (!empty($this->withtocc) || is_array($this->withtocc))
|
||||
{
|
||||
$out .= '<tr><td>';
|
||||
$out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
|
||||
$out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseFreeEmailsForRecipients"));
|
||||
$out .= '</td><td>';
|
||||
if ($this->withtoccreadonly)
|
||||
{
|
||||
@ -744,10 +744,10 @@ class FormMail extends Form
|
||||
}
|
||||
else
|
||||
{
|
||||
$out .= '<input class="minwidth200" id="sendtocc" name="sendtocc" value="'.(GETPOST("sendtocc", "alpha") ? GETPOST("sendtocc", "alpha") : ((!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />';
|
||||
//$out .= '<input class="minwidth200" id="sendtocc" name="sendtocc" value="'.(GETPOST("sendtocc", "alpha") ? GETPOST("sendtocc", "alpha") : ((!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />';
|
||||
if (!empty($this->withtocc) && is_array($this->withtocc))
|
||||
{
|
||||
$out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
|
||||
//$out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
|
||||
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
|
||||
$tmparray = $this->withtocc;
|
||||
foreach ($tmparray as $key => $val)
|
||||
@ -755,7 +755,7 @@ class FormMail extends Form
|
||||
$tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
|
||||
}
|
||||
$withtoccselected = GETPOST("receivercc"); // Array of selected value
|
||||
$out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', null, "");
|
||||
$out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', 0, '', '', 'email', '', -1, !empty($this->withtofree)?1:0);
|
||||
}
|
||||
}
|
||||
$out .= "</td></tr>\n";
|
||||
|
||||
@ -117,6 +117,7 @@ NbOfEMailingsSend=Mass emailings sent
|
||||
IdRecord=ID record
|
||||
DeliveryReceipt=Delivery Ack.
|
||||
YouCanUseCommaSeparatorForSeveralRecipients=You can use the <b>comma</b> separator to specify several recipients.
|
||||
YouCanUseFreeEmailsForRecipients=You can enter free emails to specify several recipients.
|
||||
TagCheckMail=Track mail opening
|
||||
TagUnsubscribe=Unsubscribe link
|
||||
TagSignature=Signature of sending user
|
||||
|
||||
Loading…
Reference in New Issue
Block a user