\n";
-
- // Substitution array
- if ($this->withsubstit)
- {
- print "";
- $help="";
- foreach($this->substit as $key => $val)
- {
- $help.=$key.' -> '.$langs->trans($val).' ';
- }
- print $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help);
- print " |
\n";
- }
-
- // From
- if ($this->withfrom)
- {
- if ($this->withfromreadonly)
- {
- print '';
- print '';
- print "| ".$langs->trans("MailFrom")." | ";
- if ($this->fromtype == 'user')
- {
- $langs->load("users");
- $fuser=new User($this->db);
- $fuser->fetch($this->fromid);
- print $fuser->getNomUrl(1);
- }
- else
- {
- print $this->fromname;
- }
- if ($this->frommail)
- {
- print " <".$this->frommail.">";
- }
- else
- {
- if ($this->fromtype)
- {
- $langs->load("errors");
- print ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> ';
- }
- }
- print " |
\n";
- print "\n";
- }
- else
- {
- print "| ".$langs->trans("MailFrom")." | ";
- print $langs->trans("Name").':';
- print ' ';
- print $langs->trans("EMail").':<>';
- print " |
\n";
- }
- }
-
- // Replyto
- if ($this->withreplyto)
- {
- if ($this->withreplytoreadonly)
- {
- print '';
- print '';
- print "| ".$langs->trans("MailReply")." | ".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):"");
- print " |
\n";
- }
- }
-
- // Errorsto
- if ($this->witherrorsto)
- {
- //if (! $this->errorstomail) $this->errorstomail=$this->frommail;
- if ($this->witherrorstoreadonly)
- {
- print '';
- print "| ".$langs->trans("MailErrorsTo")." | ";
- print $this->errorstomail;
- print " |
\n";
- }
- else
- {
- print "| ".$langs->trans("MailErrorsTo")." | ";
- print "errorstomail."\">";
- print " |
\n";
- }
- }
-
- // To
- if ($this->withto || is_array($this->withto))
- {
- print '| ';
- print $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
- print ' | ';
- if ($this->withtoreadonly)
- {
- print (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:"";
- }
- else
- {
- print "withto)?"30":"60")."\" name=\"sendto\" value=\"".(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"")."\">";
- if ($this->withtosocid > 0)
- {
- $liste=array();
- $liste[0]=' ';
- $soc=new Societe($this->db);
- $soc->fetch($this->withtosocid);
- foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value)
- {
- $liste[$key]=$value;
- }
- print " ".$langs->trans("or")." ";
- //var_dump($_REQUEST);exit;
- print $form->selectarray("receiver", $liste, isset($_REQUEST["receiver"])?$_REQUEST["receiver"]:0);
- }
- }
- print " |
\n";
- }
-
- // CC
- if ($this->withtocc || is_array($this->withtocc))
- {
- print '| ';
- print $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
- print ' | ';
- if ($this->withtoccreadonly)
- {
- print (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:"";
- }
- else
- {
- print "withtocc)?"30":"60")."\" name=\"sendtocc\" value=\"".((! is_array($this->withtocc) && ! is_numeric($this->withtocc))? (isset($_POST["sendtocc"])?$_POST["sendtocc"]:$this->withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") )."\">";
- if ($this->withtoccsocid > 0)
- {
- $liste=array();
- $liste[0]=' ';
- $soc=new Societe($this->db);
- $soc->fetch($this->withtoccsocid);
- foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value)
- {
- $liste[$key]=$value;
- }
- print " ".$langs->trans("or")." ";
- $form->select_array("receivercc", $liste, isset($_REQUEST["receivercc"])?$_REQUEST["receivercc"]:0);
- }
- }
- print " |
\n";
- }
-
- // CCC
- if ($this->withtoccc || is_array($this->withtoccc))
- {
- print '| ';
- print $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
- print ' | ';
- if ($this->withtocccreadonly)
- {
- print (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:"";
- }
- else
- {
- print "withtoccc)?"30":"60")."\" name=\"sendtoccc\" value=\"".((! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))? (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:$this->withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") )."\">";
- if ($this->withtocccsocid > 0)
- {
- $liste=array();
- $liste[0]=' ';
- $soc=new Societe($this->db);
- $soc->fetch($this->withtosocid);
- foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value)
- {
- $liste[$key]=$value;
- }
- print " ".$langs->trans("or")." ";
- $form->select_array("receiverccc", $liste, isset($_REQUEST["receiverccc"])?$_REQUEST["receiverccc"]:0);
- }
- }
- print " |
\n";
- }
-
- // Ask delivery receipt
- if ($this->withdeliveryreceipt)
- {
- print '| '.$langs->trans("DeliveryReceipt").' | ';
-
- if ($this->withdeliveryreceiptreadonly)
- {
- print yn($this->withdeliveryreceipt);
- }
- else
- {
- print $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0) ,1);
- }
-
- print " |
\n";
- }
-
- // Topic
- if ($this->withtopic)
- {
- $this->withtopic=make_substitutions($this->withtopic,$this->substit,$langs);
-
- print "";
- print "| ".$langs->trans("MailTopic")." | ";
- print "";
- if ($this->withtopicreadonly)
- {
- print $this->withtopic;
- print "withtopic."\">";
- }
- else
- {
- print "withtopic) ."\">";
- }
- print " |
\n";
- }
-
- // Attached files
- if ($this->withfile)
- {
- print "";
- print '| '.$langs->trans("MailFile")." | ";
- print "";
- //print '';
- }
- print " |
\n";
- }
-
- // Message
- if ($this->withbody)
- {
- $defaultmessage="";
-
- // TODO A partir du type, proposer liste de messages dans table llx_models
- if ($this->param["models"]=='body') { $defaultmessage=$this->withbody; }
- if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); }
- if ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); }
- if ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); }
- if ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); }
-
- $defaultmessage=make_substitutions($defaultmessage,$this->substit,$langs);
- if (isset($_POST["message"])) $defaultmessage=$_POST["message"];
- $defaultmessage=str_replace('\n',"\n",$defaultmessage);
-
- print "";
- print "| ".$langs->trans("MailText")." | ";
- print "";
- if ($this->withbodyreadonly)
- {
- print nl2br($defaultmessage);
- print '';
- }
- else
- {
- if ($this->withfckeditor)
- {
- // Editeur wysiwyg
- require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
- $doleditor=new DolEditor('message',$defaultmessage,280,'dolibarr_notes','In',true);
- $doleditor->Create();
- }
- else
- {
- print '';
- }
-
- }
- print " |
\n";
- }
-
- print "| ";
- print "trans("SendMail")."\"";
- // Add a javascript test to avoid to forget to submit file before sending email
- if ($this->withfile == 2 && $conf->use_javascript_ajax)
- {
- print ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"';
- }
- print ">";
- if ($this->withcancel)
- {
- print " ";
- print "trans("Cancel")."\">";
- }
- print " |
\n";
- print "
\n";
-
- print "