diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 24023eb4d89..331822b4018 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -993,23 +993,12 @@ class ExtraFields } elseif ($type == 'checkbox') { - $out=''; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + $form = new Form($db); + $value_arr=explode(',',$value); + $out=$form->multiselectarray($keysuffix.'options_'.$key.$keyprefix, $param['options'], $value_arr, '', 0, '', 0, '100%'); - foreach ($param['options'] as $keyopt=>$val ) - { - - $out.=''; - } } elseif ($type == 'radio') { @@ -1101,6 +1090,9 @@ class ExtraFields if ($resql) { $num = $this->db->num_rows($resql); $i = 0; + + $data=array(); + while ( $i < $num ) { $labeltoshow = ''; $obj = $this->db->fetch_object($resql); @@ -1126,12 +1118,9 @@ class ExtraFields $labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' '; } } - $out .= 'rowid . '"'; - - $out .= 'checked'; - - $out .= '/>' . $labeltoshow . '
'; + + $data[$obj->rowid]=$labeltoshow; + } else { if (! $notrans) { $translabel = $langs->trans($obj->{$InfoFieldList[1]}); @@ -1145,32 +1134,25 @@ class ExtraFields $labeltoshow = '(not defined)'; if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { - $out .= 'rowid . '"'; - - $out .= 'checked'; - $out .= ''; - - $out .= '/>' . $labeltoshow . '
'; + $data[$obj->rowid]=$labeltoshow; } if (! empty($InfoFieldList[3])) { $parent = $parentName . ':' . $obj->{$parentField}; } - $out .= 'rowid . '"'; - - $out .= ((is_array($value_arr) && in_array($obj->rowid, $value_arr)) ? ' checked ' : ''); - ; - $out .= ''; - - $out .= '/>' . $labeltoshow . '
'; + $data[$obj->rowid]=$labeltoshow; } - + $i ++; } $this->db->free($resql); + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + $form = new Form($db); + + $out=$form->multiselectarray($keysuffix.'options_'.$key.$keyprefix, $data, $value_arr, '', 0, '', 0, '100%'); + } else { print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
'; } @@ -1381,9 +1363,10 @@ class ExtraFields if (is_array($value_arr)) { foreach ($value_arr as $keyval=>$valueval) { - $value.=$params['options'][$valueval].'
'; + $toprint[]='
  • '.$params['options'][$valueval].'
  • '; } } + $value='
    '; } elseif ($type == 'chkbxlst') { @@ -1418,7 +1401,7 @@ class ExtraFields $resql = $this->db->query($sql); if ($resql) { $value = ''; // value was used, so now we reste it to use it to build final output - + $toprint=array(); while ( $obj = $this->db->fetch_object($resql) ) { // Several field into label (eq table:code|libelle:rowid) @@ -1431,9 +1414,9 @@ class ExtraFields $translabel = $langs->trans($obj->$field_toshow); } if ($translabel != $field_toshow) { - $value .= dol_trunc($translabel, 18) . '
    '; + $toprint[]='
  • '.dol_trunc($translabel, 18).'
  • '; } else { - $value .= $obj->$field_toshow . '
    '; + $toprint[]='
  • '.$obj->$field_toshow.'
  • '; } } } else { @@ -1442,15 +1425,18 @@ class ExtraFields $translabel = $langs->trans($obj->{$InfoFieldList[1]}); } if ($translabel != $obj->{$InfoFieldList[1]}) { - $value .= dol_trunc($translabel, 18) . '
    '; + $toprint[]='
  • '.dol_trunc($translabel, 18).'
  • '; } else { - $value .= $obj->{$InfoFieldList[1]} . '
    '; + $toprint[]='
  • '.$obj->{$InfoFieldList[1]}.'
  • '; } } } } - } else + $value='
    '; + + } else { dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); + } } elseif ($type == 'link') {