Clean code

This commit is contained in:
Laurent Destailleur 2018-04-13 16:18:33 +02:00
parent 7811796491
commit 4251748aca
2 changed files with 11 additions and 5 deletions

View File

@ -1266,8 +1266,11 @@ class FormMail extends Form
$product = new Product($this->db);
$product->fetch($line->fk_product, '', '', 1);
$product->fetch_optionals();
foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) {
$substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key];
if (is_array($extrafieldstmp->attributes[$object->table_element]['label']) && count($extrafieldstmp->attributes[$object->table_element]['label']) > 0)
{
foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) {
$substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key];
}
}
}
$this->substit_lines[] = $substit_line;

View File

@ -5964,11 +5964,14 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
// Create dynamic tags for __EXTRAFIELD_FIELD__
if ($object->table_element && $object->id > 0)
{
$extrafieldstmp = new ExtraFields($db);
if (! is_object($extrafields)) $extrafieldstmp = new ExtraFields($db);
$extralabels = $extrafieldstmp->fetch_name_optionals_label($object->table_element, true);
$object->fetch_optionals();
foreach ($extrafieldstmp->attributes[$object->table_element]['label'] as $key => $label) {
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key];
if (is_array($extrafieldstmp->attributes[$object->table_element]['label']) && count($extrafieldstmp->attributes[$object->table_element]['label']) > 0)
{
foreach ($extrafieldstmp->attributes[$object->table_element]['label'] as $key => $label) {
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key];
}
}
}