I use complementary attributes for ODT template. In the web is perfectly fine but it print something else in ODT.
Please see reference.
Please advice.
Thanks
I use complementary attributes for ODT template. In the web is perfectly fine but it print something else in ODT.
Please see reference.
Please advice.
Thanks
Hi rarehunter. I have tested your issue and raised a ticket on github as it has something to do with all the “link to an object” option.
This is still not fixed
yes, it is certain, were a bug. I’ve organized my own code. yayimlacak a more effective fix I think.
anyway, the solution is this:
/htdocs/core/class/commondocgenerator.class.php
open the file…
and “fill_substitutionarray_with_extrafields” search for this function. (892~970 lines) from the beginning to the end /* … */ close. I gave below and add the code below. your problem will be solved.
public function fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs)
{
// phpcs:enable
global $conf;
if (is_array($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) {
// Continue the operation according to the type of each field
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') {
$object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]);
$object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency);
$array_to_fill[$array_key.'_options_'.$key.'_currency'] = $object->array_options['options_'.$key.'_currency'];
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select') {
$valueofselectkey = $object->array_options['options_'.$key];
if (array_key_exists($valueofselectkey, $extrafields->attributes[$object->table_element]['param'][$key]['options'])) {
$object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$valueofselectkey];
} else {
$object->array_options['options_'.$key] = '';
}
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') {
$valArray = explode(',', $object->array_options['options_'.$key]);
$output = array();
foreach ($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt => $valopt) {
if (in_array($keyopt, $valArray)) {
$output[] = $valopt;
}
}
$object->array_options['options_'.$key] = implode(', ', $output);
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'date') {
if (strlen($object->array_options['options_'.$key]) > 0) {
$date = $object->array_options['options_'.$key];
$object->array_options['options_'.$key] = dol_print_date($date, 'day');
$object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs);
$object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc');
} else {
$object->array_options['options_'.$key] = '';
$object->array_options['options_'.$key.'_locale'] = '';
$object->array_options['options_'.$key.'_rfc'] = '';
}
$array_to_fill[$array_key.'_options_'.$key.'_locale'] = $object->array_options['options_'.$key.'_locale'];
$array_to_fill[$array_key.'_options_'.$key.'_rfc'] = $object->array_options['options_'.$key.'_rfc'];
} elseif ($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime') {
$datetime = $object->array_options['options_'.$key];
$object->array_options['options_'.$key] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($object->array_options['options_'.$key], 'dayhour') : '');
$object->array_options['options_'.$key.'_locale'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs) : '');
$object->array_options['options_'.$key.'_rfc'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($object->array_options['options_'.$key], 'dayhourrfc') : '');
$array_to_fill[$array_key.'_options_'.$key.'_locale'] = $object->array_options['options_'.$key.'_locale'];
$array_to_fill[$array_key.'_options_'.$key.'_rfc'] = $object->array_options['options_'.$key.'_rfc'];
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'link') {
$id = $object->array_options['options_'.$key];
if ($id != "") {
$param = $extrafields->attributes[$object->table_element]['param'][$key];
$param_list = array_keys($param['options']);
$InfoFieldList = explode(":", $param_list[0]);
$classname = $InfoFieldList[0];
$classpath = $InfoFieldList[1];
if (!empty($classpath)) {
dol_include_once($InfoFieldList[1]);
if ($classname && class_exists($classname)) {
$tmpobject = new $classname($this->db);
$tmpobject->fetch($id);
$object->array_options['options_'.$key] = $tmpobject->name;
}
}
}
}
// add Field value
$array_to_fill[$array_key.'_options_'.$key] = $object->array_options['options_'.$key] ?? '';
if (isset($object->array_options['options_'.$key.'_currency'])) {
$array_to_fill[$array_key.'_options_'.$key.'_currency'] = $object->array_options['options_'.$key.'_currency'];
}
}
}
return $array_to_fill;
}