Merge pull request #6061 from mrsof/patch-6

Fix: Product barcode generation in edit mode
This commit is contained in:
Laurent Destailleur 2016-11-29 23:34:18 +01:00 committed by GitHub
commit 592b9d0b20

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2006 Auguria SARL <info@auguria.org>
@ -11,9 +11,10 @@
* Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2014 Cédric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2014-2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
*
* 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 '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
@ -1483,10 +1485,13 @@ else
if (($action != 'editbarcodetype') && ! empty($user->rights->produit->creer) && $createbarcode) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&amp;id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
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 '</td><td colspan="2">';
if ($action == 'editbarcode')
{
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setbarcode">';
print '<input type="hidden" name="barcode_type_code" value="'.$object->barcode_type_code.'">';
print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$object->barcode.'">';
print '&nbsp;<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
$tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode;
if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type);
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setbarcode">';
print '<input type="hidden" name="barcode_type_code" value="'.$object->barcode_type_code.'">';
print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.'">';
print '&nbsp;<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
}
else
{