Merge pull request #29018 from bradley-jarvis/fix-add-state-province-filter-field
NEW add state province filter field
This commit is contained in:
commit
f050f7925e
3 changed files with 82 additions and 2 deletions
|
|
@ -584,6 +584,9 @@ class AdvanceTargetingMailing extends CommonObject
|
|||
if (!empty($arrayquery['cust_saleman']) && count($arrayquery['cust_saleman']) > 0) {
|
||||
$sqlwhere[] = " (saleman.fk_user IN (".$this->db->sanitize(implode(',', $arrayquery['cust_saleman']))."))";
|
||||
}
|
||||
if (!empty($arrayquery['cust_state']) && count($arrayquery['cust_state']) > 0) {
|
||||
$sqlwhere[] = " (t.fk_departement IN (".$this->db->sanitize(implode(',', $arrayquery['cust_state']))."))";
|
||||
}
|
||||
if (!empty($arrayquery['cust_country']) && count($arrayquery['cust_country']) > 0) {
|
||||
$sqlwhere[] = " (t.fk_pays IN (".$this->db->sanitize(implode(',', $arrayquery['cust_country']))."))";
|
||||
}
|
||||
|
|
@ -825,6 +828,12 @@ class AdvanceTargetingMailing extends CommonObject
|
|||
if (!empty($arrayquery['cust_saleman']) && count($arrayquery['cust_saleman']) > 0) {
|
||||
$sqlwhere[] = " (saleman.fk_user IN (".$this->db->sanitize(implode(',', $arrayquery['cust_saleman']))."))";
|
||||
}
|
||||
//if (!empty($arrayquery['cust_state'])) {
|
||||
// $sqlwhere[] = $this->transformToSQL('tsd.nom', $arrayquery['cust_state']);
|
||||
//}
|
||||
if (!empty($arrayquery['cust_state']) && count($arrayquery['cust_state']) > 0) {
|
||||
$sqlwhere[] = " (t.fk_departement IN (".$this->db->sanitize(implode(',', $arrayquery['cust_state']))."))";
|
||||
}
|
||||
if (!empty($arrayquery['cust_country']) && count($arrayquery['cust_country']) > 0) {
|
||||
$sqlwhere[] = " (ts.fk_pays IN (".$this->db->sanitize(implode(',', $arrayquery['cust_country']))."))";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,67 @@ class FormAdvTargetEmailing extends Form
|
|||
return $this->advMultiselectarray($htmlname, $options_array, $selected_array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return combo list of activated countries, into language of user
|
||||
*
|
||||
* @param string $htmlname of html select object
|
||||
* @param array $selected_array or Code or Label of preselected country
|
||||
* @return string HTML string with select
|
||||
*/
|
||||
public function multiselectState($htmlname = 'state_id', $selected_array = array())
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$langs->load("dict");
|
||||
$maxlength = 0;
|
||||
|
||||
$out = '';
|
||||
$stateArray = array();
|
||||
$label = array();
|
||||
|
||||
$options_array = array();
|
||||
|
||||
$sql = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as department, r.nom as region";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_departements d";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions r on d.fk_region=r.code_region";
|
||||
$sql .= " WHERE d.active = 1 AND d.code_departement<>'' AND r.code_region<>''";
|
||||
//$sql .= " ORDER BY r.nom ASC, d.nom ASC";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num) {
|
||||
$foundselected = false;
|
||||
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$stateArray [$i] ['rowid'] = $obj->rowid;
|
||||
$stateArray [$i] ['code'] = $obj->code;
|
||||
$stateArray [$i] ['label'] = $obj->region.'/'.$obj->department;
|
||||
$label[$i] = $stateArray[$i]['label'];
|
||||
$i++;
|
||||
}
|
||||
|
||||
$array1_sort_order = SORT_ASC;
|
||||
array_multisort($label, $array1_sort_order, $stateArray);
|
||||
|
||||
foreach ($stateArray as $row) {
|
||||
$label = dol_trunc($row['label'], $maxlength, 'middle');
|
||||
if ($row['code']) {
|
||||
$label .= ' ('.$row['code'].')';
|
||||
}
|
||||
|
||||
$options_array[$row['rowid']] = $label;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
return $this->advMultiselectarray($htmlname, $options_array, $selected_array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return combo list of activated countries, into language of user
|
||||
*
|
||||
|
|
|
|||
|
|
@ -110,9 +110,9 @@ if (!empty($array_query['cust_code'])) {
|
|||
print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
|
||||
$cust_code_str = (string) $array_query['cust_code'];
|
||||
} else {
|
||||
$cust_code_str = "null";
|
||||
$cust_code_str = null;
|
||||
}
|
||||
print '</td><td><input type="text" name="cust_code" value="'.$cust_code_str.'"/></td><td>'."\n";
|
||||
print '</td><td><input type="text" name="cust_code"'.($cust_code_str!=null?' value="'.$cust_code_str:'').'"/></td><td>'."\n";
|
||||
print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
|
|
@ -143,6 +143,16 @@ print '</td><td><input type="text" name="cust_city" value="'.$array_query['cust_
|
|||
print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// State Client
|
||||
print '<tr><td>'.$langs->trans('State');
|
||||
if (!empty($array_query['cust_state'])) {
|
||||
print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
|
||||
}
|
||||
print '</td><td>'."\n";
|
||||
print $formadvtargetemaling->multiselectState('cust_state', $array_query['cust_state']);
|
||||
print '</td><td>'."\n";
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Customer Country
|
||||
print '<tr><td>'.$langs->trans("Country");
|
||||
if (!empty($array_query['cust_country'])) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue