NEW On bulk email from a list, can uncheck "Join main document".

NEW Show direct preview link on contract
This commit is contained in:
Laurent Destailleur 2017-09-16 18:24:58 +02:00
parent 318e285ba2
commit 0fec777d0e
11 changed files with 254 additions and 181 deletions

View File

@ -238,7 +238,7 @@ llxHeader('',$langs->trans('Proposal'),$help_url);
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
$sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= ' p.rowid, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,';
@ -725,6 +725,7 @@ if ($resql)
$companystatic->name=$obj->name;
$companystatic->client=$obj->client;
$companystatic->code_client=$obj->code_client;
$companystatic->email=$obj->email;
// Thirdparty
if (! empty($arrayfields['s.nom']['checked']))

View File

@ -445,7 +445,7 @@ llxHeader('',$title,$help_url);
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
$sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,';
@ -1148,6 +1148,7 @@ if ($resql)
$companystatic->code_client = $obj->code_client;
$companystatic->name=$obj->name;
$companystatic->client=$obj->client;
$companystatic->email=$obj->email;
// Third party
if (! empty($arrayfields['s.nom']['checked']))

View File

@ -345,6 +345,7 @@ $formfile = new FormFile($db);
$bankaccountstatic=new Account($db);
$facturestatic=new Facture($db);
$formcompany=new FormCompany($db);
$thirdpartystatic=new Societe($db);
llxHeader('',$langs->trans('CustomersInvoices'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
@ -355,7 +356,7 @@ $sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
$sql.= ' f.datef as df, f.date_lim_reglement as datelimite,';
$sql.= ' f.paye as paye, f.fk_statut,';
$sql.= ' f.datec as date_creation, f.tms as date_update,';
$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
$sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name";
// We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0)
@ -1010,12 +1011,12 @@ if ($resql)
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="tdoverflowmax200">';
$thirdparty=new Societe($db);
$thirdparty->id=$obj->socid;
$thirdparty->name=$obj->name;
$thirdparty->client=$obj->client;
$thirdparty->code_client=$obj->code_client;
print $thirdparty->getNomUrl(1,'customer');
$thirdpartystatic->id=$obj->socid;
$thirdpartystatic->name=$obj->name;
$thirdpartystatic->client=$obj->client;
$thirdpartystatic->code_client=$obj->code_client;
$thirdpartystatic->email=$obj->email;
print $thirdpartystatic->getNomUrl(1,'customer');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}

View File

@ -600,6 +600,13 @@ if ($resql)
print '<a href="'.DOL_URL_ROOT.'/contrat/note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';
print '</span>';
}
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->contrat->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir);
print '</td>';
print '</td>';
}
if (! empty($arrayfields['c.ref_customer']['checked']))

View File

@ -85,6 +85,7 @@ if (! $error && $massaction == 'confirm_presend')
{
$listofobjectid[$toselectid]=$toselectid;
$thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
if ($objecttmp->element == 'societe') $thirdpartyid=$objecttmp->id;
$listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
$listofobjectref[$thirdpartyid][$toselectid]=$objecttmp;
}
@ -172,74 +173,90 @@ if (! $error && $massaction == 'confirm_presend')
$attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array());
$listofqualifiedid=array();
$listofqualifiedref=array();
$thirdpartywithoutemail=array();
foreach($listofobjectref[$thirdpartyid] as $objectid => $object)
{
//var_dump($thirdpartyid.' - '.$objectid.' - '.$object->statut);
if ($objectclass == 'Facture' && $object->statut != Facture::STATUS_VALIDATED)
if ($objectclass == 'Propal' && $object->statut == Propal::STATUS_DRAFT)
{
$langs->load("errors");
$nbignored++;
$resaction.='<div class="error">'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction',$object->ref).'</div><br>';
$resaction.='<div class="error">'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction',$object->ref).'</div><br>';
continue; // Payment done or started or canceled
}
if ($objectclass == 'Commande' && $object->statut == Commande::STATUS_DRAFT)
if ($objectclass == 'Commande' && $object->statut == Commande::STATUS_DRAFT)
{
$langs->load("errors");
$nbignored++;
$resaction.='<div class="error">'.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction',$object->ref).'</div><br>';
continue;
}
// Read document
// TODO Use future field $object->fullpathdoc to know where is stored default file
// TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc.
$filename=dol_sanitizeFileName($object->ref).'.pdf';
$filedir=$uploaddir . '/' . dol_sanitizeFileName($object->ref);
$file = $filedir . '/' . $filename;
$mime = dol_mimetype($file);
if (dol_is_file($file))
if ($objectclass == 'Facture' && $object->statut != Facture::STATUS_VALIDATED)
{
if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send)
{
$object->fetch_thirdparty();
$sendto = $object->thirdparty->email;
}
if (empty($sendto))
{
//print "No recipient for thirdparty ".$object->thirdparty->name;
$nbignored++;
continue;
}
if (dol_strlen($sendto))
{
// Create form object
$attachedfiles=array(
'paths'=>array_merge($attachedfiles['paths'],array($file)),
'names'=>array_merge($attachedfiles['names'],array($filename)),
'mimes'=>array_merge($attachedfiles['mimes'],array($mime))
);
}
$listofqualifiedid[$objectid]=$object;
$listofqualifiedref[$objectid]=$object->ref;
}
else
{
$nbignored++;
$langs->load("errors");
$resaction.='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div><br>';
dol_syslog('Failed to read file: '.$file, LOG_WARNING);
continue;
$langs->load("errors");
$nbignored++;
$resaction.='<div class="error">'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction',$object->ref).'</div><br>';
continue; // Payment done or started or canceled
}
// Test recipient
if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send)
{
$object->fetch_thirdparty();
$sendto = $object->thirdparty->email;
}
if (empty($sendto))
{
//print "No recipient for thirdparty ".$object->thirdparty->name;
$nbignored++;
if (empty($thirdpartywithoutemail[$object->thirdparty->id]))
{
$resaction.='<div class="error">'.$langs->trans('NoRecipientEmail',$object->thirdparty->name).'</div><br>';
}
dol_syslog('No recipient for thirdparty: '.$object->thirdparty->name, LOG_WARNING);
$thirdpartywithoutemail[$object->thirdparty->id]=1;
continue;
}
if ($_POST['addmaindocfile'])
{
// TODO Use future field $object->fullpathdoc to know where is stored default file
// TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc.
$filename=dol_sanitizeFileName($object->ref).'.pdf';
$filedir=$uploaddir . '/' . dol_sanitizeFileName($object->ref);
$file = $filedir . '/' . $filename;
$mime = dol_mimetype($file);
if (dol_is_file($file))
{
// Create form object
$attachedfiles=array(
'paths'=>array_merge($attachedfiles['paths'],array($file)),
'names'=>array_merge($attachedfiles['names'],array($filename)),
'mimes'=>array_merge($attachedfiles['mimes'],array($mime))
);
}
else
{
$nbignored++;
$langs->load("errors");
$resaction.='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div><br>';
dol_syslog('Failed to read file: '.$file, LOG_WARNING);
continue;
}
}
// Object of thirdparty qualified
$listofqualifiedid[$objectid]=$object;
$listofqualifiedref[$objectid]=$object->ref;
//var_dump($listofqualifiedref);
}
// Loop on each qualified objects of the thirdparty
// Send email if there is at least one qualified record
if (count($listofqualifiedid) > 0)
{
$langs->load("commercial");

View File

@ -63,6 +63,7 @@ class FormMail extends Form
var $withtoccc;
var $withtopic;
var $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files
var $withmaindocfile; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default)
var $withbody;
var $withfromreadonly;
@ -103,7 +104,8 @@ class FormMail extends Form
$this->withtoccc=0;
$this->witherrorsto=0;
$this->withtopic=1;
$this->withfile=0;
$this->withfile=0; // 1=Add section "Attached files". 2=Can add files.
$this->withmaindocfile=0; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default)
$this->withbody=1;
$this->withfromreadonly=1;
@ -220,6 +222,7 @@ class FormMail extends Form
/**
* Show the form to input an email
* this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
* this->withmaindocfile
*
* @param string $addfileaction Name of action when posting file attachments
* @param string $removefileaction Name of action when removing file attachments
@ -233,6 +236,7 @@ class FormMail extends Form
/**
* Get the form to input an email
* this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
* this->withfile
* this->param: Contains more parameteres like email templates info
*
* @param string $addfileaction Name of action when posting file attachments
@ -297,6 +301,7 @@ class FormMail extends Form
$arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
//var_dump($this->param["models"]);
//var_dump($model_id);
//var_dump($arraydefaultmessage);
$out.= "\n".'<!-- Begin form mail type='.$this->param["models"].' --><div id="mailformdiv"></div>'."\n";
if ($this->withform == 1)
@ -348,7 +353,7 @@ class FormMail extends Form
elseif (! empty($this->param['models']) && in_array($this->param['models'], array(
'propal_send','order_send','facture_send',
'shipping_send','fichinter_send','supplier_proposal_send','order_supplier_send',
'invoice_supplier_send','thirdparty','all'
'invoice_supplier_send','thirdparty','contract','all'
)))
{
$out.= '<div class="center" style="padding: 0px 0 12px 0">'."\n";
@ -641,9 +646,12 @@ class FormMail extends Form
// Topic
if (! empty($this->withtopic))
{
$defaulttopic="";
if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['topic']) $defaulttopic=$arraydefaultmessage['topic'];
elseif (! is_numeric($this->withtopic)) $defaulttopic=$this->withtopic;
$defaulttopic=GETPOST('subject','none');
if (! GETPOST('modelselected','alpha') || GETPOST('modelmailselected') != '-1')
{
if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['topic']) $defaulttopic=$arraydefaultmessage['topic'];
elseif (! is_numeric($this->withtopic)) $defaulttopic=$this->withtopic;
}
$defaulttopic=make_substitutions($defaulttopic,$this->substit);
@ -669,9 +677,22 @@ class FormMail extends Form
$out.= '<td width="180">'.$langs->trans("MailFile").'</td>';
$out.= '<td>';
if (! empty($this->withmaindocfile))
{
if ($this->withmaindocfile == 1)
{
$out.='<input type="checkbox" name="addmaindocfile" value="1" />';
}
if ($this->withmaindocfile == -1)
{
$out.='<input type="checkbox" name="addmaindocfile" checked="checked" />';
}
$out.=' '.$langs->trans("JoinMainDoc").'.<br>';
}
if (is_numeric($this->withfile))
{
// TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
// TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
$out.= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
$out.= '<script type="text/javascript" language="javascript">';
$out.= 'jQuery(document).ready(function () {';
@ -694,7 +715,7 @@ class FormMail extends Form
$out.= '<br></div>';
}
}
else
else if (empty($this->withmaindocfile)) // Do not show message if we asked to show the checkbox
{
$out.= $langs->trans("NoAttachedFiles").'<br>';
}
@ -710,15 +731,19 @@ class FormMail extends Form
{
$out.=$this->withfile;
}
$out.= "</td></tr>\n";
}
// Message
if (! empty($this->withbody))
{
$defaultmessage="";
if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['content']) $defaultmessage=$arraydefaultmessage['content'];
elseif (! is_numeric($this->withbody)) $defaultmessage=$this->withbody;
$defaultmessage=GETPOST('message','none');
if (! GETPOST('modelselected','alpha') || GETPOST('modelmailselected') != '-1')
{
if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['content']) $defaultmessage=$arraydefaultmessage['content'];
elseif (! is_numeric($this->withbody)) $defaultmessage=$this->withbody;
}
// Complete substitution array
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL))

View File

@ -26,122 +26,130 @@
// $modelmail="supplier_proposal_send";
// $trackid='ord'.$object->id;
$langs->load("mails");
if (! GETPOST('cancel','alpha'))
{
$listofselectedid=array();
$listofselectedthirdparties=array();
$listofselectedref=array();
foreach($arrayofselected as $toselectid)
{
$result=$objecttmp->fetch($toselectid);
if ($result > 0)
{
$listofselectedid[$toselectid]=$toselectid;
$thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
$listofselectedthirdparties[$thirdpartyid]=$thirdpartyid;
$listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref;
}
}
}
print '<input type="hidden" name="massaction" value="confirm_presend">';
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
dol_fiche_head(null, '', '');
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->withform=-1;
$formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
if($formmail->fromtype === 'user'){
$formmail->fromid = $user->id;
}
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set
{
$formmail->trackid=$trackid;
}
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
{
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, $trackid);
}
$formmail->withfrom=1;
$liste=$langs->trans("AllRecipientSelected", count($listofselectedthirdparties));
if (count($listofselectedthirdparties) == 1) // Only 1 different recipient selected, we can suggest contacts
{
$liste=array();
$thirdpartyid=array_shift($listofselectedthirdparties);
$soc=new Societe($db);
$soc->fetch($thirdpartyid);
foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value)
{
$liste[$key]=$value;
}
$formmail->withtoreadonly=0;
}
else
{
$formmail->withtoreadonly=1;
}
$formmail->withto=$liste;
$formmail->withtofree=0;
$formmail->withtocc=1;
$formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
$formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__');
$formmail->withfile=$langs->trans("OnlyPDFattachmentSupported");
$formmail->withbody=1;
$formmail->withdeliveryreceipt=1;
$formmail->withcancel=1;
// Make substitution in email content
$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray['__EMAIL__'] = $sendto;
$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':'';
$substitutionarray['__PERSONALIZED__'] = '';
$substitutionarray['__CONTACTCIVNAME__'] = '';
// Add specific substitution for contracts
if (is_object($object) && $object->element == 'contrat' && is_array($object->lines))
{
$datenextexpiration='';
foreach($object->lines as $line)
{
if ($line->statut != 4) continue;
if ($line->date_fin_prevue > $datenextexpiration) $datenextexpiration = $line->date_fin_prevue;
}
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
}
$parameters=array('mode'=>'formemail');
complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
// Tableau des substitutions
$formmail->substit=$substitutionarray;
// Tableau des parametres complementaires du post
$formmail->param['action']=$action;
$formmail->param['models']=$modelmail;
$formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['id']=join(',',$arrayofselected);
//$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
if (! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && count($listofselectedthirdparties) > $conf->global->MAILING_LIMIT_SENDBYWEB)
{
$langs->load("errors");
print img_warning().' '.$langs->trans('WarningNumberOfRecipientIsRestrictedInMassAction', $conf->global->MAILING_LIMIT_SENDBYWEB);
print ' - <a href="javascript: window.history.go(-1)">'.$langs->trans("GoBack").'</a>';
$arrayofmassactions=array();
}
else
if (! GETPOST('cancel', 'alpha'))
{
$listofselectedid = array();
$listofselectedthirdparties = array();
$listofselectedref = array();
foreach ($arrayofselected as $toselectid)
{
print $formmail->get_form();
$result = $objecttmp->fetch($toselectid);
if ($result > 0)
{
$listofselectedid[$toselectid] = $toselectid;
$thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
if ($objecttmp->element == 'societe')
$thirdpartyid = $objecttmp->id;
$listofselectedthirdparties[$thirdpartyid] = $thirdpartyid;
$listofselectedref[$thirdpartyid][$toselectid] = $objecttmp->ref;
}
}
}
print '<input type="hidden" name="massaction" value="confirm_presend">';
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
dol_fiche_head(null, '', '');
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->withform = - 1;
$formmail->fromtype = (GETPOST('fromtype') ? GETPOST('fromtype') : (! empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user'));
if ($formmail->fromtype === 'user')
{
$formmail->fromid = $user->id;
}
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set
{
$formmail->trackid = $trackid;
}
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
{
include DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
$formmail->frommail = dolAddEmailTrackId($formmail->frommail, $trackid);
}
$formmail->withfrom = 1;
$liste = $langs->trans("AllRecipientSelected", count($listofselectedthirdparties));
if (count($listofselectedthirdparties) == 1) // Only 1 different recipient selected, we can suggest contacts
{
$liste = array();
$thirdpartyid = array_shift($listofselectedthirdparties);
$soc = new Societe($db);
$soc->fetch($thirdpartyid);
foreach ($soc->thirdparty_and_contact_email_array(1) as $key => $value) {
$liste[$key] = $value;
}
$formmail->withtoreadonly = 0;
} else {
$formmail->withtoreadonly = 1;
}
$formmail->withto = $liste;
$formmail->withtofree = 0;
$formmail->withtocc = 1;
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
$formmail->withtopic = $langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__');
$formmail->withfile = 1;
// $formmail->withfile = 2; Not yet supported in mass action
$formmail->withmaindocfile = 1; // Add a checkbox "Attach also main document"
if ($objecttmp->element != 'societe') {
$formmail->withfile = $langs->trans("OnlyPDFattachmentSupported");
$formmail->withmaindocfile = - 1; // Add a checkbox "Attach also main document" but not checked by default
}
$formmail->withbody = 1;
$formmail->withdeliveryreceipt = 1;
$formmail->withcancel = 1;
// Make substitution in email content
$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray['__EMAIL__'] = $sendto;
$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
$substitutionarray['__PERSONALIZED__'] = '';
$substitutionarray['__CONTACTCIVNAME__'] = '';
// Add specific substitution for contracts
if (is_object($object) && $object->element == 'contrat' && is_array($object->lines))
{
$datenextexpiration = '';
foreach ($object->lines as $line)
{
if ($line->statut != 4)
continue;
if ($line->date_fin_prevue > $datenextexpiration)
$datenextexpiration = $line->date_fin_prevue;
}
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
}
$parameters = array(
'mode' => 'formemail'
);
complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
// Tableau des substitutions
$formmail->substit = $substitutionarray;
// Tableau des parametres complementaires du post
$formmail->param['action'] = $action;
$formmail->param['models'] = $modelmail;
$formmail->param['models_id'] = GETPOST('modelmailselected', 'int');
$formmail->param['id'] = join(',', $arrayofselected);
// $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
if (! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && count($listofselectedthirdparties) > $conf->global->MAILING_LIMIT_SENDBYWEB)
{
$langs->load("errors");
print img_warning() . ' ' . $langs->trans('WarningNumberOfRecipientIsRestrictedInMassAction', $conf->global->MAILING_LIMIT_SENDBYWEB);
print ' - <a href="javascript: window.history.go(-1)">' . $langs->trans("GoBack") . '</a>';
$arrayofmassactions = array();
}
else
{
print $formmail->get_form();
}
dol_fiche_end();

View File

@ -49,6 +49,7 @@ NbOfUniqueEMails=Nb of unique emails
NbOfEMails=Nb of EMails
TotalNbOfDistinctRecipients=Number of distinct recipients
NoTargetYet=No recipients defined yet (Go on tab 'Recipients')
NoRecipientEmail=No recipient email for %s
RemoveRecipient=Remove recipient
YouCanAddYourOwnPredefindedListHere=To create your email selector module, see htdocs/core/modules/mailings/README.
EMailTestSubstitutionReplacedByGenericValues=When using test mode, substitutions variables are replaced by generic values

View File

@ -540,6 +540,7 @@ MonthShort10=Oct
MonthShort11=Nov
MonthShort12=Dec
AttachedFiles=Attached files and documents
JoinMainDoc=Join main document
DateFormatYYYYMM=YYYY-MM
DateFormatYYYYMMDD=YYYY-MM-DD
DateFormatYYYYMMDDHHMM=YYYY-MM-DD HH:SS

View File

@ -1908,6 +1908,7 @@ class Societe extends CommonObject
{
$label.= '<br><b>' . $langs->trans('Name') . ':</b> '. $this->name;
if (! empty($this->name_alias)) $label.=' ('.$this->name_alias.')';
$label.= '<br><b>' . $langs->trans('Email') . ':</b> '. $this->email;
}
if (! empty($this->country_code))
$label.= '<br><b>' . $langs->trans('Country') . ':</b> '. $this->country_code;

View File

@ -575,7 +575,7 @@ if (GETPOST('delsoc'))
// List of mass actions available
$arrayofmassactions = array(
// 'presend'=>$langs->trans("SendByMail"),
'presend'=>$langs->trans("SendByMail"),
// 'builddoc'=>$langs->trans("PDFMerge"),
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
@ -606,6 +606,16 @@ foreach(array(1,2,3,4,5,6) as $key)
}
}
if ($massaction == 'presend')
{
$topicmail="SendEmail";
$modelmail="thirdparty";
$objecttmp=new Societe($db);
$trackid='thi'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php';
}
if ($search_all)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);