/
extrafields_list_print_fields.tpl.php
83 lines (80 loc) · 2.69 KB
/
extrafields_list_print_fields.tpl.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf))
{
print "Error, template page can't be called as URL";
exit;
}
// Loop to show all columns of extrafields from $obj, $extrafields and $db
if (! empty($extrafieldsobjectkey)) // New method: $extrafieldsobject can be 'societe', 'socpeople', ...
{
if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
{
foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key, $extrafieldsobjectkey);
print '<td';
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
if (in_array($extrafields->attributes[$extrafieldsobjectkey]['type'][$key], array('date', 'datetime', 'timestamp')))
{
$value = $db->jdate($obj->$tmpkey);
}
else
{
$value = $obj->$tmpkey;
}
print $extrafields->showOutputField($key, $value, '', $extrafieldsobjectkey);
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
}
}
}
}
}
else // Old method
{
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
print '<td';
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
if (in_array($extrafields->attribute_type[$key], array('date', 'datetime', 'timestamp')))
{
$value = $db->jdate($obj->$tmpkey);
if (is_array($obj->array_options) && isset($obj->array_options[$tmpkey])){
$value = $db->jdate($obj->array_options[$tmpkey]);
}
}
else
{
$value = $obj->$tmpkey;
if (is_array($obj->array_options) && isset($obj->array_options[$tmpkey])){
$value = $obj->array_options[$tmpkey];
}
}
print $extrafields->showOutputField($key, $value, '');
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
}
}
}
}
}