Proposed by MadCoder - Closes FS #93
authorx2000bedo <x2000bedo>
Tue, 12 Oct 2004 22:16:16 +0000 (22:16 +0000)
committerx2000bedo <x2000bedo>
Tue, 12 Oct 2004 22:16:16 +0000 (22:16 +0000)
htdocs/advanced_search.php
htdocs/search.php
include/search.classes.inc.php

index 66ef7db..995ad43 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: advanced_search.php,v 1.13 2004-10-12 21:51:58 x2000bedo Exp $
+        $Id: advanced_search.php,v 1.14 2004-10-12 22:16:16 x2000bedo Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -67,7 +67,7 @@ else {
         $nameField = new RefWithSoundexSField('name',array('rn.nom1_soundex','rn.nom2_soundex','rn.nom3_soundex'),'recherche_soundex','rn','u.matricule = rn.matricule');
         $firstnameField = new RefWithSoundexSField('firstname',array('rp.prenom1_soundex','rp.prenom2_soundex'),'recherche_soundex','rp','u.matricule = rp.matricule');
     } else {
-        $nameField = new StringSField('name',array('u.nom','u.epouse'),'');
+        $nameField = new NameSField('name',array('u.nom','u.epouse'),'');
         $firstnameField = new StringSField('firstname',array('u.prenom'),'');
     }
     $promo1Field = new PromoSField('promo1','egal1',array('u.promo'),'');
index dc1f526..5cd1117 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: search.php,v 1.24 2004-10-12 21:51:58 x2000bedo Exp $
+        $Id: search.php,v 1.25 2004-10-12 22:16:16 x2000bedo Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -45,7 +45,7 @@ if (array_key_exists('rechercher', $_REQUEST)) {
         StringWithSoundexSField('firstname',array('r.prenom1_soundex','r.prenom2_soundex'),'');
     }
     else {
-        $nameField = new StringSField('name',array('r.nom1','r.nom2','r.nom3'),'r.nom1');
+        $nameField = new NameSField('name',array('r.nom1','r.nom2','r.nom3'),'r.nom1');
         $firstnameField = new StringSField('firstname',array('r.prenom1','r.prenom2'),'r.prenom1');
         $with_soundex = ($nameField->length()==0 && $firstnameField->length()==0)?(-1):0;
     }
index 0e81221..6641577 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: search.classes.inc.php,v 1.18 2004-10-12 22:00:15 x2000habouzit Exp $
+        $Id: search.classes.inc.php,v 1.19 2004-10-12 22:16:19 x2000bedo Exp $
  ***************************************************************************/
 
 require_once("xorg.misc.inc.php");
@@ -249,6 +249,23 @@ class StringSField extends SField {
     }
 }
 
+/** classe pour les noms : on cherche en plus du like 'foo%' le like '% foo' (particules)
++*/
+class NameSField extends StringSField {
+    function get_single_where_statement($field) {
+        $regexp = str_replace('-',' ',$this->value);
+        $regexp = str_replace('*','%',$regexp);
+        return "$field LIKE '$regexp%' OR $field LIKE '% $regexp%'";
+    }
+    
+    function get_order_statement() {
+        if ($this->value!='' && $this->fieldResultName!='')
+            return $this->fieldResultName.' NOT LIKE "'.$this->value.'"';
+        else
+            return false;
+    }
+}
+
 /** classe de champ texte avec soundex (nom par exemple)
  */
 class StringWithSoundexSField extends StringSField {