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"];
@ -178,7 +178,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
$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"));
@ -231,7 +231,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
} }
} }
// Si le module mailing est qualifi<EFBFBD> // Si le module mailing est qualifie
if ($qualified) if ($qualified)
{ {
$var = !$var; $var = !$var;
@ -241,7 +241,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
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>';
/* /*
@ -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)."%'";
@ -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)
@ -360,15 +361,23 @@ 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").'">';
@ -386,10 +395,11 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
$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)
@ -412,7 +422,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
} }
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>";

View File

@ -40,13 +40,19 @@ $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'
); );
@ -115,7 +121,7 @@ if ($_POST["action"] == 'sendallconfirmed')
// 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;
@ -129,7 +135,7 @@ if ($_POST["action"] == 'sendallconfirmed')
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)
{ {
@ -150,11 +156,18 @@ if ($_POST["action"] == 'sendallconfirmed')
$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
$other=split(';',$obj->other);
$other1=$other[0];
$other2=$other[1];
$other3=$other[3];
$substitutionarray=array( $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;
@ -192,7 +205,7 @@ if ($_POST["action"] == 'sendallconfirmed')
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)
{ {
@ -207,7 +220,7 @@ if ($_POST["action"] == 'sendallconfirmed')
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)
{ {
@ -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>';
@ -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
@ -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();
@ -106,7 +112,7 @@ if ($result)
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

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;
@ -60,11 +60,11 @@ 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 -----

View File

@ -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,24 +18,22 @@
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;
@ -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;
@ -131,7 +136,13 @@ 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);
} }
/** /**
@ -145,6 +156,7 @@ class mailing_kiwi extends MailingTargets
$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";
@ -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

@ -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

@ -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,6 +152,7 @@ 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;

View File

@ -36,7 +36,7 @@ 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';
@ -62,7 +62,7 @@ class mailing_poire extends MailingTargets
} }
/* /**
* \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.
@ -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
@ -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

@ -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