New: Gros avancements sur l'outil de mailing. Il est possible maintenant de créer un mailing, le supprimer, editer, valider et de choisir les destinataires parmi des listes prédéfinis dans des modules.
Qual: Les modules poire et cerise de sélection de destinataire ont été revue pour respoecter la norme objet.
This commit is contained in:
parent
03e68d2e30
commit
1c2e3a2adc
@ -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='<div class="ok">'.$langs->trans("ResultOk").'</div>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$message='<div class="error">'.$langs->trans("ResultKo").'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$_GET["action"]='';
|
||||||
|
$_GET["id"]=$mil->id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$message='<div class="error">'.$langs->trans("ErrorUnknown").'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Action ajout mailing
|
||||||
if ($_POST["action"] == 'add')
|
if ($_POST["action"] == 'add')
|
||||||
{
|
{
|
||||||
$mil = new Mailing($db);
|
$mil = new Mailing($db);
|
||||||
@ -57,6 +102,7 @@ if ($_POST["action"] == 'add')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Action mise a jour mailing
|
||||||
if ($_POST["action"] == 'update')
|
if ($_POST["action"] == 'update')
|
||||||
{
|
{
|
||||||
$mil = new Mailing($db);
|
$mil = new Mailing($db);
|
||||||
@ -73,7 +119,7 @@ if ($_POST["action"] == 'update')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Action confirmation validation
|
||||||
if ($_POST["action"] == 'confirm_valide')
|
if ($_POST["action"] == 'confirm_valide')
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -122,6 +168,7 @@ if ($_POST["action"] == 'confirm_approve')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Action confirmation suppression
|
||||||
if ($_POST["action"] == 'confirm_delete')
|
if ($_POST["action"] == 'confirm_delete')
|
||||||
{
|
{
|
||||||
if ($_POST["confirm"] == 'yes')
|
if ($_POST["confirm"] == 'yes')
|
||||||
@ -167,7 +214,7 @@ if ($_GET["action"] == 'create')
|
|||||||
|
|
||||||
print '<tr><td width="20%">'.$langs->trans("MailTopic").'</td><td><input name="sujet" size="40" value=""></td></tr>';
|
print '<tr><td width="20%">'.$langs->trans("MailTopic").'</td><td><input name="sujet" size="40" value=""></td></tr>';
|
||||||
|
|
||||||
print '<tr><td width="20%" valign="top">'.$langs->trans("MailMessage").'</td><td><textarea cols="30" rows="8" name="body"></textarea></td></tr>';
|
print '<tr><td width="20%" valign="top">'.$langs->trans("MailMessage").'</td><td><textarea cols="50" rows="10" name="body"></textarea></td></tr>';
|
||||||
|
|
||||||
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("CreateMailing").'"></td></tr>';
|
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("CreateMailing").'"></td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
@ -176,6 +223,7 @@ if ($_GET["action"] == 'create')
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
|
|
||||||
if ($mil->fetch($_GET["id"]) == 0)
|
if ($mil->fetch($_GET["id"]) == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -262,6 +310,7 @@ else
|
|||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|
||||||
|
if ($message) print "$message<br>";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Boutons d'action
|
* Boutons d'action
|
||||||
@ -305,21 +354,23 @@ else
|
|||||||
// Créé l'objet formulaire mail
|
// Créé l'objet formulaire mail
|
||||||
include_once("../../html.formmail.class.php");
|
include_once("../../html.formmail.class.php");
|
||||||
$formmail = new FormMail($db);
|
$formmail = new FormMail($db);
|
||||||
$formmail->fromname = $user->fullname;
|
$formmail->fromname = $mil->email_from;
|
||||||
$formmail->frommail = $user->email;
|
$formmail->frommail = $mil->email_from;
|
||||||
$formmail->withfrom=1;
|
$formmail->withfrom=1;
|
||||||
$formmail->withto=$user->email;
|
$formmail->withto=$user->email;
|
||||||
$formmail->withcc=0;
|
$formmail->withcc=0;
|
||||||
$formmail->withtopic=0;
|
$formmail->withtopic=$mil->sujet;
|
||||||
|
$formmail->withtopicreadonly=1;
|
||||||
$formmail->withfile=0;
|
$formmail->withfile=0;
|
||||||
$formmail->withbody=1;
|
$formmail->withbody=$mil->body;
|
||||||
|
$formmail->withbodyreadonly=1;
|
||||||
// Tableau des substitutions
|
// Tableau des substitutions
|
||||||
$formmail->substit["__FACREF__"]=$fac->ref;
|
$formmail->substit["__FACREF__"]=$fac->ref;
|
||||||
// Tableau des paramètres complémentaires du post
|
// Tableau des paramètres complémentaires du post
|
||||||
$formmail->param["action"]="send";
|
$formmail->param["action"]="send";
|
||||||
$formmail->param["models"]=$mil->body;
|
$formmail->param["models"]="body";
|
||||||
$formmail->param["mailid"]=$mil->id;
|
$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();
|
$formmail->show_form();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,25 @@ class Mailing
|
|||||||
var $id;
|
var $id;
|
||||||
var $error;
|
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
|
* \brief Constructeur de la classe
|
||||||
* \param DB handler accès base de données
|
* \param DB handler accès base de données
|
||||||
@ -67,10 +86,10 @@ class Mailing
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$this->from=trim($this->from);
|
|
||||||
$this->titre=trim($this->titre);
|
$this->titre=trim($this->titre);
|
||||||
|
$this->email_from=trim($this->email_from);
|
||||||
|
|
||||||
if (! $this->from)
|
if (! $this->email_from)
|
||||||
{
|
{
|
||||||
$this->error = $langs->trans("ErrorMailFromRequired");
|
$this->error = $langs->trans("ErrorMailFromRequired");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@ -43,4 +43,9 @@ RecipientSelectionModules=Active modules for recipients selection
|
|||||||
MailSelectedRecipients=Selected recipients
|
MailSelectedRecipients=Selected recipients
|
||||||
MailingArea=Mailings area
|
MailingArea=Mailings area
|
||||||
LastMailings=Last %s mailings
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -43,3 +43,7 @@ RecipientSelectionModules=Modules actifs de s
|
|||||||
MailSelectedRecipients=Destinataires sélectionnés
|
MailSelectedRecipients=Destinataires sélectionnés
|
||||||
MailingArea=Espace Mailings
|
MailingArea=Espace Mailings
|
||||||
LastMailings=Les %s derniers 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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user