Skip to content

Commit

Permalink
Fix: filter on all contacts, not just those related to a company
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Apr 10, 2013
1 parent ef4004c commit 740bc2a
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions htdocs/core/modules/mailings/contacts2.modules.php
Expand Up @@ -81,13 +81,12 @@ function add_to_target($mailing_id,$filtersarray=array())
$sql = "SELECT sp.rowid as id, sp.email as email, sp.rowid as fk_contact,";
$sql.= " sp.lastname, sp.firstname as firstname, sp.civilite,";
$sql.= " s.nom as companyname";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE s.rowid = sp.fk_soc";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc";
$sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")";
$sql.= " AND sp.email != ''"; // Note that null != '' is false
$sql.= " AND sp.no_email = 0";
//$sql.= " AND sp.poste != ''";
$sql.= " AND sp.entity IN (".getEntity('societe', 1).")";
if ($filtersarray[0]<>'all') $sql.= " AND sp.poste ='".$this->db->escape($filtersarray[0])."'";
$sql.= " ORDER BY sp.lastname, sp.firstname";
$resql = $this->db->query($sql);
Expand Down Expand Up @@ -163,10 +162,9 @@ function getNbOfRecipients($sql='')
// Number with a filter are show in the combo list for each filter.
// If we want a filter "a position is defined", we must add it into formFilter
$sql = "SELECT count(distinct(sp.email)) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE s.rowid = sp.fk_soc";
$sql.= " AND sp.entity IN (".getEntity('societe', 1).")";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc";
$sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")";
$sql.= " AND sp.email != ''"; // Note that null != '' is false
$sql.= " AND sp.no_email = 0";
//$sql.= " AND sp.poste != ''";
Expand All @@ -188,10 +186,9 @@ function formFilter()
$langs->load("companies");

$sql = "SELECT sp.poste, count(distinct(sp.email)) AS nb";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE s.rowid = sp.fk_soc";
$sql.= " AND sp.entity IN (".getEntity('societe', 1).")";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc";
$sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")";
$sql.= " AND sp.email != ''"; // Note that null != '' is false
$sql.= " AND sp.no_email = 0";
$sql.= " AND (sp.poste IS NOT NULL AND sp.poste != '')";
Expand Down

0 comments on commit 740bc2a

Please sign in to comment.