Fix a serial is required for stock change

This commit is contained in:
Laurent Destailleur 2015-12-19 14:05:38 +01:00
parent d7e9c92144
commit 3b2a921378
3 changed files with 20 additions and 7 deletions

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
@ -115,8 +115,9 @@ if ($action == "correct_stock" && ! $cancel)
$object = new Product($db);
$result=$object->fetch($id);
if ($object->hasbatch() && (! GETPOST("sellby")) && (! GETPOST("eatby")) && (! GETPOST("batch_number"))) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors');
if ($object->hasbatch() && ! GETPOST("batch_number"))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors');
$error++;
$action='correction';
}
@ -202,7 +203,19 @@ if ($action == "transfert_stock" && ! $cancel)
$error++;
$action='transfert';
}
if (! empty($conf->productbatch->enabled))
{
$object = new Product($db);
$result=$object->fetch($id);
if ($object->hasbatch() && ! GETPOST("batch_number"))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors');
$error++;
$action='transfert';
}
}
if (! $error)
{
if ($id)

View File

@ -80,11 +80,11 @@
print '<td colspan="4"><input class="flat" name="unitprice" id="unitprice" size="10" value="'.GETPOST("unitprice").'"></td>';
print '</tr>';
// Eat-by date
// Serial / Eat-by date
if ((! empty($conf->productbatch->enabled)) && is_object($product) && $product->hasbatch())
{
print '<tr>';
print '<td colspan="2">'.$langs->trans("batch_number").'</td><td colspan="4">';
print '<td colspan="2" class="fieldrequired">'.$langs->trans("batch_number").'</td><td colspan="4">';
print '<input type="text" name="batch_number" size="40" value="'.GETPOST("batch_number").'">';
print '</td>';
print '</tr><tr>';

View File

@ -75,7 +75,7 @@
if ((! empty($conf->productbatch->enabled)) && $product->hasbatch())
{
print '<tr>';
print '<td>'.$langs->trans("batch_number").'</td><td colspan="5">';
print '<td class="fieldrequired">'.$langs->trans("batch_number").'</td><td colspan="5">';
print '<input type="text" name="batch_number" size="40"'.($pdluoid > 0 ? ' disabled':'').' value="'.(GETPOST('batch_number')?GETPOST('batch_number'):$pdluo->batch).'">'; // If form was opened for a specific pdluoid, field is disabled
print '</td>';
print '</tr><tr>';