From 03d6903248e748881f316a52769aa532cbf8f817 Mon Sep 17 00:00:00 2001 From: simnandez Date: Thu, 24 Jan 2013 12:53:42 +0100 Subject: [PATCH 1/5] Fix: [ bug #698 ] Bad calculation of totals of associated documents --- htdocs/comm/propal/tpl/linkedobjectblock.tpl.php | 4 +++- htdocs/commande/tpl/linkedobjectblock.tpl.php | 4 +++- htdocs/compta/facture/tpl/linkedobjectblock.tpl.php | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 4337611066e..e9ad176a86d 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,6 +38,7 @@ print_titre($langs->trans('RelatedCommercialProposals')); +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +39,7 @@ print_titre($langs->trans('RelatedOrders')); +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +39,7 @@ else print_titre($langs->trans("RelatedBill")); Date: Thu, 24 Jan 2013 17:29:11 +0100 Subject: [PATCH 2/5] New: add hook getFormMail --- htdocs/core/class/html.formmail.class.php | 835 +++++++++++----------- 1 file changed, 429 insertions(+), 406 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 3d15fdbeeee..c221cc33c07 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -217,422 +217,445 @@ class FormMail function get_form($addfileaction='addfile',$removefileaction='removefile') { global $conf, $langs, $user; + global $hookmanager; $langs->load("other"); $langs->load("mails"); - $out=''; - - // Define list of attached files - $listofpaths=array(); - $listofnames=array(); - $listofmimes=array(); - if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); - if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); - if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); - - - $form=new Form($this->db); - - $out.= "\n\n"; - if ($this->withform) + if (! is_object($hookmanager)) { - $out.= '
'."\n"; - $out.= ''; + if (! class_exists('HookManager')) { + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array + require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } } - foreach ($this->param as $key=>$value) + $hookmanager->initHooks(array('formmail')); + + $parameters=array( + 'addfileaction' => $addfileaction, + 'removefileaction'=> $removefileaction + ); + $reshook=$hookmanager->executeHooks('getFormMail', $parameters, $this); + + if (!empty($reshook)) { - $out.= ''."\n"; + return $hookmanager->resPrint; } - $out.= ''."\n"; - - // Substitution array - if (! empty($this->withsubstit)) + else { - $out.= '\n"; + $out=''; + + // Define list of attached files + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); + + $form=new Form($this->db); + + $out.= "\n\n"; + if ($this->withform) + { + $out.= ''."\n"; + $out.= ''; + } + foreach ($this->param as $key=>$value) + { + $out.= ''."\n"; + } + $out.= '
'; - $help=""; - foreach($this->substit as $key => $val) - { - $help.=$key.' -> '.$langs->trans($val).'
'; - } - $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); - $out.= "
'."\n"; + + // Substitution array + if (! empty($this->withsubstit)) + { + $out.= '\n"; + } + + // From + if (! empty($this->withfrom)) + { + if (! empty($this->withfromreadonly)) + { + $out.= ''; + $out.= ''; + $out.= '\n"; + $out.= "\n"; + } + else + { + $out.= "\n"; + } + } + + // Replyto + if (! empty($this->withreplyto)) + { + if ($this->withreplytoreadonly) + { + $out.= ''; + $out.= ''; + $out.= "\n"; + } + } + + // Errorsto + if (! empty($this->witherrorsto)) + { + //if (! $this->errorstomail) $this->errorstomail=$this->frommail; + $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); + if ($this->witherrorstoreadonly) + { + $out.= ''; + $out.= '\n"; + } + else + { + $out.= '\n"; + } + } + + // To + if (! empty($this->withto) || is_array($this->withto)) + { + $out.= '\n"; + } + + // CC + if (! empty($this->withtocc) || is_array($this->withtocc)) + { + $out.= '\n"; + } + + // CCC + if (! empty($this->withtoccc) || is_array($this->withtoccc)) + { + $out.= '\n"; + } + + // Ask delivery receipt + if (! empty($this->withdeliveryreceipt)) + { + $out.= '\n"; + } + + // Topic + if (! empty($this->withtopic)) + { + $this->withtopic=make_substitutions($this->withtopic,$this->substit); + + $out.= ''; + $out.= ''; + $out.= '\n"; + } + + // Attached files + if (! empty($this->withfile)) + { + $out.= ''; + $out.= ''; + $out.= '\n"; + } + + // Message + if (! empty($this->withbody)) + { + $defaultmessage=""; + + // TODO A partir du type, proposer liste de messages dans table llx_models + if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } + elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } + elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } + elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } + elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } + elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } + elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } + elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } + elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } + + // Complete substitution array + if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) + { + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + + $langs->load('paypal'); + + if ($this->param["models"]=='order_send') + { + $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + if ($this->param["models"]=='facture_send') + { + $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + } + + $defaultmessage=make_substitutions($defaultmessage,$this->substit); + if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; + $defaultmessage=str_replace('\n',"\n",$defaultmessage); + + $out.= ''; + $out.= ''; + $out.= '\n"; + } + + if (! empty($this->withform)) + { + $out.= ''."\n"; + } + + $out.= '
'; + $help=""; + foreach($this->substit as $key => $val) + { + $help.=$key.' -> '.$langs->trans($val).'
'; + } + $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); + $out.= "
'.$langs->trans("MailFrom").''; + if ($this->fromtype == 'user' && $this->fromid > 0) + { + $langs->load("users"); + $fuser=new User($this->db); + $fuser->fetch($this->fromid); + $out.= $fuser->getNomUrl(1); + } + else + { + $out.= $this->fromname; + } + if ($this->frommail) + { + $out.= " <".$this->frommail.">"; + } + else + { + if ($this->fromtype) + { + $langs->load("errors"); + $out.= ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> '; + } + } + $out.= "
".$langs->trans("MailFrom").""; + $out.= $langs->trans("Name").':'; + $out.= '    '; + $out.= $langs->trans("EMail").':<>'; + $out.= "
".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); + $out.= "
'.$langs->trans("MailErrorsTo").''; + $out.= $errorstomail; + $out.= "
'.$langs->trans("MailErrorsTo").''; + $out.= ''; + $out.= "
'; + if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + else $out.= $langs->trans("MailTo"); + $out.= ''; + if ($this->withtoreadonly) + { + if (! empty($this->toname) && ! empty($this->tomail)) + { + $out.= ''; + $out.= ''; + if ($this->totype == 'thirdparty') + { + $soc=new Societe($this->db); + $soc->fetch($this->toid); + $out.= $soc->getNomUrl(1); + } + else if ($this->totype == 'contact') + { + $contact=new Contact($this->db); + $contact->fetch($this->toid); + $out.= $contact->getNomUrl(1); + } + else + { + $out.= $this->toname; + } + $out.= ' <'.$this->tomail.'>'; + if ($this->withtofree) + { + $out.= '
'.$langs->trans("or").' withto) :"").'" />'; + } + } + else + { + $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; + } + } + else + { + if (! empty($this->withtofree)) + { + $out.= 'withto) :"").'" />'; + } + if (! empty($this->withto) && is_array($this->withto)) + { + if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); + } + if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + if ($this->withtofree) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); + } + } + $out.= "
'; + $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if ($this->withtoccreadonly) + { + $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; + } + else + { + $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; + if (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); + } + if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtoccsocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); + } + } + $out.= "
'; + $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if (! empty($this->withtocccreadonly)) + { + $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; + } + else + { + $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; + if (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); + } + if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); + } + } + //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); + $out.= "
'.$langs->trans("DeliveryReceipt").''; + + if (! empty($this->withdeliveryreceiptreadonly)) + { + $out.= yn($this->withdeliveryreceipt); + } + else + { + $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1); + } + + $out.= "
'.$langs->trans("MailTopic").''; + if ($this->withtopicreadonly) + { + $out.= $this->withtopic; + $out.= ''; + } + else + { + $out.= 'withtopic) .'" />'; + } + $out.= "
'.$langs->trans("MailFile").''; + // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript + $out.= ''."\n"; + $out.= ''."\n"; + if (count($listofpaths)) + { + foreach($listofpaths as $key => $val) + { + $out.= '
'; + $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; + if (! $this->withfilereadonly) + { + $out.= ' '; + //$out.= ' '.img_delete($langs->trans("Delete").''; + } + $out.= '
'; + } + } + else + { + $out.= $langs->trans("NoAttachedFiles").'
'; + } + if ($this->withfile == 2) // Can add other files + { + $out.= ''; + $out.= ' '; + $out.= ''; + } + $out.= "
'.$langs->trans("MailText").''; + if ($this->withbodyreadonly) + { + $out.= nl2br($defaultmessage); + $out.= ''; + } + else + { + if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; + + // Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); + $out.= $doleditor->Create(1); + } + $out.= "
'; + $out.= 'withfile == 2 && $conf->use_javascript_ajax) + { + $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; + } + $out.= ' />'; + if ($this->withcancel) + { + $out.= '     '; + $out.= ''; + } + $out.= '
'."\n"; + + if (! empty($this->withform)) $out.= '
'."\n"; + $out.= "\n"; + + return $out; } - - // From - if (! empty($this->withfrom)) - { - if (! empty($this->withfromreadonly)) - { - $out.= ''; - $out.= ''; - $out.= ''.$langs->trans("MailFrom").''; - if ($this->fromtype == 'user' && $this->fromid > 0) - { - $langs->load("users"); - $fuser=new User($this->db); - $fuser->fetch($this->fromid); - $out.= $fuser->getNomUrl(1); - } - else - { - $out.= $this->fromname; - } - if ($this->frommail) - { - $out.= " <".$this->frommail.">"; - } - else - { - if ($this->fromtype) - { - $langs->load("errors"); - $out.= ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> '; - } - } - $out.= "\n"; - $out.= "\n"; - } - else - { - $out.= "".$langs->trans("MailFrom").""; - $out.= $langs->trans("Name").':'; - $out.= '    '; - $out.= $langs->trans("EMail").':<>'; - $out.= "\n"; - } - } - - // Replyto - if (! empty($this->withreplyto)) - { - if ($this->withreplytoreadonly) - { - $out.= ''; - $out.= ''; - $out.= "".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); - $out.= "\n"; - } - } - - // Errorsto - if (! empty($this->witherrorsto)) - { - //if (! $this->errorstomail) $this->errorstomail=$this->frommail; - $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); - if ($this->witherrorstoreadonly) - { - $out.= ''; - $out.= ''.$langs->trans("MailErrorsTo").''; - $out.= $errorstomail; - $out.= "\n"; - } - else - { - $out.= ''.$langs->trans("MailErrorsTo").''; - $out.= ''; - $out.= "\n"; - } - } - - // To - if (! empty($this->withto) || is_array($this->withto)) - { - $out.= ''; - if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - else $out.= $langs->trans("MailTo"); - $out.= ''; - if ($this->withtoreadonly) - { - if (! empty($this->toname) && ! empty($this->tomail)) - { - $out.= ''; - $out.= ''; - if ($this->totype == 'thirdparty') - { - $soc=new Societe($this->db); - $soc->fetch($this->toid); - $out.= $soc->getNomUrl(1); - } - else if ($this->totype == 'contact') - { - $contact=new Contact($this->db); - $contact->fetch($this->toid); - $out.= $contact->getNomUrl(1); - } - else - { - $out.= $this->toname; - } - $out.= ' <'.$this->tomail.'>'; - if ($this->withtofree) - { - $out.= '
'.$langs->trans("or").' withto) :"").'" />'; - } - } - else - { - $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; - } - } - else - { - if (! empty($this->withtofree)) - { - $out.= 'withto) :"").'" />'; - } - if (! empty($this->withto) && is_array($this->withto)) - { - if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); - } - if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - if ($this->withtofree) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); - } - } - $out.= "\n"; - } - - // CC - if (! empty($this->withtocc) || is_array($this->withtocc)) - { - $out.= ''; - $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if ($this->withtoccreadonly) - { - $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; - } - else - { - $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); - } - if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtoccsocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); - } - } - $out.= "\n"; - } - - // CCC - if (! empty($this->withtoccc) || is_array($this->withtoccc)) - { - $out.= ''; - $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if (! empty($this->withtocccreadonly)) - { - $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; - } - else - { - $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); - } - if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); - } - } - //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); - $out.= "\n"; - } - - // Ask delivery receipt - if (! empty($this->withdeliveryreceipt)) - { - $out.= ''.$langs->trans("DeliveryReceipt").''; - - if (! empty($this->withdeliveryreceiptreadonly)) - { - $out.= yn($this->withdeliveryreceipt); - } - else - { - $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1); - } - - $out.= "\n"; - } - - // Topic - if (! empty($this->withtopic)) - { - $this->withtopic=make_substitutions($this->withtopic,$this->substit); - - $out.= ''; - $out.= ''.$langs->trans("MailTopic").''; - $out.= ''; - if ($this->withtopicreadonly) - { - $out.= $this->withtopic; - $out.= ''; - } - else - { - $out.= 'withtopic) .'" />'; - } - $out.= "\n"; - } - - // Attached files - if (! empty($this->withfile)) - { - $out.= ''; - $out.= ''.$langs->trans("MailFile").''; - $out.= ''; - // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out.= ''."\n"; - $out.= ''."\n"; - if (count($listofpaths)) - { - foreach($listofpaths as $key => $val) - { - $out.= '
'; - $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; - if (! $this->withfilereadonly) - { - $out.= ' '; - //$out.= ' '.img_delete($langs->trans("Delete").''; - } - $out.= '
'; - } - } - else - { - $out.= $langs->trans("NoAttachedFiles").'
'; - } - if ($this->withfile == 2) // Can add other files - { - $out.= ''; - $out.= ' '; - $out.= ''; - } - $out.= "\n"; - } - - // Message - if (! empty($this->withbody)) - { - $defaultmessage=""; - - // TODO A partir du type, proposer liste de messages dans table llx_models - if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } - elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } - elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } - elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } - elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } - elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } - elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } - elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } - elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } - - // Complete substitution array - if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) - { - require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; - - $langs->load('paypal'); - - if ($this->param["models"]=='order_send') - { - $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - if ($this->param["models"]=='facture_send') - { - $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - } - - $defaultmessage=make_substitutions($defaultmessage,$this->substit); - if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; - $defaultmessage=str_replace('\n',"\n",$defaultmessage); - - $out.= ''; - $out.= ''.$langs->trans("MailText").''; - $out.= ''; - if ($this->withbodyreadonly) - { - $out.= nl2br($defaultmessage); - $out.= ''; - } - else - { - if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); - $out.= $doleditor->Create(1); - } - $out.= "\n"; - } - - if (! empty($this->withform)) - { - $out.= '
'; - $out.= 'withfile == 2 && $conf->use_javascript_ajax) - { - $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; - } - $out.= ' />'; - if ($this->withcancel) - { - $out.= '     '; - $out.= ''; - } - $out.= '
'."\n"; - } - - $out.= ''."\n"; - - if (! empty($this->withform)) $out.= ''."\n"; - $out.= "\n"; - - return $out; } } From 7facbf7aa275694cd52b12ccc2eb5df8a1f65e55 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 24 Jan 2013 17:54:51 +0100 Subject: [PATCH 3/5] Multicompany restriction for transverse mode not used anymore. RestrictedArea is enough --- htdocs/user/fiche.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index bc0caf8d469..222ab62b846 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -67,12 +67,6 @@ if ($id) || (($user->id != $id) && $user->rights->user->user->password)); } -//Multicompany in mode transversal -if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->multicompany->transverse_mode) -{ - accessforbidden(); -} - // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; From e3be718a571627add1c1c6153d10a78cd4d87625 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 25 Jan 2013 12:37:03 +0100 Subject: [PATCH 4/5] Fix: wrong object name --- htdocs/fourn/facture/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 99e1bf5da0a..936fbd08572 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -2078,7 +2078,7 @@ else $formmail->frommail = $user->email; $formmail->withfrom=1; $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; - $formmail->withtosocid=$soc->id; + $formmail->withtosocid=$societe->id; $formmail->withtocc=1; $formmail->withtoccsocid=0; $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; From 20023880983ece133a0ba84cff1ec5d3368027fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Jan 2013 13:40:31 +0100 Subject: [PATCH 5/5] Revert "New: add hook getFormMail" This reverts commit c7325324839e1796400eb3246873af922d964434. --- htdocs/core/class/html.formmail.class.php | 835 +++++++++++----------- 1 file changed, 406 insertions(+), 429 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index c221cc33c07..3d15fdbeeee 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -217,445 +217,422 @@ class FormMail function get_form($addfileaction='addfile',$removefileaction='removefile') { global $conf, $langs, $user; - global $hookmanager; $langs->load("other"); $langs->load("mails"); - if (! is_object($hookmanager)) + $out=''; + + // Define list of attached files + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); + + + $form=new Form($this->db); + + $out.= "\n\n"; + if ($this->withform) { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } + $out.= '
'."\n"; + $out.= ''; } - $hookmanager->initHooks(array('formmail')); - - $parameters=array( - 'addfileaction' => $addfileaction, - 'removefileaction'=> $removefileaction - ); - $reshook=$hookmanager->executeHooks('getFormMail', $parameters, $this); - - if (!empty($reshook)) + foreach ($this->param as $key=>$value) { - return $hookmanager->resPrint; + $out.= ''."\n"; } - else + $out.= ''."\n"; + + // Substitution array + if (! empty($this->withsubstit)) { - $out=''; - - // Define list of attached files - $listofpaths=array(); - $listofnames=array(); - $listofmimes=array(); - if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); - if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); - if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); - - $form=new Form($this->db); - - $out.= "\n\n"; - if ($this->withform) - { - $out.= ''."\n"; - $out.= ''; - } - foreach ($this->param as $key=>$value) - { - $out.= ''."\n"; - } - $out.= '
'."\n"; - - // Substitution array - if (! empty($this->withsubstit)) - { - $out.= '\n"; - } - - // From - if (! empty($this->withfrom)) - { - if (! empty($this->withfromreadonly)) - { - $out.= ''; - $out.= ''; - $out.= '\n"; - $out.= "\n"; - } - else - { - $out.= "\n"; - } - } - - // Replyto - if (! empty($this->withreplyto)) - { - if ($this->withreplytoreadonly) - { - $out.= ''; - $out.= ''; - $out.= "\n"; - } - } - - // Errorsto - if (! empty($this->witherrorsto)) - { - //if (! $this->errorstomail) $this->errorstomail=$this->frommail; - $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); - if ($this->witherrorstoreadonly) - { - $out.= ''; - $out.= '\n"; - } - else - { - $out.= '\n"; - } - } - - // To - if (! empty($this->withto) || is_array($this->withto)) - { - $out.= '\n"; - } - - // CC - if (! empty($this->withtocc) || is_array($this->withtocc)) - { - $out.= '\n"; - } - - // CCC - if (! empty($this->withtoccc) || is_array($this->withtoccc)) - { - $out.= '\n"; - } - - // Ask delivery receipt - if (! empty($this->withdeliveryreceipt)) - { - $out.= '\n"; - } - - // Topic - if (! empty($this->withtopic)) - { - $this->withtopic=make_substitutions($this->withtopic,$this->substit); - - $out.= ''; - $out.= ''; - $out.= '\n"; - } - - // Attached files - if (! empty($this->withfile)) - { - $out.= ''; - $out.= ''; - $out.= '\n"; - } - - // Message - if (! empty($this->withbody)) - { - $defaultmessage=""; - - // TODO A partir du type, proposer liste de messages dans table llx_models - if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } - elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } - elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } - elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } - elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } - elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } - elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } - elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } - elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } - - // Complete substitution array - if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) - { - require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; - - $langs->load('paypal'); - - if ($this->param["models"]=='order_send') - { - $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - if ($this->param["models"]=='facture_send') - { - $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - } - - $defaultmessage=make_substitutions($defaultmessage,$this->substit); - if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; - $defaultmessage=str_replace('\n',"\n",$defaultmessage); - - $out.= ''; - $out.= ''; - $out.= '\n"; - } - - if (! empty($this->withform)) - { - $out.= ''."\n"; - } - - $out.= '
'; - $help=""; - foreach($this->substit as $key => $val) - { - $help.=$key.' -> '.$langs->trans($val).'
'; - } - $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); - $out.= "
'.$langs->trans("MailFrom").''; - if ($this->fromtype == 'user' && $this->fromid > 0) - { - $langs->load("users"); - $fuser=new User($this->db); - $fuser->fetch($this->fromid); - $out.= $fuser->getNomUrl(1); - } - else - { - $out.= $this->fromname; - } - if ($this->frommail) - { - $out.= " <".$this->frommail.">"; - } - else - { - if ($this->fromtype) - { - $langs->load("errors"); - $out.= ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> '; - } - } - $out.= "
".$langs->trans("MailFrom").""; - $out.= $langs->trans("Name").':'; - $out.= '    '; - $out.= $langs->trans("EMail").':<>'; - $out.= "
".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); - $out.= "
'.$langs->trans("MailErrorsTo").''; - $out.= $errorstomail; - $out.= "
'.$langs->trans("MailErrorsTo").''; - $out.= ''; - $out.= "
'; - if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - else $out.= $langs->trans("MailTo"); - $out.= ''; - if ($this->withtoreadonly) - { - if (! empty($this->toname) && ! empty($this->tomail)) - { - $out.= ''; - $out.= ''; - if ($this->totype == 'thirdparty') - { - $soc=new Societe($this->db); - $soc->fetch($this->toid); - $out.= $soc->getNomUrl(1); - } - else if ($this->totype == 'contact') - { - $contact=new Contact($this->db); - $contact->fetch($this->toid); - $out.= $contact->getNomUrl(1); - } - else - { - $out.= $this->toname; - } - $out.= ' <'.$this->tomail.'>'; - if ($this->withtofree) - { - $out.= '
'.$langs->trans("or").' withto) :"").'" />'; - } - } - else - { - $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; - } - } - else - { - if (! empty($this->withtofree)) - { - $out.= 'withto) :"").'" />'; - } - if (! empty($this->withto) && is_array($this->withto)) - { - if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); - } - if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - if ($this->withtofree) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); - } - } - $out.= "
'; - $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if ($this->withtoccreadonly) - { - $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; - } - else - { - $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); - } - if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtoccsocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); - } - } - $out.= "
'; - $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if (! empty($this->withtocccreadonly)) - { - $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; - } - else - { - $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); - } - if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); - } - } - //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); - $out.= "
'.$langs->trans("DeliveryReceipt").''; - - if (! empty($this->withdeliveryreceiptreadonly)) - { - $out.= yn($this->withdeliveryreceipt); - } - else - { - $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1); - } - - $out.= "
'.$langs->trans("MailTopic").''; - if ($this->withtopicreadonly) - { - $out.= $this->withtopic; - $out.= ''; - } - else - { - $out.= 'withtopic) .'" />'; - } - $out.= "
'.$langs->trans("MailFile").''; - // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out.= ''."\n"; - $out.= ''."\n"; - if (count($listofpaths)) - { - foreach($listofpaths as $key => $val) - { - $out.= '
'; - $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; - if (! $this->withfilereadonly) - { - $out.= ' '; - //$out.= ' '.img_delete($langs->trans("Delete").''; - } - $out.= '
'; - } - } - else - { - $out.= $langs->trans("NoAttachedFiles").'
'; - } - if ($this->withfile == 2) // Can add other files - { - $out.= ''; - $out.= ' '; - $out.= ''; - } - $out.= "
'.$langs->trans("MailText").''; - if ($this->withbodyreadonly) - { - $out.= nl2br($defaultmessage); - $out.= ''; - } - else - { - if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); - $out.= $doleditor->Create(1); - } - $out.= "
'; - $out.= 'withfile == 2 && $conf->use_javascript_ajax) - { - $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; - } - $out.= ' />'; - if ($this->withcancel) - { - $out.= '     '; - $out.= ''; - } - $out.= '
'."\n"; - - if (! empty($this->withform)) $out.= '
'."\n"; - $out.= "\n"; - - return $out; + $out.= ''; + $help=""; + foreach($this->substit as $key => $val) + { + $help.=$key.' -> '.$langs->trans($val).'
'; + } + $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); + $out.= "\n"; } + + // From + if (! empty($this->withfrom)) + { + if (! empty($this->withfromreadonly)) + { + $out.= ''; + $out.= ''; + $out.= ''.$langs->trans("MailFrom").''; + if ($this->fromtype == 'user' && $this->fromid > 0) + { + $langs->load("users"); + $fuser=new User($this->db); + $fuser->fetch($this->fromid); + $out.= $fuser->getNomUrl(1); + } + else + { + $out.= $this->fromname; + } + if ($this->frommail) + { + $out.= " <".$this->frommail.">"; + } + else + { + if ($this->fromtype) + { + $langs->load("errors"); + $out.= ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> '; + } + } + $out.= "\n"; + $out.= "\n"; + } + else + { + $out.= "".$langs->trans("MailFrom").""; + $out.= $langs->trans("Name").':'; + $out.= '    '; + $out.= $langs->trans("EMail").':<>'; + $out.= "\n"; + } + } + + // Replyto + if (! empty($this->withreplyto)) + { + if ($this->withreplytoreadonly) + { + $out.= ''; + $out.= ''; + $out.= "".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); + $out.= "\n"; + } + } + + // Errorsto + if (! empty($this->witherrorsto)) + { + //if (! $this->errorstomail) $this->errorstomail=$this->frommail; + $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); + if ($this->witherrorstoreadonly) + { + $out.= ''; + $out.= ''.$langs->trans("MailErrorsTo").''; + $out.= $errorstomail; + $out.= "\n"; + } + else + { + $out.= ''.$langs->trans("MailErrorsTo").''; + $out.= ''; + $out.= "\n"; + } + } + + // To + if (! empty($this->withto) || is_array($this->withto)) + { + $out.= ''; + if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + else $out.= $langs->trans("MailTo"); + $out.= ''; + if ($this->withtoreadonly) + { + if (! empty($this->toname) && ! empty($this->tomail)) + { + $out.= ''; + $out.= ''; + if ($this->totype == 'thirdparty') + { + $soc=new Societe($this->db); + $soc->fetch($this->toid); + $out.= $soc->getNomUrl(1); + } + else if ($this->totype == 'contact') + { + $contact=new Contact($this->db); + $contact->fetch($this->toid); + $out.= $contact->getNomUrl(1); + } + else + { + $out.= $this->toname; + } + $out.= ' <'.$this->tomail.'>'; + if ($this->withtofree) + { + $out.= '
'.$langs->trans("or").' withto) :"").'" />'; + } + } + else + { + $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; + } + } + else + { + if (! empty($this->withtofree)) + { + $out.= 'withto) :"").'" />'; + } + if (! empty($this->withto) && is_array($this->withto)) + { + if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); + } + if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + if ($this->withtofree) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); + } + } + $out.= "\n"; + } + + // CC + if (! empty($this->withtocc) || is_array($this->withtocc)) + { + $out.= ''; + $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if ($this->withtoccreadonly) + { + $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; + } + else + { + $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; + if (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); + } + if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtoccsocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); + } + } + $out.= "\n"; + } + + // CCC + if (! empty($this->withtoccc) || is_array($this->withtoccc)) + { + $out.= ''; + $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if (! empty($this->withtocccreadonly)) + { + $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; + } + else + { + $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; + if (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); + } + if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); + } + } + //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); + $out.= "\n"; + } + + // Ask delivery receipt + if (! empty($this->withdeliveryreceipt)) + { + $out.= ''.$langs->trans("DeliveryReceipt").''; + + if (! empty($this->withdeliveryreceiptreadonly)) + { + $out.= yn($this->withdeliveryreceipt); + } + else + { + $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1); + } + + $out.= "\n"; + } + + // Topic + if (! empty($this->withtopic)) + { + $this->withtopic=make_substitutions($this->withtopic,$this->substit); + + $out.= ''; + $out.= ''.$langs->trans("MailTopic").''; + $out.= ''; + if ($this->withtopicreadonly) + { + $out.= $this->withtopic; + $out.= ''; + } + else + { + $out.= 'withtopic) .'" />'; + } + $out.= "\n"; + } + + // Attached files + if (! empty($this->withfile)) + { + $out.= ''; + $out.= ''.$langs->trans("MailFile").''; + $out.= ''; + // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript + $out.= ''."\n"; + $out.= ''."\n"; + if (count($listofpaths)) + { + foreach($listofpaths as $key => $val) + { + $out.= '
'; + $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; + if (! $this->withfilereadonly) + { + $out.= ' '; + //$out.= ' '.img_delete($langs->trans("Delete").''; + } + $out.= '
'; + } + } + else + { + $out.= $langs->trans("NoAttachedFiles").'
'; + } + if ($this->withfile == 2) // Can add other files + { + $out.= ''; + $out.= ' '; + $out.= ''; + } + $out.= "\n"; + } + + // Message + if (! empty($this->withbody)) + { + $defaultmessage=""; + + // TODO A partir du type, proposer liste de messages dans table llx_models + if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } + elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } + elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } + elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } + elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } + elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } + elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } + elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } + elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } + + // Complete substitution array + if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) + { + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + + $langs->load('paypal'); + + if ($this->param["models"]=='order_send') + { + $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + if ($this->param["models"]=='facture_send') + { + $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + } + + $defaultmessage=make_substitutions($defaultmessage,$this->substit); + if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; + $defaultmessage=str_replace('\n',"\n",$defaultmessage); + + $out.= ''; + $out.= ''.$langs->trans("MailText").''; + $out.= ''; + if ($this->withbodyreadonly) + { + $out.= nl2br($defaultmessage); + $out.= ''; + } + else + { + if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; + + // Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); + $out.= $doleditor->Create(1); + } + $out.= "\n"; + } + + if (! empty($this->withform)) + { + $out.= '
'; + $out.= 'withfile == 2 && $conf->use_javascript_ajax) + { + $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; + } + $out.= ' />'; + if ($this->withcancel) + { + $out.= '     '; + $out.= ''; + } + $out.= '
'."\n"; + } + + $out.= ''."\n"; + + if (! empty($this->withform)) $out.= ''."\n"; + $out.= "\n"; + + return $out; } }