mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
84 lines
2.4 KiB
PHP
84 lines
2.4 KiB
PHP
<?php
|
|
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
|
|
* Copyright (C) 2008-2009 Laurent Destailleur <eldy@uers.sourceforge.net>
|
|
*
|
|
* 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
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
/**
|
|
* This page is called each time we press a key in the code or description
|
|
* search form to show product combo list
|
|
*/
|
|
include('../master.inc.php');
|
|
require ('include/environnement.php');
|
|
|
|
$langs->load("@cashdesk");
|
|
|
|
// Verification
|
|
if ( strlen ($_GET["code"]) >= 0 ) // If at least one key
|
|
{
|
|
$request="SELECT p.rowid, p.ref, p.label, p.tva_tx
|
|
FROM ".MAIN_DB_PREFIX."product as p
|
|
LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product
|
|
WHERE p.envente = 1
|
|
AND p.fk_product_type = 0";
|
|
if ($conf->stock->enabled) $request.=" AND ps.fk_entrepot = '".$conf_fkentrepot."'";
|
|
$request.=" AND (p.ref LIKE '%".$_GET['code']."%'
|
|
OR p.label LIKE '%".$_GET['code']."%')
|
|
ORDER BY label";
|
|
dol_syslog($request);
|
|
$res = $sql->query ($request);
|
|
|
|
if ( $nbr = $sql->num_rows($res) ) {
|
|
|
|
$resultat = '<ul class="dhtml_bloc">';
|
|
|
|
$ret=array(); $i=0;
|
|
while ( $tab = $sql->fetch_array($res) )
|
|
{
|
|
foreach ( $tab as $cle => $valeur )
|
|
{
|
|
$ret[$i][$cle] = $valeur;
|
|
}
|
|
$i++;
|
|
}
|
|
$tab=$ret;
|
|
|
|
for ( $i = 0; $i < count ($tab); $i++ ) {
|
|
|
|
$resultat .= '
|
|
<li class="dhtml_defaut" title="'.$tab[$i]['ref'].'"
|
|
onMouseOver="javascript: this.className = \'dhtml_selection\';"
|
|
onMouseOut="javascript: this.className = \'dhtml_defaut\';"
|
|
">'.htmlentities($tab[$i]['ref'].' - '.$tab[$i]['label']).'</li>
|
|
';
|
|
|
|
}
|
|
|
|
$resultat .= '</ul>';
|
|
|
|
echo $resultat;
|
|
|
|
} else {
|
|
echo ('
|
|
<ul class="dhtml_bloc">
|
|
<li class="dhtml_defaut">'.$langs->trans("NoResults").'</li>
|
|
</ul>
|
|
');
|
|
|
|
}
|
|
|
|
}
|
|
?>
|