Fix duplicate pdf in mass sendmail
This commit is contained in:
parent
252bd6d9ba
commit
9305403bea
@ -69,6 +69,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)
|
||||||
{
|
{
|
||||||
@ -193,7 +195,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();
|
||||||
@ -263,12 +264,12 @@ 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
|
||||||
{
|
{
|
||||||
@ -334,7 +335,7 @@ if (! $error && $massaction == 'confirm_presend')
|
|||||||
if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
|
if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
|
||||||
|
|
||||||
// $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)
|
||||||
$oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0);
|
|
||||||
$looparray=array();
|
$looparray=array();
|
||||||
if (! $oneemailperrecipient)
|
if (! $oneemailperrecipient)
|
||||||
{
|
{
|
||||||
@ -376,10 +377,33 @@ 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(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
|
||||||
|
$attachedfiles=$attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
|
||||||
|
}
|
||||||
|
|
||||||
$filepath = $attachedfiles['paths'];
|
$filepath = $attachedfiles['paths'];
|
||||||
$filename = $attachedfiles['names'];
|
$filename = $attachedfiles['names'];
|
||||||
$mimetype = $attachedfiles['mimes'];
|
$mimetype = $attachedfiles['mimes'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//var_dump($filepath);
|
//var_dump($filepath);
|
||||||
|
|
||||||
// Send mail (substitutionarray must be done just before this)
|
// Send mail (substitutionarray must be done just before this)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user