2005-03-15 09:51:03 +01:00
< ? php
/* Copyright ( C ) 2005 Laurent Destailleur < eldy @ users . sourceforge . net >
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
* or see http :// www . gnu . org /
*
* $Id $
* $Source $
*
*
* L 'utilisation d' adresses de courriers <EFBFBD> lectroniques dans les op<EFBFBD> rations
* de prospection commerciale est subordonn<EFBFBD> e au recueil du consentement
* pr<EFBFBD> alable des personnes concern<EFBFBD> es .
*
* Le dispositif juridique applicable a <EFBFBD> t<EFBFBD> introduit par l ' article 22 de
* la loi du 21 juin 2004 pour la confiance dans l ' <EFBFBD> conomie num<EFBFBD> rique .
*
* Les dispositions applicables sont d<EFBFBD> finies par les articles L . 34 - 5 du
* code des postes et des t<EFBFBD> l<EFBFBD> communications et L . 121 - 20 - 5 du code de la
* consommation . L ' application du principe du consentement pr<EFBFBD> alable en
* droit fran<EFBFBD> ais r<EFBFBD> sulte de la transposition de l ' article 13 de la Directive
* europ<EFBFBD> enne du 12 juillet 2002 <EFBFBD> Vie priv<EFBFBD> e et communications <EFBFBD> lectroniques <EFBFBD> .
*
*/
/**
\file htdocs / includes / modules / mailings / fraise . modules . php
\ingroup mailing
\brief Fichier de la classe permettant de g<EFBFBD> n<EFBFBD> rer la liste de destinataires Fraise
\version $Revision $
*/
include_once DOL_DOCUMENT_ROOT . '/includes/modules/mailings/modules_mailings.php' ;
/**
\class mailing_fraise
\brief Classe permettant de g<EFBFBD> n<EFBFBD> rer la liste des destinataires Fraise
*/
class mailing_fraise extends MailingTargets
{
2005-09-16 00:44:29 +02:00
var $name = 'FundationMembers' ; // Identifiant du module mailing
var $desc = 'Membres de l\'association' ; // Libell<6C> utilis<69> si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv<75> e
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
2005-03-15 09:51:03 +01:00
var $picto = 'user' ;
var $db ;
var $statssql = array ();
function mailing_fraise ( $DB )
{
global $langs ;
$langs -> load ( " members " );
$this -> db = $DB ;
// Liste des tableaux des stats espace mailing
2005-10-02 21:59:37 +02:00
$this -> statssql [ 0 ] = " SELECT ' " . addslashes ( $langs -> trans ( " FundationMembers " )) . " ' as label, count(*) as nb FROM " . MAIN_DB_PREFIX . " adherent where statut = 1 " ;
2005-03-15 09:51:03 +01:00
}
function getNbOfRecipients ()
{
// La requete doit retourner: nb
2005-04-07 01:23:48 +02:00
$sql = " SELECT count(distinct(a.email)) as nb " ;
2005-03-15 09:51:03 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " adherent as a " ;
2005-10-02 21:59:37 +02:00
$sql .= " WHERE a.email IS NOT NULL " ;
2005-03-15 09:51:03 +01:00
return parent :: getNbOfRecipients ( $sql );
}
2005-09-16 00:44:29 +02:00
/**
* \brief Affiche formulaire de filtre qui apparait dans page de selection
* des destinataires de mailings
* \return string Retourne zone select
*/
function formFilter ()
2005-03-15 09:51:03 +01:00
{
2005-09-16 00:44:29 +02:00
global $langs ;
2005-11-08 01:21:49 +01:00
$langs -> load ( " members " );
2005-09-16 00:44:29 +02:00
$s = '' ;
$s .= '<select name="filter" class="flat">' ;
2005-11-08 01:21:49 +01:00
$s .= '<option value="-1">' . $langs -> trans ( " MemberStatusShortDraft " ) . '</option>' ;
$s .= '<option value="1" selected="true">' . $langs -> trans ( " MemberStatusActive " ) . '</option>' ;
$s .= '<option value="0">' . $langs -> trans ( " MemberStatusResiliated " ) . '</option>' ;
2005-09-16 00:44:29 +02:00
$s .= '</select>' ;
return $s ;
}
/**
* \brief Renvoie url lien vers fiche de la source du destinataire du mailing
* \return string Url lien
*/
function url ( $id )
{
return '<a href="' . DOL_URL_ROOT . '/adherents/fiche.php?rowid=' . $id . '">' . img_object ( '' , " user " ) . '</a>' ;
}
/**
* \brief Ajoute destinataires dans table des cibles
* \param mailing_id Id du mailing concern<EFBFBD>
* \param filterarray Requete sql de selection des destinataires
* \return int < 0 si erreur , nb ajout si ok
*/
function add_to_target ( $mailing_id , $filtersarray = array ())
{
// 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 .= " FROM " . MAIN_DB_PREFIX . " adherent as a " ;
$sql .= " WHERE a.email IS NOT NULL " ;
foreach ( $filtersarray as $key )
{
if ( $key == - 1 ) $sql .= " AND a.statut=-1 " ;
if ( $key == 0 ) $sql .= " AND a.statut=0 " ;
if ( $key == 1 ) $sql .= " AND a.statut=1 " ;
}
$sql .= " ORDER BY a.email " ;
2005-03-15 09:51:03 +01:00
return parent :: add_to_target ( $mailing_id , $sql );
}
}
?>