diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 55cce13fbcf..691540d808f 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2018-2018 Andre Schild + * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This file is an example to follow to add your own email selector inside @@ -40,7 +41,8 @@ class mailing_thirdparties extends MailingTargets */ function __construct($db) { - global $conf; + global $conf, $langs; + $langs->load("companies"); $this->db=$db; } @@ -88,6 +90,51 @@ class mailing_thirdparties extends MailingTargets $sql.= " AND c.rowid = cs.fk_categorie"; $sql.= " AND c.rowid='".$this->db->escape($_POST['filter'])."'"; } + + $addDescription= ""; + if (isset($_POST["filter_client"]) && $_POST["filter_client"] <> '-1') + { + $sql.= " AND s.client=" . $_POST["filter_client"]; + $addDescription= $langs->trans('ProspectCustomer')."="; + if ($_POST["filter_client"] == 0) + { + $addDescription.= $langs->trans('NorProspectNorCustomer'); + } + else if ($_POST["filter_client"] == 1) + { + $addDescription.= $langs->trans('Customer'); + } + else if ($_POST["filter_client"] == 2) + { + $addDescription.= $langs->trans('Prospect'); + } + else if ($_POST["filter_client"] == 3) + { + $addDescription.= $langs->trans('ProspectCustomer'); + } + else + { + $addDescription.= "Unknown status ".$_POST["filter_client"]; + } + } + if (isset($_POST["filter_status"])) + { + if (strlen($addDescription) > 0) + { + $addDescription.= ";"; + } + $addDescription.= $langs->trans("Status")."="; + if ($_POST["filter_status"] == '1') + { + $sql.= " AND s.status=1"; + $addDescription.= $langs->trans("Enabled"); + } + else + { + $sql.= " AND s.status=0"; + $addDescription.= $langs->trans("Disabled"); + } + } $sql.= " ORDER BY email"; // Stock recipients emails into targets table @@ -106,12 +153,18 @@ class mailing_thirdparties extends MailingTargets $obj = $this->db->fetch_object($result); if ($old <> $obj->email) { + $otherTxt= ($obj->label?$langs->transnoentities("Category").'='.$obj->label:''); + if (strlen($addDescription) > 0 && strlen($otherTxt) > 0) + { + $otherTxt.= ";"; + } + $otherTxt.= $addDescription; $cibles[$j] = array( 'email' => $obj->email, 'fk_contact' => $obj->fk_contact, 'lastname' => $obj->name, // For a thirdparty, we must use name 'firstname' => '', // For a thirdparty, lastname is '' - 'other' => ($obj->label?$langs->transnoentities("Category").'='.$obj->label:''), + 'other' => $otherTxt, 'source_url' => $this->url($obj->id), 'source_id' => $obj->id, 'source_type' => 'thirdparty' @@ -227,6 +280,29 @@ class mailing_thirdparties extends MailingTargets dol_print_error($this->db); } + $s.=' '; + $s.= $langs->trans('ProspectCustomer'); + $s.=': '; + + $s.=$langs->trans("Status"); + $s.=': '; return $s;