diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6cfed39a02f..1d621d153f5 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1356,6 +1356,7 @@ if (empty($reshook)) { $line->origin = $object->origin; $line->origin_id = $line->id; + $line->fetch_optionals($line->id); } } @@ -1377,7 +1378,21 @@ if (empty($reshook)) $object->situation_counter = $object->situation_counter + 1; $id = $object->createFromCurrent($user); - if ($id <= 0) $mesg = $object->error; + if ($id <= 0) + { + $mesg = $object->error; + } + else + { + $nextSituationInvoice = new Facture($db); + $nextSituationInvoice->fetch($id); + // create extrafields with data from create form + $extralabels = $extrafields->fetch_name_optionals_label($nextSituationInvoice->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $nextSituationInvoice); + if ($ret > 0) { + $nextSituationInvoice->insertExtraFields(); + } + } } } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index f15c091263e..728556b3940 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -780,9 +780,15 @@ if ($action == 'create') $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print $object->showOptionals($extrafields, 'edit'); - } + if (empty($reshook) && ! empty($extrafields->attribute_label)) { + // copy from order + $orderExtrafields = new Extrafields($db); + $orderExtrafieldLabels = $orderExtrafields->fetch_name_optionals_label($object->table_element); + if ($object->fetch_optionals($object->id, $orderExtrafieldLabels) > 0) { + $expe->array_options = array_merge($expe->array_options, $object->array_options); + } + print $object->showOptionals($extrafields, 'edit'); + } // Incoterms @@ -1304,8 +1310,13 @@ if ($action == 'create') if (is_array($extralabelslines) && count($extralabelslines)>0) { $colspan=5; + $orderLineExtrafields = new Extrafields($db); + $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line); + $srcLine = new OrderLine($db); + $srcLine->fetch_optionals($line->id,$orderLineExtrafieldLabels); // fetch extrafields also available in orderline $line = new ExpeditionLigne($db); $line->fetch_optionals($object->id,$extralabelslines); + $line->array_options = array_merge($line->array_options, $srcLine->array_options); print '