diff --git a/ChangeLog b/ChangeLog index 2fcf861008b..d9891d05ab7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,7 @@ Fix: [ bug #1075 ] POS module doesn't decrement stock of products in delayed pay Fix: [ bug #1171 ] Documents lost in interventions after validating Fix: fix unsubscribe URL into mailing when sending manually (not by script) Fix: [ bug #1182 ] ODT company_country tag is htmlencoded +Fix: [ bug #1196 ] Product barcode search does not expect 13th digit on EAN13 type ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** Fix: Display buying price on line edit when no supplier price is defined diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index 1636246e536..47152524c4d 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2008 Jeremie Ollivier * Copyright (C) 2008-2011 Laurent Destailleur * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2013 Marcos García * * 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 @@ -37,7 +38,21 @@ if ( GETPOST('filtre') ) { $sql.= " AND p.tosell = 1"; if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0"; $sql.= " AND (p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'"; - if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '%".$db->escape(GETPOST('filtre'))."%')"; + if (! empty($conf->barcode->enabled)) { + + $filtre = GETPOST('filtre'); + + //If the barcode looks like an EAN13 format and the last digit is included in it, + //then whe look for the 12-digit too + //As the twelve-digit string will also hit the 13-digit code, we only look for this one + //Some code written by "hipnosapo" forum user in http://www.dolibarr.es/index.php/foro/7-bugs-versiones-estables/3891-ean13-buscador-codigo-barras-13-digitos#3891 + if (strlen($filtre) == 13) { + $crit_12digit = substr($filtre, 0, 12); + $sql .= " OR p.barcode LIKE '%".$db->escape($crit_12digit)."%')"; + } else { + $sql.= " OR p.barcode LIKE '%".$db->escape($filtre)."%')"; + } + } else $sql.= ")"; $sql.= " ORDER BY label"; diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 5c312886313..25dc8a26122 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2006 Rodolphe Quiedeville * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Marcos García + * Copyright (C) 2012-2013 Marcos García * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2013 Raphaël Doursenaud * Copyright (C) 2013 Jean Heimburger @@ -150,7 +150,16 @@ else $sql.= " AND (p.ref LIKE '%".$db->escape($crit)."%' OR p.label LIKE '%".$db->escape($crit)."%' OR p.description LIKE '%".$db->escape($crit)."%' OR p.note LIKE '%".$db->escape($crit)."%' OR pl.description LIKE '%".$db->escape($sall)."%' OR pl.note LIKE '%".$db->escape($sall)."%'"; if (! empty($conf->barcode->enabled)) { - $sql.= " OR p.barcode LIKE '%".$db->escape($crit)."%'"; + //If the barcode looks like an EAN13 format and the last digit is included in it, + //then whe look for the 12-digit too + //As the twelve-digit string will also hit the 13-digit code, we only look for this one + //Some code written by "hipnosapo" forum user in http://www.dolibarr.es/index.php/foro/7-bugs-versiones-estables/3891-ean13-buscador-codigo-barras-13-digitos#3891 + if (strlen($crit) == 13) { + $crit_12digit = substr($crit, 0, 12); + $sql .= "OR p.barcode LIKE '%".$db->escape($crit_12digit)."%'"; + } else { + $sql.= " OR p.barcode LIKE '%".$db->escape($crit)."%'"; + } } $sql.= ')'; } @@ -161,7 +170,16 @@ else $sql.= " AND (p.ref LIKE '%".$db->escape($crit)."%' OR p.label LIKE '%".$db->escape($crit)."%' OR p.description LIKE '%".$db->escape($crit)."%' OR p.note LIKE '%".$db->escape($crit)."%'"; if (! empty($conf->barcode->enabled)) { - $sql.= " OR p.barcode LIKE '%".$db->escape($crit)."%'"; + //If the barcode looks like an EAN13 format and the last digit is included in it, + //then whe look for the 12-digit too + //As the twelve-digit string will also hit the 13-digit code, we only look for this one + //Some code written by "hipnosapo" forum user in http://www.dolibarr.es/index.php/foro/7-bugs-versiones-estables/3891-ean13-buscador-codigo-barras-13-digitos#3891 + if (strlen($crit) == 13) { + $crit_12digit = substr($crit, 0, 12); + $sql .= "OR p.barcode LIKE '%".$db->escape($crit_12digit)."%'"; + } else { + $sql.= " OR p.barcode LIKE '%".$db->escape($crit)."%'"; + } } $sql.= ')'; } @@ -174,7 +192,19 @@ else else $sql.= " AND p.fk_product_type <> '1'"; } if ($sref) $sql.= " AND p.ref LIKE '%".$sref."%'"; - if ($sbarcode) $sql.= " AND p.barcode LIKE '%".$sbarcode."%'"; + if ($sbarcode) { + + //If the barcode looks like an EAN13 format and the last digit is included in it, + //then whe look for the 12-digit too + //As the twelve-digit string will also hit the 13-digit code, we only look for this one + if (strlen($sbarcode) == 13) { + $sbarcode_12digit = substr($sbarcode, 0, 12); + $sql .= "AND p.barcode LIKE '%".$sbarcode_12digit."%'"; + } else { + $sql.= " AND p.barcode LIKE '%".$sbarcode."%'"; + } + + } if ($snom) { // multilang