Skip to content

Commit

Permalink
Merge pull request #1201 from FHenry/3.4
Browse files Browse the repository at this point in the history
Fix: Mailing module : if an email is already in destinaires list all
  • Loading branch information
eldy committed Aug 28, 2013
2 parents cfa7b6e + cc90c92 commit e741ce9
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -17,6 +17,7 @@ Fix: Link "Show all supplier invoice" on suplier card not working
Fix: [ bug #1039 ] Pre-defined invoices conversion
Fix: If only service module is activated, it's impossible to delete service
Fix: [ bug #1043 ] Bad interventions ref numbering
Fix: Mailing module : if an email is already in destinaires list all other email from selector was not inserted

***** ChangeLog for 3.4 compared to 3.3.* *****
For users:
Expand Down
3 changes: 2 additions & 1 deletion htdocs/core/modules/mailings/contacts1.modules.php
Expand Up @@ -202,8 +202,9 @@ function add_to_target($mailing_id,$filtersarray=array())
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc";
$sql.= " WHERE c.entity IN (".getEntity('societe', 1).")";
$sql.= " AND c.email != ''";
$sql.= " AND c.email <> ''";
$sql.= " AND c.no_email = 0";
$sql.= " AND c.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
foreach($filtersarray as $key)
{
if ($key == 'prospects') $sql.= " AND s.client=2";
Expand Down
3 changes: 2 additions & 1 deletion htdocs/core/modules/mailings/contacts2.modules.php
Expand Up @@ -84,9 +84,10 @@ function add_to_target($mailing_id,$filtersarray=array())
$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.email <> ''"; // Note that null != '' is false
$sql.= " AND sp.no_email = 0";
//$sql.= " AND sp.poste != ''";
$sql.= " AND sp.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
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
3 changes: 2 additions & 1 deletion htdocs/core/modules/mailings/contacts3.modules.php
Expand Up @@ -83,9 +83,10 @@ function add_to_target($mailing_id,$filtersarray=array())
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc";
if ($filtersarray[0] <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie as c";
if ($filtersarray[0] <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as cs";
$sql.= " WHERE sp.email != ''"; // Note that null != '' is false
$sql.= " WHERE sp.email <> ''"; // Note that null != '' is false
$sql.= " AND sp.no_email = 0";
$sql.= " AND sp.entity IN (".getEntity('societe', 1).")";
$sql.= " AND sp.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
if ($filtersarray[0] <> 'all') $sql.= " AND cs.fk_categorie = c.rowid";
if ($filtersarray[0] <> 'all') $sql.= " AND cs.fk_societe = sp.fk_soc";
if ($filtersarray[0] <> 'all') $sql.= " AND c.label = '".$this->db->escape($filtersarray[0])."'";
Expand Down
3 changes: 2 additions & 1 deletion htdocs/core/modules/mailings/fraise.modules.php
Expand Up @@ -169,7 +169,8 @@ function add_to_target($mailing_id,$filtersarray=array())
$sql.= " a.lastname, a.firstname,";
$sql.= " a.datefin, a.civilite, a.login, a.societe"; // Other fields
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql.= " WHERE a.email IS NOT NULL";
$sql.= " WHERE a.email <> ''"; // Note that null != '' is false
$sql.= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
if (isset($_POST["filter"]) && $_POST["filter"] == '-1') $sql.= " AND a.statut=-1";
if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql.= " AND a.statut=1 AND a.datefin >= '".$this->db->idate($now)."'";
if (isset($_POST["filter"]) && $_POST["filter"] == '1b') $sql.= " AND a.statut=1 AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')";
Expand Down
3 changes: 2 additions & 1 deletion htdocs/core/modules/mailings/pomme.modules.php
Expand Up @@ -150,8 +150,9 @@ function add_to_target($mailing_id,$filtersarray=array())
$sql = "SELECT u.rowid as id, u.email as email, null as fk_contact,";
$sql.= " u.lastname as name, u.firstname as firstname, u.login, u.office_phone";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test
$sql.= " WHERE u.email <> ''"; // u.email IS NOT NULL est implicite dans ce test
$sql.= " AND u.entity IN (0,".$conf->entity.")";
$sql.= " AND u.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
foreach($filtersarray as $key)
{
if ($key == '1') $sql.= " AND u.statut=1";
Expand Down
9 changes: 6 additions & 3 deletions htdocs/core/modules/mailings/thirdparties.modules.php
Expand Up @@ -63,23 +63,26 @@ function add_to_target($mailing_id,$filtersarray=array())
{
$sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, null as label";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE s.email != ''";
$sql.= " WHERE s.email <> ''";
$sql.= " AND s.entity IN (".getEntity('societe', 1).")";
$sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
}
else
{
$sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_societe as cs, ".MAIN_DB_PREFIX."categorie as c";
$sql.= " WHERE s.email != ''";
$sql.= " WHERE s.email <> ''";
$sql.= " AND s.entity IN (".getEntity('societe', 1).")";
$sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
$sql.= " AND cs.fk_societe = s.rowid";
$sql.= " AND c.rowid = cs.fk_categorie";
$sql.= " AND c.rowid='".$this->db->escape($_POST['filter'])."'";
$sql.= " UNION ";
$sql.= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_fournisseur as cs, ".MAIN_DB_PREFIX."categorie as c";
$sql.= " WHERE s.email != ''";
$sql.= " WHERE s.email <> ''";
$sql.= " AND s.entity IN (".getEntity('societe', 1).")";
$sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
$sql.= " AND cs.fk_societe = s.rowid";
$sql.= " AND c.rowid = cs.fk_categorie";
$sql.= " AND c.rowid='".$this->db->escape($_POST['filter'])."'";
Expand Down
Expand Up @@ -100,6 +100,7 @@ function add_to_target($mailing_id,$filtersarray=array())
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."product as p";
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
$sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
$sql.= " AND s.rowid = c.fk_soc AND cd.fk_contrat = c.rowid AND s.email != ''";
$sql.= " AND cd.statut= 4 AND cd.fk_product=p.rowid AND p.ref = '".$product."'";
$sql.= " AND cd.date_fin_validite < '".$this->db->idate($now)."'";
Expand Down

0 comments on commit e741ce9

Please sign in to comment.