Can add additionnal fields in emailings selectors

This commit is contained in:
Laurent Destailleur 2009-01-25 22:04:55 +00:00
parent 1820507ed4
commit 5b2b029f16
20 changed files with 326 additions and 252 deletions

View File

@ -1,6 +1,6 @@
<?PHP <?PHP
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2008 Laurent Destailleur <eldy@uers.sourceforge.net> * Copyright (C) 2005-2009 Laurent Destailleur <eldy@uers.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -18,11 +18,11 @@
*/ */
/** /**
\file htdocs/comm/mailing/cibles.php * \file htdocs/comm/mailing/cibles.php
\ingroup mailing * \ingroup mailing
\brief Page des cibles de mailing * \brief Page des cibles de mailing
\version $Id$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
@ -46,7 +46,7 @@ $offset = $conf->liste_limit * $_GET["page"] ;
$pageprev = $_GET["page"] - 1; $pageprev = $_GET["page"] - 1;
$pagenext = $_GET["page"] + 1; $pagenext = $_GET["page"] + 1;
if (! $sortorder) $sortorder="ASC"; if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="nom"; if (! $sortfield) $sortfield="email";
$search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"]; $search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"];
$search_prenom=isset($_GET["search_prenom"])?$_GET["search_prenom"]:$_POST["search_prenom"]; $search_prenom=isset($_GET["search_prenom"])?$_GET["search_prenom"]:$_POST["search_prenom"];
@ -59,15 +59,15 @@ $search_email=isset($_GET["search_email"])?$_GET["search_email"]:$_POST["search_
if ($_GET["action"] == 'add') if ($_GET["action"] == 'add')
{ {
$modulename=$_GET["module"]; $modulename=$_GET["module"];
// Chargement de la classe // Chargement de la classe
$file = $dirmod."/".$modulename.".modules.php"; $file = $dirmod."/".$modulename.".modules.php";
$classname = "mailing_".$modulename; $classname = "mailing_".$modulename;
require_once($file); require_once($file);
$filtersarray=array(); $filtersarray=array();
if (isset($_POST["filter"])) $filtersarray[0]=$_POST["filter"]; if (isset($_POST["filter"])) $filtersarray[0]=$_POST["filter"];
$obj = new $classname($db); $obj = new $classname($db);
$result=$obj->add_to_target($_GET["rowid"],$filtersarray); $result=$obj->add_to_target($_GET["rowid"],$filtersarray);
@ -79,11 +79,11 @@ if ($_GET["action"] == 'add')
if ($result == 0) if ($result == 0)
{ {
$mesg='<div class="warning">'.$langs->trans("WarningNoEMailsAdded").'</div>'; $mesg='<div class="warning">'.$langs->trans("WarningNoEMailsAdded").'</div>';
} }
if ($result < 0) if ($result < 0)
{ {
$mesg='<div class="error">'.$obj->error.'</div>'; $mesg='<div class="error">'.$obj->error.'</div>';
} }
$_REQUEST["id"]=$_GET["rowid"]; $_REQUEST["id"]=$_GET["rowid"];
} }
@ -93,10 +93,10 @@ if ($_GET["action"] == 'clear')
$file = $dirmod."/modules_mailings.php"; $file = $dirmod."/modules_mailings.php";
$classname = "MailingTargets"; $classname = "MailingTargets";
require_once($file); require_once($file);
$obj = new $classname($db); $obj = new $classname($db);
$obj->clear_target($_GET["rowid"]); $obj->clear_target($_GET["rowid"]);
Header("Location: cibles.php?id=".$_GET["rowid"]); Header("Location: cibles.php?id=".$_GET["rowid"]);
exit; exit;
} }
@ -111,7 +111,7 @@ if ($_GET["action"] == 'delete')
$file = $dirmod."/modules_mailings.php"; $file = $dirmod."/modules_mailings.php";
$classname = "MailingTargets"; $classname = "MailingTargets";
require_once($file); require_once($file);
$obj = new $classname($db); $obj = new $classname($db);
$obj->update_nb($_REQUEST["id"]); $obj->update_nb($_REQUEST["id"]);
} }
@ -141,12 +141,12 @@ $mil = new Mailing($db);
$html = new Form($db); $html = new Form($db);
if ($mil->fetch($_REQUEST["id"]) >= 0) if ($mil->fetch($_REQUEST["id"]) >= 0)
{ {
$h=0; $h=0;
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id; $head[$h][0] = DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id;
$head[$h][1] = $langs->trans("MailCard"); $head[$h][1] = $langs->trans("MailCard");
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$mil->id; $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$mil->id;
$head[$h][1] = $langs->trans("MailRecipients"); $head[$h][1] = $langs->trans("MailRecipients");
$hselected = $h; $hselected = $h;
@ -158,10 +158,10 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
$h++; $h++;
*/ */
dolibarr_fiche_head($head, $hselected, $langs->trans("Mailing")); dolibarr_fiche_head($head, $hselected, $langs->trans("Mailing"));
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans("Ref").'</td>'; print '<tr><td width="25%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
print $html->showrefnav($mil,'id'); print $html->showrefnav($mil,'id');
@ -171,14 +171,14 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$mil->getLibStatut(4).'</td></tr>'; print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$mil->getLibStatut(4).'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("TotalNbOfDistinctRecipients").'</td><td colspan="3">'.($mil->nbemail?$mil->nbemail:'0').'</td></tr>'; print '<tr><td width="25%">'.$langs->trans("TotalNbOfDistinctRecipients").'</td><td colspan="3">'.($mil->nbemail?$mil->nbemail:'0').'</td></tr>';
print '</table>'; print '</table>';
print "</div>"; print "</div>";
if ($mesg) print "$mesg<br>\n"; if ($mesg) print "$mesg<br>\n";
$var=!$var; $var=!$var;
// Affiche les listes de s<EFBFBD>lection // Affiche les listes de selection
if ($mil->statut == 0) if ($mil->statut == 0)
{ {
print_titre($langs->trans("ToAddRecipientsChooseHere")); print_titre($langs->trans("ToAddRecipientsChooseHere"));
@ -191,19 +191,19 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
print '<td align="left">'.$langs->trans("Filter").'</td>'; print '<td align="left">'.$langs->trans("Filter").'</td>';
print '<td align="center" width="120">&nbsp;</td>'; print '<td align="center" width="120">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
clearstatcache(); clearstatcache();
$var=true; $var=true;
foreach ($conf->dol_document_root as $dirroot) foreach ($conf->dol_document_root as $dirroot)
{ {
$dir=$dirroot."/includes/modules/mailings/"; $dir=$dirroot."/includes/modules/mailings/";
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle=opendir($dir); $handle=opendir($dir);
if ($handle) if ($handle)
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
@ -212,14 +212,14 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
{ {
$modulename=$reg[1]; $modulename=$reg[1];
if ($modulename == 'example') continue; if ($modulename == 'example') continue;
// Chargement de la classe // Chargement de la classe
$file = $dir.$modulename.".modules.php"; $file = $dir.$modulename.".modules.php";
$classname = "mailing_".$modulename; $classname = "mailing_".$modulename;
require_once($file); require_once($file);
$obj = new $classname($db); $obj = new $classname($db);
$qualified=1; $qualified=1;
foreach ($obj->require_module as $key) foreach ($obj->require_module as $key)
{ {
@ -230,20 +230,20 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
break; break;
} }
} }
// Si le module mailing est qualifi<EFBFBD> // Si le module mailing est qualifie
if ($qualified) if ($qualified)
{ {
$var = !$var; $var = !$var;
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
if ($mil->statut == 0) print '<form name="'.$modulename.'" action="cibles.php?action=add&rowid='.$mil->id.'&module='.$modulename.'" method="POST" enctype="multipart/form-data">'; if ($mil->statut == 0) print '<form name="'.$modulename.'" action="cibles.php?action=add&rowid='.$mil->id.'&module='.$modulename.'" method="POST" enctype="multipart/form-data">';
print '<td>'; print '<td>';
if (! $obj->picto) $obj->picto='generic'; if (! $obj->picto) $obj->picto='generic';
print img_object('',$obj->picto).' '.$obj->getDesc(); print img_object($langs->trans("Module").': '.get_class($obj),$obj->picto).' '.$obj->getDesc();
print '</td>'; print '</td>';
/* /*
print '<td width=\"100\">'; print '<td width=\"100\">';
print $modulename; print $modulename;
@ -260,13 +260,13 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
print $langs->trans("Error").' '.img_error($obj->error); print $langs->trans("Error").' '.img_error($obj->error);
} }
print '</td>'; print '</td>';
print '<td align="left">'; print '<td align="left">';
$filter=$obj->formFilter(); $filter=$obj->formFilter();
if ($filter) print $filter; if ($filter) print $filter;
else print $langs->trans("None"); else print $langs->trans("None");
print '</td>'; print '</td>';
print '<td align="right">'; print '<td align="right">';
if ($mil->statut == 0) if ($mil->statut == 0)
{ {
@ -278,9 +278,9 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
print "&nbsp;"; print "&nbsp;";
} }
print '</td>'; print '</td>';
if ($mil->statut == 0) print '</form>'; if ($mil->statut == 0) print '</form>';
print "</tr>\n"; print "</tr>\n";
} }
} }
@ -290,10 +290,10 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
} }
} }
} // End foreach dir } // End foreach dir
print '</table>'; print '</table>';
print '<br>'; print '<br>';
print '<form action="cibles.php?action=clear&rowid='.$mil->id.'" method="POST">'; print '<form action="cibles.php?action=clear&rowid='.$mil->id.'" method="POST">';
print_titre($langs->trans("ToClearAllRecipientsClickHere")); print_titre($langs->trans("ToClearAllRecipientsClickHere"));
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
@ -304,7 +304,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
print '</form>'; print '</form>';
print '<br>'; print '<br>';
} }
// List of selected targets // List of selected targets
@ -314,7 +314,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="id" value="'.$mil->id.'">'; print '<input type="hidden" name="id" value="'.$mil->id.'">';
$sql = "SELECT mc.rowid, mc.nom, mc.prenom, mc.email, mc.statut, mc.date_envoi, mc.url"; $sql = "SELECT mc.rowid, mc.nom, mc.prenom, mc.email, mc.other, mc.statut, mc.date_envoi, mc.url";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql .= " WHERE mc.fk_mailing=".$mil->id; $sql .= " WHERE mc.fk_mailing=".$mil->id;
if ($search_nom) $sql.= " AND mc.nom like '%".addslashes($search_nom)."%'"; if ($search_nom) $sql.= " AND mc.nom like '%".addslashes($search_nom)."%'";
@ -322,12 +322,12 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
if ($search_email) $sql.= " AND mc.email like '%".addslashes($search_email)."%'"; if ($search_email) $sql.= " AND mc.email like '%".addslashes($search_email)."%'";
if ($sortfield) { $sql .= " ORDER BY $sortfield $sortorder"; } if ($sortfield) { $sql .= " ORDER BY $sortfield $sortorder"; }
$sql .= $db->plimit($conf->liste_limit+1, $offset); $sql .= $db->plimit($conf->liste_limit+1, $offset);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$addu = "&amp;id=".$mil->id; $addu = "&amp;id=".$mil->id;
if ($search_nom) $addu.= "&amp;search_nom=".urlencode($search_nom); if ($search_nom) $addu.= "&amp;search_nom=".urlencode($search_nom);
if ($search_prenom) $addu.= "&amp;search_prenom=".urlencode($search_prenom); if ($search_prenom) $addu.= "&amp;search_prenom=".urlencode($search_prenom);
@ -338,10 +338,11 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
if ($page) $addu.= "&amp;page=".$page; if ($page) $addu.= "&amp;page=".$page;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"mc.email",$addu,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Lastname"),$_SERVER["PHP_SELF"],"mc.nom",$addu,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Lastname"),$_SERVER["PHP_SELF"],"mc.nom",$addu,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Firstname"),$_SERVER["PHP_SELF"],"mc.prenom",$addu,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Firstname"),$_SERVER["PHP_SELF"],"mc.prenom",$addu,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"mc.email",$addu,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("OtherInformations"),$_SERVER["PHP_SELF"],"",$addu,"","",$sortfield,$sortorder);
print '<td align="center">&nbsp;</td>'; print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"],"",$addu,"",'align="center"',$sortfield,$sortorder);
// Date // Date
if ($mil->statut < 2) if ($mil->statut < 2)
@ -351,7 +352,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
else else
{ {
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"mc.date_envoi",$addu,'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"mc.date_envoi",$addu,'','align="center"',$sortfield,$sortorder);
} }
// Statut // Statut
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"mc.statut",$addu,'','align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"mc.statut",$addu,'','align="right"',$sortfield,$sortorder);
@ -360,37 +361,46 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
// Ligne des champs de filtres // Ligne des champs de filtres
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre">'; // EMail
print '<input class="flat" type="text" name="search_nom" size="12" value="'.$search_nom.'">';
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_prenom" size="10" value="'.$search_prenom.'">';
print '</td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_email" size="14" value="'.$search_email.'">'; print '<input class="flat" type="text" name="search_email" size="14" value="'.$search_email.'">';
print '</td>'; print '</td>';
// Name
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_nom" size="12" value="'.$search_nom.'">';
print '</td>';
// Firstname
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_prenom" size="10" value="'.$search_prenom.'">';
print '</td>';
// Other
print '<td class="liste_titre">';
print '&nbsp';
print '</td>';
// Url
print '<td class="liste_titre" align="right" colspan="3">'; print '<td class="liste_titre" align="right" colspan="3">';
print '<input type="image" value="button_search" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" alt="'.$langs->trans("Search").'">'; print '<input type="image" value="button_search" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" alt="'.$langs->trans("Search").'">';
print '&nbsp; <input type="image" value="button_removefilter" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" alt="'.$langs->trans("RemoveFilter").'">'; print '&nbsp; <input type="image" value="button_removefilter" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" alt="'.$langs->trans("RemoveFilter").'">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$var = true; $var = true;
$i = 0; $i = 0;
if ($num) if ($num)
{ {
while ($i < min($num,$conf->liste_limit)) while ($i < min($num,$conf->liste_limit))
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'.$obj->email.'</td>';
print '<td>'.$obj->nom.'</td>'; print '<td>'.$obj->nom.'</td>';
print '<td>'.$obj->prenom.'</td>'; print '<td>'.$obj->prenom.'</td>';
print '<td>'.$obj->email.'</td>'; print '<td>'.$obj->other.'</td>';
print '<td>'.$obj->url.'</td>'; print '<td align="center">'.$obj->url.'</td>';
// Statut pour l'email destinataire (Attentioon != statut du mailing) // Statut pour l'email destinataire (Attentioon != statut du mailing)
if ($obj->statut == 0) if ($obj->statut == 0)
{ {
@ -404,30 +414,30 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
if ($obj->statut==-1) print $langs->trans("MailingStatusError").' '.img_error(); if ($obj->statut==-1) print $langs->trans("MailingStatusError").' '.img_error();
if ($obj->statut==1) print $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6'); if ($obj->statut==1) print $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6');
print '</td>'; print '</td>';
} }
print '</tr>'; print '</tr>';
$i++; $i++;
} }
} }
else else
{ {
print '<tr '.$bc[false].'><td colspan="6">'.$langs->trans("NoTargetYet").'</td></tr>'; print '<tr '.$bc[false].'><td colspan="7">'.$langs->trans("NoTargetYet").'</td></tr>';
} }
print "</table><br>"; print "</table><br>";
$db->free($resql); $db->free($resql);
} }
else else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
print '</form>'; print '</form>';
print "\n<!-- Fin liste destinataires selectionnes -->\n"; print "\n<!-- Fin liste destinataires selectionnes -->\n";
} }
$db->close(); $db->close();

View File

@ -36,17 +36,23 @@ if (! $user->rights->mailing->lire || $user->societe_id > 0)
$message = ''; $message = '';
// Tableau des substitutions possibles // Tableau des substitutions possibles
$substitutionarray=array( $substitutionarray=array(
'__ID__' => 'IdRecord', '__ID__' => 'IdRecord',
'__EMAIL__' => 'EMail', '__EMAIL__' => 'EMail',
'__LASTNAME__' => 'Lastname', '__LASTNAME__' => 'Lastname',
'__FIRSTNAME__' => 'Firstname' '__FIRSTNAME__' => 'Firstname',
'__OTHER1__' => 'Other1',
'__OTHER2__' => 'Other2',
'__OTHER3__' => 'Other3',
); );
$substitutionarrayfortest=array( $substitutionarrayfortest=array(
'__ID__' => 'TESTIdRecord', '__ID__' => 'TESTIdRecord',
'__EMAIL__' => 'TESTEMail', '__EMAIL__' => 'TESTEMail',
'__LASTNAME__' => 'TESTLastname', '__LASTNAME__' => 'TESTLastname',
'__FIRSTNAME__' => 'TESTFirstname' '__FIRSTNAME__' => 'TESTFirstname',
'__OTHER1__' => 'TESTOther1',
'__OTHER2__' => 'TESTOther2',
'__OTHER3__' => 'TESTOther3'
); );
@ -92,13 +98,13 @@ if ($_POST["action"] == 'sendallconfirmed')
{ {
$mil=new Mailing($db); $mil=new Mailing($db);
$result=$mil->fetch($_GET['id']); $result=$mil->fetch($_GET['id']);
if ($mil->statut == 0) if ($mil->statut == 0)
{ {
dolibarr_print_error('','ErrorMailIsNotValidated'); dolibarr_print_error('','ErrorMailIsNotValidated');
exit; exit;
} }
$id = $mil->id; $id = $mil->id;
$subject = $mil->sujet; $subject = $mil->sujet;
$message = $mil->body; $message = $mil->body;
@ -106,16 +112,16 @@ if ($_POST["action"] == 'sendallconfirmed')
$errorsto = $mil->email_errorsto; $errorsto = $mil->email_errorsto;
// Le message est-il en html // Le message est-il en html
$msgishtml=-1; // Unknown by default $msgishtml=-1; // Unknown by default
if (eregi('[ \t]*<html>',$message)) $msgishtml=1; if (eregi('[ \t]*<html>',$message)) $msgishtml=1;
// Warning, we must not use begin-commit transaction here // Warning, we must not use begin-commit transaction here
// because we want to save update for each mail sent. // because we want to save update for each mail sent.
$nbok=0; $nbko=0; $nbok=0; $nbko=0;
// On choisit les mails non deja envoyes pour ce mailing (statut=0) // On choisit les mails non deja envoyes pour ce mailing (statut=0)
// ou envoyes en erreur (statut=-1) // ou envoyes en erreur (statut=-1)
$sql = "SELECT mc.rowid, mc.nom, mc.prenom, mc.email"; $sql = "SELECT mc.rowid, mc.nom, mc.prenom, mc.email, mc.other";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id; $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id;
@ -124,50 +130,57 @@ if ($_POST["action"] == 'sendallconfirmed')
{ {
$num = $db->num_rows($resql); // nb of possible recipients $num = $db->num_rows($resql); // nb of possible recipients
if ($num) if ($num)
{ {
dolibarr_syslog("mailing-send: nb of targets = ".$num, LOG_DEBUG); dolibarr_syslog("mailing-send: nb of targets = ".$num, LOG_DEBUG);
// Positionne date debut envoi // Positionne date debut envoi
$sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi=SYSDATE() WHERE rowid=".$id; $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi=".$db->idate(gmmktime())." WHERE rowid=".$id;
$resql2=$db->query($sql); $resql2=$db->query($sql);
if (! $resql2) if (! $resql2)
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
// Boucle sur chaque adresse et envoie le mail // Boucle sur chaque adresse et envoie le mail
$i = 0; $i = 0;
while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB)
{ {
$res=1; $res=1;
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
// sendto en RFC2822 // sendto en RFC2822
$sendto = $obj->prenom." ".$obj->nom." <".$obj->email.">"; $sendto = $obj->prenom." ".$obj->nom." <".$obj->email.">";
// Pratique les substitutions sur le sujet et message // Pratique les substitutions sur le sujet et message
$substitutionarray=array( $other=split(';',$obj->other);
$other1=$other[0];
$other2=$other[1];
$other3=$other[3];
$substitutionarray=array(
'__ID__' => $obj->rowid, '__ID__' => $obj->rowid,
'__EMAIL__' => $obj->email, '__EMAIL__' => $obj->email,
'__LASTNAME__' => $obj->nom, '__LASTNAME__' => $obj->nom,
'__FIRSTNAME__' => $obj->prenom '__FIRSTNAME__' => $obj->prenom,
'__OTHER1__' => $other1,
'__OTHER2__' => $other2,
'__OTHER3__' => $other3
); );
$substitutionisok=true; $substitutionisok=true;
$newsubject=make_substitutions($subject,$substitutionarray); $newsubject=make_substitutions($subject,$substitutionarray);
$newmessage=make_substitutions($message,$substitutionarray); $newmessage=make_substitutions($message,$substitutionarray);
// Fabrication du mail // Fabrication du mail
$mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $mail = new CMailFile($newsubject, $sendto, $from, $newmessage,
array(), array(), array(), array(), array(), array(),
'', '', 0, $msgishtml); '', '', 0, $msgishtml);
$mail->errors_to = $errorsto; $mail->errors_to = $errorsto;
if ($mail->error) if ($mail->error)
{ {
$res=0; $res=0;
@ -183,38 +196,38 @@ if ($_POST["action"] == 'sendallconfirmed')
{ {
$res=$mail->sendfile(); $res=$mail->sendfile();
} }
if ($res) if ($res)
{ {
// Mail envoye avec succes // Mail envoye avec succes
$nbok++; $nbok++;
dolibarr_syslog("mailing-send: ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); dolibarr_syslog("mailing-send: ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG);
$sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql.=" SET statut=1, date_envoi=SYSDATE() WHERE rowid=".$obj->rowid; $sql.=" SET statut=1, date_envoi=".$db->idate(gmmktime())." WHERE rowid=".$obj->rowid;
$resql2=$db->query($sql); $resql2=$db->query($sql);
if (! $resql2) if (! $resql2)
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
} }
else else
{ {
// Mail en echec // Mail en echec
$nbko++; $nbko++;
dolibarr_syslog("mailing-send: error for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); dolibarr_syslog("mailing-send: error for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG);
$sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql.=" SET statut=-1, date_envoi=SYSDATE() WHERE rowid=".$obj->rowid; $sql.=" SET statut=-1, date_envoi=".$db->idate(gmmktime())." WHERE rowid=".$obj->rowid;
$resql2=$db->query($sql); $resql2=$db->query($sql);
if (! $resql2) if (! $resql2)
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
} }
$i++; $i++;
} }
} }
@ -224,10 +237,10 @@ if ($_POST["action"] == 'sendallconfirmed')
{ {
$statut=2; // Status 'sent partially' (because at least one error) $statut=2; // Status 'sent partially' (because at least one error)
} }
else else
{ {
if ($nbok >= $num) $statut=3; // Send to everybody if ($nbok >= $num) $statut=3; // Send to everybody
else $statut=2; // Status 'sent partially' (because not send to everybody) else $statut=2; // Status 'sent partially' (because not send to everybody)
} }
$sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$id; $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$id;
@ -244,7 +257,7 @@ if ($_POST["action"] == 'sendallconfirmed')
dolibarr_print_error($db); dolibarr_print_error($db);
} }
$message=''; $message='';
$_GET["action"] = ''; $_GET["action"] = '';
} }
} }
@ -254,7 +267,7 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"])
{ {
$mil = new Mailing($db); $mil = new Mailing($db);
$result=$mil->fetch($_POST["mailid"]); $result=$mil->fetch($_POST["mailid"]);
$mil->sendto = $_POST["sendto"]; $mil->sendto = $_POST["sendto"];
if (! $mil->sendto) if (! $mil->sendto)
{ {
@ -268,12 +281,12 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"])
// Le message est-il en html // Le message est-il en html
$msgishtml=-1; // Inconnu par defaut $msgishtml=-1; // Inconnu par defaut
if (eregi('[ \t]*<html>',$message)) $msgishtml=1; if (eregi('[ \t]*<html>',$message)) $msgishtml=1;
// Pratique les substitutions sur le sujet et message // Pratique les substitutions sur le sujet et message
$mil->sujet=make_substitutions($mil->sujet,$substitutionarrayfortest); $mil->sujet=make_substitutions($mil->sujet,$substitutionarrayfortest);
$mil->body=make_substitutions($mil->body,$substitutionarrayfortest); $mil->body=make_substitutions($mil->body,$substitutionarrayfortest);
$mailfile = new CMailFile($mil->sujet,$mil->sendto,$mil->email_from,$mil->body, $mailfile = new CMailFile($mil->sujet,$mil->sendto,$mil->email_from,$mil->body,
$arr_file,$arr_mime,$arr_name, $arr_file,$arr_mime,$arr_name,
'', '', 0, $msgishtml); '', '', 0, $msgishtml);
@ -297,7 +310,7 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"])
if ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
{ {
$message=''; $message='';
$mil = new Mailing($db); $mil = new Mailing($db);
$mil->email_from = trim($_POST["from"]); $mil->email_from = trim($_POST["from"]);
@ -371,11 +384,11 @@ if ($_POST["action"] == 'confirm_approve')
if ($_POST["confirm"] == 'yes') if ($_POST["confirm"] == 'yes')
{ {
$mil = new Mailing($db); $mil = new Mailing($db);
if ($mil->fetch($_GET["id"]) >= 0) if ($mil->fetch($_GET["id"]) >= 0)
{ {
$mil->approve($user); $mil->approve($user);
Header("Location: fiche.php?id=".$mil->id); Header("Location: fiche.php?id=".$mil->id);
exit; exit;
} }
@ -398,7 +411,7 @@ if ($_POST["action"] == 'confirm_delete')
{ {
$mil = new Mailing($db); $mil = new Mailing($db);
$mil->id = $_GET["id"]; $mil->id = $_GET["id"];
if ($mil->delete($mil->id)) if ($mil->delete($mil->id))
{ {
Header("Location: index.php"); Header("Location: index.php");
@ -430,14 +443,15 @@ if ($_GET["action"] == 'create')
print '<form action="fiche.php" method="post">'."\n"; print '<form action="fiche.php" method="post">'."\n";
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print_titre($langs->trans("NewMailing")); print_fiche_titre($langs->trans("NewMailing"));
if ($message) print "$message<br>"; if ($message) print "$message<br>";
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td><input class="flat" name="from" size="40" value="'.$conf->global->MAILING_EMAIL_FROM.'"></td></tr>';
print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td><input class="flat" name="titre" size="40" value=""></td></tr>'; print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td><input class="flat" name="titre" size="40" value=""></td></tr>';
print '<tr><td colspan="2">&nbsp;</td></tr>';
print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td><input class="flat" name="from" size="40" value="'.$conf->global->MAILING_EMAIL_FROM.'"></td></tr>';
print '<tr><td width="25%">'.$langs->trans("MailTopic").'</td><td><input class="flat" name="sujet" size="60" value=""></td></tr>'; print '<tr><td width="25%">'.$langs->trans("MailTopic").'</td><td><input class="flat" name="sujet" size="60" value=""></td></tr>';
print '<tr><td width="25%" valign="top">'.$langs->trans("MailMessage").'<br>'; print '<tr><td width="25%" valign="top">'.$langs->trans("MailMessage").'<br>';
print '<br><i>'.$langs->trans("CommonSubstitutions").':<br>'; print '<br><i>'.$langs->trans("CommonSubstitutions").':<br>';
@ -571,8 +585,8 @@ else
print '</table>'; print '</table>';
print "</div>"; print "</div>";
// Clone confirmation // Clone confirmation
if ($_GET["action"] == 'clone') if ($_GET["action"] == 'clone')
{ {
@ -585,10 +599,10 @@ else
// Paiement incomplet. On demande si motif = escompte ou autre // Paiement incomplet. On demande si motif = escompte ou autre
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$mil->id,$langs->trans('CloneEMailing'),$langs->trans('ConfirmCloneEMailing',$mil->ref),'confirm_clone',$formquestion,'yes'); $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$mil->id,$langs->trans('CloneEMailing'),$langs->trans('ConfirmCloneEMailing',$mil->ref),'confirm_clone',$formquestion,'yes');
} }
if ($mesg) print $mesg; if ($mesg) print $mesg;
if ($_GET["action"] == 'sendall') if ($_GET["action"] == 'sendall')
{ {
@ -597,7 +611,7 @@ else
$message='<div class="warning">'.$langs->trans("MailingNeedCommand").'</div>'; $message='<div class="warning">'.$langs->trans("MailingNeedCommand").'</div>';
$message.='<br><textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/mailing/mailing-send.php '.$_GET["id"].'</textarea>'; $message.='<br><textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/mailing/mailing-send.php '.$_GET["id"].'</textarea>';
} }
if ($message) print "$message<br>"; if ($message) print "$message<br>";
/* /*
@ -643,10 +657,10 @@ else
if ($_GET["action"] == 'test') if ($_GET["action"] == 'test')
{ {
print_titre($langs->trans("TestMailing")); print_titre($langs->trans("TestMailing"));
// Create l'objet formulaire mail // Create 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 = $mil->email_from; $formmail->fromname = $mil->email_from;
$formmail->frommail = $mil->email_from; $formmail->frommail = $mil->email_from;
$formmail->withsubstit=1; $formmail->withsubstit=1;
@ -667,15 +681,15 @@ else
$formmail->param["models"]="body"; $formmail->param["models"]="body";
$formmail->param["mailid"]=$mil->id; $formmail->param["mailid"]=$mil->id;
$formmail->param["returnurl"]=DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id; $formmail->param["returnurl"]=DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id;
// Init list of files // Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
{ {
$formmail->clear_attached_files(); $formmail->clear_attached_files();
} }
$formmail->show_form(); $formmail->show_form();
print '<br>'; print '<br>';
} }
@ -700,6 +714,7 @@ else
print '__EMAIL__ = '.$langs->trans("EMail").'<br>'; print '__EMAIL__ = '.$langs->trans("EMail").'<br>';
print '__LASTNAME__ = '.$langs->trans("Lastname").'<br>'; print '__LASTNAME__ = '.$langs->trans("Lastname").'<br>';
print '__FIRSTNAME__ = '.$langs->trans("Firstname").'<br>'; print '__FIRSTNAME__ = '.$langs->trans("Firstname").'<br>';
print '__OTHER1__ = '.$langs->trans("Other").'<br>';
print '</i></td>'; print '</i></td>';
print '<td colspan="3">'; print '<td colspan="3">';
// Editeur wysiwyg // Editeur wysiwyg

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -28,7 +28,7 @@ require("./pre.inc.php");
if (!$user->rights->mailing->lire) accessforbidden(); if (!$user->rights->mailing->lire) accessforbidden();
// Sécurité accés client // Sécurité accés client
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socid = $user->societe_id; $socid = $user->societe_id;
@ -42,11 +42,17 @@ if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $_GET["page"] ; $offset = $conf->liste_limit * $_GET["page"] ;
$pageprev = $_GET["page"] - 1; $pageprev = $_GET["page"] - 1;
$pagenext = $_GET["page"] + 1; $pagenext = $_GET["page"] + 1;
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="m.date_creat";
$sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"]; $sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"];
$sref=isset($_GET["sref"])?$_GET["sref"]:$_POST["sref"]; $sref=isset($_GET["sref"])?$_GET["sref"]:$_POST["sref"];
/*
* View
*/
llxHeader(); llxHeader();
@ -67,7 +73,7 @@ if ($result)
print_barre_liste($langs->trans("ListOfEMailings"), $page, "liste.php","",$sortfield,$sortorder,"",$num); print_barre_liste($langs->trans("ListOfEMailings"), $page, "liste.php","",$sortfield,$sortorder,"",$num);
$i = 0; $i = 0;
$addu = "&amp;sall=".$sall; $addu = "&amp;sall=".$sall;
print '<table class="liste">'; print '<table class="liste">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -91,22 +97,22 @@ if ($result)
print "</td>"; print "</td>";
print "</tr>\n"; print "</tr>\n";
print '</form>'; print '</form>';
$var=True; $var=True;
$email=new Mailing($db); $email=new Mailing($db);
while ($i < min($num,$conf->liste_limit)) while ($i < min($num,$conf->liste_limit))
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/comm/mailing/fiche.php?id='.$obj->rowid.'">'; print '<td><a href="'.DOL_URL_ROOT.'/comm/mailing/fiche.php?id='.$obj->rowid.'">';
print img_object($langs->trans("ShowEMail"),"email").' '.stripslashes($obj->rowid).'</a></td>'; print img_object($langs->trans("ShowEMail"),"email").' '.stripslashes($obj->rowid).'</a></td>';
print '<td>'.$obj->titre.'</td>'; print '<td>'.$obj->titre.'</td>';
print '<td align="center">'.dolibarr_print_date($obj->datec).'</td>'; print '<td align="center">'.dolibarr_print_date($obj->datec,'day').'</td>';
print '<td align="center">'.$obj->nbemail.'</td>'; print '<td align="center">'.$obj->nbemail.'</td>';
print '<td align="right">'.$email->LibStatut($obj->statut,5).'</td>'; print '<td align="right">'.$email->LibStatut($obj->statut,5).'</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -37,7 +37,7 @@ class Mailing extends CommonObject
var $error; var $error;
var $element='mailing'; var $element='mailing';
var $table_element='mailing'; var $table_element='mailing';
var $id; var $id;
var $statut; var $statut;
var $titre; var $titre;
@ -225,9 +225,9 @@ class Mailing extends CommonObject
function createFromClone($fromid,$option1,$option2) function createFromClone($fromid,$option1,$option2)
{ {
global $user,$langs; global $user,$langs;
$error=0; $error=0;
$object=new Mailing($this->db); $object=new Mailing($this->db);
$this->db->begin(); $this->db->begin();
@ -243,7 +243,7 @@ class Mailing extends CommonObject
// If no option copy content // If no option copy content
if (empty($option1)) if (empty($option1))
{ {
// Clear values // Clear values
$object->nbemail = 0; $object->nbemail = 0;
$object->titre = $langs->trans("Draft").' '.mktime(); $object->titre = $langs->trans("Draft").' '.mktime();
$object->sujet = ''; $object->sujet = '';
@ -265,19 +265,19 @@ class Mailing extends CommonObject
$result=$object->create($user); $result=$object->create($user);
// Other options // Other options
if ($result < 0) if ($result < 0)
{ {
$this->error=$object->error; $this->error=$object->error;
$error++; $error++;
} }
if (! $error) if (! $error)
{ {
} }
// End // End
if (! $error) if (! $error)
{ {

View File

@ -33,14 +33,14 @@ fill the $target PHP array with one record for each email your selector must ret
You can choose the way you get data: From a file, a database. You are free, You can choose the way you get data: From a file, a database. You are free,
the only requirement is that the $target array is filled by records that are the only requirement is that the $target array is filled by records that are
themselves array of: ('email', 'name', 'firstname'). themselves array of: ('email', 'name', 'firstname', 'other').
This is for example how you can fill the $target array: This is for example how you can fill the $target array:
// ----- Your code start here ----- // ----- Your code start here -----
$target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0'); $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0', 'other'=>'other_0');
... ...
$target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n'); $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n', 'other'=>'other_n');
// ----- Your code end here ----- // ----- Your code end here -----

View File

@ -29,7 +29,7 @@ class mailing_example extends MailingTargets
// CHANGE THIS: Put here a name not already used // CHANGE THIS: Put here a name not already used
var $name='example'; var $name='example';
// CHANGE THIS: Put here a description of your selector module. // CHANGE THIS: Put here a description of your selector module.
// This label is used if no translation for MailingModuleDescXXX where XXX=name is found // This label is used if no translation is found for key MailingModuleDescXXX where XXX=name is found
var $desc='Put here a description'; var $desc='Put here a description';
// CHANGE THIS: Set to 1 if selector is available for admin users only // CHANGE THIS: Set to 1 if selector is available for admin users only
var $require_admin=0; var $require_admin=0;
@ -37,7 +37,7 @@ class mailing_example extends MailingTargets
var $require_module=array(); var $require_module=array();
var $picto=''; var $picto='';
var $db; var $db;
// CHANGE THIS: Constructor name must be called mailing_xxx with xxx=name of your selector // CHANGE THIS: Constructor name must be called mailing_xxx with xxx=name of your selector
function mailing_example($DB) function mailing_example($DB)
@ -60,18 +60,18 @@ class mailing_example extends MailingTargets
// ----- Your code start here ----- // ----- Your code start here -----
// You must fill the $target array with record like this // You must fill the $target array with record like this
// $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0'); // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0', 'other'=>'other_0');
// ... // ...
// $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n'); // $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n', 'other'=>'other_n');
// Example: $target[0]=array('email'=>'myemail@mydomain.com','name'=>'Doe','firstname'=>'John'); // Example: $target[0]=array('email'=>'myemail@mydomain.com', 'name'=>'Doe', 'firstname'=>'John', 'other'=>'Other information');
// ----- Your code end here ----- // ----- Your code end here -----
return parent::add_to_target($mailing_id, $target); return parent::add_to_target($mailing_id, $target);
} }
/** /**
* \brief On the main mailing area, there is a box with statistics. * \brief On the main mailing area, there is a box with statistics.
* If you want to add a line in this report you must provide an * If you want to add a line in this report you must provide an
@ -82,7 +82,7 @@ class mailing_example extends MailingTargets
function getSqlArrayForStats() function getSqlArrayForStats()
{ {
// CHANGE THIS: Optionnal // CHANGE THIS: Optionnal
//var $statssql=array(); //var $statssql=array();
//$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL";
return array(); return array();
@ -101,9 +101,9 @@ class mailing_example extends MailingTargets
// Example: return parent::getNbOfRecipients("SELECT count(*) as nb from dolibarr_table"); // Example: return parent::getNbOfRecipients("SELECT count(*) as nb from dolibarr_table");
// Example: return 500; // Example: return 500;
return '?'; return '?';
} }
/** /**
* \brief This is to add a form filter to provide variant of selector * \brief This is to add a form filter to provide variant of selector
* If used, the HTML select must be called "filter" * If used, the HTML select must be called "filter"
@ -116,8 +116,8 @@ class mailing_example extends MailingTargets
$s=''; $s='';
return $s; return $s;
} }
/** /**
* \brief Can include an URL link on each record provided by selector * \brief Can include an URL link on each record provided by selector
* shown on target page. * shown on target page.

View File

@ -39,7 +39,7 @@ class mailing_fraise extends MailingTargets
var $require_module=array('adherent'); // Module mailing actif si modules require_module actifs var $require_module=array('adherent'); // Module mailing actif si modules require_module actifs
var $require_admin=0; // Module mailing actif pour user admin ou non var $require_admin=0; // Module mailing actif pour user admin ou non
var $picto='user'; var $picto='user';
var $db; var $db;
@ -47,7 +47,7 @@ class mailing_fraise extends MailingTargets
{ {
$this->db=$DB; $this->db=$DB;
} }
function getSqlArrayForStats() function getSqlArrayForStats()
{ {
@ -78,10 +78,10 @@ class mailing_fraise extends MailingTargets
// La requete doit retourner un champ "nb" pour etre comprise // La requete doit retourner un champ "nb" pour etre comprise
// par parent::getNbOfRecipients // par parent::getNbOfRecipients
return parent::getNbOfRecipients($sql); return parent::getNbOfRecipients($sql);
} }
/** /**
* \brief Affiche formulaire de filtre qui apparait dans page de selection * \brief Affiche formulaire de filtre qui apparait dans page de selection
* des destinataires de mailings * des destinataires de mailings
@ -91,7 +91,7 @@ class mailing_fraise extends MailingTargets
{ {
global $langs; global $langs;
$langs->load("members"); $langs->load("members");
$s=''; $s='';
$s.='<select name="filter" class="flat">'; $s.='<select name="filter" class="flat">';
$s.='<option value="-1">'.$langs->trans("MemberStatusDraft").'</option>'; $s.='<option value="-1">'.$langs->trans("MemberStatusDraft").'</option>';
@ -101,8 +101,8 @@ class mailing_fraise extends MailingTargets
$s.='</select>'; $s.='</select>';
return $s; return $s;
} }
/** /**
* \brief Renvoie url lien vers fiche de la source du destinataire du mailing * \brief Renvoie url lien vers fiche de la source du destinataire du mailing
* \return string Url lien * \return string Url lien
@ -111,8 +111,8 @@ class mailing_fraise extends MailingTargets
{ {
return '<a href="'.DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$id.'">'.img_object('',"user").'</a>'; return '<a href="'.DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$id.'">'.img_object('',"user").'</a>';
} }
/** /**
* \brief Ajoute destinataires dans table des cibles * \brief Ajoute destinataires dans table des cibles
* \param mailing_id Id du mailing concerné * \param mailing_id Id du mailing concerné
@ -121,10 +121,15 @@ class mailing_fraise extends MailingTargets
*/ */
function add_to_target($mailing_id,$filtersarray=array()) function add_to_target($mailing_id,$filtersarray=array())
{ {
$cibles = array(); global $langs;
$langs->load("members");
$cibles = array();
// La requete doit retourner: id, email, fk_contact, name, firstname // La requete doit retourner: id, email, fk_contact, name, firstname
$sql = "SELECT a.rowid as id, a.email as email, null as fk_contact, a.nom as name, a.prenom as firstname"; $sql = "SELECT a.rowid as id, a.email as email, null as fk_contact, ";
$sql.= " a.nom as name, a.prenom as firstname,";
$sql.= " a.datefin"; // Other fields
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql.= " WHERE a.email IS NOT NULL"; $sql.= " WHERE a.email IS NOT NULL";
foreach($filtersarray as $key) foreach($filtersarray as $key)
@ -157,6 +162,7 @@ class mailing_fraise extends MailingTargets
'fk_contact' => $obj->fk_contact, 'fk_contact' => $obj->fk_contact,
'name' => $obj->name, 'name' => $obj->name,
'firstname' => $obj->firstname, 'firstname' => $obj->firstname,
'other' => $obj->datefin?($langs->transnoentities("DateEnd").'='.dolibarr_print_date($this->db->jdate($obj->datefin),'day')):'',
'url' => $this->url($obj->id) 'url' => $this->url($obj->id)
); );
$old = $obj->email; $old = $obj->email;

View File

@ -18,26 +18,24 @@
include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php'; include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php';
// CHANGE THIS: Class name must be called mailing_xxx with xxx=name of your selector
/** /**
\class mailing_kiwi * \class mailing_kiwi
\brief Class to manage a list of personalised recipients for mailing feature * \brief Class to manage a list of personalised recipients for mailing feature
*/ */
class mailing_kiwi extends MailingTargets class mailing_kiwi extends MailingTargets
{ {
// CHANGE THIS: Put here a name not already used // CHANGE THIS: Put here a name not already used
var $name='ContactsCategories'; var $name='ContactsCategories';
// CHANGE THIS: Put here a description of your selector module. // CHANGE THIS: Put here a description of your selector module.
// This label is used if no translation for MailingModuleDescXXX where XXX=name is found // This label is used if no translation found for key MailingModuleDescXXX where XXX=name is found
var $desc="Contacts des tiers (par categorie)"; var $desc="Third parties (by categories)";
// CHANGE THIS: Set to 1 if selector is available for admin users only // CHANGE THIS: Set to 1 if selector is available for admin users only
var $require_admin=0; var $require_admin=0;
var $require_module=array("categorie"); var $require_module=array("categorie");
var $picto='contact'; var $picto='company';
var $db; var $db;
// CHANGE THIS: Constructor name must be called mailing_xxx with xxx=name of your selector // CHANGE THIS: Constructor name must be called mailing_xxx with xxx=name of your selector
function mailing_categories($DB) function mailing_categories($DB)
@ -54,15 +52,21 @@ class mailing_kiwi extends MailingTargets
*/ */
function add_to_target($mailing_id,$filtersarray=array()) function add_to_target($mailing_id,$filtersarray=array())
{ {
$cibles = array(); global $langs;
$cibles = array();
// CHANGE THIS // CHANGE THIS
// Select the contacts from category // Select the contacts from category
$sql = "SELECT s.rowid as id, s.email as email, s.nom as name, llx_categorie.label, null as fk_contact, null as firstname $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname,";
FROM llx_societe as s if ($_POST['filter']) $sql.= " llx_categorie.label as label";
LEFT JOIN llx_categorie_societe ON llx_categorie_societe.fk_societe=s.rowid else $sql.=" null as label";
LEFT JOIN llx_categorie ON llx_categorie.rowid = llx_categorie_societe.fk_categorie $sql.= " FROM llx_societe as s";
WHERE llx_categorie.rowid='".$_POST['filter']."'"; if ($_POST['filter']) $sql.= " LEFT JOIN llx_categorie_societe ON llx_categorie_societe.fk_societe=s.rowid";
if ($_POST['filter']) $sql.= " LEFT JOIN llx_categorie ON llx_categorie.rowid = llx_categorie_societe.fk_categorie";
$sql.= " WHERE s.email != ''";
if ($_POST['filter']) $sql.= " AND llx_categorie.rowid='".$_POST['filter']."'";
$sql.= " ORDER BY s.email";
// Stocke destinataires dans cibles // Stocke destinataires dans cibles
$result=$this->db->query($sql); $result=$this->db->query($sql);
@ -85,6 +89,7 @@ class mailing_kiwi extends MailingTargets
'fk_contact' => $obj->fk_contact, 'fk_contact' => $obj->fk_contact,
'name' => $obj->name, 'name' => $obj->name,
'firstname' => $obj->firstname, 'firstname' => $obj->firstname,
'other' => ($obj->label?$langs->transnoentities("Category").'='.$obj->label:''),
'url' => $this->url($obj->id) 'url' => $this->url($obj->id)
); );
$old = $obj->email; $old = $obj->email;
@ -101,11 +106,11 @@ class mailing_kiwi extends MailingTargets
return -1; return -1;
} }
return parent::add_to_target($mailing_id, $cibles); return parent::add_to_target($mailing_id, $cibles);
} }
/** /**
* \brief On the main mailing area, there is a box with statistics. * \brief On the main mailing area, there is a box with statistics.
* If you want to add a line in this report you must provide an * If you want to add a line in this report you must provide an
@ -116,7 +121,7 @@ class mailing_kiwi extends MailingTargets
function getSqlArrayForStats() function getSqlArrayForStats()
{ {
// CHANGE THIS: Optionnal // CHANGE THIS: Optionnal
//var $statssql=array(); //var $statssql=array();
//$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL";
return array(); return array();
@ -131,9 +136,15 @@ class mailing_kiwi extends MailingTargets
*/ */
function getNbOfRecipients() function getNbOfRecipients()
{ {
return '?'; $sql = "SELECT count(distinct(s.email)) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.email != ''";
// La requete doit retourner un champ "nb" pour etre comprise
// par parent::getNbOfRecipients
return parent::getNbOfRecipients($sql);
} }
/** /**
* \brief This is to add a form filter to provide variant of selector * \brief This is to add a form filter to provide variant of selector
* If used, the HTML select must be called "filter" * If used, the HTML select must be called "filter"
@ -142,10 +153,11 @@ class mailing_kiwi extends MailingTargets
function formFilter() function formFilter()
{ {
global $langs; global $langs;
$s=''; $s='';
$s.='<select name="filter" class="flat">'; $s.='<select name="filter" class="flat">';
$s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
# Show categories # Show categories
$sql = "SELECT rowid, label, type"; $sql = "SELECT rowid, label, type";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie";
@ -175,8 +187,8 @@ class mailing_kiwi extends MailingTargets
return $s; return $s;
} }
/** /**
* \brief Can include an URL link on each record provided by selector * \brief Can include an URL link on each record provided by selector
* shown on target page. * shown on target page.
@ -184,9 +196,11 @@ class mailing_kiwi extends MailingTargets
*/ */
function url($id) function url($id)
{ {
// CHANGE THIS: Optionnal //$companystatic=new Societe($this->db);
//$companystatic->id=$id;
return ''; //$companystatic->nom='';
//return $companystatic->getNomUrl(1); // Url too long
return '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$id.'">'.img_object('',"company").'</a>';
} }
} }

View File

@ -43,7 +43,7 @@ class MailingTargets
{ {
$this->db=$DB; $this->db=$DB;
} }
/** \brief Renvoi un exemple de numérotation /** \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é * \return string Retourne la traduction de la clé MailingModuleDescXXX ou XXX nom du module, ou $this->desc si non trouvé
*/ */
@ -52,7 +52,7 @@ class MailingTargets
global $langs; global $langs;
$langs->load("mails"); $langs->load("mails");
$transstring="MailingModuleDesc".$this->name; $transstring="MailingModuleDesc".$this->name;
if ($langs->trans($transstring) != $transstring) return $langs->trans($transstring); if ($langs->trans($transstring) != $transstring) return $langs->trans($transstring);
else return $this->desc; else return $this->desc;
} }
@ -93,7 +93,7 @@ class MailingTargets
{ {
return ''; return '';
} }
/** /**
* \brief Met a jour nombre de destinataires * \brief Met a jour nombre de destinataires
* \param mailing_id Id du mailing concerné * \param mailing_id Id du mailing concerné
@ -109,7 +109,7 @@ class MailingTargets
{ {
$obj=$this->db->fetch_object($result); $obj=$this->db->fetch_object($result);
$nb=$obj->nb; $nb=$obj->nb;
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing"; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing";
$sql .= " SET nbemail = ".$nb." WHERE rowid = ".$mailing_id; $sql .= " SET nbemail = ".$nb." WHERE rowid = ".$mailing_id;
if (!$this->db->query($sql)) if (!$this->db->query($sql))
@ -133,9 +133,9 @@ class MailingTargets
*/ */
function add_to_target($mailing_id, $cibles) function add_to_target($mailing_id, $cibles)
{ {
$this->db->begin(); $this->db->begin();
// Insère destinataires de cibles dans table // Insert emailing targest from array into database
$j = 0; $j = 0;
$num = sizeof($cibles); $num = sizeof($cibles);
for ($i = 0 ; $i < $num ; $i++) for ($i = 0 ; $i < $num ; $i++)
@ -143,12 +143,13 @@ class MailingTargets
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " (fk_mailing,"; $sql .= " (fk_mailing,";
$sql .= " fk_contact,"; $sql .= " fk_contact,";
$sql .= " nom, prenom, email, url)"; $sql .= " nom, prenom, email, other, url)";
$sql .= " VALUES (".$mailing_id.","; $sql .= " VALUES (".$mailing_id.",";
$sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .","; $sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .",";
$sql .= "'".addslashes($cibles[$i]['name'])."',"; $sql .= "'".addslashes($cibles[$i]['name'])."',";
$sql .= "'".addslashes($cibles[$i]['firstname'])."',"; $sql .= "'".addslashes($cibles[$i]['firstname'])."',";
$sql .= "'".addslashes($cibles[$i]['email'])."',"; $sql .= "'".addslashes($cibles[$i]['email'])."',";
$sql .= "'".addslashes($cibles[$i]['other'])."',";
$sql .= "'".addslashes($cibles[$i]['url'])."')"; $sql .= "'".addslashes($cibles[$i]['url'])."')";
$result=$this->db->query($sql); $result=$this->db->query($sql);

View File

@ -106,11 +106,11 @@ class mailing_peche extends MailingTargets
function add_to_target($mailing_id,$filtersarray=array()) function add_to_target($mailing_id,$filtersarray=array())
{ {
global $conf,$langs,$_FILES; global $conf,$langs,$_FILES;
$cibles = array(); $cibles = array();
$upload_dir=$conf->mailings->dir_temp; $upload_dir=$conf->mailings->dir_temp;
// Save file // Save file
if (! is_dir($upload_dir)) create_exdir($upload_dir); if (! is_dir($upload_dir)) create_exdir($upload_dir);
@ -120,16 +120,16 @@ class mailing_peche extends MailingTargets
if ($result > 0) if ($result > 0)
{ {
$cpt=0; $cpt=0;
//$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>'; //$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES); //print_r($_FILES);
$file=$upload_dir . "/" . $_FILES['username']['name']; $file=$upload_dir . "/" . $_FILES['username']['name'];
$handle = @fopen($file, "r"); $handle = @fopen($file, "r");
if ($handle) if ($handle)
{ {
$i = 0; $i = 0;
$j = 0; $j = 0;
$old = ''; $old = '';
while (!feof($handle)) while (!feof($handle))
{ {
@ -139,6 +139,7 @@ class mailing_peche extends MailingTargets
$email=$tab[0]; $email=$tab[0];
$name=$tab[1]; $name=$tab[1];
$firstname=$tab[2]; $firstname=$tab[2];
$other=$tab[3];
if (! empty($buffer)) if (! empty($buffer))
{ {
//print 'xx'.strlen($buffer).empty($buffer)."<br>\n"; //print 'xx'.strlen($buffer).empty($buffer)."<br>\n";
@ -151,13 +152,14 @@ class mailing_peche extends MailingTargets
'email' => $email, 'email' => $email,
'name' => $name, 'name' => $name,
'firstname' => $firstname, 'firstname' => $firstname,
'other' => $other,
'url' => $this->url($id) 'url' => $this->url($id)
); );
$old = $email; $old = $email;
$j++; $j++;
} }
} }
else else
{ {
$i++; $i++;
$langs->load("errors"); $langs->load("errors");
@ -166,8 +168,8 @@ class mailing_peche extends MailingTargets
} }
} }
fclose($handle); fclose($handle);
if ($i > 0) if ($i > 0)
{ {
return -$i; return -$i;
} }
@ -177,7 +179,7 @@ class mailing_peche extends MailingTargets
$this->error = $langs->trans("ErrorFaildToOpenFile"); $this->error = $langs->trans("ErrorFaildToOpenFile");
return -1; return -1;
} }
dolibarr_syslog(get_class($this)."::add_to_target mailing ".$cpt." targets found"); dolibarr_syslog(get_class($this)."::add_to_target mailing ".$cpt." targets found");
} }
else if ($result < 0) else if ($result < 0)

View File

@ -36,13 +36,13 @@ include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php'
class mailing_poire extends MailingTargets class mailing_poire extends MailingTargets
{ {
var $name='ContactCompanies'; // Identifiant du module mailing var $name='ContactCompanies'; // Identifiant du module mailing
var $desc='Contacts des societes'; // Libellé utilisé si aucune traduction pour MailingModuleDescXXX ou XXX=name trouvée var $desc='Contacts des tiers (prospects, clients, fournisseurs...)'; // Libellé utilisé si aucune traduction pour MailingModuleDescXXX ou XXX=name trouvée
var $require_module=array("commercial"); // Module mailing actif si modules require_module actifs var $require_module=array("commercial"); // Module mailing actif si modules require_module actifs
var $require_admin=0; // Module mailing actif pour user admin ou non var $require_admin=0; // Module mailing actif pour user admin ou non
var $picto='contact'; var $picto='contact';
var $db; var $db;
function mailing_poire($DB) function mailing_poire($DB)
{ {
@ -61,8 +61,8 @@ class mailing_poire extends MailingTargets
return $statssql; return $statssql;
} }
/* /**
* \brief Return here number of distinct emails returned by your selector. * \brief Return here number of distinct emails returned by your selector.
* For example if this selector is used to extract 500 different * For example if this selector is used to extract 500 different
* emails from a text file, this function must return 500. * emails from a text file, this function must return 500.
@ -78,10 +78,10 @@ class mailing_poire extends MailingTargets
// La requete doit retourner un champ "nb" pour etre comprise // La requete doit retourner un champ "nb" pour etre comprise
// par parent::getNbOfRecipients // par parent::getNbOfRecipients
return parent::getNbOfRecipients($sql); return parent::getNbOfRecipients($sql);
} }
/** /**
* \brief Affiche formulaire de filtre qui apparait dans page de selection * \brief Affiche formulaire de filtre qui apparait dans page de selection
* des destinataires de mailings * des destinataires de mailings
@ -93,7 +93,7 @@ class mailing_poire extends MailingTargets
$langs->load("companies"); $langs->load("companies");
$langs->load("commercial"); $langs->load("commercial");
$langs->load("suppliers"); $langs->load("suppliers");
$s=''; $s='';
$s.='<select name="filter" class="flat">'; $s.='<select name="filter" class="flat">';
$s.='<option value="all">'.$langs->trans("ContactsAllShort").'</option>'; $s.='<option value="all">'.$langs->trans("ContactsAllShort").'</option>';
@ -123,8 +123,8 @@ class mailing_poire extends MailingTargets
$s.='</select>'; $s.='</select>';
return $s; return $s;
} }
/** /**
* \brief Renvoie url lien vers fiche de la source du destinataire du mailing * \brief Renvoie url lien vers fiche de la source du destinataire du mailing
* \return string Url lien * \return string Url lien
@ -133,8 +133,8 @@ class mailing_poire extends MailingTargets
{ {
return '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$id.'">'.img_object('',"contact").'</a>'; return '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$id.'">'.img_object('',"contact").'</a>';
} }
/** /**
* \brief Ajoute destinataires dans table des cibles * \brief Ajoute destinataires dans table des cibles
* \param mailing_id Id du mailing concerné * \param mailing_id Id du mailing concerné
@ -143,7 +143,9 @@ class mailing_poire extends MailingTargets
*/ */
function add_to_target($mailing_id,$filtersarray=array()) function add_to_target($mailing_id,$filtersarray=array())
{ {
$cibles = array(); global $langs;
$cibles = array();
# List prospects levels # List prospects levels
$prospectlevel=array(); $prospectlevel=array();
@ -165,12 +167,14 @@ class mailing_poire extends MailingTargets
} }
else dolibarr_print_error($this->db); else dolibarr_print_error($this->db);
// La requete doit retourner: id, email, fk_contact, name, firstname // La requete doit retourner: id, email, fk_contact, name, firstname, other
$sql = "SELECT c.rowid as id, c.email as email, c.rowid as fk_contact, c.name as name, c.firstname as firstname"; $sql = "SELECT c.rowid as id, c.email as email, c.rowid as fk_contact,";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql.= " c.name as name, c.firstname as firstname, c.civilite,";
$sql .= ", ".MAIN_DB_PREFIX."societe as s"; $sql.= " s.nom as companyname";
$sql .= " WHERE s.rowid = c.fk_soc"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c,";
$sql .= " AND c.email != ''"; $sql.= " ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE s.rowid = c.fk_soc";
$sql.= " AND c.email != ''";
foreach($filtersarray as $key) foreach($filtersarray as $key)
{ {
if ($key == 'prospects') $sql.= " AND s.client=2"; if ($key == 'prospects') $sql.= " AND s.client=2";
@ -179,7 +183,7 @@ class mailing_poire extends MailingTargets
if ($key == 'customers') $sql.= " AND s.client=1"; if ($key == 'customers') $sql.= " AND s.client=1";
if ($key == 'suppliers') $sql.= " AND s.fournisseur=1"; if ($key == 'suppliers') $sql.= " AND s.fournisseur=1";
} }
$sql .= " ORDER BY c.email"; $sql.= " ORDER BY c.email";
//print "x".$sql; //print "x".$sql;
// Stocke destinataires dans cibles // Stocke destinataires dans cibles
@ -198,11 +202,15 @@ class mailing_poire extends MailingTargets
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($old <> $obj->email) if ($old <> $obj->email)
{ {
$cibles[$j] = array( $other='';
if ($obj->companyname) { if ($other) $other.=';'; $other.=$langs->transnoentities("ThirdParty").'='.$obj->companyname; }
if ($obj->civilite) { if ($other) $other.=';'; $other.=$langs->transnoentities("Civility".$obj->civilite); }
$cibles[$j] = array(
'email' => $obj->email, 'email' => $obj->email,
'fk_contact' => $obj->fk_contact, 'fk_contact' => $obj->fk_contact,
'name' => $obj->name, 'name' => $obj->name,
'firstname' => $obj->firstname, 'firstname' => $obj->firstname,
'other' => $other,
'url' => $this->url($obj->id) 'url' => $this->url($obj->id)
); );
$old = $obj->email; $old = $obj->email;

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -62,7 +62,7 @@ class mailing_pomme extends MailingTargets
return $statssql; return $statssql;
} }
/* /*
* \brief Return here number of distinct emails returned by your selector. * \brief Return here number of distinct emails returned by your selector.
* For example if this selector is used to extract 500 different * For example if this selector is used to extract 500 different
@ -77,10 +77,10 @@ class mailing_pomme extends MailingTargets
// La requete doit retourner un champ "nb" pour etre comprise // La requete doit retourner un champ "nb" pour etre comprise
// par parent::getNbOfRecipients // par parent::getNbOfRecipients
return parent::getNbOfRecipients($sql); return parent::getNbOfRecipients($sql);
} }
/** /**
* \brief Renvoie url lien vers fiche de la source du destinataire du mailing * \brief Renvoie url lien vers fiche de la source du destinataire du mailing
* \return string Url lien * \return string Url lien
@ -90,7 +90,7 @@ class mailing_pomme extends MailingTargets
return '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$id.'">'.img_object('',"user").'</a>'; return '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$id.'">'.img_object('',"user").'</a>';
} }
/** /**
* \brief Ajoute destinataires dans table des cibles * \brief Ajoute destinataires dans table des cibles
* \param mailing_id Id du mailing concerné * \param mailing_id Id du mailing concerné
@ -99,13 +99,16 @@ class mailing_pomme extends MailingTargets
*/ */
function add_to_target($mailing_id,$filtersarray=array()) function add_to_target($mailing_id,$filtersarray=array())
{ {
global $langs;
$cibles = array(); $cibles = array();
// La requete doit retourner: id, email, fk_contact, name, firstname // La requete doit retourner: id, email, fk_contact, name, firstname
$sql = "SELECT u.rowid as id, u.email as email, null as fk_contact, u.name as name, u.firstname as firstname"; $sql = "SELECT u.rowid as id, u.email as email, null as fk_contact,";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " u.name as name, u.firstname as firstname, u.login, u.office_phone";
$sql .= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " ORDER BY u.email"; $sql.= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test
$sql.= " ORDER BY u.email";
// Stocke destinataires dans cibles // Stocke destinataires dans cibles
$result=$this->db->query($sql); $result=$this->db->query($sql);
@ -128,6 +131,7 @@ class mailing_pomme extends MailingTargets
'fk_contact' => $obj->fk_contact, 'fk_contact' => $obj->fk_contact,
'name' => $obj->name, 'name' => $obj->name,
'firstname' => $obj->firstname, 'firstname' => $obj->firstname,
'other' => $langs->transnoentities("Login").'='.$obj->login.';'.$langs->transnoentities("PhonePro").'='.$obj->office_phone,
'url' => $this->url($obj->id) 'url' => $this->url($obj->id)
); );
$old = $obj->email; $old = $obj->email;

View File

@ -162,7 +162,7 @@ if (is_readable($conffile) && filesize($conffile) > 8)
} }
else else
{ {
// Si non on le crée // Si non on le crée
dolibarr_install_syslog("check: we try to creat conf file '$conffile'"); dolibarr_install_syslog("check: we try to creat conf file '$conffile'");
$confexists=0; $confexists=0;
@ -250,7 +250,7 @@ else
print $langs->trans("ChooseYourSetupMode"); print $langs->trans("ChooseYourSetupMode");
print '<table width="100%" cellspacing="1" cellpadding="4" border="1">'; print '<table width="100%" cellspacing="1" cellpadding="4" border="1">';
print '<tr><td nowrap="nowrap"><b>'.$langs->trans("FreshInstall").'</b></td><td>'; print '<tr><td nowrap="nowrap"><b>'.$langs->trans("FreshInstall").'</b></td><td>';
print $langs->trans("FreshInstallDesc").'</td>'; print $langs->trans("FreshInstallDesc").'</td>';
print '<td align="center">'; print '<td align="center">';
@ -269,7 +269,7 @@ else
array('from'=>'2.1.0', 'to'=>'2.2.0'), array('from'=>'2.1.0', 'to'=>'2.2.0'),
array('from'=>'2.2.0', 'to'=>'2.4.0'), array('from'=>'2.2.0', 'to'=>'2.4.0'),
array('from'=>'2.4.0', 'to'=>'2.5.0'), array('from'=>'2.4.0', 'to'=>'2.5.0'),
//array('from'=>'2.5.0', 'to'=>'2.6.0') array('from'=>'2.5.0', 'to'=>'2.6.0')
); );
# Upgrade lines # Upgrade lines
foreach ($migrationscript as $migarray) foreach ($migrationscript as $migarray)

View File

@ -63,8 +63,8 @@ NoAttachedFiles=No attached files
MailingModuleDescContactCompanies=Contacts of all third parties (customer, prospect, supplier, ...) MailingModuleDescContactCompanies=Contacts of all third parties (customer, prospect, supplier, ...)
MailingModuleDescDolibarrUsers=All Dolibarr users with emails MailingModuleDescDolibarrUsers=All Dolibarr users with emails
MailingModuleDescFundationMembers=Fundation members with emails MailingModuleDescFundationMembers=Fundation members with emails
MailingModuleDescEmailsFromFile=EMails from a text file (email;name;surname) MailingModuleDescEmailsFromFile=EMails from a text file (email;name;surname;comments)
MailingModuleDescContactsCategories=Contacts of all third parties (by category) MailingModuleDescContactsCategories=Third parties with emails (by category)
LineInFile=Line %s in file LineInFile=Line %s in file
RecipientSelectionModules=Defined requests for recipients' selection RecipientSelectionModules=Defined requests for recipients' selection

View File

@ -304,6 +304,7 @@ and=and
or=or or=or
Other=Other Other=Other
Others=Others Others=Others
OtherInformations=Other informations
Quantity=Quantity Quantity=Quantity
Qty=Qty Qty=Qty
ChangedBy=Changed by ChangedBy=Changed by

View File

@ -63,8 +63,8 @@ NoAttachedFiles=Aucun fichier joint
MailingModuleDescContactCompanies=Contacts des tiers (prospects, clients, fournisseurs...) MailingModuleDescContactCompanies=Contacts des tiers (prospects, clients, fournisseurs...)
MailingModuleDescDolibarrUsers=Utilisateurs de Dolibarr avec e-mail MailingModuleDescDolibarrUsers=Utilisateurs de Dolibarr avec e-mail
MailingModuleDescFundationMembers=Adhérents avec e-mail MailingModuleDescFundationMembers=Adhérents avec e-mail
MailingModuleDescEmailsFromFile=EMails issus d'un fichier texte (email;nom;prenom) MailingModuleDescEmailsFromFile=EMails issus d'un fichier texte (email;nom;prenom;divers)
MailingModuleDescContactsCategories=Contacts des tiers (par categorie) MailingModuleDescContactsCategories=Tiers avec e-mail (par categorie)
LineInFile=Ligne %s du fichier LineInFile=Ligne %s du fichier
RecipientSelectionModules=Modules de sélection des destinataires RecipientSelectionModules=Modules de sélection des destinataires

View File

@ -305,6 +305,7 @@ and=et
or=ou or=ou
Other=Autre Other=Autre
Others=Autres Others=Autres
OtherInformations=Autres informations
Quantity=Quantité Quantity=Quantité
Qty=Qté Qty=Qté
ChangedBy=Modifié par ChangedBy=Modifié par

View File

@ -30,5 +30,7 @@ ALTER TABLE llx_bank ADD INDEX idx_bank_fk_account(fk_account);
ALTER TABLE llx_bank ADD INDEX idx_bank_rappro(rappro); ALTER TABLE llx_bank ADD INDEX idx_bank_rappro(rappro);
ALTER TABLE llx_mailing_cibles add column other varchar(255) NULL, ALTER TABLE llx_mailing_cibles add column other varchar(255) NULL;
ALTER TABLE llx_mailing_cibles ADD INDEX idx_mailing_cibles_email (email);

View File

@ -1,5 +1,5 @@
-- =================================================================== -- ===================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> -- Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- --
-- This program is free software; you can redistribute it and/or modify -- 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 -- it under the terms of the GNU General Public License as published by
@ -20,3 +20,6 @@
ALTER TABLE llx_mailing_cibles ADD UNIQUE uk_mailing_cibles (fk_mailing, email); ALTER TABLE llx_mailing_cibles ADD UNIQUE uk_mailing_cibles (fk_mailing, email);
ALTER TABLE llx_mailing_cibles ADD INDEX idx_mailing_cibles_email (email);

View File

@ -1,5 +1,6 @@
-- ======================================================================== -- ========================================================================
-- Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- --
-- This program is free software; you can redistribute it and/or modify -- 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 -- it under the terms of the GNU General Public License as published by