From 5de650435a597dc641be2648941b0bd83a53f32c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Jun 2018 14:06:23 +0200 Subject: [PATCH] Fix filter on country/zip --- htdocs/contact/list.php | 67 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 7 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index d837a6c6421..30b7c5158ba 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -32,6 +32,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page @@ -76,6 +77,7 @@ $search_type=GETPOST('search_type','alpha'); $search_zip=GETPOST('search_zip','alpha'); $search_town=GETPOST('search_town','alpha'); $search_import_key=GETPOST("search_import_key","alpha"); +$search_country=GETPOST("search_country",'intcomma'); if ($search_status=='') $search_status=1; // always display activ customer first @@ -148,6 +150,7 @@ $arrayfields=array( 'p.poste'=>array('label'=>"PostOrFunction", 'checked'=>1), 'p.town'=>array('label'=>"Town", 'checked'=>0), 'p.zip'=>array('label'=>"Zip", 'checked'=>0), + 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), 'p.phone'=>array('label'=>"Phone", 'checked'=>1), 'p.phone_perso'=>array('label'=>"PhonePerso", 'checked'=>0), 'p.phone_mobile'=>array('label'=>"PhoneMobile", 'checked'=>1), @@ -203,6 +206,9 @@ if (empty($reshook)) $search_lastname=""; $search_firstname=""; $search_societe=""; + $search_town=""; + $search_zip=""; + $search_country=""; $search_poste=""; $search_phone=""; $search_phone_perso=""; @@ -298,6 +304,7 @@ if ($search_id > 0) $sql.= natural_search("p.rowid",$search_id,1 if ($search_lastname) $sql.= natural_search('p.lastname', $search_lastname); if ($search_firstname) $sql.= natural_search('p.firstname', $search_firstname); if ($search_societe) $sql.= natural_search('s.nom', $search_societe); +if ($search_country) $sql .= " AND p.fk_pays IN (".$search_country.')'; if (strlen($search_poste)) $sql.= natural_search('p.poste', $search_poste); if (strlen($search_phone_perso)) $sql.= natural_search('p.phone_perso', $search_phone_perso); if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone); @@ -396,6 +403,7 @@ if ($search_firstname != '') $param.='&search_firstname='.urlencode($search_ if ($search_societe != '') $param.='&search_societe='.urlencode($search_societe); if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip); if ($search_town != '') $param.='&search_town='.urlencode($search_town); +if ($search_country != '') $param.= "&search_country=".urlencode($search_country); if ($search_job != '') $param.='&search_job='.urlencode($search_job); if ($search_phone_pro != '') $param.='&search_phone_pro='.urlencode($search_phone_pro); if ($search_phone_perso != '') $param.='&search_phone_perso='.urlencode($search_phone_perso); @@ -518,6 +526,12 @@ if (! empty($arrayfields['p.firstname']['checked'])) print ''; print ''; } +if (! empty($arrayfields['p.poste']['checked'])) +{ + print ''; + print ''; + print ''; +} if (! empty($arrayfields['p.zip']['checked'])) { print ''; @@ -530,10 +544,25 @@ if (! empty($arrayfields['p.town']['checked'])) print ''; print ''; } -if (! empty($arrayfields['p.poste']['checked'])) +// State +/*if (! empty($arrayfields['state.nom']['checked'])) + { + print ''; + print ''; + print ''; + } + // Region + if (! empty($arrayfields['region.nom']['checked'])) + { + print ''; + print ''; + print ''; + }*/ +// Country +if (! empty($arrayfields['country.code_iso']['checked'])) { - print ''; - print ''; + print ''; + print $form->select_country($search_country,'search_country','',0,'maxwidth100'); print ''; } if (! empty($arrayfields['p.phone']['checked'])) @@ -630,9 +659,12 @@ print ''; if (! empty($arrayfields['p.rowid']['checked'])) print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"],"p.rowid","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['p.lastname']['checked'])) print_liste_field_titre($arrayfields['p.lastname']['label'],$_SERVER["PHP_SELF"],"p.lastname", $begin, $param, '', $sortfield,$sortorder); if (! empty($arrayfields['p.firstname']['checked'])) print_liste_field_titre($arrayfields['p.firstname']['label'],$_SERVER["PHP_SELF"],"p.firstname", $begin, $param, '', $sortfield,$sortorder); +if (! empty($arrayfields['p.poste']['checked'])) print_liste_field_titre($arrayfields['p.poste']['label'],$_SERVER["PHP_SELF"],"p.poste", $begin, $param, '', $sortfield,$sortorder); if (! empty($arrayfields['p.zip']['checked'])) print_liste_field_titre($arrayfields['p.zip']['label'],$_SERVER["PHP_SELF"],"p.zip", $begin, $param, '', $sortfield,$sortorder); if (! empty($arrayfields['p.town']['checked'])) print_liste_field_titre($arrayfields['p.town']['label'],$_SERVER["PHP_SELF"],"p.town", $begin, $param, '', $sortfield,$sortorder); -if (! empty($arrayfields['p.poste']['checked'])) print_liste_field_titre($arrayfields['p.poste']['label'],$_SERVER["PHP_SELF"],"p.poste", $begin, $param, '', $sortfield,$sortorder); +//if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); +//if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"co.code_iso","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($arrayfields['p.phone']['label'],$_SERVER["PHP_SELF"],"p.phone", $begin, $param, '', $sortfield,$sortorder); if (! empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_titre($arrayfields['p.phone_perso']['label'],$_SERVER["PHP_SELF"],"p.phone_perso", $begin, $param, '', $sortfield,$sortorder); if (! empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'],$_SERVER["PHP_SELF"],"p.phone_mobile", $begin, $param, '', $sortfield,$sortorder); @@ -697,6 +729,12 @@ while ($i < min($num,$limit)) print ''.$obj->firstname.''; if (! $i) $totalarray['nbfield']++; } + // Job position + if (! empty($arrayfields['p.poste']['checked'])) + { + print ''.dol_trunc($obj->poste,20).''; + if (! $i) $totalarray['nbfield']++; + } // Zip if (! empty($arrayfields['p.zip']['checked'])) { @@ -709,10 +747,25 @@ while ($i < min($num,$limit)) print ''.$obj->town.''; if (! $i) $totalarray['nbfield']++; } - // Function - if (! empty($arrayfields['p.poste']['checked'])) + // State + /*if (! empty($arrayfields['state.nom']['checked'])) { - print ''.dol_trunc($obj->poste,20).''; + print "".$obj->state_name."\n"; + if (! $i) $totalarray['nbfield']++; + } + // Region + if (! empty($arrayfields['region.nom']['checked'])) + { + print "".$obj->region_name."\n"; + if (! $i) $totalarray['nbfield']++; + }*/ + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + $tmparray=getCountry($obj->fk_pays,'all'); + print $tmparray['label']; + print ''; if (! $i) $totalarray['nbfield']++; } // Phone