From 1c2e3a2adc21f22de5f873d9bfa28ac29ea9d97f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 Feb 2005 18:37:11 +0000 Subject: [PATCH] =?UTF-8?q?New:=20Gros=20avancements=20sur=20l'outil=20de?= =?UTF-8?q?=20mailing.=20Il=20est=20possible=20maintenant=20de=20cr=E9er?= =?UTF-8?q?=20un=20mailing,=20le=20supprimer,=20editer,=20valider=20et=20d?= =?UTF-8?q?e=20choisir=20les=20destinataires=20parmi=20des=20listes=20pr?= =?UTF-8?q?=E9d=E9finis=20dans=20des=20modules.=20Qual:=20Les=20modules=20?= =?UTF-8?q?poire=20et=20cerise=20de=20s=E9lection=20de=20destinataire=20on?= =?UTF-8?q?t=20=E9t=E9=20revue=20pour=20respoecter=20la=20norme=20objet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/mailing/fiche.php | 67 +++++++++++++++++++++++---- htdocs/comm/mailing/mailing.class.php | 27 +++++++++-- htdocs/langs/en_US/mails.lang | 5 ++ htdocs/langs/fr_FR/mails.lang | 4 ++ 4 files changed, 91 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index fab545d9d28..e982d2c0ae7 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -37,6 +37,51 @@ llxHeader("","","Fiche Mailing"); +// Action envoi test mailing +if ($_POST["action"] == 'send') +{ + $mil = new Mailing($db); + + $mil->id = $_POST["mailid"]; + $mil->fromname = $_POST["fromname"]; + $mil->frommail = $_POST["frommail"]; + $mil->sendto = $_POST["sendto"]; + $mil->titre = $_POST["titre"]; + $mil->sujet = $_POST["subject"]; + $mil->body = $_POST["message"]; + + if ($mil->sendto && $mil->sujet && $mil->body) + { + // \todo Utiliser la class DolibarrMail ou CMailFile pour envoyer le mail + $headers = "MIME-Version: 1.0\r\n"; + $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; + $headers .= "From: ".$mil->fromname." <".$mil->frommail.">\r\n"; + $headers .= "Reply-to:".$mil->fromname." <".$mil->frommail.">\r\n"; + $headers .= "X-Priority: 3\r\n"; + $headers .= "X-Mailer: Dolibarr ".DOL_VERSION."\r\n"; + + $m=mail($mil->sendto, $mil->sujet, $mil->body, $headers); + + if($m) + { + $message='
'.$langs->trans("ResultOk").'
'; + } + else + { + $message='
'.$langs->trans("ResultKo").'
'; + } + + $_GET["action"]=''; + $_GET["id"]=$mil->id; + } + else + { + $message='
'.$langs->trans("ErrorUnknown").'
'; + } + +} + +// Action ajout mailing if ($_POST["action"] == 'add') { $mil = new Mailing($db); @@ -57,6 +102,7 @@ if ($_POST["action"] == 'add') } } +// Action mise a jour mailing if ($_POST["action"] == 'update') { $mil = new Mailing($db); @@ -73,7 +119,7 @@ if ($_POST["action"] == 'update') } } - +// Action confirmation validation if ($_POST["action"] == 'confirm_valide') { @@ -122,6 +168,7 @@ if ($_POST["action"] == 'confirm_approve') } } +// Action confirmation suppression if ($_POST["action"] == 'confirm_delete') { if ($_POST["confirm"] == 'yes') @@ -167,7 +214,7 @@ if ($_GET["action"] == 'create') print ''.$langs->trans("MailTopic").''; - print ''.$langs->trans("MailMessage").''; + print ''.$langs->trans("MailMessage").''; print ''; print ''; @@ -176,6 +223,7 @@ if ($_GET["action"] == 'create') else { $html = new Form($db); + if ($mil->fetch($_GET["id"]) == 0) { @@ -262,6 +310,7 @@ else print ""; + if ($message) print "$message
"; /* * Boutons d'action @@ -305,21 +354,23 @@ else // Créé l'objet formulaire mail include_once("../../html.formmail.class.php"); $formmail = new FormMail($db); - $formmail->fromname = $user->fullname; - $formmail->frommail = $user->email; + $formmail->fromname = $mil->email_from; + $formmail->frommail = $mil->email_from; $formmail->withfrom=1; $formmail->withto=$user->email; $formmail->withcc=0; - $formmail->withtopic=0; + $formmail->withtopic=$mil->sujet; + $formmail->withtopicreadonly=1; $formmail->withfile=0; - $formmail->withbody=1; + $formmail->withbody=$mil->body; + $formmail->withbodyreadonly=1; // Tableau des substitutions $formmail->substit["__FACREF__"]=$fac->ref; // Tableau des paramètres complémentaires du post $formmail->param["action"]="send"; - $formmail->param["models"]=$mil->body; + $formmail->param["models"]="body"; $formmail->param["mailid"]=$mil->id; - $formmail->param["returnurl"]=DOL_URL_ROOT."/comm/mailing.php?id=$mil->id"; + $formmail->param["returnurl"]=DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id; $formmail->show_form(); } diff --git a/htdocs/comm/mailing/mailing.class.php b/htdocs/comm/mailing/mailing.class.php index 41af629e8c4..73bfb36af51 100644 --- a/htdocs/comm/mailing/mailing.class.php +++ b/htdocs/comm/mailing/mailing.class.php @@ -32,9 +32,28 @@ */ class Mailing { - var $id; - var $error; + var $id; + var $error; + var $statut; + var $titre; + var $sujet; + var $body; + var $nbemail; + + var $email_from; + var $email_replyto; + var $email_errorsto; + + var $user_creat; + var $user_valid; + var $user_appro; + + var $date_creat; + var $date_valid; + var $date_appro; + + /** * \brief Constructeur de la classe * \param DB handler accès base de données @@ -67,10 +86,10 @@ class Mailing $this->db->begin(); - $this->from=trim($this->from); $this->titre=trim($this->titre); + $this->email_from=trim($this->email_from); - if (! $this->from) + if (! $this->email_from) { $this->error = $langs->trans("ErrorMailFromRequired"); return -1; diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 6411f6414da..5a9337049b4 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -43,4 +43,9 @@ RecipientSelectionModules=Active modules for recipients selection MailSelectedRecipients=Selected recipients MailingArea=Mailings area LastMailings=Last %s mailings +TargetsStatistics=Targets statistics +NbOfProspectsContacts=Unique contacts for all prospects +NbOfCustomersContacts=Unique contacts for all customers +MailNoChangePossible=Recipients for validated mailing can't be changed + diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index 6283b4b5d40..ecad90ed2cc 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -43,3 +43,7 @@ RecipientSelectionModules=Modules actifs de s MailSelectedRecipients=Destinataires sélectionnés MailingArea=Espace Mailings LastMailings=Les %s derniers mailings +TargetsStatistics=Statistiques destinataires +NbOfProspectsContacts=Contacts uniques tous prospects +NbOfCustomersContacts=Contacts uniques tous clients +MailNoChangePossible=Destinataires d'un mailing validé non modifiables