New: Gros avancements sur l'outil de mailing. Il est possible maintenant de crer un mailing, le supprimer, editer, valider et de choisir les destinataires parmi des listes prdfinis dans des modules.
Qual: Les modules poire et cerise de slection de destinataire ont t revue pour respoecter la norme objet.
This commit is contained in:
parent
93bf985bf8
commit
9406e2f0bb
@ -30,92 +30,165 @@ require("./pre.inc.php");
|
||||
|
||||
$langs->load("mails");
|
||||
|
||||
$dir=DOL_DOCUMENT_ROOT."/includes/modules/mailings";
|
||||
|
||||
$mesg = '';
|
||||
|
||||
|
||||
llxHeader("","",$langs->trans("MailCard"));
|
||||
|
||||
if ($_POST["cancel"] == $langs->trans("Cancel"))
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
if ($_GET["action"] == 'add')
|
||||
{
|
||||
$action = '';
|
||||
$modulename=$_GET["module"];
|
||||
|
||||
// Chargement de la classe
|
||||
$file = $dir."/".$modulename.".modules.php";
|
||||
$classname = "mailing_".$modulename;
|
||||
require_once($file);
|
||||
|
||||
$obj = new $classname($db);
|
||||
$obj->add_to_target($_GET["rowid"]);
|
||||
|
||||
Header("Location: cibles.php?id=".$_GET["rowid"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Fiche mailing en mode création
|
||||
*
|
||||
* Liste des destinataires
|
||||
*/
|
||||
|
||||
$mil = new Mailing($db);
|
||||
llxHeader("","",$langs->trans("MailCard"));
|
||||
|
||||
$mil = new Mailing($db);
|
||||
|
||||
$html = new Form($db);
|
||||
if ($mil->fetch($_GET["id"]) == 0)
|
||||
{
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans("MailCard");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans("MailTargets");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, substr($mil->titre,0,20));
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans("MailTitle").'</td><td>'.$mil->titre.'</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
$sql = "SELECT mc.nom, mc.prenom, mc.email";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
||||
$sql .= " WHERE mc.fk_mailing=".$mil->id;
|
||||
|
||||
if ( $db->query($sql) )
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans("MailCard");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans("MailRecipients");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
/*
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/history.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans("MailHistory");
|
||||
$h++;
|
||||
*/
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Mailing").": ".substr($mil->titre,0,20));
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$mil->titre.'</td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td colspan="3">'.htmlentities($mil->email_from).'</td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("TotalNbOfDistinctRecipients").'</td><td colspan="3">'.($mil->nbemail?$mil->nbemail:'<font class="error">'.$langs->trans("NoTargetYet").'</font>').'</td></tr>';
|
||||
print '</table><br>';
|
||||
|
||||
// Ajout d'une liste de sélection
|
||||
print '<table class="noborder" width=\"100%\">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("RecipientSelectionModules").'</td>';
|
||||
//print '<td>'.$langs->trans("Name").'</td>';
|
||||
print '<td align="center">'.$langs->trans("NbOfRecipients").'</td>';
|
||||
print '<td width="80"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
$handle=opendir($dir);
|
||||
|
||||
$var=True;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
|
||||
print '<br /><table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("MailTargets").'</td></tr>';
|
||||
$var = true;
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num )
|
||||
{
|
||||
$obj = $db->fetch_object();
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>'.stripslashes($obj->prenom).'</a></td>';
|
||||
print '<td>'.stripslashes($obj->nom).'</a></td>';
|
||||
print '<td>'.$obj->email.'</td>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
print "</table><br>";
|
||||
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
|
||||
{
|
||||
$var = !$var;
|
||||
if (eregi("(.*)\.(.*)\.(.*)",$file,$reg)) {
|
||||
$modulename=$reg[1];
|
||||
|
||||
// Chargement de la classe
|
||||
$file = $dir."/".$modulename.".modules.php";
|
||||
$classname = "mailing_".$modulename;
|
||||
require_once($file);
|
||||
|
||||
print '<tr '.$bc[$var].'>';
|
||||
|
||||
print '<td>';
|
||||
$obj = new $classname($db);
|
||||
print $obj->getDesc();
|
||||
print '</td>';
|
||||
|
||||
/*
|
||||
print '<td width=\"100\">';
|
||||
print $modulename;
|
||||
print "</td>";
|
||||
*/
|
||||
print '<td align="center">'.$obj->getNbOfRecipients().'</td>';
|
||||
print '<td><a href="cibles.php?action=add&rowid='.$mil->id.'&module='.$modulename.'">'.img_edit_add($langs->trans("AddRecipients")).'</a></td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
|
||||
print "</div>";
|
||||
|
||||
$NBMAX=100;
|
||||
|
||||
$sql = "SELECT mc.nom, mc.prenom, mc.email";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
||||
$sql .= " WHERE mc.fk_mailing=".$mil->id;
|
||||
$sql .= " limit ".($NBMAX+1);
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
$num = $db->num_rows();
|
||||
|
||||
print_titre($langs->trans("MailSelectedRecipients"));
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Firstname").'</td>';
|
||||
print '<td>'.$langs->trans("Lastname").'</td>';
|
||||
print '<td>'.$langs->trans("EMail").'</td>';
|
||||
print '</tr>';
|
||||
$var = true;
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num )
|
||||
{
|
||||
$obj = $db->fetch_object();
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>'.stripslashes($obj->prenom).'</a></td>';
|
||||
print '<td>'.stripslashes($obj->nom).'</a></td>';
|
||||
print '<td>'.$obj->email.'</td>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
print "</table><br>";
|
||||
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
|
||||
@ -33,33 +33,41 @@ $langs->load("mails");
|
||||
$mesg = '';
|
||||
|
||||
|
||||
llxHeader("","","Fiche Mailing");
|
||||
|
||||
|
||||
|
||||
if ($_POST["action"] == 'add')
|
||||
{
|
||||
$mil = new Mailing($db);
|
||||
|
||||
$mil->from = $_POST["from"];
|
||||
$mil->titre = $_POST["titre"];
|
||||
$mil->sujet = $_POST["sujet"];
|
||||
$mil->body = $_POST["body"];
|
||||
|
||||
|
||||
if ( $mil->create($user) == 0)
|
||||
if ($mil->create($user))
|
||||
{
|
||||
Header("Location: fiche.php?id=".$mil->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$message='<div class="error">'.$mil->error.'</div>';
|
||||
$_GET["action"]="create";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($_POST["action"] == 'update')
|
||||
{
|
||||
$mil = new Mailing($db);
|
||||
|
||||
$mil->id = $_GET["id"];
|
||||
$mil->id = $_POST["id"];
|
||||
$mil->from = $_POST["from"];
|
||||
$mil->titre = $_POST["titre"];
|
||||
$mil->sujet = $_POST["sujet"];
|
||||
$mil->body = $_POST["body"];
|
||||
|
||||
|
||||
if ( $mil->update() == 0)
|
||||
if ($mil->update())
|
||||
{
|
||||
Header("Location: fiche.php?id=".$mil->id);
|
||||
}
|
||||
@ -114,19 +122,29 @@ if ($_POST["action"] == 'confirm_approve')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
llxHeader("","","Fiche Mailing");
|
||||
if ($_POST["action"] == 'confirm_delete')
|
||||
{
|
||||
if ($_POST["confirm"] == 'yes')
|
||||
{
|
||||
$mil = new Mailing($db);
|
||||
$mil->id = $_GET["id"];
|
||||
|
||||
if ($mil->delete($mil->id))
|
||||
{
|
||||
Header("Location: index.php");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["cancel"] == $langs->trans("Cancel"))
|
||||
{
|
||||
$action = '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Création
|
||||
* Mailing en mode création
|
||||
*
|
||||
*/
|
||||
|
||||
@ -134,149 +152,205 @@ $mil = new Mailing($db);
|
||||
|
||||
if ($_GET["action"] == 'create')
|
||||
{
|
||||
print '<form action="fiche.php" method="post">'."\n";
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<form action="fiche.php" method="post">'."\n";
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print_titre($langs->trans("NewMailing"));
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print_titre($langs->trans("NewMailing"));
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans("MailTitle").'</td><td><input name="titre" size="30" value=""></td></tr>';
|
||||
if ($message) print "$message<br>";
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans("MailTopic").'</td><td><input name="sujet" size="40" value=""></td></tr>';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
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%">'.$langs->trans("MailFrom").'</td><td><input name="from" size="30" value="'.MAIN_MAIL_FROM.'"></td></tr>';
|
||||
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("CreateMailing").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
print '<tr><td width="20%">'.$langs->trans("MailTitle").'</td><td><input name="titre" size="30" 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 colspan="2" align="center"><input type="submit" value="'.$langs->trans("CreateMailing").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$html = new Form($db);
|
||||
if ($mil->fetch($_GET["id"]) == 0)
|
||||
$html = new Form($db);
|
||||
if ($mil->fetch($_GET["id"]) == 0)
|
||||
{
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans("MailCard");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans('MailTargets');
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, substr($mil->titre,0,20));
|
||||
|
||||
|
||||
/*
|
||||
* Confirmation de la validation du mailing
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'valide')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=".$mil->id,
|
||||
"Valider le mailing",
|
||||
"Confirmez-vous la validation du mailing ?",
|
||||
"confirm_valide");
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirmation de l'approbation du mailing
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'approve')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=".$mil->id,
|
||||
"Approuver le mailing",
|
||||
"Confirmez-vous l'approbation du mailing ?",
|
||||
"confirm_approve");
|
||||
}
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$mil->titre.'</td></tr>';
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans("MailFrom").'</td><td>'.htmlentities($mil->email_from).'</td>';
|
||||
print '<td>'.$langs->trans("EMail").'</td><td>'.htmlentities($mil->email_from).'</td></tr>';
|
||||
|
||||
//print '<tr><td width="20%">Réponse</td><td>'.htmlentities($mil->email_replyto).'</td></tr>';
|
||||
//print '<tr><td width="20%">Retour Erreur</td><td>'.htmlentities($mil->email_errorsto).'</td></tr>';
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans("MailCard");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
if ($mil->statut > 0)
|
||||
{
|
||||
print '<tr><td width="20%">Nb destinataires</td><td colspan="3">'.$mil->nbemail.'</td></tr>';
|
||||
}
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans('MailRecipients');
|
||||
$h++;
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="3">'.$mil->statuts[$mil->statut].'</td></tr>';
|
||||
/*
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/history.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans("MailHistory");
|
||||
$h++;
|
||||
*/
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Mailing").": ".substr($mil->titre,0,20));
|
||||
|
||||
$uc = new User($db, $mil->user_creat);
|
||||
$uc->fetch();
|
||||
print '<tr><td width="20%">'.$langs->trans("CreatedBy").'</td><td>'.$uc->fullname.'</td>';
|
||||
print '<td>'.$langs->trans("DateCreation").'</td>';
|
||||
print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_creat).'</td></tr>';
|
||||
// Confirmation de la validation du mailing
|
||||
if ($_GET["action"] == 'valide')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=".$mil->id,$langs->trans("ValidMailing"),$langs->trans("ConfirmValidMailing"),"confirm_valide");
|
||||
}
|
||||
|
||||
if ($mil->statut > 0)
|
||||
{
|
||||
$uv = new User($db, $mil->user_valid);
|
||||
$uv->fetch();
|
||||
print '<tr><td width="20%">'.$langs->trans("ValidatedBy").'</td><td>'.$uv->fullname.'</td>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_valid).'</td></tr>';
|
||||
}
|
||||
// Confirmation de l'approbation du mailing
|
||||
if ($_GET["action"] == 'approve')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=".$mil->id,"Approuver le mailing","Confirmez-vous l'approbation du mailing ?","confirm_approve");
|
||||
}
|
||||
|
||||
if ($mil->statut > 1)
|
||||
{
|
||||
$ua = new User($db, $mil->user_appro);
|
||||
$ua->fetch();
|
||||
print '<tr><td width="20%">'.$langs->trans("ApprovedBy").'</td><td>'.$ua->fullname.'</td>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_appro).'</td></tr>';
|
||||
}
|
||||
|
||||
// Contenu du mail
|
||||
print '<tr><td width="20%">'.$langs->trans("MailTopic").'</td><td colspan="3">'.$mil->sujet.'</td></tr>';
|
||||
|
||||
print '<tr><td width="20%" valign="top">'.$langs->trans("MailMessage").'</td><td colspan="3">';
|
||||
print nl2br($mil->body).'</td></tr>';
|
||||
// Confirmation de la suppression
|
||||
if ($_GET["action"] == 'delete')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=".$mil->id,$langs->trans("DeleteAMailing"),$langs->trans("ConfirmDeleteMailing"),"confirm_delete");
|
||||
}
|
||||
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
print "</div>";
|
||||
|
||||
|
||||
/*
|
||||
* Boutons d'action
|
||||
*/
|
||||
|
||||
print "\n\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($_GET["action"] == '')
|
||||
{
|
||||
|
||||
print '<a class="tabAction" href="fiche.php?action=test&id='.$mil->id.'">'.$langs->trans("TestMailing").'</a>';
|
||||
|
||||
if ($mil->statut == 0)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=valide&id='.$mil->id.'">'.$langs->trans("ValidMailing").'</a>';
|
||||
}
|
||||
|
||||
if ($mil->statut == 1 && $mil->nbemail > 0)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=approve&id='.$mil->id.'">'.$langs->trans("ApproveMailing").'</a>';
|
||||
}
|
||||
|
||||
if ($_GET["action"] != 'edit')
|
||||
{
|
||||
/*
|
||||
* Mailing en mode visu
|
||||
*
|
||||
*/
|
||||
|
||||
}
|
||||
print '<br /><br /></div>';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$mil->titre.'</td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td colspan="3">'.htmlentities($mil->email_from).'</td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("TotalNbOfDistinctRecipients").'</td><td colspan="3">'.($mil->nbemail?$mil->nbemail:'<font class="error">'.$langs->trans("NoTargetYet").'</font>').'</td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$mil->statuts[$mil->statut].'</td></tr>';
|
||||
|
||||
$uc = new User($db, $mil->user_creat);
|
||||
$uc->fetch();
|
||||
print '<tr><td>'.$langs->trans("CreatedBy").'</td><td>'.$uc->fullname.'</td>';
|
||||
print '<td>'.$langs->trans("DateCreation").'</td>';
|
||||
print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_creat).'</td></tr>';
|
||||
|
||||
if ($mil->statut > 0)
|
||||
{
|
||||
$uv = new User($db, $mil->user_valid);
|
||||
$uv->fetch();
|
||||
print '<tr><td>'.$langs->trans("ValidatedBy").'</td><td>'.$uv->fullname.'</td>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_valid).'</td></tr>';
|
||||
}
|
||||
|
||||
if ($mil->statut > 1)
|
||||
{
|
||||
$ua = new User($db, $mil->user_appro);
|
||||
$ua->fetch();
|
||||
print '<tr><td>'.$langs->trans("ApprovedBy").'</td><td>'.$ua->fullname.'</td>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_appro).'</td></tr>';
|
||||
}
|
||||
|
||||
// Contenu du mail
|
||||
print '<tr><td>'.$langs->trans("MailTopic").'</td><td colspan="3">'.$mil->sujet.'</td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans("MailMessage").'</td><td colspan="3">';
|
||||
print nl2br($mil->body).'</td></tr>';
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
print "</div>";
|
||||
|
||||
|
||||
/*
|
||||
* Boutons d'action
|
||||
*/
|
||||
if ($_GET["action"] == '')
|
||||
{
|
||||
print "\n\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($mil->statut == 0)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=edit&id='.$mil->id.'">'.$langs->trans("EditMailing").'</a>';
|
||||
}
|
||||
|
||||
//print '<a class="tabAction" href="fiche.php?action=test&id='.$mil->id.'">'.$langs->trans("PreviewMailing").'</a>';
|
||||
|
||||
print '<a class="tabAction" href="fiche.php?action=test&id='.$mil->id.'">'.$langs->trans("TestMailing").'</a>';
|
||||
|
||||
if ($mil->statut == 0 && $mil->nbemail > 0)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=valide&id='.$mil->id.'">'.$langs->trans("ValidMailing").'</a>';
|
||||
}
|
||||
|
||||
/* if ($mil->statut == 1 && $mil->nbemail > 0)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=approve&id='.$mil->id.'">'.$langs->trans("ApproveMailing").'</a>';
|
||||
}
|
||||
*/
|
||||
if ($mil->statut <= 1)
|
||||
{
|
||||
print '<a class="butDelete" href="fiche.php?action=delete&id='.$mil->id.'">'.$langs->trans("DeleteMailing").'</a>';
|
||||
}
|
||||
|
||||
print '<br /><br /></div>';
|
||||
}
|
||||
|
||||
|
||||
if ($_GET["action"] == 'test')
|
||||
{
|
||||
print_titre($langs->trans("TestMailing"));
|
||||
|
||||
// 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=$user->email;
|
||||
$formmail->withcc=0;
|
||||
$formmail->withtopic=0;
|
||||
$formmail->withfile=0;
|
||||
$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"]=$mil->body;
|
||||
$formmail->param["mailid"]=$mil->id;
|
||||
$formmail->param["returnurl"]=DOL_URL_ROOT."/comm/mailing.php?id=$mil->id";
|
||||
|
||||
$formmail->show_form();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Mailing en mode edition
|
||||
*/
|
||||
print '<form action="fiche.php" method="post">'."\n";
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$mil->id.'">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans("MailTitle").'</td><td colspan="3"><input type="text" size=50 name="titre" value="'.$mil->titre.'"></td></tr>';
|
||||
print '<tr><td width="20%">'.$langs->trans("MailFrom").'</td><td colspan="3"><input type="text" size=50 name="from" value="'.htmlentities($mil->email_from).'"></td></tr>';
|
||||
print '<tr><td width="20%">'.$langs->trans("MailTopic").'</td><td colspan="3"><input type="text" size=50 name="sujet" value="'.$mil->sujet.'"></td></tr>';
|
||||
print '<tr><td width="20%" valign="top">'.$langs->trans("MailMessage").'</td><td colspan="3"><textarea name="body" cols=50 rows=10>';
|
||||
print nl2br($mil->body).'</textarea></td></tr>';
|
||||
|
||||
print '<tr><td colspan="4" align="center"><input type="submit" value="'.$langs->trans("Save").'"></td></tr>';
|
||||
print '</table><br>';
|
||||
print '</form>';
|
||||
|
||||
print "</div>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
|
||||
@ -33,7 +33,8 @@
|
||||
class Mailing
|
||||
{
|
||||
var $id;
|
||||
|
||||
var $error;
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB handler accès base de données
|
||||
@ -55,49 +56,83 @@ class Mailing
|
||||
/**
|
||||
* \brief Création du mailing
|
||||
* \param user object utilisateur qui crée
|
||||
* \return -1 si erreur, >0 sinon
|
||||
*
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
dolibarr_syslog("Mailing::Create");
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$this->from=trim($this->from);
|
||||
$this->titre=trim($this->titre);
|
||||
|
||||
if (! $this->from)
|
||||
{
|
||||
$this->error = $langs->trans("ErrorMailFromRequired");
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".$this->db_table;
|
||||
$sql .= " (date_creat, fk_user_creat)";
|
||||
$sql .= " VALUES (now(), ".$user->id.")";
|
||||
|
||||
if (strlen(trim($this->titre)) == 0)
|
||||
if (! $this->titre)
|
||||
{
|
||||
$this->titre = "Sans titre";
|
||||
$this->titre = $langs->trans("NoTitle");
|
||||
}
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id();
|
||||
|
||||
return $this->update();
|
||||
$this->id = $this->db->last_insert_id($result);
|
||||
|
||||
if ($this->update() > 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
$this->error=$langs->trans("ErrorUnknown");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
|
||||
dolibarr_syslog("Mailing::Create Erreur -1");
|
||||
$this->error=$langs->trans("UnknownError");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Update les infos du mailing
|
||||
* \brief Update les infos du mailing
|
||||
* \return < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function update()
|
||||
{
|
||||
dolibarr_syslog("Mailing::Update");
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
|
||||
$sql .= " SET titre = '".$this->titre."'";
|
||||
$sql .= " , sujet = '".$this->sujet."'";
|
||||
$sql .= " , body = '".$this->body."'";
|
||||
$sql .= " SET titre = '".addslashes($this->titre)."'";
|
||||
$sql .= " , sujet = '".addslashes($this->sujet)."'";
|
||||
$sql .= " , body = '".addslashes($this->body)."'";
|
||||
$sql .= " , email_from = '".$this->from."'";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -211,15 +246,17 @@ class Mailing
|
||||
|
||||
|
||||
/**
|
||||
* \brief Supprime le mailing
|
||||
* \param rowid id du mailing à supprimer
|
||||
* \brief Supprime le mailing
|
||||
* \param rowid id du mailing à supprimer
|
||||
* \return int 1 en cas de succès
|
||||
*/
|
||||
function delete($rowid)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing";
|
||||
$sql .= " WHERE fk_facture = ".$rowid;
|
||||
$sql .= " WHERE rowid = ".$rowid;
|
||||
|
||||
$this->db->query($sql);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,137 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*
|
||||
* L'utilisation d'adresses de courriers électroniques dans les opérations
|
||||
* de prospection commerciale est subordonnée au recueil du consentement
|
||||
* préalable des personnes concernées.
|
||||
*
|
||||
* Le dispositif juridique applicable a été introduit par l'article 22 de
|
||||
* la loi du 21 juin 2004 pour la confiance dans l'économie numérique.
|
||||
*
|
||||
* Les dispositions applicables sont définies par les articles L. 34-5 du
|
||||
* code des postes et des télécommunications et L. 121-20-5 du code de la
|
||||
* consommation. L'application du principe du consentement préalable en
|
||||
* droit français résulte de la transposition de l'article 13 de la Directive
|
||||
* européenne du 12 juillet 2002 « Vie privée et communications électroniques ».
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file
|
||||
\ingroup mailing
|
||||
\brief
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
class mailing_cerise
|
||||
{
|
||||
function mailing_cerise()
|
||||
{
|
||||
$this->desc = 'Tous les contacts assaociés aux prospects';
|
||||
}
|
||||
|
||||
|
||||
function prepare_cible($db, $mailing_id)
|
||||
{
|
||||
$cibles = array();
|
||||
|
||||
$sql = "SELECT distinct(c.email), c.idp, c.name, c.firstname, s.nom ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE s.idp = c.fk_soc";
|
||||
$sql .= " AND s.client = 2";
|
||||
$sql .= " AND c.email IS NOT NULL";
|
||||
$sql .= " ORDER BY c.email ASC";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
|
||||
dolibarr_syslog("mailing-prepare: mailing $num cibles trouvées");
|
||||
|
||||
$olde = '';
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row();
|
||||
|
||||
if ($olde <> $row[0])
|
||||
{
|
||||
$cibles[$j] = $row;
|
||||
$olde = $row[0];
|
||||
$j++;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog($db->error());
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " WHERE fk_mailing = ".$mailing_id;
|
||||
|
||||
if (!$db->query($sql))
|
||||
{
|
||||
dolibarr_syslog($db->error());
|
||||
}
|
||||
|
||||
$num = sizeof($cibles);
|
||||
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " (fk_mailing, fk_contact, nom, prenom, email)";
|
||||
$sql .= " VALUES (".$mailing_id.",";
|
||||
$sql .= $cibles[$i][1] .",";
|
||||
$sql .= "'".$cibles[$i][2] ."',";
|
||||
$sql .= "'".$cibles[$i][3] ."',";
|
||||
$sql .= "'".$cibles[$i][0] ."')";
|
||||
|
||||
if (!$db->query($sql))
|
||||
{
|
||||
dolibarr_syslog($db->error());
|
||||
}
|
||||
}
|
||||
|
||||
dolibarr_syslog("mailing-prepare: mailing $i cibles ajoutées");
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing";
|
||||
$sql .= " SET nbemail = ".$i." WHERE rowid = ".$mailing_id;
|
||||
|
||||
if (!$db->query($sql))
|
||||
{
|
||||
dolibarr_syslog($db->error());
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,137 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*
|
||||
* L'utilisation d'adresses de courriers électroniques dans les opérations
|
||||
* de prospection commerciale est subordonnée au recueil du consentement
|
||||
* préalable des personnes concernées.
|
||||
*
|
||||
* Le dispositif juridique applicable a été introduit par l'article 22 de
|
||||
* la loi du 21 juin 2004 pour la confiance dans l'économie numérique.
|
||||
*
|
||||
* Les dispositions applicables sont définies par les articles L. 34-5 du
|
||||
* code des postes et des télécommunications et L. 121-20-5 du code de la
|
||||
* consommation. L'application du principe du consentement préalable en
|
||||
* droit français résulte de la transposition de l'article 13 de la Directive
|
||||
* européenne du 12 juillet 2002 « Vie privée et communications électroniques ».
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file
|
||||
\ingroup mailing
|
||||
\brief
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
class mailing_poire
|
||||
{
|
||||
function mailing_poire()
|
||||
{
|
||||
$this->desc = 'Tous les contacts assaociés aux clients';
|
||||
}
|
||||
|
||||
|
||||
function prepare_cible($db, $mailing_id)
|
||||
{
|
||||
$cibles = array();
|
||||
|
||||
$sql = "SELECT distinct(c.email), c.idp, c.name, c.firstname, s.nom ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE s.idp = c.fk_soc";
|
||||
$sql .= " AND s.client = 1";
|
||||
$sql .= " AND c.email IS NOT NULL";
|
||||
$sql .= " ORDER BY c.email ASC";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
|
||||
dolibarr_syslog("mailing-prepare: mailing $num cibles trouvées");
|
||||
|
||||
$olde = '';
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row();
|
||||
|
||||
if ($olde <> $row[0])
|
||||
{
|
||||
$cibles[$j] = $row;
|
||||
$olde = $row[0];
|
||||
$j++;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog($db->error());
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " WHERE fk_mailing = ".$mailing_id;
|
||||
|
||||
if (!$db->query($sql))
|
||||
{
|
||||
dolibarr_syslog($db->error());
|
||||
}
|
||||
|
||||
$num = sizeof($cibles);
|
||||
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " (fk_mailing, fk_contact, nom, prenom, email)";
|
||||
$sql .= " VALUES (".$mailing_id.",";
|
||||
$sql .= $cibles[$i][1] .",";
|
||||
$sql .= "'".$cibles[$i][2] ."',";
|
||||
$sql .= "'".$cibles[$i][3] ."',";
|
||||
$sql .= "'".$cibles[$i][0] ."')";
|
||||
|
||||
if (!$db->query($sql))
|
||||
{
|
||||
dolibarr_syslog($db->error());
|
||||
}
|
||||
}
|
||||
|
||||
dolibarr_syslog("mailing-prepare: mailing $i cibles ajoutées");
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing";
|
||||
$sql .= " SET nbemail = ".$i." WHERE rowid = ".$mailing_id;
|
||||
|
||||
if (!$db->query($sql))
|
||||
{
|
||||
dolibarr_syslog($db->error());
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -134,7 +134,7 @@ class FormMail
|
||||
if ($this->withtoreadonly) {
|
||||
print (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:"";
|
||||
} else {
|
||||
print "<input size=\"30\" name=\"sendto\" value=\"".(! is_array($this->withto)?$this->withto:"")."\">";
|
||||
print "<input size=\"30\" name=\"sendto\" value=\"".(! is_array($this->withto) && ! is_numeric($this->withto)?$this->withto:"")."\">";
|
||||
if (is_array($this->withto))
|
||||
{
|
||||
print " ".$langs->trans("or")." ";
|
||||
|
||||
163
htdocs/includes/modules/mailings/cerise.modules.php
Normal file
163
htdocs/includes/modules/mailings/cerise.modules.php
Normal file
@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*
|
||||
* L'utilisation d'adresses de courriers électroniques dans les opérations
|
||||
* de prospection commerciale est subordonnée au recueil du consentement
|
||||
* préalable des personnes concernées.
|
||||
*
|
||||
* Le dispositif juridique applicable a été introduit par l'article 22 de
|
||||
* la loi du 21 juin 2004 pour la confiance dans l'économie numérique.
|
||||
*
|
||||
* Les dispositions applicables sont définies par les articles L. 34-5 du
|
||||
* code des postes et des télécommunications et L. 121-20-5 du code de la
|
||||
* consommation. L'application du principe du consentement préalable en
|
||||
* droit français résulte de la transposition de l'article 13 de la Directive
|
||||
* européenne du 12 juillet 2002 « Vie privée et communications électroniques ».
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file htdocs/includes/modules/mailings/poire.modules.php
|
||||
\ingroup mailing
|
||||
\brief Fichier de la classe permettant de générer la liste de destinataires Cerise
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php';
|
||||
|
||||
|
||||
/** \class mailing_cerise
|
||||
\brief Classe permettant de générer la liste des destinataires Cerise
|
||||
*/
|
||||
|
||||
class mailing_cerise extends MailingTargets
|
||||
{
|
||||
var $name="ContactProspects";
|
||||
var $desc='Tous les contacts associés aux prospects';
|
||||
var $require_module=array("prospet");
|
||||
|
||||
function mailing_cerise($DB)
|
||||
{
|
||||
$this->db=$DB;
|
||||
}
|
||||
|
||||
function getNbOfRecipients()
|
||||
{
|
||||
$sql = "SELECT count(distinct(c.email)) nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE s.idp = c.fk_soc";
|
||||
$sql .= " AND s.client = 2";
|
||||
$sql .= " AND c.email IS NOT NULL";
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
return $obj->nb;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function add_to_target($mailing_id)
|
||||
{
|
||||
$cibles = array();
|
||||
|
||||
$sql = "SELECT distinct(c.email), c.idp, c.name, c.firstname, s.nom ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE s.idp = c.fk_soc";
|
||||
$sql .= " AND s.client = 2";
|
||||
$sql .= " AND c.email IS NOT NULL";
|
||||
$sql .= " ORDER BY c.email ASC";
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$num = $this->db->num_rows();
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
|
||||
dolibarr_syslog("mailing-prepare: mailing $num cibles trouvées");
|
||||
|
||||
$olde = '';
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_row();
|
||||
|
||||
if ($olde <> $row[0])
|
||||
{
|
||||
$cibles[$j] = $row;
|
||||
$olde = $row[0];
|
||||
$j++;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " WHERE fk_mailing = ".$mailing_id;
|
||||
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
|
||||
$num = sizeof($cibles);
|
||||
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " (fk_mailing, fk_contact, nom, prenom, email)";
|
||||
$sql .= " VALUES (".$mailing_id.",";
|
||||
$sql .= $cibles[$i][1] .",";
|
||||
$sql .= "'".$cibles[$i][2] ."',";
|
||||
$sql .= "'".$cibles[$i][3] ."',";
|
||||
$sql .= "'".$cibles[$i][0] ."')";
|
||||
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
}
|
||||
|
||||
dolibarr_syslog("mailing-prepare: mailing $i cibles ajoutées");
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing";
|
||||
$sql .= " SET nbemail = ".$i." WHERE rowid = ".$mailing_id;
|
||||
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
62
htdocs/includes/modules/mailings/modules_mailings.php
Normal file
62
htdocs/includes/modules/mailings/modules_mailings.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
*
|
||||
* 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.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file htdocs/includes/modules/mailings/modules_mailings.php
|
||||
\ingroup mailing
|
||||
\brief Fichier contenant la classe mère des classes de liste de destinataires mailing
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
/** \class MailingTargets
|
||||
\brief Classe mère des classes de liste de destinataires mailing
|
||||
*/
|
||||
|
||||
class MailingTargets
|
||||
{
|
||||
var $error='';
|
||||
|
||||
/** \brief Renvoi un exemple de numérotation
|
||||
* \return string Retourne la traduction de la clé MailingModuleDescXXX ou XXX nom du module, ou $this->desc si non trouvé
|
||||
*/
|
||||
function getDesc()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("mails");
|
||||
$transstring="MailingModuleDesc".$this->name;
|
||||
if ($langs->trans($transstring) != $transstring) return $langs->trans($transstring);
|
||||
else return $this->desc;
|
||||
}
|
||||
|
||||
/** \brief Renvoi un exemple de numérotation
|
||||
* \return string Example
|
||||
*/
|
||||
function getNbOfRecords()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
165
htdocs/includes/modules/mailings/poire.modules.php
Normal file
165
htdocs/includes/modules/mailings/poire.modules.php
Normal file
@ -0,0 +1,165 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*
|
||||
* L'utilisation d'adresses de courriers électroniques dans les opérations
|
||||
* de prospection commerciale est subordonnée au recueil du consentement
|
||||
* préalable des personnes concernées.
|
||||
*
|
||||
* Le dispositif juridique applicable a été introduit par l'article 22 de
|
||||
* la loi du 21 juin 2004 pour la confiance dans l'économie numérique.
|
||||
*
|
||||
* Les dispositions applicables sont définies par les articles L. 34-5 du
|
||||
* code des postes et des télécommunications et L. 121-20-5 du code de la
|
||||
* consommation. L'application du principe du consentement préalable en
|
||||
* droit français résulte de la transposition de l'article 13 de la Directive
|
||||
* européenne du 12 juillet 2002 « Vie privée et communications électroniques ».
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file htdocs/includes/modules/mailings/poire.modules.php
|
||||
\ingroup mailing
|
||||
\brief Fichier de la classe permettant de générer la liste de destinataires Poire
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php';
|
||||
|
||||
|
||||
/** \class mailing_poire
|
||||
\brief Classe permettant de générer la liste des destinataires Poire
|
||||
*/
|
||||
|
||||
class mailing_poire extends MailingTargets
|
||||
{
|
||||
var $name='ContactCustomers';
|
||||
var $desc='Tous les contacts associés aux clients';
|
||||
var $require_module=array("customer");
|
||||
|
||||
var $db;
|
||||
|
||||
function mailing_poire($DB)
|
||||
{
|
||||
$this->db=$DB;
|
||||
}
|
||||
|
||||
function getNbOfRecipients()
|
||||
{
|
||||
$sql = "SELECT count(distinct(c.email)) nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE s.idp = c.fk_soc";
|
||||
$sql .= " AND s.client = 1";
|
||||
$sql .= " AND c.email IS NOT NULL";
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
return $obj->nb;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function add_to_target($mailing_id)
|
||||
{
|
||||
$cibles = array();
|
||||
|
||||
$sql = "SELECT distinct(c.email), c.idp, c.name, c.firstname, s.nom ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE s.idp = c.fk_soc";
|
||||
$sql .= " AND s.client = 1";
|
||||
$sql .= " AND c.email IS NOT NULL";
|
||||
$sql .= " ORDER BY c.email ASC";
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$num = $this->db->num_rows();
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
|
||||
dolibarr_syslog("mailing-prepare: mailing $num cibles trouvées");
|
||||
|
||||
$olde = '';
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_row();
|
||||
|
||||
if ($olde <> $row[0])
|
||||
{
|
||||
$cibles[$j] = $row;
|
||||
$olde = $row[0];
|
||||
$j++;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " WHERE fk_mailing = ".$mailing_id;
|
||||
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
|
||||
$num = sizeof($cibles);
|
||||
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " (fk_mailing, fk_contact, nom, prenom, email)";
|
||||
$sql .= " VALUES (".$mailing_id.",";
|
||||
$sql .= $cibles[$i][1] .",";
|
||||
$sql .= "'".$cibles[$i][2] ."',";
|
||||
$sql .= "'".$cibles[$i][3] ."',";
|
||||
$sql .= "'".$cibles[$i][0] ."')";
|
||||
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
}
|
||||
|
||||
dolibarr_syslog("mailing-prepare: mailing $i cibles ajoutées");
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing";
|
||||
$sql .= " SET nbemail = ".$i." WHERE rowid = ".$mailing_id;
|
||||
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -2,6 +2,7 @@
|
||||
Mailing=Mailing
|
||||
MailCard=Mailing card
|
||||
MailTargets=Targets
|
||||
MailRecipients=Recipients
|
||||
MailTitle=Title
|
||||
MailTopic=Mail topic
|
||||
MailFrom=Sender
|
||||
@ -13,6 +14,10 @@ MailText=Message
|
||||
MailFile=Attach a file
|
||||
MailMessage=Message
|
||||
NewMailing=New mailing
|
||||
EditMailing=Edit mailing
|
||||
DeleteMailing=Delete mailing
|
||||
DeleteAMailing=Delete a mailing
|
||||
PreviewMailing=Preview mailing
|
||||
PrepareMailing=Prepare mailing
|
||||
CreateMailing=Create mailing
|
||||
MailingDesc=This page allows you to send mailings to a group of people.
|
||||
@ -26,4 +31,14 @@ MailingStatusApproved=Approved
|
||||
MailingStatusSent=Sent
|
||||
MailSuccessfulySent=Mail successfuly sent (from %s to %s)
|
||||
ErrorMailRecipientIsEmpty=Mail recipient is empty
|
||||
ConfirmValidMailing=Are you sure you want to validate this mailing ?
|
||||
ConfirmDeleteMailing=Are you sure you want to delete this mailling ?
|
||||
NbOfRecipients=Number of recipients
|
||||
TotalNbOfDistinctRecipients=Total number of distinct recipients
|
||||
NoTargetYet=No recipients defined yet
|
||||
AddRecipients=Add recipients
|
||||
MailingModuleDescContactProspects=All contacts for all prospect companies
|
||||
MailingModuleDescContactCustomers=All contacts for all customer companies
|
||||
RecipientSelectionModules=Active modules for recipients selection
|
||||
MailSelectedRecipients=Selected recipients
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
Mailing=Mailing
|
||||
MailCard=Fiche mailing
|
||||
MailTargets=Destinataires
|
||||
MailRecipients=Destinataires
|
||||
MailTitle=Titre
|
||||
MailTopic=Sujet du mail
|
||||
MailFrom=Emetteur
|
||||
@ -13,6 +14,10 @@ MailText=Message
|
||||
MailFile=Joindre un fichier
|
||||
MailMessage=Message
|
||||
NewMailing=Nouveau mailing
|
||||
EditMailing=Editer mailing
|
||||
DeleteMailing=Supprimer mailing
|
||||
DeleteAMailing=Supprimer un mailing
|
||||
PreviewMailing=Prévisualiser mailing
|
||||
PrepareMailing=Preparer mailing
|
||||
CreateMailing=Créer mailing
|
||||
MailingDesc=Cette page vous permet d'envoyer des mailings à un groupe de personnes.
|
||||
@ -26,3 +31,13 @@ MailingStatusApproved=Approv
|
||||
MailingStatusSent=Envoyé
|
||||
MailSuccessfulySent=Mail envoyé avec succès (de la part de %s pour %s)
|
||||
ErrorMailRecipientIsEmpty=Le mail du destinataire est vide
|
||||
ConfirmValidMailing=Confirmez-vous la validation du mailing ?
|
||||
ConfirmDeleteMailing=Confirmez-vous la suppression du mailing ?
|
||||
NbOfRecipients=Nombre de destinataires
|
||||
TotalNbOfdistinctRecipients=Nombre total de destinataires uniques
|
||||
NoTargetYet=Pas de destinataire définis
|
||||
AddRecipients=Ajout de destinataires
|
||||
MailingModuleDescContactProspects=Tous les contacts de toutes les sociétés propsects
|
||||
MailingModuleDescContactCustomers=Tous les contacts de toutes les sociétés clientes
|
||||
RecipientSelectionModules=Modules actifs de sélection de destinataires
|
||||
MailSelectedRecipients=Destinataires sélectionnés
|
||||
|
||||
@ -56,13 +56,12 @@ if ( $db->query($sql) )
|
||||
dolibarr_syslog("mailing-prepare: mailing $row[0]");
|
||||
dolibarr_syslog("mailing-prepare: mailing module $row[1]");
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/comm/mailing/modules/'.$row[1].'.modules.php';
|
||||
require DOL_DOCUMENT_ROOT.'/includes/modules/mailings/'.$row[1].'.modules.php';
|
||||
|
||||
$classname = "mailing_".$row[1];
|
||||
|
||||
$obj = new $classname;
|
||||
|
||||
$obj->prepare_cible($db, $row[0]);
|
||||
$obj = new $classname($db);
|
||||
$obj->add_to_target($row[0]);
|
||||
|
||||
$i++;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user