|
@@ -152,7 +152,7 @@ if ($user->socid > 0) { // Protection if external user
|
|
}
|
|
}
|
|
|
|
|
|
// Fetch optionals attributes and labels
|
|
// Fetch optionals attributes and labels
|
|
-$extrafields->fetch_name_optionals_label($object->table_element);
|
|
|
|
|
|
+$extrafields->fetch_name_optionals_label('all'); // We load all extrafields definitions for all objects
|
|
//$extrafields->fetch_name_optionals_label($object->table_element_line);
|
|
//$extrafields->fetch_name_optionals_label($object->table_element_line);
|
|
|
|
|
|
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
|
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
|
@@ -277,8 +277,18 @@ if (is_array($search_groupby) && count($search_groupby)) {
|
|
|
|
|
|
$sql = "SELECT DISTINCT ".$fieldtocount." as val";
|
|
$sql = "SELECT DISTINCT ".$fieldtocount." as val";
|
|
|
|
|
|
- if (strpos($fieldtocount, 'te.') === 0) {
|
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te";
|
|
|
|
|
|
+ if (strpos($fieldtocount, 'te') === 0) {
|
|
|
|
+ $tabletouse = $object->table_element;
|
|
|
|
+ $tablealiastouse = 'te';
|
|
|
|
+ if (!empty($arrayofgroupby[$gval])) {
|
|
|
|
+ $tmpval = explode('.', $gval);
|
|
|
|
+ $tabletouse = $arrayofgroupby[$gval]['table'];
|
|
|
|
+ $tablealiastouse = $tmpval[0];
|
|
|
|
+ }
|
|
|
|
+ //var_dump($tablealiastouse);exit;
|
|
|
|
+
|
|
|
|
+ //$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te";
|
|
|
|
+ $sql .= " FROM ".MAIN_DB_PREFIX.$tabletouse."_extrafields as ".$tablealiastouse;
|
|
} else {
|
|
} else {
|
|
$tabletouse = $object->table_element;
|
|
$tabletouse = $object->table_element;
|
|
$tablealiastouse = 't';
|
|
$tablealiastouse = 't';
|
|
@@ -290,9 +300,9 @@ if (is_array($search_groupby) && count($search_groupby)) {
|
|
$sql .= " FROM ".MAIN_DB_PREFIX.$tabletouse." as ".$tablealiastouse;
|
|
$sql .= " FROM ".MAIN_DB_PREFIX.$tabletouse." as ".$tablealiastouse;
|
|
}
|
|
}
|
|
|
|
|
|
- // Add the where here
|
|
|
|
- /*
|
|
|
|
- $sqlfilters = GETPOST('search_component_params_hidden', 'alphanohtml');
|
|
|
|
|
|
+ // Add a where here keeping only the citeria on $tabletouse
|
|
|
|
+ // TODO
|
|
|
|
+ /*$sqlfilters = ... GETPOST('search_component_params_hidden', 'alphanohtml');
|
|
if ($sqlfilters) {
|
|
if ($sqlfilters) {
|
|
$errormessage = '';
|
|
$errormessage = '';
|
|
$sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
|
|
$sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
|
|
@@ -358,7 +368,8 @@ if (is_array($search_groupby) && count($search_groupby)) {
|
|
// Add a protection/error to refuse the request if number of differentr values for the group by is higher than $MAXUNIQUEVALFORGROUP
|
|
// Add a protection/error to refuse the request if number of differentr values for the group by is higher than $MAXUNIQUEVALFORGROUP
|
|
if (count($arrayofvaluesforgroupby['g_'.$gkey]) > $MAXUNIQUEVALFORGROUP) {
|
|
if (count($arrayofvaluesforgroupby['g_'.$gkey]) > $MAXUNIQUEVALFORGROUP) {
|
|
$langs->load("errors");
|
|
$langs->load("errors");
|
|
- if (strpos($fieldtocount, 'te.') === 0) { // This is an extrafield
|
|
|
|
|
|
+
|
|
|
|
+ if (strpos($fieldtocount, 'te') === 0) { // This is a field of an extrafield
|
|
//if (!empty($extrafields->attributes[$object->table_element]['langfile'][$gvalwithoutprefix])) {
|
|
//if (!empty($extrafields->attributes[$object->table_element]['langfile'][$gvalwithoutprefix])) {
|
|
// $langs->load($extrafields->attributes[$object->table_element]['langfile'][$gvalwithoutprefix]);
|
|
// $langs->load($extrafields->attributes[$object->table_element]['langfile'][$gvalwithoutprefix]);
|
|
//}
|
|
//}
|
|
@@ -367,10 +378,13 @@ if (is_array($search_groupby) && count($search_groupby)) {
|
|
} elseif (strpos($fieldtocount, 't__') === 0) { // This is a field of a foreign key
|
|
} elseif (strpos($fieldtocount, 't__') === 0) { // This is a field of a foreign key
|
|
$reg = array();
|
|
$reg = array();
|
|
if (preg_match('/^(.*)\.(.*)/', $gvalwithoutprefix, $reg)) {
|
|
if (preg_match('/^(.*)\.(.*)/', $gvalwithoutprefix, $reg)) {
|
|
|
|
+ /*
|
|
$gvalwithoutprefix = preg_replace('/\..*$/', '', $gvalwithoutprefix);
|
|
$gvalwithoutprefix = preg_replace('/\..*$/', '', $gvalwithoutprefix);
|
|
- $gvalwithoutprefix = preg_replace('/t__/', '', $gvalwithoutprefix);
|
|
|
|
|
|
+ $gvalwithoutprefix = preg_replace('/^t__/', '', $gvalwithoutprefix);
|
|
$keyforlabeloffield = $object->fields[$gvalwithoutprefix]['label'];
|
|
$keyforlabeloffield = $object->fields[$gvalwithoutprefix]['label'];
|
|
$labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield).'-'.$reg[2];
|
|
$labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield).'-'.$reg[2];
|
|
|
|
+ */
|
|
|
|
+ $labeloffield = $arrayofgroupby[$fieldtocount]['labelnohtml'];
|
|
} else {
|
|
} else {
|
|
$labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield);
|
|
$labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield);
|
|
}
|
|
}
|
|
@@ -385,7 +399,6 @@ if (is_array($search_groupby) && count($search_groupby)) {
|
|
$labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield);
|
|
$labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //var_dump($gkey.' '.$gval.' '.$gvalwithoutprefix.' '.$fieldtocount.' '.$keyforlabeloffield);
|
|
|
|
//var_dump($object->fields);
|
|
//var_dump($object->fields);
|
|
setEventMessages($langs->trans("ErrorTooManyDifferentValueForSelectedGroupBy", $MAXUNIQUEVALFORGROUP, $labeloffield), null, 'warnings');
|
|
setEventMessages($langs->trans("ErrorTooManyDifferentValueForSelectedGroupBy", $MAXUNIQUEVALFORGROUP, $labeloffield), null, 'warnings');
|
|
$search_groupby = array();
|
|
$search_groupby = array();
|
|
@@ -405,7 +418,7 @@ $startyear = $endyear - 2;
|
|
|
|
|
|
$param = '';
|
|
$param = '';
|
|
|
|
|
|
-print '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
|
|
|
|
|
|
+print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" autocomplete="off">';
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
print '<input type="hidden" name="action" value="viewgraph">';
|
|
print '<input type="hidden" name="action" value="viewgraph">';
|
|
print '<input type="hidden" name="tabfamily" value="'.$tabfamily.'">';
|
|
print '<input type="hidden" name="tabfamily" value="'.$tabfamily.'">';
|
|
@@ -452,12 +465,12 @@ if (empty($conf->use_javascript_ajax)) {
|
|
}
|
|
}
|
|
print '</div><div class="clearboth"></div>';
|
|
print '</div><div class="clearboth"></div>';
|
|
|
|
|
|
-// Add Filter (you can use param &show_search_component_params_hidden=1 for debug)
|
|
|
|
|
|
+// Filter (you can use param &show_search_component_params_hidden=1 for debug)
|
|
print '<div class="divadvancedsearchfield quatrevingtpercent">';
|
|
print '<div class="divadvancedsearchfield quatrevingtpercent">';
|
|
print $form->searchComponent(array($object->element => $object->fields), $search_component_params, array(), $search_component_params_hidden);
|
|
print $form->searchComponent(array($object->element => $object->fields), $search_component_params, array(), $search_component_params_hidden);
|
|
print '</div>';
|
|
print '</div>';
|
|
|
|
|
|
-// Add measures into array
|
|
|
|
|
|
+// YAxis (add measures into array)
|
|
$count = 0;
|
|
$count = 0;
|
|
//var_dump($arrayofmesures);
|
|
//var_dump($arrayofmesures);
|
|
print '<div class="divadvancedsearchfield clearboth">';
|
|
print '<div class="divadvancedsearchfield clearboth">';
|
|
@@ -559,6 +572,8 @@ print '</form>';
|
|
// Generate the SQL request
|
|
// Generate the SQL request
|
|
$sql = '';
|
|
$sql = '';
|
|
if (!empty($search_measures) && !empty($search_xaxis)) {
|
|
if (!empty($search_measures) && !empty($search_xaxis)) {
|
|
|
|
+ $errormessage = '';
|
|
|
|
+
|
|
$fieldid = 'rowid';
|
|
$fieldid = 'rowid';
|
|
|
|
|
|
$sql = "SELECT ";
|
|
$sql = "SELECT ";
|
|
@@ -613,7 +628,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
|
if ($object->isextrafieldmanaged) {
|
|
if ($object->isextrafieldmanaged) {
|
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te ON te.fk_object = t.".$fieldid;
|
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te ON te.fk_object = t.".$fieldid;
|
|
}
|
|
}
|
|
- // Add table for link for multientity
|
|
|
|
|
|
+ // Add table for link on multientity
|
|
if ($object->ismultientitymanaged) { // 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
|
|
if ($object->ismultientitymanaged) { // 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
|
|
if ($object->ismultientitymanaged == 1) {
|
|
if ($object->ismultientitymanaged == 1) {
|
|
// No table to add here
|
|
// No table to add here
|
|
@@ -624,6 +639,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Init the list of tables added. We include by default always the main table.
|
|
$listoftablesalreadyadded = array($object->table_element => $object->table_element);
|
|
$listoftablesalreadyadded = array($object->table_element => $object->table_element);
|
|
|
|
|
|
// Add LEFT JOIN for all parent tables mentionned into the Xaxis
|
|
// Add LEFT JOIN for all parent tables mentionned into the Xaxis
|
|
@@ -631,13 +647,25 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
|
foreach ($search_xaxis as $key => $val) {
|
|
foreach ($search_xaxis as $key => $val) {
|
|
if (!empty($arrayofxaxis[$val])) {
|
|
if (!empty($arrayofxaxis[$val])) {
|
|
$tmpval = explode('.', $val);
|
|
$tmpval = explode('.', $val);
|
|
- //var_dump($arrayofxaxis[$val]['table']);
|
|
|
|
- if (! in_array($arrayofxaxis[$val]['table'], $listoftablesalreadyadded)) { // We do not add join for main table already added
|
|
|
|
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$arrayofxaxis[$val]['table']." as ".$db->sanitize($tmpval[0])." ON t.".str_replace('t__', '', $db->sanitize($tmpval[0]))." = ".$db->sanitize($tmpval[0]).".rowid";
|
|
|
|
- $listoftablesalreadyadded[$arrayofxaxis[$val]['table']] = $arrayofxaxis[$val]['table'];
|
|
|
|
|
|
+ //var_dump($arrayofgroupby);
|
|
|
|
+ $tmpforloop = dolExplodeIntoArray($arrayofxaxis[$val]['tablefromt'], ',');
|
|
|
|
+ foreach ($tmpforloop as $tmptable => $tmptablealias) {
|
|
|
|
+ if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added
|
|
|
|
+ $tmpforexplode = explode('__', $tmptablealias);
|
|
|
|
+ $endpart = end($tmpforexplode);
|
|
|
|
+ $parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart;
|
|
|
|
+
|
|
|
|
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable." as ".$db->sanitize($tmptablealias)." ON ".$db->sanitize($parenttableandfield)." = ".$db->sanitize($tmptablealias).".rowid";
|
|
|
|
+ $listoftablesalreadyadded[$tmptable] = $tmptable;
|
|
|
|
+
|
|
|
|
+ if (preg_match('/^te/', $tmpval[0]) && preg_replace('/^t_/', 'te_', $tmptablealias) == $tmpval[0]) {
|
|
|
|
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable."_extrafields as ".$db->sanitize($tmpval[0])." ON ".$db->sanitize($tmpval[0]).".fk_object = ".$db->sanitize($tmptablealias).".rowid";
|
|
|
|
+ $listoftablesalreadyadded[$tmptable] = $tmptable;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- dol_print_error($db, 'Found a key into search_xaxis not found into arrayofxaxis');
|
|
|
|
|
|
+ $errormessage = 'Found a key into search_xaxis not found into arrayofxaxis';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -646,13 +674,25 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
|
foreach ($search_groupby as $key => $val) {
|
|
foreach ($search_groupby as $key => $val) {
|
|
if (!empty($arrayofgroupby[$val])) {
|
|
if (!empty($arrayofgroupby[$val])) {
|
|
$tmpval = explode('.', $val);
|
|
$tmpval = explode('.', $val);
|
|
- //var_dump($arrayofxaxis[$val]['table']);
|
|
|
|
- if (! in_array($arrayofgroupby[$val]['table'], $listoftablesalreadyadded)) { // We do not add join for main table already added
|
|
|
|
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$arrayofgroupby[$val]['table']." as ".$tmpval[0]." ON t.".str_replace('t__', '', $tmpval[0])." = ".$tmpval[0].".rowid";
|
|
|
|
- $listoftablesalreadyadded[$arrayofgroupby[$val]['table']] = $arrayofgroupby[$val]['table'];
|
|
|
|
|
|
+ //var_dump($arrayofgroupby[$val]); var_dump($tmpval);
|
|
|
|
+ $tmpforloop = dolExplodeIntoArray($arrayofgroupby[$val]['tablefromt'], ',');
|
|
|
|
+ foreach ($tmpforloop as $tmptable => $tmptablealias) {
|
|
|
|
+ if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added
|
|
|
|
+ $tmpforexplode = explode('__', $tmptablealias);
|
|
|
|
+ $endpart = end($tmpforexplode);
|
|
|
|
+ $parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart;
|
|
|
|
+
|
|
|
|
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable." as ".$db->sanitize($tmptablealias)." ON ".$db->sanitize($parenttableandfield)." = ".$db->sanitize($tmptablealias).".rowid";
|
|
|
|
+ $listoftablesalreadyadded[$tmptable] = $tmptable;
|
|
|
|
+
|
|
|
|
+ if (preg_match('/^te/', $tmpval[0]) && preg_replace('/^t_/', 'te_', $tmptablealias) == $tmpval[0]) {
|
|
|
|
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable."_extrafields as ".$db->sanitize($tmpval[0])." ON ".$db->sanitize($tmpval[0]).".fk_object = ".$db->sanitize($tmptablealias).".rowid";
|
|
|
|
+ $listoftablesalreadyadded[$tmptable] = $tmptable;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- dol_print_error($db, 'Found a key into search_groupby not found into arrayofgroupby');
|
|
|
|
|
|
+ $errormessage = 'Found a key into search_groupby not found into arrayofgroupby';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -661,13 +701,25 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
|
foreach ($search_measures as $key => $val) {
|
|
foreach ($search_measures as $key => $val) {
|
|
if (!empty($arrayofmesures[$val])) {
|
|
if (!empty($arrayofmesures[$val])) {
|
|
$tmpval = explode('.', $val);
|
|
$tmpval = explode('.', $val);
|
|
- //var_dump($arrayofxaxis[$val]['table']);
|
|
|
|
- if (! in_array($arrayofmesures[$val]['table'], $listoftablesalreadyadded)) { // We do not add join for main table already added
|
|
|
|
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$arrayofmesures[$val]['table']." as ".$tmpval[0]." ON t.".str_replace('t__', '', $tmpval[0])." = ".$tmpval[0].".rowid";
|
|
|
|
- $listoftablesalreadyadded[$arrayofmesures[$val]['table']] = $arrayofmesures[$val]['table'];
|
|
|
|
|
|
+ //var_dump($arrayofgroupby);
|
|
|
|
+ $tmpforloop = dolExplodeIntoArray($arrayofmesures[$val]['tablefromt'], ',');
|
|
|
|
+ foreach ($tmpforloop as $tmptable => $tmptablealias) {
|
|
|
|
+ if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added
|
|
|
|
+ $tmpforexplode = explode('__', $tmptablealias);
|
|
|
|
+ $endpart = end($tmpforexplode);
|
|
|
|
+ $parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart;
|
|
|
|
+
|
|
|
|
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable." as ".$db->sanitize($tmptablealias)." ON ".$db->sanitize($parenttableandfield)." = ".$db->sanitize($tmptablealias).".rowid";
|
|
|
|
+ $listoftablesalreadyadded[$tmptable] = $tmptable;
|
|
|
|
+
|
|
|
|
+ if (preg_match('/^te/', $tmpval[0]) && preg_replace('/^t_/', 'te_', $tmptablealias) == $tmpval[0]) {
|
|
|
|
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable."_extrafields as ".$db->sanitize($tmpval[0])." ON ".$db->sanitize($tmpval[0]).".fk_object = ".$db->sanitize($tmptablealias).".rowid";
|
|
|
|
+ $listoftablesalreadyadded[$tmptable] = $tmptable;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- dol_print_error($db, 'Found a key into search_measures not found into arrayofmesures');
|
|
|
|
|
|
+ $errormessage = 'Found a key into search_measures not found into arrayofmesures';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -678,11 +730,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
|
// Add the where here
|
|
// Add the where here
|
|
$sqlfilters = $search_component_params_hidden;
|
|
$sqlfilters = $search_component_params_hidden;
|
|
if ($sqlfilters) {
|
|
if ($sqlfilters) {
|
|
- $errormessage = '';
|
|
|
|
- $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
|
|
|
|
- if ($errormessage) {
|
|
|
|
- print dol_escape_htmltag($errormessage);
|
|
|
|
- }
|
|
|
|
|
|
+ $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage, 0, 0, 1);
|
|
}
|
|
}
|
|
$sql .= " GROUP BY ";
|
|
$sql .= " GROUP BY ";
|
|
foreach ($search_xaxis as $key => $val) {
|
|
foreach ($search_xaxis as $key => $val) {
|
|
@@ -747,6 +795,11 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
|
}
|
|
}
|
|
//print $sql;
|
|
//print $sql;
|
|
|
|
|
|
|
|
+if ($errormessage) {
|
|
|
|
+ print dol_escape_htmltag($errormessage);
|
|
|
|
+ $sql = '';
|
|
|
|
+}
|
|
|
|
+
|
|
$legend = array();
|
|
$legend = array();
|
|
foreach ($search_measures as $key => $val) {
|
|
foreach ($search_measures as $key => $val) {
|
|
$legend[] = $langs->trans($arrayofmesures[$val]['label']);
|
|
$legend[] = $langs->trans($arrayofmesures[$val]['label']);
|
|
@@ -952,7 +1005,6 @@ $db->close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Fill arrayofmesures for an object
|
|
* Fill arrayofmesures for an object
|
|
*
|
|
*
|
|
@@ -962,9 +1014,10 @@ $db->close();
|
|
* @param array $arrayofmesures Array of mesures already filled
|
|
* @param array $arrayofmesures Array of mesures already filled
|
|
* @param int $level Level
|
|
* @param int $level Level
|
|
* @param int $count Count
|
|
* @param int $count Count
|
|
|
|
+ * @param string $tablepath Path of all tables ('t' or 't,contract' or 't,contract,societe'...)
|
|
* @return array Array of mesures
|
|
* @return array Array of mesures
|
|
*/
|
|
*/
|
|
-function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesures, $level = 0, &$count = 0)
|
|
|
|
|
|
+function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesures, $level = 0, &$count = 0, &$tablepath = '')
|
|
{
|
|
{
|
|
global $langs, $extrafields, $db;
|
|
global $langs, $extrafields, $db;
|
|
|
|
|
|
@@ -972,38 +1025,56 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
|
|
return $arrayofmesures;
|
|
return $arrayofmesures;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (empty($tablepath)) {
|
|
|
|
+ $tablepath = $object->table_element.'='.$tablealias;
|
|
|
|
+ } else {
|
|
|
|
+ $tablepath .= ','.$object->table_element.'='.$tablealias;
|
|
|
|
+ }
|
|
|
|
+
|
|
if ($level == 0) {
|
|
if ($level == 0) {
|
|
// Add the count of record only for the main/first level object. Parents are necessarly unique for each record.
|
|
// Add the count of record only for the main/first level object. Parents are necessarly unique for each record.
|
|
$arrayofmesures[$tablealias.'.count'] = array(
|
|
$arrayofmesures[$tablealias.'.count'] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': Count',
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': Count',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': Count',
|
|
'position' => 0,
|
|
'position' => 0,
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Note: here $tablealias can be 't' or 't__fk_contract' or 't_fk_contract_fk_soc'
|
|
|
|
+
|
|
// Add main fields of object
|
|
// Add main fields of object
|
|
foreach ($object->fields as $key => $val) {
|
|
foreach ($object->fields as $key => $val) {
|
|
if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) {
|
|
if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) {
|
|
$position = (empty($val['position']) ? 0 : intVal($val['position']));
|
|
$position = (empty($val['position']) ? 0 : intVal($val['position']));
|
|
$arrayofmesures[$tablealias.'.'.$key.'-sum'] = array(
|
|
$arrayofmesures[$tablealias.'.'.$key.'-sum'] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>',
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
|
|
'position' => ($position + ($count * 100000)).'.1',
|
|
'position' => ($position + ($count * 100000)).'.1',
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
$arrayofmesures[$tablealias.'.'.$key.'-average'] = array(
|
|
$arrayofmesures[$tablealias.'.'.$key.'-average'] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Average").')</span>',
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Average").')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
|
|
'position' => ($position + ($count * 100000)).'.2',
|
|
'position' => ($position + ($count * 100000)).'.2',
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
$arrayofmesures[$tablealias.'.'.$key.'-min'] = array(
|
|
$arrayofmesures[$tablealias.'.'.$key.'-min'] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>',
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
|
|
'position' => ($position + ($count * 100000)).'.3',
|
|
'position' => ($position + ($count * 100000)).'.3',
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
$arrayofmesures[$tablealias.'.'.$key.'-max'] = array(
|
|
$arrayofmesures[$tablealias.'.'.$key.'-max'] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>',
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
|
|
'position' => ($position + ($count * 100000)).'.4',
|
|
'position' => ($position + ($count * 100000)).'.4',
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1012,25 +1083,33 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
|
|
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
|
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, 1, '1'))) {
|
|
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, 1, '1'))) {
|
|
$position = (!empty($val['position']) ? $val['position'] : 0);
|
|
$position = (!empty($val['position']) ? $val['position'] : 0);
|
|
- $arrayofmesures[$tablealias.'e.'.$key.'-sum'] = array(
|
|
|
|
|
|
+ $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-sum'] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>',
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
|
|
'position' => ($position+($count * 100000)).'.1',
|
|
'position' => ($position+($count * 100000)).'.1',
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
- $arrayofmesures[$tablealias.'e.'.$key.'-average'] = array(
|
|
|
|
|
|
+ $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-average'] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Average").')</span>',
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Average").')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
|
|
'position' => ($position+($count * 100000)).'.2',
|
|
'position' => ($position+($count * 100000)).'.2',
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
- $arrayofmesures[$tablealias.'e.'.$key.'-min'] = array(
|
|
|
|
|
|
+ $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-min'] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>',
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
|
|
'position' => ($position+($count * 100000)).'.3',
|
|
'position' => ($position+($count * 100000)).'.3',
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
- $arrayofmesures[$tablealias.'e.'.$key.'-max'] = array(
|
|
|
|
|
|
+ $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-max'] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>',
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
|
|
'position' => ($position+($count * 100000)).'.4',
|
|
'position' => ($position+($count * 100000)).'.4',
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1039,14 +1118,14 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
|
|
foreach ($object->fields as $key => $val) {
|
|
foreach ($object->fields as $key => $val) {
|
|
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
|
|
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
|
|
$tmptype = explode(':', $val['type'], 4);
|
|
$tmptype = explode(':', $val['type'], 4);
|
|
- if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
|
|
|
|
|
|
+ if ($tmptype[0] == 'integer' && !empty($tmptype[1]) && !empty($tmptype[2])) {
|
|
$newobject = $tmptype[1];
|
|
$newobject = $tmptype[1];
|
|
dol_include_once($tmptype[2]);
|
|
dol_include_once($tmptype[2]);
|
|
if (class_exists($newobject)) {
|
|
if (class_exists($newobject)) {
|
|
$tmpobject = new $newobject($db);
|
|
$tmpobject = new $newobject($db);
|
|
//var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
|
|
//var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
|
|
$count++;
|
|
$count++;
|
|
- $arrayofmesures = fillArrayOfMeasures($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofmesures, $level + 1, $count);
|
|
|
|
|
|
+ $arrayofmesures = fillArrayOfMeasures($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofmesures, $level + 1, $count, $tablepath);
|
|
} else {
|
|
} else {
|
|
print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
|
|
print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
|
|
}
|
|
}
|
|
@@ -1067,18 +1146,21 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
|
|
* @param array $arrayofxaxis Array of xaxis already filled
|
|
* @param array $arrayofxaxis Array of xaxis already filled
|
|
* @param int $level Level
|
|
* @param int $level Level
|
|
* @param int $count Count
|
|
* @param int $count Count
|
|
|
|
+ * @param string $tablepath Path of all tables ('t' or 't,contract' or 't,contract,societe'...)
|
|
* @return array Array of xaxis
|
|
* @return array Array of xaxis
|
|
*/
|
|
*/
|
|
-function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, $level = 0, &$count = 0)
|
|
|
|
|
|
+function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, $level = 0, &$count = 0, &$tablepath = '')
|
|
{
|
|
{
|
|
global $langs, $extrafields, $db;
|
|
global $langs, $extrafields, $db;
|
|
|
|
|
|
- if ($level > 10) { // Protection against infinite loop
|
|
|
|
|
|
+ if ($level >= 3) { // Limit scan on 2 levels max
|
|
return $arrayofxaxis;
|
|
return $arrayofxaxis;
|
|
}
|
|
}
|
|
|
|
|
|
- if ($level >= 2) {
|
|
|
|
- return $arrayofxaxis;
|
|
|
|
|
|
+ if (empty($tablepath)) {
|
|
|
|
+ $tablepath = $object->table_element.'='.$tablealias;
|
|
|
|
+ } else {
|
|
|
|
+ $tablepath .= ','.$object->table_element.'='.$tablealias;
|
|
}
|
|
}
|
|
|
|
|
|
$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);
|
|
$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);
|
|
@@ -1088,6 +1170,12 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
|
|
$MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 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);
|
|
$SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1);
|
|
|
|
|
|
|
|
+ /*if ($level > 0) {
|
|
|
|
+ var_dump($object->element.' '.$object->isextrafieldmanaged);
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ // Note: here $tablealias can be 't' or 't__fk_contract' or 't_fk_contract_fk_soc'
|
|
|
|
+
|
|
// Add main fields of object
|
|
// Add main fields of object
|
|
foreach ($object->fields as $key => $val) {
|
|
foreach ($object->fields as $key => $val) {
|
|
if (empty($val['measure'])) {
|
|
if (empty($val['measure'])) {
|
|
@@ -1115,25 +1203,33 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
|
|
$position = (empty($val['position']) ? 0 : intVal($val['position']));
|
|
$position = (empty($val['position']) ? 0 : intVal($val['position']));
|
|
$arrayofxaxis[$tablealias.'.'.$key.'-year'] = array(
|
|
$arrayofxaxis[$tablealias.'.'.$key.'-year'] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>',
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
|
|
'position' => ($position + ($count * 100000)).'.1',
|
|
'position' => ($position + ($count * 100000)).'.1',
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
$arrayofxaxis[$tablealias.'.'.$key.'-month'] = array(
|
|
$arrayofxaxis[$tablealias.'.'.$key.'-month'] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>',
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
|
|
'position' => ($position + ($count * 100000)).'.2',
|
|
'position' => ($position + ($count * 100000)).'.2',
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
$arrayofxaxis[$tablealias.'.'.$key.'-day'] = array(
|
|
$arrayofxaxis[$tablealias.'.'.$key.'-day'] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>',
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
|
|
'position' => ($position + ($count * 100000)).'.3',
|
|
'position' => ($position + ($count * 100000)).'.3',
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
$position = (empty($val['position']) ? 0 : intVal($val['position']));
|
|
$position = (empty($val['position']) ? 0 : intVal($val['position']));
|
|
$arrayofxaxis[$tablealias.'.'.$key] = array(
|
|
$arrayofxaxis[$tablealias.'.'.$key] = array(
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']),
|
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']),
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
|
|
'position' => ($position + ($count * 100000)),
|
|
'position' => ($position + ($count * 100000)),
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1148,11 +1244,39 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
|
|
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
|
|
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
|
|
continue;
|
|
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),
|
|
|
|
- 'table' => $object->table_element
|
|
|
|
- );
|
|
|
|
|
|
+
|
|
|
|
+ if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('timestamp', 'date', 'datetime'))) {
|
|
|
|
+ $position = (empty($extrafields->attributes[$object->table_element]['pos'][$key]) ? 0 : intVal($extrafields->attributes[$object->table_element]['pos'][$key]));
|
|
|
|
+ $arrayofxaxis[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-year'] = array(
|
|
|
|
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' <span class="opacitymedium">('.$YYYY.')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
|
|
|
|
+ 'position' => ($position + ($count * 100000)).'.1',
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
|
|
+ );
|
|
|
|
+ $arrayofxaxis[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-month'] = array(
|
|
|
|
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
|
|
|
|
+ 'position' => ($position + ($count * 100000)).'.2',
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
|
|
+ );
|
|
|
|
+ $arrayofxaxis[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-day'] = array(
|
|
|
|
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
|
|
|
|
+ 'position' => ($position + ($count * 100000)).'.3',
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ $arrayofxaxis[preg_replace('/^t/', 'te', $tablealias).'.'.$key] = array(
|
|
|
|
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val),
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
|
|
|
|
+ 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000),
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1167,7 +1291,7 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
|
|
$tmpobject = new $newobject($db);
|
|
$tmpobject = new $newobject($db);
|
|
//var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
|
|
//var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
|
|
$count++;
|
|
$count++;
|
|
- $arrayofxaxis = fillArrayOfXAxis($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofxaxis, $level + 1, $count);
|
|
|
|
|
|
+ $arrayofxaxis = fillArrayOfXAxis($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofxaxis, $level + 1, $count, $tablepath);
|
|
} else {
|
|
} else {
|
|
print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
|
|
print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
|
|
}
|
|
}
|
|
@@ -1188,18 +1312,21 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
|
|
* @param array $arrayofgroupby Array of groupby already filled
|
|
* @param array $arrayofgroupby Array of groupby already filled
|
|
* @param int $level Level
|
|
* @param int $level Level
|
|
* @param int $count Count
|
|
* @param int $count Count
|
|
|
|
+ * @param string $tablepath Path of all tables ('t' or 't,contract' or 't,contract,societe'...)
|
|
* @return array Array of groupby
|
|
* @return array Array of groupby
|
|
*/
|
|
*/
|
|
-function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroupby, $level = 0, &$count = 0)
|
|
|
|
|
|
+function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroupby, $level = 0, &$count = 0, &$tablepath = '')
|
|
{
|
|
{
|
|
global $langs, $extrafields, $db;
|
|
global $langs, $extrafields, $db;
|
|
|
|
|
|
- if ($level > 10) { // Protection against infinite loop
|
|
|
|
|
|
+ if ($level >= 3) {
|
|
return $arrayofgroupby;
|
|
return $arrayofgroupby;
|
|
}
|
|
}
|
|
|
|
|
|
- if ($level >= 2) {
|
|
|
|
- return $arrayofgroupby;
|
|
|
|
|
|
+ if (empty($tablepath)) {
|
|
|
|
+ $tablepath = $object->table_element.'='.$tablealias;
|
|
|
|
+ } else {
|
|
|
|
+ $tablepath .= ','.$object->table_element.'='.$tablealias;
|
|
}
|
|
}
|
|
|
|
|
|
$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);
|
|
$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);
|
|
@@ -1209,6 +1336,8 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
|
|
$MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 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);
|
|
$SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1);
|
|
|
|
|
|
|
|
+ // Note: here $tablealias can be 't' or 't__fk_contract' or 't_fk_contract_fk_soc'
|
|
|
|
+
|
|
// Add main fields of object
|
|
// Add main fields of object
|
|
foreach ($object->fields as $key => $val) {
|
|
foreach ($object->fields as $key => $val) {
|
|
if (empty($val['isameasure'])) {
|
|
if (empty($val['isameasure'])) {
|
|
@@ -1235,26 +1364,34 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
|
|
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
|
|
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
|
|
$position = (empty($val['position']) ? 0 : intVal($val['position']));
|
|
$position = (empty($val['position']) ? 0 : intVal($val['position']));
|
|
$arrayofgroupby[$tablealias.'.'.$key.'-year'] = array(
|
|
$arrayofgroupby[$tablealias.'.'.$key.'-year'] = array(
|
|
- 'label' => img_picto('', $object->picto,
|
|
|
|
- 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => ($position + ($count * 100000)).'.1',
|
|
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
|
|
|
|
+ 'position' => ($position + ($count * 100000)).'.1',
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
$arrayofgroupby[$tablealias.'.'.$key.'-month'] = array(
|
|
$arrayofgroupby[$tablealias.'.'.$key.'-month'] = array(
|
|
- 'label' => img_picto('', $object->picto,
|
|
|
|
- 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => ($position + ($count * 100000)).'.2',
|
|
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
|
|
|
|
+ 'position' => ($position + ($count * 100000)).'.2',
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
$arrayofgroupby[$tablealias.'.'.$key.'-day'] = array(
|
|
$arrayofgroupby[$tablealias.'.'.$key.'-day'] = array(
|
|
- 'label' => img_picto('', $object->picto,
|
|
|
|
- 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => ($position + ($count * 100000)).'.3',
|
|
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
|
|
|
|
+ 'position' => ($position + ($count * 100000)).'.3',
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
$position = (empty($val['position']) ? 0 : intVal($val['position']));
|
|
$position = (empty($val['position']) ? 0 : intVal($val['position']));
|
|
$arrayofgroupby[$tablealias.'.'.$key] = array(
|
|
$arrayofgroupby[$tablealias.'.'.$key] = array(
|
|
- 'label' => img_picto('', $object->picto,
|
|
|
|
- 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($position + ($count * 100000)),
|
|
|
|
- 'table' => $object->table_element
|
|
|
|
|
|
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']),
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
|
|
|
|
+ 'position' => ($position + ($count * 100000)),
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
);
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1269,11 +1406,39 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
|
|
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
|
|
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
|
|
continue;
|
|
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),
|
|
|
|
- 'table' => $object->table_element
|
|
|
|
- );
|
|
|
|
|
|
+
|
|
|
|
+ if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('timestamp', 'date', 'datetime'))) {
|
|
|
|
+ $position = (empty($extrafields->attributes[$object->table_element]['pos'][$key]) ? 0 : intVal($extrafields->attributes[$object->table_element]['pos'][$key]));
|
|
|
|
+ $arrayofgroupby[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-year'] = array(
|
|
|
|
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' <span class="opacitymedium">('.$YYYY.')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
|
|
|
|
+ 'position' => ($position + ($count * 100000)).'.1',
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
|
|
+ );
|
|
|
|
+ $arrayofgroupby[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-month'] = array(
|
|
|
|
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
|
|
|
|
+ 'position' => ($position + ($count * 100000)).'.2',
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
|
|
+ );
|
|
|
|
+ $arrayofgroupby[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-day'] = array(
|
|
|
|
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>',
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
|
|
|
|
+ 'position' => ($position + ($count * 100000)).'.3',
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ $arrayofgroupby[preg_replace('/^t/', 'te', $tablealias).'.'.$key] = array(
|
|
|
|
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val),
|
|
|
|
+ 'labelnohtml' => $labelofobject.': '.$langs->trans($val),
|
|
|
|
+ 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000),
|
|
|
|
+ 'table' => $object->table_element,
|
|
|
|
+ 'tablefromt' => $tablepath
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1288,7 +1453,7 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
|
|
$tmpobject = new $newobject($db);
|
|
$tmpobject = new $newobject($db);
|
|
//var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
|
|
//var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
|
|
$count++;
|
|
$count++;
|
|
- $arrayofgroupby = fillArrayOfGroupBy($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofgroupby, $level + 1, $count);
|
|
|
|
|
|
+ $arrayofgroupby = fillArrayOfGroupBy($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofgroupby, $level + 1, $count, $tablepath);
|
|
} else {
|
|
} else {
|
|
print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
|
|
print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
|
|
}
|
|
}
|