NEW On a form to send an email, we show all emails of contacts of object
This commit is contained in:
parent
d70c70a5fe
commit
147207b4e1
@ -9,7 +9,7 @@ English Dolibarr ChangeLog
|
|||||||
For users:
|
For users:
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
NEW: PHP 8.1 compatibility.
|
NEW: PHP 8.1 compatibility:
|
||||||
Warning: Application works correctly with PHP8 and 8.1 but you may experience a lot of PHP warning into the PHP server log files (depending
|
Warning: Application works correctly with PHP8 and 8.1 but you may experience a lot of PHP warning into the PHP server log files (depending
|
||||||
on the PHP setup). Removal of all PHP warnings on server side is planned for v17.
|
on the PHP setup). Removal of all PHP warnings on server side is planned for v17.
|
||||||
NEW: Support for recurring purchase invoices.
|
NEW: Support for recurring purchase invoices.
|
||||||
@ -121,6 +121,7 @@ NEW: Ticket triggers: allow to automatically send messages on new tickets
|
|||||||
NEW: Accountancy - Add hidden feature for accounting reconciliation
|
NEW: Accountancy - Add hidden feature for accounting reconciliation
|
||||||
NEW: Can store the session into database (instead of beeing managed by PHP)
|
NEW: Can store the session into database (instead of beeing managed by PHP)
|
||||||
NEW: Added MMK currency (Myanmar Kyat)
|
NEW: Added MMK currency (Myanmar Kyat)
|
||||||
|
NEW: On a form to send an email, we show all emails of contacts of object
|
||||||
|
|
||||||
Modules
|
Modules
|
||||||
NEW: Module Partnership Management
|
NEW: Module Partnership Management
|
||||||
|
|||||||
@ -147,7 +147,7 @@ if ($action == 'presend') {
|
|||||||
$formmail->trackid = $trackid;
|
$formmail->trackid = $trackid;
|
||||||
$formmail->withfrom = 1;
|
$formmail->withfrom = 1;
|
||||||
|
|
||||||
// Fill list of recipient with email inside <>.
|
// Define $liste, a list of recipients with email inside <>.
|
||||||
$liste = array();
|
$liste = array();
|
||||||
if ($object->element == 'expensereport') {
|
if ($object->element == 'expensereport') {
|
||||||
$fuser = new User($db);
|
$fuser = new User($db);
|
||||||
@ -193,16 +193,6 @@ if ($action == 'presend') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$formmail->withto = $liste;
|
|
||||||
$formmail->withtofree = (GETPOST('sendto', 'alphawithlgt') ? GETPOST('sendto', 'alphawithlgt') : '1');
|
|
||||||
$formmail->withtocc = $liste;
|
|
||||||
$formmail->withtoccc = getDolGlobalString('MAIN_EMAIL_USECCC');
|
|
||||||
$formmail->withtopic = $topicmail;
|
|
||||||
$formmail->withfile = 2;
|
|
||||||
$formmail->withbody = 1;
|
|
||||||
$formmail->withdeliveryreceipt = 1;
|
|
||||||
$formmail->withcancel = 1;
|
|
||||||
|
|
||||||
//$arrayoffamiliestoexclude=array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...);
|
//$arrayoffamiliestoexclude=array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...);
|
||||||
if (!isset($arrayoffamiliestoexclude)) {
|
if (!isset($arrayoffamiliestoexclude)) {
|
||||||
$arrayoffamiliestoexclude = null;
|
$arrayoffamiliestoexclude = null;
|
||||||
@ -210,6 +200,7 @@ if ($action == 'presend') {
|
|||||||
|
|
||||||
// Make substitution in email content
|
// Make substitution in email content
|
||||||
if ($object) {
|
if ($object) {
|
||||||
|
// First we set ->substit (useless, it will be erased later) and ->substit_lines
|
||||||
$formmail->setSubstitFromObject($object, $langs);
|
$formmail->setSubstitFromObject($object, $langs);
|
||||||
}
|
}
|
||||||
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object);
|
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object);
|
||||||
@ -228,7 +219,7 @@ if ($action == 'presend') {
|
|||||||
);
|
);
|
||||||
complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters);
|
complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters);
|
||||||
|
|
||||||
// Find the good contact address
|
// Find all external contact addresses
|
||||||
$tmpobject = $object;
|
$tmpobject = $object;
|
||||||
if (($object->element == 'shipping' || $object->element == 'reception')) {
|
if (($object->element == 'shipping' || $object->element == 'reception')) {
|
||||||
$origin = $object->origin;
|
$origin = $object->origin;
|
||||||
@ -280,17 +271,46 @@ if ($action == 'presend') {
|
|||||||
|
|
||||||
if (is_array($contactarr) && count($contactarr) > 0) {
|
if (is_array($contactarr) && count($contactarr) > 0) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||||
$contactstatic = new Contact($db);
|
$contactstatic = new Contact($db);
|
||||||
|
$tmpcompany = new Societe($db);
|
||||||
|
|
||||||
foreach ($contactarr as $contact) {
|
foreach ($contactarr as $contact) {
|
||||||
$contactstatic->fetch($contact['id']);
|
$contactstatic->fetch($contact['id']);
|
||||||
|
// Complete substitution array
|
||||||
$substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($outputlangs, 1);
|
$substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($outputlangs, 1);
|
||||||
$substitutionarray['__CONTACT_LASTNAME_'.$contact['code'].'__'] = $contactstatic->lastname;
|
$substitutionarray['__CONTACT_LASTNAME_'.$contact['code'].'__'] = $contactstatic->lastname;
|
||||||
$substitutionarray['__CONTACT_FIRSTNAME_'.$contact['code'].'__'] = $contactstatic->firstname;
|
$substitutionarray['__CONTACT_FIRSTNAME_'.$contact['code'].'__'] = $contactstatic->firstname;
|
||||||
$substitutionarray['__CONTACT_TITLE_'.$contact['code'].'__'] = $contactstatic->getCivilityLabel();
|
$substitutionarray['__CONTACT_TITLE_'.$contact['code'].'__'] = $contactstatic->getCivilityLabel();
|
||||||
|
|
||||||
|
// Complete $liste with the $contact
|
||||||
|
if (empty($liste[$contact['id']])) { // If this contact id not already into the $liste
|
||||||
|
$contacttoshow = '';
|
||||||
|
if (isset($object->thirdparty) && is_object($object->thirdparty)) {
|
||||||
|
if ($contactstatic->fk_soc != $object->thirdparty->id) {
|
||||||
|
$tmpcompany->fetch($contactstatic->fk_soc);
|
||||||
|
if ($tmpcompany->id > 0) {
|
||||||
|
$contacttoshow .= $tmpcompany->name.': ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$contacttoshow .= $contactstatic->getFullName($outputlangs, 1);
|
||||||
|
$contacttoshow .= " <".($contactstatic->email ? $contactstatic->email : $langs->transnoentitiesnoconv("NoEMail")) .">";
|
||||||
|
$liste[$contact['id']] = $contacttoshow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$formmail->withto = $liste;
|
||||||
|
$formmail->withtofree = (GETPOST('sendto', 'alphawithlgt') ? GETPOST('sendto', 'alphawithlgt') : '1');
|
||||||
|
$formmail->withtocc = $liste;
|
||||||
|
$formmail->withtoccc = getDolGlobalString('MAIN_EMAIL_USECCC');
|
||||||
|
$formmail->withtopic = $topicmail;
|
||||||
|
$formmail->withfile = 2;
|
||||||
|
$formmail->withbody = 1;
|
||||||
|
$formmail->withdeliveryreceipt = 1;
|
||||||
|
$formmail->withcancel = 1;
|
||||||
|
|
||||||
// Array of substitutions
|
// Array of substitutions
|
||||||
$formmail->substit = $substitutionarray;
|
$formmail->substit = $substitutionarray;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user