From 9dfdce03aa649330d70507273f7212c31baf1f31 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Feb 2022 19:09:26 +0100 Subject: [PATCH] Work on generic reporting tool. --- htdocs/contrat/class/contrat.class.php | 1 - htdocs/core/class/commonobjectline.class.php | 5 + htdocs/core/class/html.formother.class.php | 111 +------ htdocs/core/customreports.php | 306 +++++++++++++++++-- htdocs/core/lib/functions.lib.php | 4 +- htdocs/user/class/user.class.php | 4 +- 6 files changed, 295 insertions(+), 136 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index f2fc588348d..4e4437c1b2c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2591,7 +2591,6 @@ class ContratLigne extends CommonObjectLine */ public $table_element = 'contratdet'; - /** * @var string Name to use for 'features' parameter to check module permissions with restrictedArea() */ diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 487482a9b3c..74bab57c605 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -45,6 +45,11 @@ abstract class CommonObjectLine extends CommonObject */ public $rowid; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'line'; + /** * Product/service unit code ('km', 'm', 'p', ...) * @var string diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index ad0c74ab9a8..0c55a1fd853 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1486,58 +1486,6 @@ class FormOther { global $langs, $extrafields, $form; - $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); - $MM = substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1); - $DD = substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1); - $HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1); - $MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1); - $SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1); - - foreach ($object->fields as $key => $val) { - if (!$val['isameasure']) { - if (in_array($key, array( - 'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams', - 'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) { - continue; - } - if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) { - continue; - } - if (isset($val['visible']) && !dol_eval($val['visible'], 1)) { - continue; - } - if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) { - continue; - } - if (preg_match('/^pass/', $key)) { - continue; - } - if (in_array($val['type'], array('html', 'text'))) { - continue; - } - if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { - $arrayofgroupby['t.'.$key.'-year'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.')', 'position' => $val['position'].'-y'); - $arrayofgroupby['t.'.$key.'-month'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => $val['position'].'-m'); - $arrayofgroupby['t.'.$key.'-day'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => $val['position'].'-d'); - } else { - $arrayofgroupby['t.'.$key] = array('label' => $langs->trans($val['label']), 'position' => (int) $val['position']); - } - } - } - // Add extrafields to Group by - if ($object->isextrafieldmanaged) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') { - continue; - } - if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) { - continue; - } - $arrayofgroupby['te.'.$key] = array('label' => $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key]); - } - } - - $arrayofgroupby = dol_sort_array($arrayofgroupby, 'position', 'asc', 0, 0, 1); $arrayofgroupbylabel = array(); foreach ($arrayofgroupby as $key => $val) { $arrayofgroupbylabel[$key] = $val['label']; @@ -1558,68 +1506,13 @@ class FormOther */ public function selectXAxisField($object, $search_xaxis, &$arrayofxaxis, $showempty = '1') { - global $langs, $extrafields, $form; - - $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); - $MM = substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1); - $DD = substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1); - $HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1); - $MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1); - $SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1); - - - foreach ($object->fields as $key => $val) { - if (!$val['measure']) { - if (in_array($key, array( - 'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams', - 'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) { - continue; - } - if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) { - continue; - } - if (isset($val['visible']) && !dol_eval($val['visible'], 1)) { - continue; - } - if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) { - continue; - } - if (preg_match('/^pass/', $key)) { - continue; - } - if (in_array($val['type'], array('html', 'text'))) { - continue; - } - if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { - $arrayofxaxis['t.'.$key.'-year'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.')', 'position' => $val['position'].'-y'); - $arrayofxaxis['t.'.$key.'-month'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => $val['position'].'-m'); - $arrayofxaxis['t.'.$key.'-day'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => $val['position'].'-d'); - } else { - $arrayofxaxis['t.'.$key] = array('label' => $langs->trans($val['label']), 'position' => (int) $val['position']); - } - } - } - - // Add extrafields to X-Axis - if ($object->isextrafieldmanaged) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') { - continue; - } - if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) { - continue; - } - $arrayofxaxis['te.'.$key] = array('label' => $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key]); - } - } - - $arrayofxaxis = dol_sort_array($arrayofxaxis, 'position', 'asc', 0, 0, 1); + global $form; $arrayofxaxislabel = array(); foreach ($arrayofxaxis as $key => $val) { $arrayofxaxislabel[$key] = $val['label']; } - $result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth250', 1); + $result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth250 maxwidth500', 1); return $result; } diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index f1616feb21b..fd1b8069264 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -175,7 +175,7 @@ $HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1); $MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1); $SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1); -$arrayofmesures = array('t.count'=>'Count'); +$arrayofmesures = array(); $arrayofxaxis = array(); $arrayofgroupby = array(); $arrayofyaxis = array(); @@ -411,39 +411,28 @@ print $form->searchComponent(array($object->element => $object->fields), $search print ''; // Add measures into array +$count = 0; +$arrayofmesures = fillArrayOfMeasures($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofmesures, 0, $count); +//var_dump($arrayofmesures); print '
'; -foreach ($object->fields as $key => $val) { - if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1))) { - $arrayofmesures['t.'.$key.'-sum'] = $langs->trans($val['label']).' ('.$langs->trans("Sum").')'; - $arrayofmesures['t.'.$key.'-average'] = $langs->trans($val['label']).' ('.$langs->trans("Average").')'; - $arrayofmesures['t.'.$key.'-min'] = $langs->trans($val['label']).' ('.$langs->trans("Minimum").')'; - $arrayofmesures['t.'.$key.'-max'] = $langs->trans($val['label']).' ('.$langs->trans("Maximum").')'; - } -} -// Add extrafields to Measures -if ($object->isextrafieldmanaged) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1))) { - $arrayofmesures['te.'.$key.'-sum'] = $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' ('.$langs->trans("Sum").')'; - $arrayofmesures['te.'.$key.'-average'] = $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' ('.$langs->trans("Average").')'; - $arrayofmesures['te.'.$key.'-min'] = $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' ('.$langs->trans("Minimum").')'; - $arrayofmesures['te.'.$key.'-max'] = $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' ('.$langs->trans("Maximum").')'; - } - } -} print '
'; print $form->multiselectarray('search_measures', $arrayofmesures, $search_measures, 0, 0, 'minwidth400', 1, 0, '', '', $langs->trans("Measures")); // Fill the array $arrayofmeasures with possible fields print '
'; - // XAxis +$count = 0; +$arrayofxaxis = fillArrayOfXAxis($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofxaxis, 0, $count); +$arrayofxaxis = dol_sort_array($arrayofxaxis, 'position', 'asc', 0, 0, 1); print '
'; print '
'; +//var_dump($arrayofxaxis); print $formother->selectXAxisField($object, $search_xaxis, $arrayofxaxis, $langs->trans("XAxis")); // Fill the array $arrayofxaxis with possible fields print '
'; - // Group by +$count = 0; +$arrayofgroupby = fillArrayOfGroupBy($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofgroupby, 0, $count); +$arrayofgroupby = dol_sort_array($arrayofgroupby, 'position', 'asc', 0, 0, 1); print '
'; print '
'; print $formother->selectGroupByField($object, $search_groupby, $arrayofgroupby, 'minwidth200 maxwidth250', $langs->trans("GroupBy")); // Fill the array $arrayofgroupby with possible fields @@ -846,3 +835,276 @@ if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) { llxFooter(); $db->close(); + + + + + +/** + * Fill arrayofmesures for an object + * + * @param mixed $object Any object + * @param string $tablealias Alias of table + * @param string $labelofobject Label of object + * @param array $arrayofmesures Array of mesures already filled + * @param int $level Level + * @param int $count Count + * @return array Array of mesures + */ +function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesures, $level = 0, &$count = 0) +{ + global $langs, $extrafields, $db; + + if ($level > 10) { // Protection against infinite loop + return $arrayofmesures; + } + + if ($level == 0) { + // Add the count of record only for the main/first level object. Parents are necessarly unique for each record. + $arrayofmesures[$tablealias.'.count'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': Count'; + } + + // Add main fields of object + foreach ($object->fields as $key => $val) { + if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1))) { + $arrayofmesures[$tablealias.'.'.$key.'-sum'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Sum").')'; + $arrayofmesures[$tablealias.'.'.$key.'-average'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Average").')'; + $arrayofmesures[$tablealias.'.'.$key.'-min'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Minimum").')'; + $arrayofmesures[$tablealias.'.'.$key.'-max'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Maximum").')'; + } + } + // Add extrafields to Measures + if ($object->isextrafieldmanaged) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1))) { + $arrayofmesures[$tablealias.'e.'.$key.'-sum'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' ('.$langs->trans("Sum").')'; + $arrayofmesures[$tablealias.'e.'.$key.'-average'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' ('.$langs->trans("Average").')'; + $arrayofmesures[$tablealias.'e.'.$key.'-min'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' ('.$langs->trans("Minimum").')'; + $arrayofmesures[$tablealias.'e.'.$key.'-max'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' ('.$langs->trans("Maximum").')'; + } + } + } + // Add fields for parent objects + foreach ($object->fields as $key => $val) { + if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) { + $tmptype = explode(':', $val['type'], 4); + if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) { + $newobject = $tmptype[1]; + dol_include_once($tmptype[2]); + if (class_exists($newobject)) { + $tmpobject = new $newobject($db); + /*var_dump($val['label']); + var_dump($tmptype); + var_dump($arrayofmesures); + var_dump('t-'.$key);*/ + $count++; + $arrayofmesures = fillArrayOfMeasures($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofmesures, $level + 1, $count); + } else { + print 'Failed to find '.$newobject.' class for field '.$key.' of object '.$object->element."\n"; + } + } + } + } + + return $arrayofmesures; +} + + +/** + * Fill arrayofmesures for an object + * + * @param mixed $object Any object + * @param string $tablealias Alias of table + * @param string $labelofobject Label of object + * @param array $arrayofxaxis Array of xaxis already filled + * @param int $level Level + * @param int $count Count + * @return array Array of xaxis + */ +function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, $level = 0, &$count = 0) +{ + global $langs, $extrafields, $db; + + if ($level > 10) { // Protection against infinite loop + return $arrayofxaxis; + } + + if ($level >= 2) { + return $arrayofxaxis; + } + + $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); + $MM = substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1); + $DD = substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1); + $HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1); + $MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1); + $SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1); + + // Add main fields of object + foreach ($object->fields as $key => $val) { + if (empty($val['measure'])) { + if (in_array($key, array( + 'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams', + 'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) { + continue; + } + if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) { + continue; + } + if (isset($val['visible']) && !dol_eval($val['visible'], 1)) { + continue; + } + if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) { + continue; + } + if (preg_match('/^pass/', $key)) { + continue; + } + if (in_array($val['type'], array('html', 'text'))) { + continue; + } + if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { + $arrayofxaxis[$tablealias.'.'.$key.'-year'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.')', 'position' => ($val['position']+($count * 100000)).'.1'); + $arrayofxaxis[$tablealias.'.'.$key.'-month'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => ($val['position']+($count * 100000)).'.2'); + $arrayofxaxis[$tablealias.'.'.$key.'-day'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => ($val['position']+($count * 100000)).'.3'); + } else { + $arrayofxaxis[$tablealias.'.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($val['position']+($count * 100000))); + } + } + } + // Add extrafields to X-Axis + if ($object->isextrafieldmanaged) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') { + continue; + } + if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) { + continue; + } + $arrayofxaxis[$tablealias.'e.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000)); + } + } + // Add fields for parent objects + foreach ($object->fields as $key => $val) { + if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) { + $tmptype = explode(':', $val['type'], 4); + if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) { + $newobject = $tmptype[1]; + dol_include_once($tmptype[2]); + if (class_exists($newobject)) { + $tmpobject = new $newobject($db); + /*var_dump($val['label']); + var_dump($tmptype); + var_dump($arrayofmesures); + var_dump('t-'.$key);*/ + $count++; + $arrayofxaxis = fillArrayOfXAxis($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofxaxis, $level + 1, $count); + } else { + print 'Failed to find '.$newobject.' class for field '.$key.' of object '.$object->element."\n"; + } + } + } + } + + return $arrayofxaxis; +} + + +/** + * Fill arrayofgrupby for an object + * + * @param mixed $object Any object + * @param string $tablealias Alias of table + * @param string $labelofobject Label of object + * @param array $arrayofgroupby Array of groupby already filled + * @param int $level Level + * @param int $count Count + * @return array Array of groupby + */ +function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroupby, $level = 0, &$count = 0) +{ + global $langs, $extrafields, $db; + + if ($level > 10) { // Protection against infinite loop + return $arrayofgroupby; + } + + if ($level >= 2) { + return $arrayofgroupby; + } + + $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); + $MM = substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1); + $DD = substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1); + $HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1); + $MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1); + $SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1); + + // Add main fields of object + foreach ($object->fields as $key => $val) { + if (!$val['isameasure']) { + if (in_array($key, array( + 'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams', + 'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) { + continue; + } + if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) { + continue; + } + if (isset($val['visible']) && !dol_eval($val['visible'], 1)) { + continue; + } + if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) { + continue; + } + if (preg_match('/^pass/', $key)) { + continue; + } + if (in_array($val['type'], array('html', 'text'))) { + continue; + } + if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { + $arrayofgroupby[$tablealias.'.'.$key.'-year'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.')', 'position' => ($val['position']+($count * 100000)).'.1'); + $arrayofgroupby[$tablealias.'.'.$key.'-month'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => ($val['position']+($count * 100000)).'.2'); + $arrayofgroupby[$tablealias.'.'.$key.'-day'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => ($val['position']+($count * 100000)).'.3'); + } else { + $arrayofgroupby[$tablealias.'.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($val['position']+($count * 100000))); + } + } + } + // Add extrafields to Group by + if ($object->isextrafieldmanaged) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') { + continue; + } + if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) { + continue; + } + $arrayofgroupby[$tablealias.'e.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000)); + } + } + // Add fields for parent objects + foreach ($object->fields as $key => $val) { + if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) { + $tmptype = explode(':', $val['type'], 4); + if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) { + $newobject = $tmptype[1]; + dol_include_once($tmptype[2]); + if (class_exists($newobject)) { + $tmpobject = new $newobject($db); + /*var_dump($val['label']); + var_dump($tmptype); + var_dump($arrayofmesures); + var_dump('t-'.$key);*/ + $count++; + $arrayofgroupby = fillArrayOfGroupBy($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofgroupby, $level + 1, $count); + } else { + print 'Failed to find '.$newobject.' class for field '.$key.' of object '.$object->element."\n"; + } + } + } + } + + return $arrayofgroupby; +} diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 86c1cbe0888..75b2102d4fa 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3731,7 +3731,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'generate', 'globe', 'globe-americas', 'graph', 'grip', 'grip_title', 'group', 'help', 'holiday', 'images', 'incoterm', 'info', 'intervention', 'inventory', 'intracommreport', 'knowledgemanagement', - 'label', 'language', 'link', 'list', 'list-alt', 'listlight', 'loan', 'lot', 'long-arrow-alt-right', + 'label', 'language', 'line', 'link', 'list', 'list-alt', 'listlight', 'loan', 'lot', 'long-arrow-alt-right', 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'off', 'on', 'order', 'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'puce', @@ -3776,7 +3776,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'email'=>'at', 'establishment'=>'building', 'edit'=>'pencil-alt', 'entity'=>'globe', 'graph'=>'chart-line', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle', 'generic'=>'file', 'holiday'=>'umbrella-beach', - 'info'=>'info-circle', 'inventory'=>'boxes', 'intracommreport'=>'globe-europe', 'knowledgemanagement'=>'ticket-alt', 'label'=>'layer-group', 'loan'=>'money-bill-alt', + 'info'=>'info-circle', 'inventory'=>'boxes', 'intracommreport'=>'globe-europe', 'knowledgemanagement'=>'ticket-alt', 'label'=>'layer-group', 'line'=>'bars', 'loan'=>'money-bill-alt', 'member'=>'user-alt', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right', 'trip'=>'wallet', 'expensereport'=>'wallet', 'group'=>'users', 'movement'=>'people-carry', 'sign-out'=>'sign-out-alt', diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 736dcf99680..6c5926f8c43 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -348,8 +348,8 @@ class User extends CommonObject public $fields = array( 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1), - 'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), + 'lastname'=>array('type'=>'varchar(50)', 'label'=>'LastName', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1), + 'firstname'=>array('type'=>'varchar(50)', 'label'=>'FirstName', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), );