27 print
"Error, template page can't be called as URL";
31if (empty($extrafieldsobjectkey) && is_object(
$object)) {
32 $extrafieldsobjectkey =
$object->table_element;
36if (!empty($extrafieldsobjectkey) && !empty($extrafields->attributes[$extrafieldsobjectkey])) {
37 if (array_key_exists(
'label', $extrafields->attributes[$extrafieldsobjectkey]) && is_array($extrafields->attributes[$extrafieldsobjectkey][
'label']) && count($extrafields->attributes[$extrafieldsobjectkey][
'label'])) {
38 if (empty($extrafieldsobjectprefix)) {
39 $extrafieldsobjectprefix =
'ef.';
42 foreach ($extrafields->attributes[$extrafieldsobjectkey][
'label'] as $key => $val) {
43 if (!empty($arrayfields[$extrafieldsobjectprefix.$key][
'checked'])) {
44 if ($extrafields->attributes[$extrafieldsobjectkey][
'type'][$key] ==
'separate') {
48 $cssclass = $extrafields->getAlignFlag($key, $extrafieldsobjectkey);
50 $tmpkey =
'options_'.$key;
52 if (in_array($extrafields->attributes[$extrafieldsobjectkey][
'type'][$key], array(
'date',
'datetime',
'timestamp')) && isset($obj->$tmpkey) && !is_numeric($obj->$tmpkey)) {
53 $datenotinstring = $obj->$tmpkey;
54 if (!is_numeric($obj->$tmpkey)) {
55 $datenotinstring = $db->jdate($datenotinstring);
57 $value = $datenotinstring;
58 } elseif (in_array($extrafields->attributes[$extrafieldsobjectkey][
'type'][$key], array(
'int'))) {
59 $value = (!empty($obj->$tmpkey) || $obj->$tmpkey ===
'0' ? $obj->$tmpkey :
'');
62 $value = (isset($obj->$tmpkey) ? $obj->$tmpkey :
63 (isset($obj->array_options[$tmpkey]) ? $obj->array_options[$tmpkey] :
'') );
66 if ($extrafields->attributes[$extrafieldsobjectkey][
'computed'][$key]) {
68 $value =
dol_eval((
string) $extrafields->attributes[$extrafieldsobjectkey][
'computed'][$key], 1, 1,
'2');
69 if (is_numeric(
price2num($value)) && $extrafields->attributes[$extrafieldsobjectkey][
'totalizable'][$key]) {
74 $valuetoshow = $extrafields->showOutputField($key, $value,
'', $extrafieldsobjectkey,
null,
$object);
77 print
'<td'.($cssclass ?
' class="'.$cssclass.
'"' :
'');
78 print
' data-key="'.$extrafieldsobjectkey.
'.'.$key.
'"';
85 if (empty($totalarray)) {
86 $totalarray[
'nbfield'] = 0;
88 $totalarray[
'nbfield']++;
91 if (!empty($extrafields->attributes[$extrafieldsobjectkey][
'totalizable'][$key])) {
94 $totalarray[
'totalizable'][$key][
'pos'] = $totalarray[
'nbfield'];
96 if (isset($obj->$tmpkey) && is_numeric($obj->$tmpkey)) {
97 if (!isset($totalarray[
'totalizable'][$key][
'total'])) {
98 $totalarray[
'totalizable'][$key][
'total'] = 0;
100 $totalarray[
'totalizable'][$key][
'total'] += $obj->$tmpkey;
104 if (!empty($extrafields->attributes[$extrafieldsobjectkey][
'totalizable'][$key]) && $extrafields->attributes[$extrafieldsobjectkey][
'totalizable'][$key] == 1) {
106 $totalarray[
'pos'][$totalarray[
'nbfield']] = $extrafieldsobjectprefix.$tmpkey;
108 if (!isset($totalarray[
'val'])) {
109 $totalarray[
'val'] = array();
111 if (!isset($totalarray[
'val'][$extrafieldsobjectprefix.$tmpkey])) {
112 $totalarray[
'val'][$extrafieldsobjectprefix.$tmpkey] = 0;
114 if (isset($obj->$tmpkey) && is_numeric($obj->$tmpkey)) {
115 if (!isset($totalarray[
'val'][$extrafieldsobjectprefix.$tmpkey])) {
116 $totalarray[
'val'][$extrafieldsobjectprefix.$tmpkey] = 0;
118 $totalarray[
'val'][$extrafieldsobjectprefix.$tmpkey] += $obj->$tmpkey;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...