dolibarr 21.0.0-alpha
customreports.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4*
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 * or see https://www.gnu.org/
18 */
19
37function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesures, $level = 0, &$count = 0, &$tablepath = '')
38{
39 global $langs, $extrafields, $db;
40
41 if (empty($object)) { // Protection against bad use of method
42 return array();
43 }
44 if ($level > 10) { // Protection against infinite loop
45 return $arrayofmesures;
46 }
47
48 if (empty($tablepath)) {
49 $tablepath = $object->table_element.'='.$tablealias;
50 } else {
51 $tablepath .= ','.$object->table_element.'='.$tablealias;
52 }
53
54 if ($level == 0) {
55 // Add the count of record only for the main/first level object. Parents are necessarily unique for each record.
56 $arrayofmesures[$tablealias.'.count'] = array(
57 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans("Number"),
58 'labelnohtml' => $labelofobject.': '.$langs->trans("Number"),
59 'position' => 0,
60 'table' => $object->table_element,
61 'tablefromt' => $tablepath
62 );
63 }
64
65 // Note: here $tablealias can be 't' or 't__fk_contract' or 't_fk_contract_fk_soc'
66
67 // Add main fields of object
68 foreach ($object->fields as $key => $val) {
69 if (!empty($val['isameasure']) && (!isset($val['enabled']) || (int) dol_eval($val['enabled'], 1, 1, '1'))) {
70 $position = (empty($val['position']) ? 0 : intval($val['position']));
71 $arrayofmesures[$tablealias.'.'.$key.'-sum'] = array(
72 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>',
73 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
74 'position' => ($position + ($count * 100000)).'.1',
75 'table' => $object->table_element,
76 'tablefromt' => $tablepath
77 );
78 $arrayofmesures[$tablealias.'.'.$key.'-average'] = array(
79 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Average").')</span>',
80 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
81 'position' => ($position + ($count * 100000)).'.2',
82 'table' => $object->table_element,
83 'tablefromt' => $tablepath
84 );
85 $arrayofmesures[$tablealias.'.'.$key.'-min'] = array(
86 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>',
87 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
88 'position' => ($position + ($count * 100000)).'.3',
89 'table' => $object->table_element,
90 'tablefromt' => $tablepath
91 );
92 $arrayofmesures[$tablealias.'.'.$key.'-max'] = array(
93 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>',
94 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
95 'position' => ($position + ($count * 100000)).'.4',
96 'table' => $object->table_element,
97 'tablefromt' => $tablepath
98 );
99 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
100 $arrayofmesures[$tablealias.'.'.$key.'-stddevpop'] = array(
101 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("StandardDeviationPop").')</span>',
102 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
103 'position' => ($position + ($count * 100000)).'.5',
104 'table' => $object->table_element,
105 'tablefromt' => $tablepath
106 );
107 }
108 }
109 }
110 // Add extrafields to Measures
111 if (!empty($object->isextrafieldmanaged) && isset($extrafields->attributes[$object->table_element]['label'])) {
112 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
113 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'))) {
114 // @phan-suppress-next-line PhanTypeMismatchDimAssignment
115 $position = (!empty($val['position']) ? $val['position'] : 0);
116 $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-sum'] = array(
117 '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>',
118 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
119 'position' => ($position + ($count * 100000)).'.1',
120 'table' => $object->table_element,
121 'tablefromt' => $tablepath
122 );
123 $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-average'] = 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("Average").')</span>',
125 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
126 'position' => ($position + ($count * 100000)).'.2',
127 'table' => $object->table_element,
128 'tablefromt' => $tablepath
129 );
130 $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-min'] = 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("Minimum").')</span>',
132 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
133 'position' => ($position + ($count * 100000)).'.3',
134 'table' => $object->table_element,
135 'tablefromt' => $tablepath
136 );
137 $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-max'] = 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("Maximum").')</span>',
139 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
140 'position' => ($position + ($count * 100000)).'.4',
141 'table' => $object->table_element,
142 'tablefromt' => $tablepath
143 );
144 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
145 $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-stddevpop'] = array(
146 '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>',
147 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
148 'position' => ($position + ($count * 100000)).'.5',
149 'table' => $object->table_element,
150 'tablefromt' => $tablepath
151 );
152 }
153 }
154 }
155 }
156 // Add fields for parent objects
157 foreach ($object->fields as $key => $val) {
158 if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
159 $tmptype = explode(':', $val['type'], 4);
160 if ($tmptype[0] == 'integer' && !empty($tmptype[1]) && !empty($tmptype[2])) {
161 $newobject = $tmptype[1];
162 dol_include_once($tmptype[2]);
163 if (class_exists($newobject)) {
164 $tmpobject = new $newobject($db);
165 //var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
166 $count++;
167 $arrayofmesures = fillArrayOfMeasures($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofmesures, $level + 1, $count, $tablepath);
168 } else {
169 print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
170 }
171 }
172 }
173 }
174
175 return $arrayofmesures;
176}
177
178
191function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, $level = 0, &$count = 0, &$tablepath = '')
192{
193 global $langs, $extrafields, $db;
194
195 if (empty($object)) { // Protection against bad use of method
196 return array();
197 }
198 if ($level >= 3) { // Limit scan on 2 levels max
199 return $arrayofxaxis;
200 }
201
202 if (empty($tablepath)) {
203 $tablepath = $object->table_element.'='.$tablealias;
204 } else {
205 $tablepath .= ','.$object->table_element.'='.$tablealias;
206 }
207
208 $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);
209 $MM = substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1);
210 $DD = substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1);
211 $HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1);
212 $MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1);
213 $SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1);
214
215 /*if ($level > 0) {
216 var_dump($object->element.' '.$object->isextrafieldmanaged);
217 }*/
218
219 // Note: here $tablealias can be 't' or 't__fk_contract' or 't_fk_contract_fk_soc'
220
221 // Add main fields of object
222 foreach ($object->fields as $key => $val) {
223 if (empty($val['measure'])) {
224 if (in_array($key, array(
225 'id', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams',
226 'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) {
227 continue;
228 }
229 if (isset($val['enabled']) && ! (int) dol_eval($val['enabled'], 1, 1, '1')) {
230 continue;
231 }
232 if (isset($val['visible']) && ! (int) dol_eval($val['visible'], 1, 1, '1')) {
233 continue;
234 }
235 if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) {
236 continue;
237 }
238 if (preg_match('/^pass/', $key)) {
239 continue;
240 }
241 if (in_array($val['type'], array('html', 'text'))) {
242 continue;
243 }
244 if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
245 $position = (empty($val['position']) ? 0 : intval($val['position']));
246 $arrayofxaxis[$tablealias.'.'.$key.'-year'] = array(
247 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>',
248 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
249 'position' => ($position + ($count * 100000)).'.1',
250 'table' => $object->table_element,
251 'tablefromt' => $tablepath
252 );
253 $arrayofxaxis[$tablealias.'.'.$key.'-month'] = array(
254 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>',
255 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
256 'position' => ($position + ($count * 100000)).'.2',
257 'table' => $object->table_element,
258 'tablefromt' => $tablepath
259 );
260 $arrayofxaxis[$tablealias.'.'.$key.'-day'] = array(
261 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>',
262 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
263 'position' => ($position + ($count * 100000)).'.3',
264 'table' => $object->table_element,
265 'tablefromt' => $tablepath
266 );
267 } else {
268 $position = (empty($val['position']) ? 0 : intval($val['position']));
269 $arrayofxaxis[$tablealias.'.'.$key] = array(
270 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']),
271 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
272 'position' => ($position + ($count * 100000)),
273 'table' => $object->table_element,
274 'tablefromt' => $tablepath
275 );
276 }
277 }
278 }
279
280 // Add extrafields to X-Axis
281 if (!empty($object->isextrafieldmanaged) && isset($extrafields->attributes[$object->table_element]['label'])) {
282 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
283 if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') {
284 continue;
285 }
286 if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
287 continue;
288 }
289
290 if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('timestamp', 'date', 'datetime'))) {
291 $position = (empty($extrafields->attributes[$object->table_element]['pos'][$key]) ? 0 : intval($extrafields->attributes[$object->table_element]['pos'][$key]));
292 $arrayofxaxis[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-year'] = array(
293 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' <span class="opacitymedium">('.$YYYY.')</span>',
294 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
295 'position' => ($position + ($count * 100000)).'.1',
296 'table' => $object->table_element,
297 'tablefromt' => $tablepath
298 );
299 $arrayofxaxis[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-month'] = array(
300 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>',
301 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
302 'position' => ($position + ($count * 100000)).'.2',
303 'table' => $object->table_element,
304 'tablefromt' => $tablepath
305 );
306 $arrayofxaxis[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-day'] = array(
307 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>',
308 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
309 'position' => ($position + ($count * 100000)).'.3',
310 'table' => $object->table_element,
311 'tablefromt' => $tablepath
312 );
313 } else {
314 $arrayofxaxis[preg_replace('/^t/', 'te', $tablealias).'.'.$key] = array(
315 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val),
316 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
317 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000),
318 'table' => $object->table_element,
319 'tablefromt' => $tablepath
320 );
321 }
322 }
323 }
324
325 // Add fields for parent objects
326 foreach ($object->fields as $key => $val) {
327 if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
328 $tmptype = explode(':', $val['type'], 4);
329 if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
330 $newobject = $tmptype[1];
331 dol_include_once($tmptype[2]);
332 if (class_exists($newobject)) {
333 $tmpobject = new $newobject($db);
334 //var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
335 $count++;
336 $arrayofxaxis = fillArrayOfXAxis($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofxaxis, $level + 1, $count, $tablepath);
337 } else {
338 print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
339 }
340 }
341 }
342 }
343
344 return $arrayofxaxis;
345}
346
347
360function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroupby, $level = 0, &$count = 0, &$tablepath = '')
361{
362 global $langs, $extrafields, $db;
363
364 if (empty($object)) { // Protection against bad use of method
365 return array();
366 }
367 if ($level >= 3) {
368 return $arrayofgroupby;
369 }
370
371 if (empty($tablepath)) {
372 $tablepath = $object->table_element.'='.$tablealias;
373 } else {
374 $tablepath .= ','.$object->table_element.'='.$tablealias;
375 }
376
377 $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);
378 $MM = substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1);
379 $DD = substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1);
380 $HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1);
381 $MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1);
382 $SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1);
383
384 // Note: here $tablealias can be 't' or 't__fk_contract' or 't_fk_contract_fk_soc'
385
386 // Add main fields of object
387 foreach ($object->fields as $key => $val) {
388 if (empty($val['isameasure'])) {
389 if (in_array($key, array(
390 'id', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams',
391 'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) {
392 continue;
393 }
394 if (isset($val['enabled']) && ! (int) dol_eval($val['enabled'], 1, 1, '1')) {
395 continue;
396 }
397 if (isset($val['visible']) && ! (int) dol_eval($val['visible'], 1, 1, '1')) {
398 continue;
399 }
400 if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) {
401 continue;
402 }
403 if (preg_match('/^pass/', $key)) {
404 continue;
405 }
406 if (in_array($val['type'], array('html', 'text'))) {
407 continue;
408 }
409 if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
410 $position = (empty($val['position']) ? 0 : intval($val['position']));
411 $arrayofgroupby[$tablealias.'.'.$key.'-year'] = array(
412 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>',
413 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
414 'position' => ($position + ($count * 100000)).'.1',
415 'table' => $object->table_element,
416 'tablefromt' => $tablepath
417 );
418 $arrayofgroupby[$tablealias.'.'.$key.'-month'] = array(
419 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>',
420 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
421 'position' => ($position + ($count * 100000)).'.2',
422 'table' => $object->table_element,
423 'tablefromt' => $tablepath
424 );
425 $arrayofgroupby[$tablealias.'.'.$key.'-day'] = array(
426 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>',
427 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
428 'position' => ($position + ($count * 100000)).'.3',
429 'table' => $object->table_element,
430 'tablefromt' => $tablepath
431 );
432 } else {
433 $position = (empty($val['position']) ? 0 : intval($val['position']));
434 $arrayofgroupby[$tablealias.'.'.$key] = array(
435 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']),
436 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
437 'position' => ($position + ($count * 100000)),
438 'table' => $object->table_element,
439 'tablefromt' => $tablepath
440 );
441 }
442 }
443 }
444
445 // Add extrafields to Group by
446 if (!empty($object->isextrafieldmanaged) && isset($extrafields->attributes[$object->table_element]['label'])) {
447 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
448 if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') {
449 continue;
450 }
451 if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
452 continue;
453 }
454
455 if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('timestamp', 'date', 'datetime'))) {
456 $position = (empty($extrafields->attributes[$object->table_element]['pos'][$key]) ? 0 : intval($extrafields->attributes[$object->table_element]['pos'][$key]));
457 $arrayofgroupby[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-year'] = array(
458 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' <span class="opacitymedium">('.$YYYY.')</span>',
459 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
460 'position' => ($position + ($count * 100000)).'.1',
461 'table' => $object->table_element,
462 'tablefromt' => $tablepath
463 );
464 $arrayofgroupby[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-month'] = array(
465 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>',
466 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
467 'position' => ($position + ($count * 100000)).'.2',
468 'table' => $object->table_element,
469 'tablefromt' => $tablepath
470 );
471 $arrayofgroupby[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-day'] = array(
472 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>',
473 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
474 'position' => ($position + ($count * 100000)).'.3',
475 'table' => $object->table_element,
476 'tablefromt' => $tablepath
477 );
478 } else {
479 $arrayofgroupby[preg_replace('/^t/', 'te', $tablealias).'.'.$key] = array(
480 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val),
481 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
482 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000),
483 'table' => $object->table_element,
484 'tablefromt' => $tablepath
485 );
486 }
487 }
488 }
489
490 // Add fields for parent objects
491 foreach ($object->fields as $key => $val) {
492 if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
493 $tmptype = explode(':', $val['type'], 4);
494 if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
495 $newobject = $tmptype[1];
496 dol_include_once($tmptype[2]);
497 if (class_exists($newobject)) {
498 $tmpobject = new $newobject($db);
499 //var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
500 $count++;
501 $arrayofgroupby = fillArrayOfGroupBy($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofgroupby, $level + 1, $count, $tablepath);
502 } else {
503 print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
504 }
505 }
506 }
507 }
508
509 return $arrayofgroupby;
510}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroupby, $level=0, &$count=0, &$tablepath='')
Fill arrayofgrupby for an object.
fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesures, $level=0, &$count=0, &$tablepath='')
Fill arrayofmesures for an object.
fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, $level=0, &$count=0, &$tablepath='')
Fill arrayofmesures for an object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.