FIX Selection of addmaindocfile is lost on error

This commit is contained in:
Laurent Destailleur 2018-10-29 02:11:33 +01:00
parent 244c7f8dc3
commit 553e984465
2 changed files with 12 additions and 7 deletions

View File

@ -846,8 +846,12 @@ class FormMail extends Form
$out.= '<td>'; $out.= '<td>';
if (GETPOSTISSET('sendmail'))
{
$this->withmaindocfile = (GETPOST('addmaindocfile', 'alpha') ? -1 : 1);
}
// If a template was selected, we use setup of template to define if join file checkbox is selected or not. // If a template was selected, we use setup of template to define if join file checkbox is selected or not.
if (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) elseif (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{ {
$this->withmaindocfile = ($arraydefaultmessage->joinfiles ? -1 : 1); $this->withmaindocfile = ($arraydefaultmessage->joinfiles ? -1 : 1);
} }
@ -860,7 +864,7 @@ class FormMail extends Form
} }
if ($this->withmaindocfile == -1) if ($this->withmaindocfile == -1)
{ {
$out.='<input type="checkbox" name="addmaindocfile" checked="checked" />'; $out.='<input type="checkbox" name="addmaindocfile" value="1" checked="checked" />';
} }
$out.=' '.$langs->trans("JoinMainDoc").'.<br>'; $out.=' '.$langs->trans("JoinMainDoc").'.<br>';
} }

View File

@ -41,11 +41,12 @@ if ($massaction == 'presend')
{ {
$langs->load("mails"); $langs->load("mails");
$listofselectedid = array();
$listofselectedthirdparties = array();
$listofselectedref = array();
if (! GETPOST('cancel', 'alpha')) if (! GETPOST('cancel', 'alpha'))
{ {
$listofselectedid = array();
$listofselectedthirdparties = array();
$listofselectedref = array();
foreach ($arrayofselected as $toselectid) foreach ($arrayofselected as $toselectid)
{ {
$result = $objecttmp->fetch($toselectid); $result = $objecttmp->fetch($toselectid);
@ -110,8 +111,8 @@ if ($massaction == 'presend')
} else { } else {
$formmail->withtoreadonly = 1; $formmail->withtoreadonly = 1;
} }
$formmail->withoptiononeemailperrecipient = empty($liste)?0:((GETPOST('oneemailperrecipient')=='on')?1:-1); $formmail->withoptiononeemailperrecipient = (count($listofselectedref) == 1 || empty($liste))? 0 : ((GETPOST('oneemailperrecipient')=='on')?1:-1);
$formmail->withto = empty($liste)?(GETPOST('sendto','alpha')?GETPOST('sendto','alpha'):array()):$liste; $formmail->withto = empty($liste)?(GETPOST('sendto','alpha')?GETPOST('sendto','alpha'):array()):$liste;
$formmail->withtofree = empty($liste)?1:0; $formmail->withtofree = empty($liste)?1:0;
$formmail->withtocc = 1; $formmail->withtocc = 1;