Skip to content
Snippets Groups Projects
Commit f5168625 authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: broken feature: barcode search #3019

parent 296b7660
No related branches found
No related tags found
No related merge requests found
<?php
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2008-2009 Laurent Destailleur <eldy@uers.sourceforge.net>
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2008-2009 Laurent Destailleur <eldy@uers.sourceforge.net>
* Copyright (C) 2015 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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
......@@ -41,8 +42,10 @@ require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
//header("Content-type: text/html; charset=UTF-8");
header("Content-type: text/html; charset=".$conf->file->character_set_client);
$search = GETPOST("code", "alpha");
// Search from criteria
if (dol_strlen($_GET["code"]) >= 0) // If search criteria is on char length at least
if (dol_strlen($search) >= 0) // If search criteria is on char length at least
{
$sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx";
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
......@@ -54,11 +57,15 @@ if (dol_strlen($_GET["code"]) >= 0) // If search criteria is on char length at l
// Add criteria on ref/label
if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE))
{
$sql.= " AND (p.ref LIKE '".$_GET['code']."%' OR p.label LIKE '".$_GET['code']."%')";
$sql.= " AND (p.ref LIKE '".$db->escape($search)."%' OR p.label LIKE '".$db->escape($search)."%'";
if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$db->escape($search)."%'";
$sql.= ")";
}
else
{
$sql.= " AND (p.ref LIKE '%".$_GET['code']."%' OR p.label LIKE '%".$_GET['code']."%')";
$sql.= " AND (p.ref LIKE '%".$db->escape($search)."%' OR p.label LIKE '%".$db->escape($search)."%'";
if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '%".$db->escape($search)."%'";
$sql.= ")";
}
$sql.= " ORDER BY label";
......
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2015 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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
......@@ -59,8 +60,8 @@ function afficheDonnees(aId, aTexte) {
// aCible : id du bloc de destination; aCode : argument a passer a la page php chargee du traitement et de l'affichage
function verifResultat(aCible, aCode) {
if (aCode != '') {
function verifResultat(aCible, aCode, iLimit = 1) {
if (aCode != '' && aCode.length >= iLimit) {
if (texte = file ('facturation_dhtml.php?code='+escape(aCode))) {
......
......@@ -2,6 +2,7 @@
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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
......@@ -43,8 +44,8 @@ $langs->load("cashdesk");
<!-- Affichage de la reference et de la designation -->
<td><input class="texte_ref" type="text" id ="txtRef" name="txtRef" value="<?php echo $obj_facturation->ref() ?>"
onchange="javascript: setSource('REF');"
onkeyup="javascript: verifResultat('resultats_dhtml', this.value);"
onfocus="javascript: this.select(); verifResultat('resultats_dhtml', this.value);"
onkeyup="javascript: verifResultat('resultats_dhtml', this.value, <?php echo (! empty($conf->global->BARCODE_USE_SEARCH_TO_SELECT)?(int)$conf->global->BARCODE_USE_SEARCH_TO_SELECT:1) ?>);"
onfocus="javascript: this.select(); verifResultat('resultats_dhtml', this.value, <?php echo (! empty($conf->global->BARCODE_USE_SEARCH_TO_SELECT)?(int)$conf->global->BARCODE_USE_SEARCH_TO_SELECT:1) ?>);"
onBlur="javascript: document.getElementById('resultats_dhtml').innerHTML = '';"/>
</td>
<td class="select_design">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment