41 global $langs, $extrafields, $db;
47 return $arrayofmesures;
50 if (empty($tablepath)) {
51 $tablepath =
$object->table_element.
'='.$tablealias;
53 $tablepath .=
','.$object->table_element.
'='.$tablealias;
58 $arrayofmesures[$tablealias.
'.count'] = array(
59 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').$labelofobject.
': '.$langs->trans(
"Number"),
60 'labelnohtml' => $labelofobject.
': '.$langs->trans(
"Number"),
62 'table' =>
$object->table_element,
63 'tablefromt' => $tablepath
70 foreach (
$object->fields as $key => $val) {
72 if (isset($val[
'bi']) && (int) $val[
'bi'] == 0) {
75 if (!empty($val[
'isameasure']) && (!isset($val[
'enabled']) || (int)
dol_eval((
string) $val[
'enabled'], 1, 1,
'1'))) {
76 $position = (empty($val[
'position']) ? 0 : intval($val[
'position']));
77 $arrayofmesures[$tablealias.
'.'.$key.
'-sum'] = array(
78 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').$labelofobject.
': '.$langs->trans($val[
'label']).
' <span class="opacitymedium">('.$langs->trans(
"Sum").
')</span>',
79 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
80 'position' => ($position + ($count * 100000)).
'.1',
81 'table' =>
$object->table_element,
82 'tablefromt' => $tablepath
84 $arrayofmesures[$tablealias.
'.'.$key.
'-average'] = array(
85 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').$labelofobject.
': '.$langs->trans($val[
'label']).
' <span class="opacitymedium">('.$langs->trans(
"Average").
')</span>',
86 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
87 'position' => ($position + ($count * 100000)).
'.2',
88 'table' =>
$object->table_element,
89 'tablefromt' => $tablepath
91 $arrayofmesures[$tablealias.
'.'.$key.
'-min'] = array(
92 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').$labelofobject.
': '.$langs->trans($val[
'label']).
' <span class="opacitymedium">('.$langs->trans(
"Minimum").
')</span>',
93 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
94 'position' => ($position + ($count * 100000)).
'.3',
95 'table' =>
$object->table_element,
96 'tablefromt' => $tablepath
98 $arrayofmesures[$tablealias.
'.'.$key.
'-max'] = array(
99 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').$labelofobject.
': '.$langs->trans($val[
'label']).
' <span class="opacitymedium">('.$langs->trans(
"Maximum").
')</span>',
100 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
101 'position' => ($position + ($count * 100000)).
'.4',
102 'table' =>
$object->table_element,
103 'tablefromt' => $tablepath
105 $arrayofmesures[$tablealias.
'.'.$key.
'-stddevpop'] = array(
106 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').$labelofobject.
': '.$langs->trans($val[
'label']).
' <span class="opacitymedium">('.$langs->trans(
"StandardDeviationPop").
')</span>',
107 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
108 'position' => ($position + ($count * 100000)).
'.5',
109 'table' =>
$object->table_element,
110 'tablefromt' => $tablepath
115 if (!empty(
$object->isextrafieldmanaged) && isset($extrafields->attributes[
$object->table_element][
'label'])) {
116 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
117 if (!empty($extrafields->attributes[
$object->table_element][
'totalizable'][$key]) && (!isset($extrafields->attributes[
$object->table_element][
'enabled'][$key]) || (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'enabled'][$key], 1, 1,
'1'))) {
118 if (isset($extrafields->attributes[
$object->table_element][
'pos'][$key])) {
119 $position = $extrafields->attributes[
$object->table_element][
'pos'][$key];
123 $arrayofmesures[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key.
'-sum'] = array(
124 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').$labelofobject.
': '.$langs->trans($extrafields->attributes[
$object->table_element][
'label'][$key]).
' <span class="opacitymedium">('.$langs->trans(
"Sum").
')</span>',
125 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
126 'position' => ($position + ($count * 100000)).
'.1',
127 'table' =>
$object->table_element,
128 'tablefromt' => $tablepath
130 $arrayofmesures[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key.
'-average'] = array(
131 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').$labelofobject.
': '.$langs->trans($extrafields->attributes[
$object->table_element][
'label'][$key]).
' <span class="opacitymedium">('.$langs->trans(
"Average").
')</span>',
132 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
133 'position' => ($position + ($count * 100000)).
'.2',
134 'table' =>
$object->table_element,
135 'tablefromt' => $tablepath
137 $arrayofmesures[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key.
'-min'] = array(
138 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').$labelofobject.
': '.$langs->trans($extrafields->attributes[
$object->table_element][
'label'][$key]).
' <span class="opacitymedium">('.$langs->trans(
"Minimum").
')</span>',
139 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
140 'position' => ($position + ($count * 100000)).
'.3',
141 'table' =>
$object->table_element,
142 'tablefromt' => $tablepath
144 $arrayofmesures[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key.
'-max'] = array(
145 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').$labelofobject.
': '.$langs->trans($extrafields->attributes[
$object->table_element][
'label'][$key]).
' <span class="opacitymedium">('.$langs->trans(
"Maximum").
')</span>',
146 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
147 'position' => ($position + ($count * 100000)).
'.4',
148 'table' =>
$object->table_element,
149 'tablefromt' => $tablepath
151 $arrayofmesures[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key.
'-stddevpop'] = array(
152 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').$labelofobject.
': '.$langs->trans($extrafields->attributes[
$object->table_element][
'label'][$key]).
' <span class="opacitymedium">('.$langs->trans(
"StandardDeviationPop").
')</span>',
153 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
154 'position' => ($position + ($count * 100000)).
'.5',
155 'table' =>
$object->table_element,
156 'tablefromt' => $tablepath
162 foreach (
$object->fields as $key => $val) {
165 if (isset($val[
'bi']) && (int) $val[
'bi'] == 0) {
168 if (preg_match(
'/^[^:]+:[^:]+:/', $val[
'type'])) {
169 $tmptype = explode(
':', $val[
'type'], 4);
170 if ($tmptype[0] ==
'integer' && !empty($tmptype[1]) && !empty($tmptype[2])) {
171 $newobject = $tmptype[1];
173 if (class_exists($newobject)) {
174 $tmpobject =
new $newobject($db);
177 $tmptablepath = $tablepath;
178 $arrayofmesures =
fillArrayOfMeasures($tmpobject, $tablealias.
'__'.$key, ($level >= 1 ? $labelofobject.
' - ' :
'').$langs->trans($val[
'label']), $arrayofmesures, $level + 1, $count, $tmptablepath);
180 print
'For property '.$object->element.
'->'.$key.
', type="'.$val[
'type'].
'": Failed to find class '.$newobject.
" in file ".$tmptype[2].
"<br>\n";
186 return $arrayofmesures;
204 global $langs, $extrafields, $db;
210 return $arrayofxaxis;
213 if (empty($tablepath)) {
214 $tablepath =
$object->table_element.
'='.$tablealias;
216 $tablepath .=
','.$object->table_element.
'='.$tablealias;
219 $YYYY = substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1);
220 $MM = substr($langs->trans(
"Month"), 0, 1).substr($langs->trans(
"Month"), 0, 1);
221 $DD = substr($langs->trans(
"Day"), 0, 1).substr($langs->trans(
"Day"), 0, 1);
222 $HH = substr($langs->trans(
"Hour"), 0, 1).substr($langs->trans(
"Hour"), 0, 1);
223 $MI = substr($langs->trans(
"Minute"), 0, 1).substr($langs->trans(
"Minute"), 0, 1);
224 $SS = substr($langs->trans(
"Second"), 0, 1).substr($langs->trans(
"Second"), 0, 1);
233 foreach (
$object->fields as $key => $val) {
235 if (isset($val[
'bi']) && (
int) $val[
'bi'] == 0) {
238 if (empty($val[
'measure'])) {
239 if (in_array($key, array(
240 'id',
'ref_ext',
'rowid',
'entity',
'last_main_doc',
'logo',
'logo_squarred',
'extraparams',
241 'parent',
'photo',
'socialnetworks',
'webservices_url',
'webservices_key'))) {
244 if (isset($val[
'enabled']) && ! (
int)
dol_eval((
string) $val[
'enabled'], 1, 1,
'1')) {
247 if (isset($val[
'visible']) && ! (
int)
dol_eval((
string) $val[
'visible'], 1, 1,
'1')) {
250 if (preg_match(
'/^fk_/', $key) && !preg_match(
'/^fk_statu/', $key)) {
253 if (preg_match(
'/^pass/', $key)) {
256 if (in_array($val[
'type'], array(
'html',
'text'))) {
259 if (in_array($val[
'type'], array(
'timestamp',
'date',
'datetime'))) {
260 $position = (empty($val[
'position']) ? 0 : intval($val[
'position']));
261 $arrayofxaxis[$tablealias.
'.'.$key.
'-year'] = array(
262 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val[
'label']).
' <span class="opacitymedium">('.$YYYY.
')</span>',
263 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
264 'position' => ($position + ($count * 100000)).
'.1',
265 'table' =>
$object->table_element,
266 'tablefromt' => $tablepath
268 $arrayofxaxis[$tablealias.
'.'.$key.
'-month'] = array(
269 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val[
'label']).
' <span class="opacitymedium">('.$YYYY.
'-'.$MM.
')</span>',
270 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
271 'position' => ($position + ($count * 100000)).
'.2',
272 'table' =>
$object->table_element,
273 'tablefromt' => $tablepath
275 $arrayofxaxis[$tablealias.
'.'.$key.
'-day'] = array(
276 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val[
'label']).
' <span class="opacitymedium">('.$YYYY.
'-'.$MM.
'-'.$DD.
')</span>',
277 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
278 'position' => ($position + ($count * 100000)).
'.3',
279 'table' =>
$object->table_element,
280 'tablefromt' => $tablepath
283 $position = (empty($val[
'position']) ? 0 : intval($val[
'position']));
284 $arrayofxaxis[$tablealias.
'.'.$key] = array(
285 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val[
'label']),
286 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
287 'position' => ($position + ($count * 100000)),
288 'table' =>
$object->table_element,
289 'tablefromt' => $tablepath
296 if (!empty(
$object->isextrafieldmanaged) && isset($extrafields->attributes[
$object->table_element][
'label'])) {
297 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
298 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'separate') {
301 if (!empty($extrafields->attributes[
$object->table_element][
'totalizable'][$key])) {
305 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$key], array(
'timestamp',
'date',
'datetime'))) {
306 $position = (empty($extrafields->attributes[
$object->table_element][
'pos'][$key]) ? 0 : intval($extrafields->attributes[
$object->table_element][
'pos'][$key]));
307 $arrayofxaxis[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key.
'-year'] = array(
308 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val).
' <span class="opacitymedium">('.$YYYY.
')</span>',
309 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
310 'position' => ($position + ($count * 100000)).
'.1',
311 'table' =>
$object->table_element,
312 'tablefromt' => $tablepath
314 $arrayofxaxis[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key.
'-month'] = array(
315 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val).
' <span class="opacitymedium">('.$YYYY.
'-'.$MM.
')</span>',
316 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
317 'position' => ($position + ($count * 100000)).
'.2',
318 'table' =>
$object->table_element,
319 'tablefromt' => $tablepath
321 $arrayofxaxis[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key.
'-day'] = array(
322 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val).
' <span class="opacitymedium">('.$YYYY.
'-'.$MM.
'-'.$DD.
')</span>',
323 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
324 'position' => ($position + ($count * 100000)).
'.3',
325 'table' =>
$object->table_element,
326 'tablefromt' => $tablepath
329 $arrayofxaxis[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key] = array(
330 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val),
331 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
332 'position' => 1000 + (int) $extrafields->attributes[
$object->table_element][
'pos'][$key] + ($count * 100000),
333 'table' =>
$object->table_element,
334 'tablefromt' => $tablepath
341 foreach (
$object->fields as $key => $val) {
344 if (isset($val[
'bi']) && (int) $val[
'bi'] == 0) {
347 if (preg_match(
'/^[^:]+:[^:]+:/', $val[
'type'])) {
348 $tmptype = explode(
':', $val[
'type'], 4);
349 if ($tmptype[0] ==
'integer' && $tmptype[1] && $tmptype[2]) {
350 $newobject = $tmptype[1];
352 if (class_exists($newobject)) {
353 $tmpobject =
new $newobject($db);
356 $tmptablepath = $tablepath;
357 $arrayofxaxis =
fillArrayOfXAxis($tmpobject, $tablealias.
'__'.$key, ($level >= 1 ? $labelofobject.
' - ' :
'').$langs->trans($val[
'label']), $arrayofxaxis, $level + 1, $count, $tmptablepath);
359 print
'For property '.$object->element.
'->'.$key.
', type="'.$val[
'type'].
'": Failed to find class '.$newobject.
" in file ".$tmptype[2].
"<br>\n";
365 return $arrayofxaxis;
383 global $langs, $extrafields, $db;
389 return $arrayofgroupby;
392 if (empty($tablepath)) {
393 $tablepath =
$object->table_element.
'='.$tablealias;
395 $tablepath .=
','.$object->table_element.
'='.$tablealias;
398 $YYYY = substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1);
399 $MM = substr($langs->trans(
"Month"), 0, 1).substr($langs->trans(
"Month"), 0, 1);
400 $DD = substr($langs->trans(
"Day"), 0, 1).substr($langs->trans(
"Day"), 0, 1);
401 $HH = substr($langs->trans(
"Hour"), 0, 1).substr($langs->trans(
"Hour"), 0, 1);
402 $MI = substr($langs->trans(
"Minute"), 0, 1).substr($langs->trans(
"Minute"), 0, 1);
403 $SS = substr($langs->trans(
"Second"), 0, 1).substr($langs->trans(
"Second"), 0, 1);
408 foreach (
$object->fields as $key => $val) {
410 if (isset($val[
'bi']) && (
int) $val[
'bi'] == 0) {
413 if (empty($val[
'isameasure'])) {
414 if (in_array($key, array(
415 'id',
'ref_ext',
'rowid',
'entity',
'last_main_doc',
'logo',
'logo_squarred',
'extraparams',
416 'parent',
'photo',
'socialnetworks',
'webservices_url',
'webservices_key'))) {
419 if (isset($val[
'enabled']) && ! (
int)
dol_eval((
string) $val[
'enabled'], 1, 1,
'1')) {
422 if (isset($val[
'visible']) && ! (
int)
dol_eval((
string) $val[
'visible'], 1, 1,
'1')) {
425 if (preg_match(
'/^fk_/', $key) && !preg_match(
'/^fk_statu/', $key)) {
428 if (preg_match(
'/^pass/', $key)) {
431 if (in_array($val[
'type'], array(
'html',
'text'))) {
434 if (in_array($val[
'type'], array(
'timestamp',
'date',
'datetime'))) {
435 $position = (empty($val[
'position']) ? 0 : intval($val[
'position']));
436 $arrayofgroupby[$tablealias.
'.'.$key.
'-year'] = array(
437 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val[
'label']).
' <span class="opacitymedium">('.$YYYY.
')</span>',
438 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
439 'position' => ($position + ($count * 100000)).
'.1',
440 'table' =>
$object->table_element,
441 'tablefromt' => $tablepath
443 $arrayofgroupby[$tablealias.
'.'.$key.
'-month'] = array(
444 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val[
'label']).
' <span class="opacitymedium">('.$YYYY.
'-'.$MM.
')</span>',
445 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
446 'position' => ($position + ($count * 100000)).
'.2',
447 'table' =>
$object->table_element,
448 'tablefromt' => $tablepath
450 $arrayofgroupby[$tablealias.
'.'.$key.
'-day'] = array(
451 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val[
'label']).
' <span class="opacitymedium">('.$YYYY.
'-'.$MM.
'-'.$DD.
')</span>',
452 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
453 'position' => ($position + ($count * 100000)).
'.3',
454 'table' =>
$object->table_element,
455 'tablefromt' => $tablepath
458 $position = (empty($val[
'position']) ? 0 : intval($val[
'position']));
459 $arrayofgroupby[$tablealias.
'.'.$key] = array(
460 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val[
'label']),
461 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
462 'position' => ($position + ($count * 100000)),
463 'table' =>
$object->table_element,
464 'tablefromt' => $tablepath
471 if (!empty(
$object->isextrafieldmanaged) && isset($extrafields->attributes[
$object->table_element][
'label'])) {
472 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
473 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'separate') {
476 if (!empty($extrafields->attributes[
$object->table_element][
'totalizable'][$key])) {
480 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$key], array(
'timestamp',
'date',
'datetime'))) {
481 $position = (empty($extrafields->attributes[
$object->table_element][
'pos'][$key]) ? 0 : intval($extrafields->attributes[
$object->table_element][
'pos'][$key]));
482 $arrayofgroupby[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key.
'-year'] = array(
483 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val).
' <span class="opacitymedium">('.$YYYY.
')</span>',
484 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
485 'position' => ($position + ($count * 100000)).
'.1',
486 'table' =>
$object->table_element,
487 'tablefromt' => $tablepath
489 $arrayofgroupby[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key.
'-month'] = array(
490 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val).
' <span class="opacitymedium">('.$YYYY.
'-'.$MM.
')</span>',
491 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
492 'position' => ($position + ($count * 100000)).
'.2',
493 'table' =>
$object->table_element,
494 'tablefromt' => $tablepath
496 $arrayofgroupby[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key.
'-day'] = array(
497 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val).
' <span class="opacitymedium">('.$YYYY.
'-'.$MM.
'-'.$DD.
')</span>',
498 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
499 'position' => ($position + ($count * 100000)).
'.3',
500 'table' =>
$object->table_element,
501 'tablefromt' => $tablepath
504 $arrayofgroupby[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key] = array(
505 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val),
506 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
507 'position' => 1000 + (int) $extrafields->attributes[
$object->table_element][
'pos'][$key] + ($count * 100000),
508 'table' =>
$object->table_element,
509 'tablefromt' => $tablepath
516 foreach (
$object->fields as $key => $val) {
519 if (isset($val[
'bi']) && (int) $val[
'bi'] == 0) {
522 if (preg_match(
'/^[^:]+:[^:]+:/', $val[
'type'])) {
523 $tmptype = explode(
':', $val[
'type'], 4);
524 if ($tmptype[0] ==
'integer' && $tmptype[1] && $tmptype[2]) {
525 $newobject = $tmptype[1];
527 if (class_exists($newobject)) {
528 $tmpobject =
new $newobject($db);
531 $tmptablepath = $tablepath;
532 $arrayofgroupby =
fillArrayOfGroupBy($tmpobject, $tablealias.
'__'.$key, ($level >= 1 ? $labelofobject.
' - ' :
'').$langs->trans($val[
'label']), $arrayofgroupby, $level + 1, $count, $tmptablepath);
534 print
'For property '.$object->element.
'->'.$key.
', type="'.$val[
'type'].
'": Failed to find class '.$newobject.
" in file ".$tmptype[2].
"<br>\n";
540 return $arrayofgroupby;
558 global $langs, $extrafields, $db;
565 if ($level > $MAXLEVEL) {
566 return $arrayoffields;
569 if (empty($tablepath)) {
570 $tablepath =
$object->table_element.
'='.$tablealias;
572 $tablepath .=
','.$object->table_element.
'='.$tablealias;
578 foreach (
$object->fields as $key => $val) {
579 if (empty($val[
'measure'])) {
581 if (in_array($key, array(
582 'id',
'ref_ext',
'rowid',
'entity',
'last_main_doc',
'logo',
'logo_squarred',
'extraparams',
583 'parent',
'pass',
'pass_crypted',
'pass_temp',
'photo',
'socialnetworks',
'webservices_url',
'webservices_key'))) {
586 if (isset($val[
'enabled']) && ! (
int)
dol_eval((
string) $val[
'enabled'], 1, 1,
'1')) {
589 if (isset($val[
'visible']) && ! (
int)
dol_eval((
string) $val[
'visible'], 1, 1,
'1')) {
592 if (preg_match(
'/^fk_/', $key) && !preg_match(
'/^fk_statu/', $key)) {
595 if (preg_match(
'/^pass/', $key)) {
598 if (in_array($val[
'type'], array(
'html',
'text'))) {
602 $position = (empty($val[
'position']) ? 0 : intval($val[
'position']));
603 $arrayoffields[$tablealias.
'.'.$key] = array(
604 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val[
'label']),
605 'labelnohtml' => $labelofobject.
': '.$langs->trans($val[
'label']),
606 'position' => ($position + ($count * 100000)),
607 'table' =>
$object->table_element,
608 'tablefromt' => $tablepath,
609 'type' => $val[
'type']
611 if (!empty($val[
'arrayofkeyval'])) {
612 $arrayoffields[$tablealias.
'.'.$key][
'arrayofkeyval'] = $val[
'arrayofkeyval'];
614 if ((!isset($val[
'isamesaure']) || $val[
'isamesaure'] != 1) && (!isset($val[
'notnull']) || $val[
'notnull'] !=
'1')) {
615 $arrayoffields[$tablealias.
'.'.$key][
'maybenull'] = 1;
618 if (isset($val[
'bi'])) {
619 $arrayoffields[$tablealias.
'.'.$key][
'bi'] = (int) $val[
'bi'];
625 if (!empty(
$object->isextrafieldmanaged) && isset($extrafields->attributes[
$object->table_element][
'label'])) {
626 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
627 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'separate') {
630 if (!empty($extrafields->attributes[
$object->table_element][
'totalizable'][$key])) {
634 $arrayoffields[preg_replace(
'/^t/',
'te', $tablealias).
'.'.$key] = array(
635 'label' => img_picto(
'', (empty(
$object->picto) ?
'generic' :
$object->picto),
'class="pictofixedwidth"').
' '.$labelofobject.
': '.$langs->trans($val),
636 'labelnohtml' => $labelofobject.
': '.$langs->trans($val),
637 'position' => 1000 + (int) $extrafields->attributes[
$object->table_element][
'pos'][$key] + ($count * 100000),
638 'table' =>
$object->table_element,
639 'tablefromt' => $tablepath,
640 'type' => $extrafields->attributes[
$object->table_element][
'type'][$key],
646 foreach (
$object->fields as $key => $val) {
649 if (isset($val[
'bi']) && (int) $val[
'bi'] == 0) {
652 if (preg_match(
'/^[^:]+:[^:]+:/', $val[
'type'])) {
653 $tmptype = explode(
':', $val[
'type'], 4);
654 if ($tmptype[0] ==
'integer' && $tmptype[1] && $tmptype[2]) {
655 $newobject = $tmptype[1];
657 if (class_exists($newobject)) {
658 $tmpobject =
new $newobject($db);
660 if (!empty($val[
'nodepth'])) {
661 $tmptablepath = $tablepath;
662 $arrayoffields =
fillArrayOfFilterFields($tmpobject, $tablealias.
'__'.$key, ($level >= 1 ? $labelofobject.
' - ' :
'').$langs->trans($val[
'label']), $arrayoffields, $MAXLEVEL, $count, $tmptablepath);
664 $tmptablepath = $tablepath;
665 $arrayoffields =
fillArrayOfFilterFields($tmpobject, $tablealias.
'__'.$key, ($level >= 1 ? $labelofobject.
' - ' :
'').$langs->trans($val[
'label']), $arrayoffields, $level + 1, $count, $tmptablepath);
668 print
'For property '.$object->element.
'->'.$key.
', type="'.$val[
'type'].
'": Failed to find class '.$newobject.
" in file ".$tmptype[2].
"<br>\n";
674 return $arrayoffields;
691 global
$conf, $langs;
693 $variantlabels = array(
694 'sum' => $langs->trans(
"Sum"),
695 'average' => $langs->trans(
"Average"),
696 'min' => $langs->trans(
"Minimum"),
697 'max' => $langs->trans(
"Maximum"),
698 'stddevpop' => $langs->trans(
"StandardDeviationPop"),
703 foreach ($arrayofmesures as $key => $val) {
705 if (preg_match(
'/^(.+)-(sum|average|min|max|stddevpop)$/', $key, $reg)) {
712 if (!isset($groups[$groupkey])) {
715 $pos = strpos($val[
'label'], $val[
'labelnohtml']);
716 if ($pos !==
false) {
717 $picto = substr($val[
'label'], 0, $pos);
719 $groups[$groupkey] = array(
721 'labelnohtml' => $val[
'labelnohtml'],
722 'variants' => array()
725 $groups[$groupkey][
'variants'][$key] = ($variant ? $variantlabels[$variant] :
'');
728 $out =
'<div class="customreportsmeasures divadvancedsearchfieldcompinput inline-block minwidth300 maxwidth500" id="'.dol_escape_htmltag($htmlname).
'_component" data-htmlname="'.
dol_escape_htmltag($htmlname).
'">';
731 $out .=
'<select id="'.dol_escape_htmltag($htmlname).
'" name="'.
dol_escape_htmltag($htmlname).
'[]" multiple class="hideobject">';
732 foreach ($arrayofmesures as $key => $val) {
733 $out .=
'<option value="'.dol_escape_htmltag($key).
'"'.(in_array($key, $selected) ?
' selected' :
'').
'>'.
dol_escape_htmltag($val[
'labelnohtml']).
'</option>';
738 $out .=
'<div class="customreportsmeasures-control noborderbottom search_component_params inline-block" tabindex="0" role="combobox" aria-expanded="false" aria-haspopup="listbox">';
739 $out .=
'<span class="customreportsmeasures-tags"></span>';
740 $out .=
'<span class="customreportsmeasures-placeholder opacitymedium">'.dol_escape_htmltag($placeholder).
'</span>';
741 $out .=
'<span class="fas fa-caret-down customreportsmeasures-caret"></span>';
745 $out .=
'<div class="customreportsmeasures-dropdown hidden">';
746 $out .=
'<div class="liinputsearch"><input type="text" class="customreportsmeasures-search noborderfocus" placeholder="'.dol_escape_htmltag($langs->trans(
"Search")).
'" autocomplete="off"></div>';
747 $out .=
'<ul class="customreportsmeasures-list" role="listbox">';
748 foreach ($groups as $groupkey => $group) {
749 $hasvariants = (count($group[
'variants']) > 1 || key($group[
'variants']) != $groupkey);
750 $out .=
'<li class="customreportsmeasures-field'.($hasvariants ?
' customreportsmeasures-hasvariants' :
'').
'" data-search="'.
dol_escape_htmltag(
dol_strtolower($group[
'labelnohtml'])).
'">';
752 $out .=
'<div class="customreportsmeasures-fieldlabel">';
753 $out .=
'<span class="customreportsmeasures-text">'.$group[
'picto'].dol_escape_htmltag($group[
'labelnohtml']).
'</span>';
754 $out .=
'<span class="customreportsmeasures-count badge badge-secondary hidden"></span>';
755 $out .=
'<span class="fas fa-caret-right customreportsmeasures-expand"></span>';
757 $out .=
'<ul class="customreportsmeasures-variants hidden">';
758 foreach ($group[
'variants'] as $key => $variantlabel) {
759 $out .=
'<li class="customreportsmeasures-item" role="option" data-value="'.dol_escape_htmltag($key).
'" data-tag="'.
dol_escape_htmltag($group[
'labelnohtml'].
' ('.$variantlabel.
')').
'">';
760 $out .=
'<span class="customreportsmeasures-text">'.dol_escape_htmltag($variantlabel).
'</span>';
761 $out .=
'<span class="fas fa-check customreportsmeasures-check"></span>';
766 $out .=
'<div class="customreportsmeasures-fieldlabel customreportsmeasures-item" role="option" data-value="'.dol_escape_htmltag($groupkey).
'" data-tag="'.
dol_escape_htmltag($group[
'labelnohtml']).
'">';
767 $out .=
'<span class="customreportsmeasures-text">'.$group[
'picto'].dol_escape_htmltag($group[
'labelnohtml']).
'</span>';
768 $out .=
'<span class="fas fa-check customreportsmeasures-check"></span>';
778 if (empty(
$conf->cache[
'customreportsjsloaded'])) {
779 $out .=
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/customreports.js"></script>';
780 $conf->cache[
'customreportsjsloaded'] = 1;
782 $out .=
'<script nonce="'.getNonce().
'">jQuery(document).ready(function() { initCustomReportsMeasures(\''.
dol_escape_js($htmlname).
'_component\'); });</script>';
802 global
$conf, $langs;
804 $selectedkey = (is_array($selected) && count($selected)) ? (
string) reset($selected) :
'';
806 $variantlabels = array(
'year' => $langs->trans(
"Year"),
'month' => $langs->trans(
"Year").
' - '.$langs->trans(
"Month"),
'day' => $langs->trans(
"Year").
' - '.$langs->trans(
"Month").
' - '.$langs->trans(
"Day"));
811 foreach ($arrayoffields as $key => $val) {
812 $elementkey = preg_replace(
'/^te(__|$)/',
't$1', preg_replace(
'/\.[^.]*$/',
'', $key));
814 $elementlabel = $elementkey;
816 if (preg_match(
'/^(.+?): /', $val[
'labelnohtml'], $reg)) {
817 $elementlabel = $reg[1];
820 $fieldlabel = $val[
'labelnohtml'];
821 $pos = strpos($val[
'label'], $val[
'labelnohtml']);
822 if ($pos !==
false) {
823 $picto = trim(substr($val[
'label'], 0, $pos));
824 $fieldlabel = trim(
dol_string_nohtmltag(substr($val[
'label'], $pos + ($elementlabel != $elementkey ? strlen($elementlabel) + 2 : 0))));
826 if (!isset($elements[$elementkey])) {
827 $elements[$elementkey] = array(
'picto' => $picto,
'label' => $elementlabel,
'fields' => array(),
'datefields' => array());
829 $elements[$elementkey][
'fields'][$key] = $fieldlabel;
831 if (preg_match(
'/^(.+)-(year|month|day)$/', $key, $reg)) {
832 $regformat = array();
833 $format = (preg_match(
'/(\([^()]*\))\s*<\/span>\s*$/', $val[
'label'], $regformat) ?
' '.$regformat[1] :
'');
834 $elements[$elementkey][
'datefields'][$reg[1]][
'label'] = ($elementlabel != $elementkey ? substr($val[
'labelnohtml'], strlen($elementlabel) + 2) : $val[
'labelnohtml']);
835 $elements[$elementkey][
'datefields'][$reg[1]][
'variants'][$key] = $variantlabels[$reg[2]].$format;
837 if ($key === $selectedkey) {
839 $selectedtitle = $elementlabel.
': '.$fieldlabel;
843 $out =
'<div class="customreportscombo divadvancedsearchfieldcompinput" id="'.dol_escape_htmltag($htmlname).
'_component">';
844 $out .=
'<input type="hidden" id="'.dol_escape_htmltag($htmlname).
'" name="'.
dol_escape_htmltag($htmlname).
'" value="'.
dol_escape_htmltag($selectedlabel ? $selectedkey :
'').
'">';
845 $out .=
'<button type="button" class="customreportscombo-toggle noborderbottom search_component_params minwidth300">';
846 $out .=
'<span class="customreportscombo-label'.($selectedlabel ?
'' :
' opacitymedium').
'"'.($selectedtitle ?
' title="'.dolPrintHTMLForAttribute($selectedtitle).
'"' :
'').
' data-placeholder="'.
dol_escape_htmltag($placeholder).
'">'.($selectedlabel ? $selectedlabel :
dol_escape_htmltag($placeholder)).
'</span>';
848 $out .=
'<span class="fas fa-times customreportscombo-clear'.($selectedlabel ?
'' :
' hideobject').
'" title="'.
dol_escape_htmltag($langs->trans(
'Reset')).
'"></span>';
850 $out .=
'<span class="fas fa-caret-down customreportscombo-caret"></span>';
852 $out .=
'<div class="customreportscombo-panel" style="display:none">';
853 $out .=
'<div class="liinputsearch"><input type="text" class="customreportscombo-search noborderfocus" placeholder="'.dol_escape_htmltag($langs->trans(
'Search')).
'" autocomplete="off"></div>';
854 $out .=
'<div class="customreportscombo-list">';
861 $renderElement =
function (
string $elementkey) use ($elements, $selectedkey, &$renderElement):
string {
862 $element = $elements[$elementkey];
863 $out =
'<div class="customreportscombo-element" data-element="'.dol_escape_htmltag($elementkey).
'">';
864 $out .=
'<div class="customreportscombo-elementheader" tabindex="0"><span class="customreportscombo-elementlabel">'.$element[
'picto'].
' '.
dol_escape_htmltag($element[
'label']).
'</span><span class="fas fa-caret-right customreportscombo-elementcaret"></span></div>';
865 $out .=
'<div class="customreportscombo-fields" style="display:none">';
866 foreach ($element[
'fields'] as $fieldkey => $fieldlabel) {
868 if (preg_match(
'/^(.+)-(year|month|day)$/', $fieldkey, $reg) && isset($element[
'datefields'][$reg[1]])) {
870 if (empty($element[
'datefields'][$reg[1]][
'variants'])) {
873 $out .=
'<div class="customreportscombo-datefield">';
874 $out .=
'<div class="customreportscombo-datefieldheader" tabindex="0"><span>'.dol_escape_htmltag($element[
'datefields'][$reg[1]][
'label']).
'</span><span class="fas fa-caret-right customreportscombo-datefieldcaret"></span></div>';
875 $out .=
'<div class="customreportscombo-variants" style="display:none">';
876 foreach ($element[
'datefields'][$reg[1]][
'variants'] as $variantkey => $variantlabel) {
877 $out .=
'<div class="customreportscombo-field'.($variantkey === $selectedkey ?
' selected' :
'').
'" tabindex="0" data-field="'.
dol_escape_htmltag($variantkey).
'" data-label="'.
dol_escape_htmltag($element[
'fields'][$variantkey]).
'">'.
dol_escape_htmltag($variantlabel).
'</div>';
881 $element[
'datefields'][$reg[1]][
'variants'] = array();
884 $out .=
'<div class="customreportscombo-field'.($fieldkey === $selectedkey ?
' selected' :
'').
'" tabindex="0" data-field="'.
dol_escape_htmltag($fieldkey).
'">'.
dol_escape_htmltag($fieldlabel).
'</div>';
888 foreach (array_keys($elements) as $childkey) {
889 if (strpos($childkey, $elementkey.
'__') === 0 && strpos(substr($childkey, strlen($elementkey) + 2),
'__') ===
false) {
890 $children .= $renderElement($childkey);
894 $out .=
'<div class="customreportscombo-children" style="display:none">'.$children.
'</div>';
900 foreach (array_keys($elements) as $elementkey) {
901 $parentkey = (strpos($elementkey,
'__') !==
false) ? substr($elementkey, 0, strrpos($elementkey,
'__')) :
'';
902 if ($parentkey ==
'' || !isset($elements[$parentkey])) {
903 $out .= $renderElement($elementkey);
911 if (empty(
$conf->cache[
'customreportsjsloaded'])) {
912 $out .=
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/customreports.js"></script>';
913 $conf->cache[
'customreportsjsloaded'] = 1;
915 $out .=
'<script nonce="'.getNonce().
'">jQuery(document).ready(function() { initCustomReportsCombo(\''.
dol_escape_js($htmlname).
'_component\'); });</script>';
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined: