From 8a38a768218b36c20056d576b2271535f27f0ab1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 6 Aug 2010 18:18:23 +0000 Subject: [PATCH] Fix: bad search ajax --- htdocs/societe/ajaxcompanies.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/societe/ajaxcompanies.php b/htdocs/societe/ajaxcompanies.php index d8f08f671dc..00808eb13dd 100644 --- a/htdocs/societe/ajaxcompanies.php +++ b/htdocs/societe/ajaxcompanies.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2007 Laurent Destailleur - * Copyright (C) 2009 Cyrille de Lambert + * Copyright (C) 2010 Cyrille de Lambert * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,25 +48,24 @@ if (! empty($_POST['newcompany']) || ! empty($_POST['socid']) || ! empty($_POST[ $socid = $_POST['newcompany']?$_POST['newcompany']:''; if (! $socid) $socid = $_POST['socid']?$_POST['socid']:''; if (! $socid) $socid = $_POST['id_fourn']?$_POST['id_fourn']:''; + $sql = "SELECT rowid, nom"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE 1=1"; if ($socid){ - $sql.=" AND (rowid LIKE '%" . $socid . "%'"; - $sql.=" OR nom LIKE '%" . $socid . "%'"; - $sql.=" OR code_fournisseur LIKE '%" . $socid . "%')"; + $sql.=" AND (rowid LIKE '%" . $socid . "%'"; + $sql.=" OR nom LIKE '%" . $socid . "%'"; + $sql.=" OR code_fournisseur LIKE '%" . $socid . "%')"; } if (! empty($_GET["filter"])) $sql.= " AND ".$_GET["filter"]; // Add other filters $sql.= " ORDER BY nom ASC"; - dol_syslog("requete sql = ".$sql); + //dol_syslog("ajaxcompanies sql=".$sql); $resql=$db->query($sql); - if ($resql) { - dol_syslog("resulat OK"); print '
    '; - while ($company = $resql->fetch_object()) + while ($company = $db->fetch_object($resql)) { print '
  • '; print $company->nom; @@ -84,4 +83,4 @@ else print ""; print ""; -?> \ No newline at end of file +?>