diff --git a/htdocs/comm/mailing.php b/htdocs/comm/mailing.php index 924a66d03c7..46d7e3de9cc 100644 --- a/htdocs/comm/mailing.php +++ b/htdocs/comm/mailing.php @@ -23,9 +23,9 @@ * */ -/*! - \file htdocs/comm/mailing.php - \brief Page pour faire des mailing +/** \file htdocs/comm/mailing.php + \brief Page pour faire des mailing + \todo A virer quand remplacer completement par ecrans en /comm/mailing */ require("./pre.inc.php"); @@ -45,6 +45,7 @@ require("./propal_model_pdf.class.php"); require("../propal.class.php"); require("../actioncomm.class.php"); require("../lib/CMailFile.class.php"); +require("../html.formmail.class.php"); /* * Sécurité accés client @@ -71,7 +72,7 @@ if ($_GET["action"] != 'mailing') { print $langs->trans("MailingDesc")."

"; - $form = new Form($db); + $formmail = new FormMail($db); print "
"; @@ -88,7 +89,7 @@ if ($_GET["action"] != 'mailing') print ""; // Affiche la partie mail topic + message + file - $form->mail_topicmessagefile(1,1,1,$defaultmessage); + $formmail->mail_topicmessagefile(1,1,1,$defaultmessage); print "
trans("Send")."\">
\n"; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 6baf1017fa7..d08f973a768 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -153,7 +153,7 @@ if ($_GET["action"] == 'modif' && $user->rights->propale->creer) } -if ($_POST["addligne"] == 'Ajouter' && $user->rights->propale->creer) +if ($_POST["addligne"] == $langs->trans("Add") && $user->rights->propale->creer) { /* * Ajout d'une ligne produit dans la propale @@ -167,7 +167,7 @@ if ($_POST["addligne"] == 'Ajouter' && $user->rights->propale->creer) } } -if ($_POST["addproduct"] == 'Ajouter' && $user->rights->propale->creer) +if ($_POST["addproduct"] == $langs->trans("Add") && $user->rights->propale->creer) { /* * Ajout d'une ligne produit dans la propale @@ -619,9 +619,10 @@ if ($_GET["propalid"]) $filepath[1] = $_FILES['addedfile']['tmp_name']; $filename[1] = $_FILES['addedfile']['name']; $mimetype[1] = $_FILES['addedfile']['type']; - $replyto = $_POST["replytoname"]. " <".$_POST["replytomail"].">"; + $from = $_POST["fromname"] . " <".$_POST["frommail"] .">"; + $replyto = $_POST["replytoname"]. " <".$_POST["replytomail"].">"; - $mailfile = new CMailFile($subject,$_POST["sendto"],$replyto,$_POST["message"],$filepath,$mimetype,$filename,$sendtocc); + $mailfile = new CMailFile($subject,$_POST["sendto"],$from,$_POST["message"],$filepath,$mimetype,$filename,$sendtocc); if (! $mailfile->sendfile() ) { @@ -797,32 +798,28 @@ if ($_GET["propalid"]) print ''; print_titre("Envoyer la propale par mail"); - $form=new Form($db); - // Formulaire envoi mail - print ''; - // Destinataire - print ""; - print ""; + // Créé l'objet formulaire mail + include_once("../html.formmail.class.php"); + $formmail = new FormMail($db); + $formmail->fromname = $user->fullname; + $formmail->frommail = $user->email; + $formmail->withfrom=1; +// $formmail->withto=array_merge(array(" "),$soc->contact_email_array()); + $formmail->withto=ucfirst(strtolower($obj->firstname)) . " " . ucfirst(strtolower($obj->name)) . " <$obj->email>"; + $formmail->withcc=1; + $formmail->withtopic=1; + $formmail->withfile=1; + $formmail->withbody=1; + // Tableau des substitutions + $formmail->substit["__PROPREF__"]=$propal->ref; + // Tableau des paramètres complémentaires + $formmail->param["action"]="send"; + $formmail->param["models"]="propal_send"; + $formmail->param["propalid"]=$propal->id; + $formmail->param["returnurl"]=DOL_URL_ROOT."/comm/propal.php?propalid=$propal->id"; - // CC - print ''; - print ''; - - // Sender -/* - print ""; - print ""; - print ""; - print ""; - - print ""; - print "
Destinatairefirstname)) . " " . ucfirst(strtolower($obj->name)) . " <$obj->email>\">
Copie à
Expediteur$from_name$from_mail
Reply-to$replytoname$replytomail
Joindre un fichier en plus de la propale
(conditions générales de ventes ...)
Message
"; -*/ -$form->mail_topicmessagefile(0,1,1,$message); - - print "trans("Send")."\">"; - print "
"; + $formmail->show_form(); } } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 54e18be0747..a24e4da03c0 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -22,8 +22,7 @@ * */ -/** - \file htdocs/compta/facture.php +/** \file htdocs/compta/facture.php \ingroup facture \brief Page de création d'une facture \version $Revision$ @@ -348,7 +347,6 @@ if ($_POST["action"] == 'send' || $_POST["action"] == 'relance') if (is_readable($file)) { - if ($_POST["sendto"]) { // Le destinataire a été fourni via le champ libre $sendto = $_POST["sendto"]; @@ -376,7 +374,8 @@ if ($_POST["action"] == 'send' || $_POST["action"] == 'relance') $actionmsg2="Relance Facture par mail"; } $message = $_POST["message"]; - $replyto = $_POST["replytoname"] . " <".$_POST["replytomail"] .">"; + $from = $_POST["fromname"] . " <".$_POST["frommail"] .">"; + $replyto = $_POST["replytoname"]. " <".$_POST["replytomail"].">"; $filepath[0] = $file; $filename[0] = $fac->ref.".pdf"; @@ -384,10 +383,9 @@ if ($_POST["action"] == 'send' || $_POST["action"] == 'relance') $filepath[1] = $_FILES['addedfile']['tmp_name']; $filename[1] = $_FILES['addedfile']['name']; $mimetype[1] = $_FILES['addedfile']['type']; - $replyto = $_POST["replytoname"]. " <".$_POST["replytomail"].">"; // Envoi de la facture - $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath, $mimetype,$filename,$sendtocc); + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath, $mimetype,$filename,$sendtocc); if ( $mailfile->sendfile() ) { @@ -397,7 +395,7 @@ if ($_POST["action"] == 'send' || $_POST["action"] == 'relance') if (! $db->query($sql) ) { - dolibarr_print_error($db->error()); + dolibarr_print_error($db); } else { @@ -1331,108 +1329,67 @@ else print '

'; } + /* - * + * Affiche formulaire mail * */ if ($_GET["action"] == 'presend') { + print '
'; print_titre("Envoyer la facture par mail"); - $langs->load("other"); - - $replytoname = $user->fullname; - $from_name = $replytoname; + // Créé l'objet formulaire mail + include_once("../html.formmail.class.php"); + $formmail = new FormMail($db); + $formmail->fromname = $user->fullname; + $formmail->frommail = $user->email; + $formmail->withfrom=1; + $formmail->withto=array_merge(array(" "),$soc->contact_email_array()); + $formmail->withcc=1; + $formmail->withtopic=1; + $formmail->withfile=1; + $formmail->withbody=1; + // Tableau des substitutions + $formmail->substit["__FACREF__"]=$fac->ref; + // Tableau des paramètres complémentaires du post + $formmail->param["action"]="send"; + $formmail->param["models"]="facture_send"; + $formmail->param["facid"]=$fac->id; + $formmail->param["returnurl"]=DOL_URL_ROOT."/compta/facture.php?facid=$fac->id"; - $replytomail = $user->email; - $from_mail = $replytomail; - - $form = new Form($db); - - print "
\n"; - print ''; - print ''; - print ''; - print ''; - print "
\n"; - - // From - print "\n"; - print " \n"; - print " \n"; + $formmail->show_form(); - // To - print ' \n"; - - // CC - print ' \n"; - - // File - print " \n"; - - print "
".$langs->trans("MailFrom")."$from_name".($from_mail?" <$from_mail>":"")."
".$langs->trans("MailReply")."$replytoname".($replytomail?" <$replytomail>":""); - print "
'.$langs->trans("MailTo").''; - $form->select_array("receiver",$soc->contact_email_array()); - print " ".$langs->trans("or")." email\">
'.$langs->trans("MailCC").''; - print "
" . $langs->trans("MailFile"). "
"; - - // Topic + Message - $defaultmessage="Veuillez trouver ci-joint la facture $fac->ref\n\nCordialement\n\n"; - $form->mail_topicmessagefile(0,1,0,$defaultmessage); - - print "
trans("Send")."\">
\n"; - - print "
\n"; + print '
'; } if ($_GET["action"] == 'prerelance') { + print '
'; print_titre("Envoyer une relance par mail"); - $langs->load("other"); + // Créé l'objet formulaire mail + include_once("../html.formmail.class.php"); + $formmail = new FormMail($db); + $formmail->fromname = $user->fullname; + $formmail->frommail = $user->email; + $formmail->withfrom=1; + $formmail->withto=array_merge(array(" "),$soc->contact_email_array()); + $formmail->withcc=1; + $formmail->withtopic=1; + $formmail->withfile=1; + $formmail->withbody=1; + // Tableau des substitutions + $formmail->substit["__FACREF__"]=$fac->ref; + // Tableau des paramètres complémentaires + $formmail->param["action"]="relance"; + $formmail->param["models"]="facture_relance"; + $formmail->param["facid"]=$fac->id; + $formmail->param["returnurl"]=DOL_URL_ROOT."/compta/facture.php?facid=$fac->id"; - $replytoname = $user->fullname; - $from_name = $replytoname; + $formmail->show_form(); - $replytomail = $user->email; - $from_mail = $replytomail; - - $form = new Form($db); - - print "
\n"; - print ''; - print ''; - print ''; - print ''; - print '
'; - - // From - print "\n"; - print " \n"; - print " \n"; - - // To - print ' \n"; - - // CC - print ' \n"; - - // File - print " \n"; - - print "
".$langs->trans("MailFrom")."$from_name".($from_mail?" <$from_mail>":"")."
".$langs->trans("MailReply")."$replytoname".($replytomail?" <$replytomail>":""); - print "
'.$langs->trans("MailTo").''; - $form->select_array("receiver",$soc->contact_email_array()); - print " ".$langs->trans("or")." email\">
'.$langs->trans("MailCC").''; - print "
" . $langs->trans("MailFile"). "
"; - - // Topic + Message - $defaultmessage="Nous apportons à votre connaissance que la facture ".$fac->ref." ne semble toujours pas avoir été réglée. La voici donc, pour rappel, en pièce jointe.\n\nCordialement\n\n"; - $form->mail_topicmessagefile(0,1,0,$defaultmessage); - - print "
trans("Send")."\">
\n"; - - print "'; } /* diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 534cad57bf0..ee9533310e6 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -872,53 +872,6 @@ class Form } } - /* - * \brief Affiche la partie de formulaire pour saisie d'un mail - * \param withtopic 1 pour proposer à la saisie le sujet - * \param withbody 1 pour proposer à la saisie le corps du message - * \param withfile 1 pour proposer à la saisie l'ajout d'un fichier joint - */ - function mail_topicmessagefile($withtopic=1,$withbody=1,$withfile=1,$defaultbody) { - global $langs; - - $langs->load("other"); - - print ""; - - // Topic - if ($withtopic) - { - print ""; - print ""; - print ""; - } - - // Message - if ($withbody) - { - print ""; - print ""; - print ""; - } - - // Si fichier joint - if ($withfile) - { - print ""; - print ""; - print ""; - } - - print "
".$langs->trans("MailTopic").""; - print ""; - print "
".$langs->trans("MailText").""; - print ""; - print "
".$langs->trans("MailFile").""; - print "trans("Upload")."\"/>"; - print "
"; - } } ?> diff --git a/htdocs/html.formmail.class.php b/htdocs/html.formmail.class.php new file mode 100644 index 00000000000..3dbcbbb66dc --- /dev/null +++ b/htdocs/html.formmail.class.php @@ -0,0 +1,262 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** \file htdocs/html.formmail.class.php + \brief Fichier de la classe permettant la génération du formulaire html d'envoi de mail unitaire + \version $Revision$ +*/ + +include_once ("html.form.class.php"); + + +/** \class FormMail + \brief Classe permettant la génération du formulaire html d'envoi de mail unitaire + \remarks Utilisation: $formail = new FormMail($db) + \remarks $formmail->proprietes=1 ou chaine ou tableau de valeurs + \remarks $formmail->show_form() affiche le formulaire +*/ + +class FormMail +{ + var $db; + + var $fromname; + var $frommail; + var $replytoname; + var $replytomail; + var $toname; + var $tomail; + + var $withfrom; + var $withto; + var $withtocc; + var $withtopic; + var $withfile; + var $withbody; + + var $withfromreadonly; + var $withreplytoreadonly; + var $withtoreadonly; + var $withtoccreadonly; + var $withtopicreadonly; + + var $substit=array(); + var $param=array(); + + var $errorstr; + + /** \brief Constructeur + \param DB handler d'accès base de donnée + */ + + function FormMail($DB) + { + $this->db = $DB; + + $this->withfrom=1; + $this->withto=1; + $this->withtocc=1; + $this->withtopic=1; + $this->withfile=0; + $this->withbody=1; + + $this->withfromreadonly=1; + $this->withreplytoreadonly=1; + $this->withtoreadonly=0; + $this->withtoccreadonly=0; + $this->withtopicreadonly=0; + + return 1; + } + + + /* + * \brief Affiche la partie de formulaire pour saisie d'un mail en fonction des propriétés + */ + function show_form() { + global $langs; + $langs->load("other"); + + $form=new Form($DB); + + print "\n\n"; + print "param["returnurl"]."\">\n"; + foreach ($this->param as $key=>$value) { + print "\n"; + } + print "\n"; + + // From + if ($this->withfrom) + { + if ($this->withfromreadonly) { + print ''; + print ''; + print "\n"; + print "\n"; + } + } + + // Replyto + if ($this->withreplyto) + { + if ($this->withreplytoreadonly) { + print ''; + print ''; + print "\n"; + } + } + + // To + if ($this->withto || is_array($this->withto)) { + print '\n"; + } + + // CC + if ($this->withcc) + { + print '\n"; + } + + // Topic + if ($this->withtopic) + { + print ""; + print ""; + print "\n"; + } + + // Si fichier joint + if ($this->withfile) + { + 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"]=='facture_send') { $defaultmessage="Veuillez trouver ci-joint la facture __FACREF__\n\nCordialement\n\n"; } + if ($this->param["models"]=='facture_relance') { $defaultmessage="Nous apportons à votre connaissance que la facture __FACREF__ ne semble toujours pas avoir été réglée. La voici donc, pour rappel, en pièce jointe.\n\nCordialement\n\n"; } + + foreach ($this->substit as $key=>$value) { + $defaultmessage=ereg_replace($key,$value,$defaultmessage); + } + print ""; + print ""; + print "\n"; + } + + print "\n"; + print "
".$langs->trans("MailFrom")."".$this->fromname.($this->frommail?(" <".$this->frommail.">"):"")."
".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); + print "
'.$langs->trans("MailTo").''; + if ($this->withtoreadonly) { + print (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; + } else { + print "withto)?$this->withto:"")."\">"; + if (is_array($this->withto)) + { + print " ".$langs->trans("or")." "; + $form->select_array("receiver",$this->withto); + } + } + print "
'.$langs->trans("MailCC").''; + if ($this->withtoccreadonly) { + print (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; + } else { + print "withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:"")."\">"; + if (is_array($this->withtocc)) + { + print " ".$langs->trans("or")." "; + $form->select_array("receivercc",$this->withtocc); + } + } + print "
".$langs->trans("MailTopic").""; + print ""; + print "
".$langs->trans("MailFile").""; + print "trans("Upload")."\"/>"; + print "
".$langs->trans("MailText").""; + print ""; + print "
trans("Send")."\">
\n"; + + print "
\n"; + print "\n"; + } + + + /* + * \brief Affiche la partie de formulaire pour saisie d'un mail + * \param withtopic 1 pour proposer à la saisie le sujet + * \param withbody 1 pour proposer à la saisie le corps du message + * \param withfile 1 pour proposer à la saisie l'ajout d'un fichier joint + * \todo Fonction a virer quand fichier /comm/mailing.php viré (= quand ecran dans /comm/mailing prets) + */ + function mail_topicmessagefile($withtopic=1,$withbody=1,$withfile=1,$defaultbody) { + global $langs; + + $langs->load("other"); + + print ""; + + // Topic + if ($withtopic) + { + print ""; + print ""; + print ""; + } + + // Message + if ($withbody) + { + print ""; + print ""; + print ""; + } + + // Si fichier joint + if ($withfile) + { + print ""; + print ""; + print ""; + } + + print "
".$langs->trans("MailTopic").""; + print ""; + print "
".$langs->trans("MailText").""; + print ""; + print "
".$langs->trans("MailFile").""; + print "trans("Upload")."\"/>"; + print "
"; + } + +} + +?>