Fix filter on email selector for thirdparties
This commit is contained in:
parent
3354a27a6f
commit
c94df95c23
@ -73,55 +73,53 @@ class mailing_thirdparties extends MailingTargets
|
||||
$cibles = array();
|
||||
|
||||
$addDescription = "";
|
||||
$addFilter = "";
|
||||
if (GETPOSTISSET("filter_client_thirdparties") && GETPOST("filter_client_thirdparties") <> '-1') {
|
||||
$addFilter .= " AND s.client=".((int) GETPOST("filter_client_thirdparties", 'int'));
|
||||
$addDescription = $langs->trans('ProspectCustomer')."=";
|
||||
if (GETPOST("filter_client_thirdparties") == 0) {
|
||||
$addDescription .= $langs->trans('NorProspectNorCustomer');
|
||||
} elseif (GETPOST("filter_client_thirdparties") == 1) {
|
||||
$addDescription .= $langs->trans('Customer');
|
||||
} elseif (GETPOST("filter_client_thirdparties") == 2) {
|
||||
$addDescription .= $langs->trans('Prospect');
|
||||
} elseif (GETPOST("filter_client_thirdparties") == 3) {
|
||||
$addDescription .= $langs->trans('ProspectCustomer');
|
||||
} else {
|
||||
$addDescription .= "Unknown status ".GETPOST("filter_client_thirdparties");
|
||||
}
|
||||
}
|
||||
if (GETPOSTISSET("filter_status")) {
|
||||
if (strlen($addDescription) > 0) {
|
||||
$addDescription .= ";";
|
||||
}
|
||||
$addDescription .= $langs->trans("Status")."=";
|
||||
if (GETPOST("filter_status") == '1') {
|
||||
$addFilter .= " AND s.status=1";
|
||||
$addDescription .= $langs->trans("Enabled");
|
||||
} else {
|
||||
$addFilter .= " AND s.status=0";
|
||||
$addDescription .= $langs->trans("Disabled");
|
||||
}
|
||||
}
|
||||
if (GETPOST('default_lang', 'alpha')) {
|
||||
$addFilter .= " AND s.default_lang LIKE '".$this->db->escape(GETPOST('default_lang', 'alpha'))."%'";
|
||||
$addDescription = $langs->trans('DefaultLang')."=";
|
||||
}
|
||||
if (GETPOST('filter_lang_thirdparties', 'alpha')) {
|
||||
$addFilter .= " AND s.default_lang LIKE '".$this->db->escape(GETPOST('filter_lang_thirdparties', 'alpha'))."%'";
|
||||
$addDescription = $langs->trans('DefaultLang')."=";
|
||||
}
|
||||
|
||||
// Select the third parties from category
|
||||
if (!GETPOST('filter')) {
|
||||
if (!GETPOST('filter_thirdparties') || GETPOST('filter_thirdparties') == '-1') {
|
||||
$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 .= " AND s.entity IN (".getEntity('societe').")";
|
||||
$sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")";
|
||||
if (GETPOST('default_lang', 'alpha')) {
|
||||
$sql .= " AND s.default_lang LIKE '".$this->db->escape(GETPOST('default_lang', 'alpha'))."%'";
|
||||
}
|
||||
$sql .= $addFilter;
|
||||
} else {
|
||||
$addFilter = "";
|
||||
if (GETPOSTISSET("filter_client") && GETPOST("filter_client") <> '-1') {
|
||||
$addFilter .= " AND s.client=".((int) GETPOST("filter_client", 'int'));
|
||||
$addDescription = $langs->trans('ProspectCustomer')."=";
|
||||
if (GETPOST("filter_client") == 0) {
|
||||
$addDescription .= $langs->trans('NorProspectNorCustomer');
|
||||
} elseif (GETPOST("filter_client") == 1) {
|
||||
$addDescription .= $langs->trans('Customer');
|
||||
} elseif (GETPOST("filter_client") == 2) {
|
||||
$addDescription .= $langs->trans('Prospect');
|
||||
} elseif (GETPOST("filter_client") == 3) {
|
||||
$addDescription .= $langs->trans('ProspectCustomer');
|
||||
} else {
|
||||
$addDescription .= "Unknown status ".GETPOST("filter_client");
|
||||
}
|
||||
}
|
||||
if (GETPOSTISSET("filter_status")) {
|
||||
if (strlen($addDescription) > 0) {
|
||||
$addDescription .= ";";
|
||||
}
|
||||
$addDescription .= $langs->trans("Status")."=";
|
||||
if (GETPOST("filter_status") == '1') {
|
||||
$addFilter .= " AND s.status=1";
|
||||
$addDescription .= $langs->trans("Enabled");
|
||||
} else {
|
||||
$addFilter .= " AND s.status=0";
|
||||
$addDescription .= $langs->trans("Disabled");
|
||||
}
|
||||
}
|
||||
if (GETPOST('default_lang', 'alpha')) {
|
||||
$addFilter .= " AND s.default_lang LIKE '".$this->db->escape(GETPOST('default_lang', 'alpha'))."%'";
|
||||
$addDescription = $langs->trans('DefaultLang')."=";
|
||||
}
|
||||
if (GETPOST('filter_lang_thirdparties', 'alpha')) {
|
||||
$addFilter .= " AND s.default_lang LIKE '".$this->db->escape(GETPOST('filter_lang_thirdparties', '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 <> ''";
|
||||
@ -129,8 +127,8 @@ class mailing_thirdparties extends MailingTargets
|
||||
$sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")";
|
||||
$sql .= " AND cs.fk_soc = s.rowid";
|
||||
$sql .= " AND c.rowid = cs.fk_categorie";
|
||||
if (GETPOST('filter', 'int') > 0) {
|
||||
$sql .= " AND c.rowid=".((int) GETPOST('filter', 'int'));
|
||||
if (GETPOST('filter_thirdparties', 'int') > 0) {
|
||||
$sql .= " AND c.rowid=".((int) GETPOST('filter_thirdparties', 'int'));
|
||||
}
|
||||
$sql .= $addFilter;
|
||||
$sql .= " UNION ";
|
||||
@ -141,13 +139,15 @@ class mailing_thirdparties extends MailingTargets
|
||||
$sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")";
|
||||
$sql .= " AND cs.fk_soc = s.rowid";
|
||||
$sql .= " AND c.rowid = cs.fk_categorie";
|
||||
if (GETPOST('filter', 'int') > 0) {
|
||||
$sql .= " AND c.rowid=".((int) GETPOST('filter', 'int'));
|
||||
if (GETPOST('filter_thirdparties', 'int') > 0) {
|
||||
$sql .= " AND c.rowid=".((int) GETPOST('filter_thirdparties', 'int'));
|
||||
}
|
||||
$sql .= $addFilter;
|
||||
}
|
||||
$sql .= " ORDER BY email";
|
||||
|
||||
//print $sql;exit;
|
||||
|
||||
// Stock recipients emails into targets table
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
@ -243,7 +243,8 @@ class mailing_thirdparties extends MailingTargets
|
||||
|
||||
$langs->load("companies");
|
||||
|
||||
$s = '<select id="filter_thirdparties" name="filter" class="flat">';
|
||||
// filter
|
||||
$s = '<select id="filter_thirdparties" name="filter_thirdparties" class="flat">';
|
||||
|
||||
// Show categories
|
||||
$sql = "SELECT rowid, label, type, visible";
|
||||
@ -293,6 +294,7 @@ class mailing_thirdparties extends MailingTargets
|
||||
|
||||
$s .= '</select> ';
|
||||
|
||||
// filter_client_thirdparties
|
||||
$s .= '<select id="filter_client_thirdparties" name="filter_client_thirdparties" class="flat">';
|
||||
$s .= '<option value="-1">'.$langs->trans('ProspectCustomer').'</option>';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
|
||||
@ -309,6 +311,7 @@ class mailing_thirdparties extends MailingTargets
|
||||
$s .= '</select> ';
|
||||
$s .= ajax_combobox("filter_client_thirdparties");
|
||||
|
||||
// filter_status
|
||||
$s .= ' <select id="filter_status_thirdparties" name="filter_status" class="flat">';
|
||||
$s .= '<option value="-1">'.$langs->trans("Status").'</option>';
|
||||
$s .= '<option value="1">'.$langs->trans("Enabled").'</option>';
|
||||
@ -316,6 +319,7 @@ class mailing_thirdparties extends MailingTargets
|
||||
$s .= '</select>';
|
||||
$s .= ajax_combobox("filter_status_thirdparties");
|
||||
|
||||
// filter_lang_thirdparties
|
||||
if (getDolGlobalInt('MAIN_MULTILANGS')) {
|
||||
// Choose language
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user