From 0b6bd0bc146f3e9646e4a5b05feacc8e84820689 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Feb 2016 15:49:38 +0100 Subject: [PATCH] More robust error management on barcode module. --- htdocs/barcode/codeinit.php | 2 +- htdocs/core/lib/barcode.lib.php | 17 +-- htdocs/langs/en_US/admin.lang | 2 + htdocs/product/admin/product.php | 246 ++++++++++++++++--------------- htdocs/product/card.php | 66 +++++---- htdocs/product/document.php | 1 - htdocs/viewimage.php | 2 +- 7 files changed, 177 insertions(+), 159 deletions(-) diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index db662b6d9e4..e421c17a470 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -298,7 +298,7 @@ if ($conf->product->enabled || $conf->product->service) { $disabled=1; $titleno=$langs->trans("NoBarcodeNumberingTemplateDefined"); - print ''.$langs->trans("NoBarcodeNumberingTemplateDefined").'
'; + print ''.$langs->trans("NoBarcodeNumberingTemplateDefined").' ('.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").')
'; } if (empty($nbno)) { diff --git a/htdocs/core/lib/barcode.lib.php b/htdocs/core/lib/barcode.lib.php index 778723c5f3b..eaaa6f349c4 100644 --- a/htdocs/core/lib/barcode.lib.php +++ b/htdocs/core/lib/barcode.lib.php @@ -63,8 +63,6 @@ else $genbarcode_loc = $conf->global->GENBARCODE_LOCATION; * @param string $encoding Encoding * @param integer $scale Scale * @param string $mode 'png' or 'jpg' ... - * - * * @return array $bars array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info) */ function barcode_print($code, $encoding="ANY", $scale = 2 ,$mode = "png") @@ -116,8 +114,7 @@ function barcode_encode($code,$encoding) global $genbarcode_loc; if ( - ((preg_match("/^ean$/i", $encoding) - && ( strlen($code)==12 || strlen($code)==13))) + (preg_match("/^ean$/i", $encoding)) || (($encoding) && (preg_match("/^isbn$/i", $encoding)) && (( strlen($code)==9 || strlen($code)==10) || @@ -140,7 +137,7 @@ function barcode_encode($code,$encoding) } else { - print "barcode_encode needs an external programm for encodings other then EAN/ISBN
\n"; + print "barcode_encode needs an external programm for encodings other then EAN/ISBN (code=".$code.", encoding=".$encoding.")
\n"; print "