Merge branch '8.0' of git@github.com:Dolibarr/dolibarr.git into 9.0

Conflicts:
	htdocs/adherents/class/adherent.class.php
	htdocs/core/actions_massactions.inc.php
	htdocs/core/tpl/massactions_pre.tpl.php
This commit is contained in:
Laurent Destailleur 2019-06-24 16:12:20 +02:00
commit 3d185b6818
2 changed files with 981 additions and 958 deletions

View File

@ -70,6 +70,8 @@ if (! $error && $massaction == 'confirm_presend')
$listofobjectid=array(); $listofobjectid=array();
$listofobjectthirdparties=array(); $listofobjectthirdparties=array();
$listofobjectref=array(); $listofobjectref=array();
$attachedfilesThirdpartyObj=array();
$oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0);
if (! $error) if (! $error)
{ {
@ -200,7 +202,6 @@ if (! $error && $massaction == 'confirm_presend')
$sendtocc=implode(',',$tmparray); $sendtocc=implode(',',$tmparray);
//var_dump($listofobjectref);exit; //var_dump($listofobjectref);exit;
$attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array());
$listofqualifiedobj=array(); $listofqualifiedobj=array();
$listofqualifiedref=array(); $listofqualifiedref=array();
$thirdpartywithoutemail=array(); $thirdpartywithoutemail=array();
@ -215,7 +216,7 @@ if (! $error && $massaction == 'confirm_presend')
$resaction.='<div class="error">'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction',$objectobj->ref).'</div><br>'; $resaction.='<div class="error">'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction',$objectobj->ref).'</div><br>';
continue; // Payment done or started or canceled continue; // Payment done or started or canceled
} }
if ($objectclass == 'Commande' && $objectojb->statut == Commande::STATUS_DRAFT) if ($objectclass == 'Commande' && $objectobj->statut == Commande::STATUS_DRAFT)
{ {
$langs->load("errors"); $langs->load("errors");
$nbignored++; $nbignored++;
@ -288,10 +289,10 @@ if (! $error && $massaction == 'confirm_presend')
if (dol_is_file($file)) if (dol_is_file($file))
{ {
// Create form object // Create form object
$attachedfiles=array( $attachedfilesThirdpartyObj[$thirdpartyid][$objectid]=array(
'paths'=>array_merge($attachedfiles['paths'],array($file)), 'paths'=>array($file),
'names'=>array_merge($attachedfiles['names'],array($filename)), 'names'=>array($filename),
'mimes'=>array_merge($attachedfiles['mimes'],array($mime)) 'mimes'=>array($mime)
); );
} }
else else
@ -308,6 +309,7 @@ if (! $error && $massaction == 'confirm_presend')
$listofqualifiedobj[$objectid]=$objectobj; $listofqualifiedobj[$objectid]=$objectobj;
$listofqualifiedref[$objectid]=$objectobj->ref; $listofqualifiedref[$objectid]=$objectobj->ref;
//var_dump($listofqualifiedref); //var_dump($listofqualifiedref);
} }
@ -359,7 +361,6 @@ if (! $error && $massaction == 'confirm_presend')
// $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet) // $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet)
// $looparray will be an array with number of email to send for the current thirdparty (so 1 or n if n object for same thirdparty) // $looparray will be an array with number of email to send for the current thirdparty (so 1 or n if n object for same thirdparty)
$oneemailperrecipient=(GETPOST('oneemailperrecipient','alpha')=='on'?1:0);
$looparray=array(); $looparray=array();
if (! $oneemailperrecipient) if (! $oneemailperrecipient)
{ {
@ -401,6 +402,28 @@ if (! $error && $massaction == 'confirm_presend')
$subjectreplaced=make_substitutions($subject, $substitutionarray); $subjectreplaced=make_substitutions($subject, $substitutionarray);
$messagereplaced=make_substitutions($message, $substitutionarray); $messagereplaced=make_substitutions($message, $substitutionarray);
$attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array());
if ($oneemailperrecipient)
{
// if "one email per recipient" is check we must collate $attachedfiles by thirdparty
if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id]))
{
foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles){
// Create form object
$attachedfiles=array(
'paths'=>array_merge($attachedfiles['paths'], $objAttachedFiles['paths']),
'names'=>array_merge($attachedfiles['names'], $objAttachedFiles['names']),
'mimes'=>array_merge($attachedfiles['mimes'], $objAttachedFiles['mimes'])
);
}
}
}
elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])){
// Create form object
// if "one email per recipient" isn't check we must separate $attachedfiles by object
$attachedfiles=$attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
}
$filepath = $attachedfiles['paths']; $filepath = $attachedfiles['paths'];
$filename = $attachedfiles['names']; $filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes']; $mimetype = $attachedfiles['mimes'];
@ -1287,3 +1310,4 @@ $reshook=$hookmanager->executeHooks('doMassActions',$parameters, $object, $actio
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

View File

@ -1030,7 +1030,6 @@ class FormMail extends Form
$defaultmessage=preg_replace("/^(<br>)+/","",$defaultmessage); $defaultmessage=preg_replace("/^(<br>)+/","",$defaultmessage);
$defaultmessage=preg_replace("/^\n+/","",$defaultmessage); $defaultmessage=preg_replace("/^\n+/","",$defaultmessage);
} }
$out.= '<tr>'; $out.= '<tr>';
$out.= '<td valign="top">'; $out.= '<td valign="top">';
$out.=$form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody'); $out.=$form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody');