diff --git a/htdocs/product/card.php b/htdocs/product/card.php index c31c8885454..122e80b2e69 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1,7 +1,7 @@ +/* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006 Auguria SARL @@ -11,9 +11,10 @@ * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2014 Cédric Gross * Copyright (C) 2014-2015 Ferran Marcet - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2016 Meziane Sof * * 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 @@ -820,6 +821,23 @@ $formfile = new FormFile($db); $formproduct = new FormProduct($db); if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); +// Load object modBarCodeProduct +$res=0; +if (! empty($conf->barcode->enabled) && ! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) +{ + $module=strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); + $dirbarcode=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']); + foreach ($dirbarcode as $dirroot) + { + $res=dol_include_once($dirroot.$module.'.php'); + if ($res) break; + } + if ($res > 0) + { + $modBarCodeProduct =new $module(); + } +} + if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { @@ -857,22 +875,6 @@ else $modCodeProduct = new $module(); } - // Load object modBarCodeProduct - if (! empty($conf->barcode->enabled) && ! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) - { - $module=strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); - $dirbarcode=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']); - foreach ($dirbarcode as $dirroot) - { - $res=dol_include_once($dirroot.$module.'.php'); - if ($res) break; - } - if ($res > 0) - { - $modBarCodeProduct =new $module(); - } - } - print '
'; print ''; print ''; @@ -1483,10 +1485,13 @@ else if (($action != 'editbarcodetype') && ! empty($user->rights->produit->creer) && $createbarcode) print 'id.'">'.img_edit($langs->trans('Edit'),1).''; print ''; print ''; - if ($action == 'editbarcodetype') + if ($action == 'editbarcodetype' || $action == 'editbarcode') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); + } + if ($action == 'editbarcodetype') + { $formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$object->id,$object->barcode_type,'fk_barcode_type'); } else @@ -1506,13 +1511,16 @@ else print ''; if ($action == 'editbarcode') { - print ''; - print ''; - print ''; - print ''; - print ''; - print ' '; - print '
'; + $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; + if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ' '; + print '
'; } else {