Skip to content

Commit

Permalink
Clean code of extrafields
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 6, 2019
1 parent d4bb649 commit 1285f71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
20 changes: 13 additions & 7 deletions htdocs/expedition/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -2256,8 +2258,8 @@
}
}
}
print '</td>';
}
print '</td>';

if ($action == 'editline' && $lines[$i]->id == $line_id)
{
Expand Down Expand Up @@ -2425,8 +2427,9 @@
print '<td class="center" colspan="2" valign="middle">';
print '<input type="submit" class="button" id="savelinebutton" name="save" value="' . $langs->trans("Save") . '"><br>';
print '<input type="submit" class="button" id="cancellinebutton" name="cancel" value="' . $langs->trans("Cancel") . '"><br>';
print '</td>';
}
elseif ($object->statut == 0)
elseif ($object->statut == Expedition::STATUS_DRAFT)
{
// edit-delete buttons
print '<td class="linecoledit center">';
Expand All @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions htdocs/expedition/shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@
print '</td></tr>';
}

$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';
Expand Down

0 comments on commit 1285f71

Please sign in to comment.