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