From 1285f71ceb25354b9bc97f6a888cc5424368844e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Oct 2019 16:50:04 +0200 Subject: [PATCH] Clean code of extrafields --- htdocs/expedition/card.php | 20 +++++++++++++------- htdocs/expedition/shipment.php | 3 +++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index cfb2e45722327..ce98313d60f8c 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1031,8 +1031,7 @@ if (empty($reshook)) { // copy from order - $orderExtrafields = new Extrafields($db); - $orderExtrafieldLabels = $orderExtrafields->fetch_name_optionals_label($object->table_element); + $extrafields->fetch_name_optionals_label($object->table_element); if ($object->fetch_optionals() > 0) { $expe->array_options = array_merge($expe->array_options, $object->array_options); } @@ -1576,13 +1575,16 @@ { //var_dump($line); $colspan=5; - $extrafields->fetch_name_optionals_label($object->table_element_line); + $extrafields->fetch_name_optionals_label($expe->table_element_line); + $expLine = new ExpeditionLigne($db); + $srcLine = new OrderLine($db); + $extrafields->fetch_name_optionals_label($srcLine->table_element); $srcLine->fetch_optionals($line->id); // fetch extrafields also available in orderline //$line->fetch_optionals($line->id); $line->array_options = array_merge($line->array_options, $srcLine->array_options); - print $line->showOptionals($extrafields, 'edit', array('style'=>'class="drag drop oddeven"','colspan'=>$colspan), $indiceAsked, '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); + print $expLine->showOptionals($extrafields, 'edit', array('style'=>'class="drag drop oddeven"', 'colspan'=>$colspan), $indiceAsked, '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } } @@ -2256,8 +2258,8 @@ } } } + print ''; } - print ''; if ($action == 'editline' && $lines[$i]->id == $line_id) { @@ -2425,8 +2427,9 @@ print ''; print '
'; print '
'; + print ''; } - elseif ($object->statut == 0) + elseif ($object->statut == Expedition::STATUS_DRAFT) { // edit-delete buttons print ''; @@ -2448,7 +2451,10 @@ // Display lines extrafields if (! empty($extrafields)) { - $colspan= empty($conf->productbatch->enabled) ? 5 : 6; + $colspan=6; + if ($origin && $origin_id > 0) $colspan++; + if (! empty($conf->productbatch->enabled)) $colspan++; + if (! empty($conf->stock->enabled)) $colspan++; $lines[$i]->fetch_optionals($lines[$i]->id); diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 20973437e2d62..34a89233f1ef1 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -537,6 +537,9 @@ print ''; } + $expe = new Expedition($db); + $extrafields->fetch_name_optionals_label($expe->table_element); + // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';