fix #20690: add lang filter for companies

This commit is contained in:
Eric Seigne 2022-04-22 15:05:38 +02:00
parent d2ec1efb42
commit 72ac1fdfd2

View File

@ -79,6 +79,11 @@ class mailing_thirdparties extends MailingTargets
$sql .= " WHERE s.email <> ''";
$sql .= " AND s.entity IN (".getEntity('societe').")";
$sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
if (GETPOST('default_lang','alpha'))
{
$sql .= " AND s.default_lang LIKE '".GETPOST('default_lang','alpha')."%'";
}
}
else
{
@ -126,6 +131,13 @@ class mailing_thirdparties extends MailingTargets
$addDescription .= $langs->trans("Disabled");
}
}
if (GETPOST('default_lang','alpha'))
{
$addFilter .= " AND s.default_lang LIKE '".GETPOST('default_lang','alpha')."%'";
$addDescription = $langs->trans('DefaultLang')."=";
}
$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 <> ''";
@ -147,7 +159,6 @@ class mailing_thirdparties extends MailingTargets
$sql .= $addFilter;
}
$sql .= " ORDER BY email";
// Stock recipients emails into targets table
$result = $this->db->query($sql);
if ($result)
@ -314,6 +325,14 @@ class mailing_thirdparties extends MailingTargets
$s .= '<option value="1" selected>'.$langs->trans("Enabled").'</option>';
$s .= '<option value="0">'.$langs->trans("Disabled").'</option>';
$s .= '</select>';
//Choose language
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
$formadmin = new FormAdmin($this->db);
$s .= $langs->trans("DefaultLang").': ';
$s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang', 0, 0, 1, 0, 0, '', 0, 0, 0, null, 1);
return $s;
}