";
}
@@ -837,15 +835,15 @@ if ($action == 'create')
// Other attributes
$parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'cols' => '3', 'socid'=>$socid);
- $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook
+ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $objectsrc may have been modified by hook
print $hookmanager->resPrint;
- // Here $object can be of an object Order
+ // Here $object can be of an object Reception
$extrafields->fetch_name_optionals_label($object->table_element);
if (empty($reshook) && !empty($extrafields->attributes[$object->table_element]['label'])) {
// copy from order
- if ($object->fetch_optionals() > 0) {
- $recept->array_options = array_merge($recept->array_options, $object->array_options);
+ if ($objectsrc->fetch_optionals() > 0) {
+ $recept->array_options = array_merge($recept->array_options, $objectsrc->array_options);
}
print $object->showOptionals($extrafields, 'edit', $parameters);
}
@@ -854,9 +852,9 @@ if ($action == 'create')
if (!empty($conf->incoterm->enabled))
{
print '
';
}
@@ -876,15 +874,15 @@ if ($action == 'create')
print dol_get_fiche_end();
-
// Reception lines
$numAsked = 0;
$dispatchLines = array();
- foreach ($_POST as $key => $value)
- {
+ foreach ($_POST as $key => $value) {
+ // If create form is coming from the button "Create Reception" of previous page
+
// without batch module enabled
- if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg))
- {
+ $reg = array();
+ if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
$numAsked++;
// $numline=$reg[2] + 1; // line of product
@@ -915,6 +913,25 @@ if ($action == 'create')
$fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2];
$dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha'));
}
+
+ // If create form is coming from same page post was sent but an error occured
+ if (preg_match('/^productid([0-9]+)$/i', $key, $reg)) {
+ $numAsked++;
+
+ // eat-by date dispatch
+ // $numline=$reg[2] + 1; // line of product
+ $numline = $numAsked;
+ $prod = 'productid'.$reg[1];
+ $comment = 'comment'.$reg[1];
+ $qty = 'qtyl'.$reg[1];
+ $ent = 'entl'.$reg[1];
+ $pu = 'pul'.$reg[1];
+ $lot = 'batch'.$reg[1];
+ $dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo'.$reg[1].'month', 'int'), GETPOST('dluo'.$reg[1].'day', 'int'), GETPOST('dluo'.$reg[1].'year', 'int'));
+ $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc'.$reg[1].'month', 'int'), GETPOST('dlc'.$reg[1].'day', 'int'), GETPOST('dlc'.$reg[1].'year', 'int'));
+ $fk_commandefourndet = 'fk_commandefournisseurdet'.$reg[1];
+ $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST($comment), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha'));
+ }
}
@@ -944,7 +961,7 @@ if ($action == 'create')
print '
';
// Load receptions already done for same order
- $object->loadReceptions();
+ $objectsrc->loadReceptions();
if ($numAsked)
{
@@ -980,14 +997,13 @@ if ($action == 'create')
while ($indiceAsked <= $numAsked)
{
$product = new Product($db);
- foreach ($object->lines as $supplierLine) {
+ foreach ($objectsrc->lines as $supplierLine) {
if ($dispatchLines[$indiceAsked]['fk_commandefourndet'] == $supplierLine->id) {
$line = $supplierLine;
break;
}
}
-
// Show product and description
$type = $line->product_type ? $line->product_type : $line->fk_product_type;
// Try to enhance type detection using date_start and date_end for free lines where type
@@ -995,7 +1011,7 @@ if ($action == 'create')
if (!empty($line->date_start)) $type = 1;
if (!empty($line->date_end)) $type = 1;
- print ''."\n";
+ print ''."\n";
print '
';
print ''; // ancre pour retourner sur la ligne
+ print '';
// Show product and description
$product_static->type = $line->fk_product_type;
@@ -1049,17 +1066,15 @@ if ($action == 'create')
// Qty
print '