';
// Add measures into array
$count = 0;
-$arrayofmesures = fillArrayOfMeasures($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofmesures, 0, $count);
//var_dump($arrayofmesures);
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 '
';
// 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
@@ -454,18 +484,38 @@ if ($mode == 'grid') {
continue;
}
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
- $arrayofyaxis['t.'.$key.'-year'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.')', 'position' => $val['position']);
- $arrayofyaxis['t.'.$key.'-month'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => $val['position']);
- $arrayofyaxis['t.'.$key.'-day'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => $val['position']);
+ $arrayofyaxis['t.'.$key.'-year'] = array(
+ 'label' => $langs->trans($val['label']).' ('.$YYYY.')',
+ 'position' => $val['position'],
+ 'table' => $object->table_element
+ );
+ $arrayofyaxis['t.'.$key.'-month'] = array(
+ 'label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')',
+ 'position' => $val['position'],
+ 'table' => $object->table_element
+ );
+ $arrayofyaxis['t.'.$key.'-day'] = array(
+ 'label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')',
+ 'position' => $val['position'],
+ 'table' => $object->table_element
+ );
} else {
- $arrayofyaxis['t.'.$key] = array('label' => $val['label'], 'position' => (int) $val['position']);
+ $arrayofyaxis['t.'.$key] = array(
+ 'label' => $val['label'],
+ 'position' => (int) $val['position'],
+ 'table' => $object->table_element
+ );
}
}
// Add measure from extrafields
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, 1, '1'))) {
- $arrayofyaxis['te.'.$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'position' => (int) $extrafields->attributes[$object->table_element]['pos'][$key]);
+ $arrayofyaxis['te.'.$key] = array(
+ 'label' => $extrafields->attributes[$object->table_element]['label'][$key],
+ 'position' => (int) $extrafields->attributes[$object->table_element]['pos'][$key],
+ 'table' => $object->table_element
+ );
}
}
}
@@ -495,7 +545,7 @@ $sql = '';
if (!empty($search_measures) && !empty($search_xaxis)) {
$fieldid = 'rowid';
- $sql = 'SELECT ';
+ $sql = "SELECT ";
foreach ($search_xaxis as $key => $val) {
if (preg_match('/\-year$/', $val)) {
$tmpval = preg_replace('/\-year$/', '', $val);
@@ -542,40 +592,72 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
}
}
$sql = preg_replace('/,\s*$/', '', $sql);
- $sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
+ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
// Add measure from extrafields
if ($object->isextrafieldmanaged) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te ON te.fk_object = t.".$fieldid;
}
- if ($object->ismultientitymanaged) {
+ // Add table for link for 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 == 1) {
- // Nothing here
+ // No table to add here
} else {
$tmparray = explode('@', $object->ismultientitymanaged);
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX.$tmparray[1]." as parenttable ON t.".$tmparray[0]." = parenttable.rowid";
- $sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')';
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX.$tmparray[1]." as parenttableforentity ON t.".$tmparray[0]." = parenttableforentity.rowid";
+ $sql .= " AND parenttableforentity.entity IN (".getEntity($tmparray[1]).")";
}
}
- // Add INNER JOIN for all parent tables
- //var_dump($arrayofxaxis); var_dump($search_xaxis);
$listoftablesalreadyadded = array($object->table_element => $object->table_element);
+
+ // Add LEFT JOIN for all parent tables mentionned into the Xaxis
+ //var_dump($arrayofxaxis); var_dump($search_xaxis);
foreach ($search_xaxis as $key => $val) {
if (!empty($arrayofxaxis[$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 .= ' INNER JOIN '.MAIN_DB_PREFIX.$arrayofxaxis[$val]['table'].' as '.$db->sanitize($tmpval[0]);
+ $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'];
}
} else {
- dol_print_error($db, 'Found an key into search_xaxis not found into arrayofxaxis');
+ dol_print_error($db, 'Found a key into search_xaxis not found into arrayofxaxis');
}
}
- $sql .= ' WHERE 1 = 1';
- if ($object->ismultientitymanaged == 1) {
- $sql .= ' AND t.entity IN ('.getEntity($object->element).')';
+ // Add LEFT JOIN for all parent tables mentionned into the Group by
+ //var_dump($arrayofgroupby); var_dump($search_groupby);
+ foreach ($search_groupby as $key => $val) {
+ if (!empty($arrayofgroupby[$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'];
+ }
+ } else {
+ dol_print_error($db, 'Found a key into search_groupby not found into arrayofgroupby');
+ }
+ }
+
+ // Add LEFT JOIN for all parent tables mentionned into the Yaxis
+ //var_dump($arrayofgroupby); var_dump($search_groupby);
+ foreach ($search_measures as $key => $val) {
+ if (!empty($arrayofmesures[$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'];
+ }
+ } else {
+ dol_print_error($db, 'Found a key into search_measures not found into arrayofmesures');
+ }
+ }
+
+ $sql .= " WHERE 1 = 1";
+ if ($object->ismultientitymanaged == 1) { // 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
+ $sql .= " AND t.entity IN (".getEntity($object->element).")";
}
// Add the where here
$sqlfilters = $search_component_params_hidden;
@@ -588,7 +670,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
print $errormessage;
}
}
- $sql .= ' GROUP BY ';
+ $sql .= " GROUP BY ";
foreach ($search_xaxis as $key => $val) {
if (preg_match('/\-year$/', $val)) {
$tmpval = preg_replace('/\-year$/', '', $val);
@@ -653,7 +735,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
$legend = array();
foreach ($search_measures as $key => $val) {
- $legend[] = $langs->trans($arrayofmesures[$val]);
+ $legend[] = $langs->trans($arrayofmesures[$val]['label']);
}
$useagroupby = (is_array($search_groupby) && count($search_groupby));
@@ -684,7 +766,7 @@ if ($sql) {
if (!empty($object->fields[$xvalwithoutprefix]['arrayofkeyval'])) {
$xlabel = $object->fields[$xvalwithoutprefix]['arrayofkeyval'][$obj->$fieldforxkey];
}
- $labeltouse = (($xlabel || $xlabel == '0') ? dol_trunc($xlabel, 20, 'middle') : ($xlabel === '' ? $langs->trans("Empty") : $langs->trans("NotDefined")));
+ $labeltouse = (($xlabel || $xlabel == '0') ? dol_trunc($xlabel, 20, 'middle') : ($xlabel === '' ? $langs->transnoentitiesnoconv("Empty") : $langs->transnoentitiesnoconv("NotDefined")));
if ($oldlabeltouse && ($labeltouse != $oldlabeltouse)) {
$xi++; // Increase $xi
@@ -878,26 +960,62 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
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';
+ $arrayofmesures[$tablealias.'.count'] = array(
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': Count',
+ 'position' => 0,
+ 'table' => $object->table_element
+ );
}
// Add main fields of object
foreach ($object->fields as $key => $val) {
if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '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").')';
+ $arrayofmesures[$tablealias.'.'.$key.'-sum'] = array(
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).'
('.$langs->trans("Sum").')',
+ 'position' => ($val['position']+($count * 100000)).'.1',
+ 'table' => $object->table_element
+ );
+ $arrayofmesures[$tablealias.'.'.$key.'-average'] = array(
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).'
('.$langs->trans("Average").')',
+ 'position' => ($val['position']+($count * 100000)).'.2',
+ 'table' => $object->table_element
+ );
+ $arrayofmesures[$tablealias.'.'.$key.'-min'] = array(
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).'
('.$langs->trans("Minimum").')',
+ 'position' => ($val['position']+($count * 100000)).'.3',
+ 'table' => $object->table_element
+ );
+ $arrayofmesures[$tablealias.'.'.$key.'-max'] = array(
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).'
('.$langs->trans("Maximum").')',
+ 'position' => ($val['position']+($count * 100000)).'.4',
+ 'table' => $object->table_element
+ );
}
}
// 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, 1, '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").')';
+ $arrayofmesures[$tablealias.'e.'.$key.'-sum'] = array(
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).'
('.$langs->trans("Sum").')',
+ 'position' => ($val['position']+($count * 100000)).'.1',
+ 'table' => $object->table_element
+ );
+ $arrayofmesures[$tablealias.'e.'.$key.'-average'] = array(
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).'
('.$langs->trans("Average").')',
+ 'position' => ($val['position']+($count * 100000)).'.2',
+ 'table' => $object->table_element
+ );
+ $arrayofmesures[$tablealias.'e.'.$key.'-min'] = array(
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).'
('.$langs->trans("Minimum").')',
+ 'position' => ($val['position']+($count * 100000)).'.3',
+ 'table' => $object->table_element
+ );
+ $arrayofmesures[$tablealias.'e.'.$key.'-max'] = array(
+ 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).'
('.$langs->trans("Maximum").')',
+ 'position' => ($val['position']+($count * 100000)).'.4',
+ 'table' => $object->table_element
+ );
}
}
}
@@ -905,19 +1023,16 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
foreach ($object->fields as $key => $val) {
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
$tmptype = explode(':', $val['type'], 4);
- if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) {
+ 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);*/
+ //var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); 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";
+ print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."
\n";
}
}
}
@@ -1027,7 +1142,7 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
foreach ($object->fields as $key => $val) {
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
$tmptype = explode(':', $val['type'], 4);
- if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) {
+ if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
$newobject = $tmptype[1];
dol_include_once($tmptype[2]);
if (class_exists($newobject)) {
@@ -1036,7 +1151,7 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
$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";
+ print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."
\n";
}
}
}
@@ -1100,14 +1215,31 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
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');
+ $arrayofgroupby[$tablealias.'.'.$key.'-year'] = array(
+ 'label' => img_picto('', $object->picto,
+ 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).'
('.$YYYY.')', 'position' => ($val['position']+($count * 100000)).'.1',
+ 'table' => $object->table_element
+ );
+ $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',
+ 'table' => $object->table_element
+ );
+ $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',
+ 'table' => $object->table_element
+ );
} else {
- $arrayofgroupby[$tablealias.'.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($val['position']+($count * 100000)));
+ $arrayofgroupby[$tablealias.'.'.$key] = array(
+ 'label' => img_picto('', $object->picto,
+ 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($val['position']+($count * 100000)),
+ 'table' => $object->table_element
+ );
}
}
}
+
// Add extrafields to Group by
if ($object->isextrafieldmanaged) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
@@ -1117,26 +1249,28 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
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));
+ $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
+ );
}
}
+
// 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]) {
+ 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);*/
+ //var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); 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";
+ print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."
\n";
}
}
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 0f57222a6ce..6a1bac203bb 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -9111,6 +9111,7 @@ function dol_getmypid()
* 3=value is list of string separated with comma (Example 'text 1,text 2'), 4=value is a list of ID separated with comma (Example '2,7') to be used to search into a multiselect string '1,2,3,4'
* @param integer $nofirstand 1=Do not output the first 'AND'
* @return string $res The statement to append to the SQL query
+ * @see dolSqlDateFilter()
*/
function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
{
diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
index d30107fcbfb..3b946d1f3ce 100644
--- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
@@ -609,7 +609,7 @@ class pdf_eratosthene extends ModelePDFCommandes
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height'];
}
diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php
index 742d06e2e34..65912a8b9a0 100644
--- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php
+++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php
@@ -461,7 +461,7 @@ class pdf_storm extends ModelePDFDeliveryOrder
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height'];
}
diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
index fc1094ea949..efc061b9e67 100644
--- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
@@ -562,7 +562,7 @@ class pdf_espadon extends ModelePdfExpedition
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height'];
}
diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
index 9c0088bd398..e9b985ee151 100644
--- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
+++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
@@ -383,10 +383,10 @@ class doc_generic_invoice_odt extends ModelePDFFactures
}
// Define substitution array
- $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
+ $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); // Set tags __...__
$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
- $array_objet = $this->get_substitutionarray_object($object, $outputlangs);
- $array_user = $this->get_substitutionarray_user($user, $outputlangs);
+ $array_objet = $this->get_substitutionarray_object($object, $outputlangs); // Set tags object_...
+ $array_user = $this->get_substitutionarray_user($user, $outputlangs); // Set tags myuser_...
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_propal = is_object($propal_object) ? $this->get_substitutionarray_object($propal_object, $outputlangs, 'propal') : array();
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index df4bfeedb9c..8046347e881 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -477,7 +477,7 @@ class pdf_crabe extends ModelePDFFactures
}
$tab_top += $extra_under_address_shift;
- $tab_top_newpage += $extra_under_address_shift;
+ $tab_top_newpage += 0;
// Incoterm
$height_incoterms = 0;
diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
index a5e9c0b841b..c1e0468b868 100644
--- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
@@ -460,7 +460,7 @@ class pdf_sponge extends ModelePDFFactures
}
$tab_top += $extra_under_address_shift;
- $tab_top_newpage += $extra_under_address_shift;
+ $tab_top_newpage += 0;
// Define heigth of table for lines (for first page)
@@ -685,7 +685,7 @@ class pdf_sponge extends ModelePDFFactures
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height'];
}
diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php
index 781c22ce7e3..947dd3d18d3 100644
--- a/htdocs/core/modules/import/import_csv.modules.php
+++ b/htdocs/core/modules/import/import_csv.modules.php
@@ -612,19 +612,8 @@ class ImportCsv extends ModeleImports
break;
}
$classinstance = new $class($this->db);
- $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord));
- if ($res < 0) {
- if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) {
- $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict']));
- } else {
- $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn';
- }
- $this->errors[$error]['type'] = 'FOREIGNKEY';
- $errorforthistable++;
- $error++;
- } else {
- $newval = $arrayrecord[($key - 1)]['val']; //We get new value computed.
- }
+ $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $listfields, ($key - 1)));
+ $newval = $res; // We get new value computed.
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') {
$newval = price2num($newval);
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') {
@@ -716,6 +705,8 @@ class ImportCsv extends ModeleImports
}
// We add hidden fields (but only if there is at least one field to add into table)
+ // We process here all the fields that were declared into the array ->import_fieldshidden_array of the descriptor file.
+ // Previously we processed the ->import_fields_array.
if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) {
// Loop on each hidden fields to add them into listfields/listvalues
foreach ($objimport->array_import_fieldshidden[0] as $key => $val) {
@@ -749,14 +740,13 @@ class ImportCsv extends ModeleImports
break;
}
$classinstance = new $class($this->db);
- $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $fieldname, &$listfields, &$listvalues));
- if ($res < 0) {
- if (!empty($objimport->array_import_convertvalue[0][$fieldname]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, end($listvalues), 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$fieldname]['dict']));
- else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn';
- $this->errors[$error]['type'] = 'FOREIGNKEY';
- $errorforthistable++;
- $error++;
+ $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $listfields, ($key - 1)));
+ $fieldArr = explode('.', $fieldname);
+ if (count($fieldArr) > 0) {
+ $fieldname = $fieldArr[1];
}
+ $listfields[] = $fieldname;
+ $listvalues[] = $res;
}
}
} else {
diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php
index 1c38f52cbfc..3747e8f6847 100644
--- a/htdocs/core/modules/import/import_xlsx.modules.php
+++ b/htdocs/core/modules/import/import_xlsx.modules.php
@@ -654,18 +654,7 @@ class ImportXlsx extends ModeleImports
}
$classinstance = new $class($this->db);
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord));
- if ($res < 0) {
- if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) {
- $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict']));
- } else {
- $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn';
- }
- $this->errors[$error]['type'] = 'FOREIGNKEY';
- $errorforthistable++;
- $error++;
- } else {
- $newval = $arrayrecord[($key)]['val']; //We get new value computed.
- }
+ $newval = $res; // We get new value computed.
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') {
$newval = price2num($newval);
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') {
@@ -757,6 +746,8 @@ class ImportXlsx extends ModeleImports
}
// We add hidden fields (but only if there is at least one field to add into table)
+ // We process here all the fields that were declared into the array $this->import_fieldshidden_array of the descriptor file.
+ // Previously we processed the ->import_fields_array.
if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) {
// Loop on each hidden fields to add them into listfields/listvalues
foreach ($objimport->array_import_fieldshidden[0] as $key => $val) {
@@ -791,13 +782,12 @@ class ImportXlsx extends ModeleImports
}
$classinstance = new $class($this->db);
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $fieldname, &$listfields, &$listvalues));
- if ($res < 0) {
- if (!empty($objimport->array_import_convertvalue[0][$fieldname]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, end($listvalues), 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$fieldname]['dict']));
- else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn';
- $this->errors[$error]['type'] = 'FOREIGNKEY';
- $errorforthistable++;
- $error++;
+ $fieldArr = explode('.', $fieldname);
+ if (count($fieldArr) > 0) {
+ $fieldname = $fieldArr[1];
}
+ $listfields[] = $fieldname;
+ $listvalues[] = $res;
}
}
} else {
diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php
index 73494a6cb04..5e30978693e 100644
--- a/htdocs/core/modules/modAccounting.class.php
+++ b/htdocs/core/modules/modAccounting.class.php
@@ -354,8 +354,12 @@ class modAccounting extends DolibarrModules
'b.sens'=>'rule-computeDirection'
); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_convertvalue_array[$r]=array(
+ 'b.piece_num' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'cleanValue', 'element' => 'Accountancy'),
'b.numero_compte'=>array('rule'=>'accountingaccount'),
'b.subledger_account'=>array('rule'=>'accountingaccount'),
+ 'b.debit' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'cleanAmount', 'element' => 'Accountancy'),
+ 'b.credit' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'cleanAmount', 'element' => 'Accountancy'),
+ 'b.multicurrency_amount' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'cleanAmount', 'element' => 'Accountancy'),
'b.montant' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeAmount', 'element' => 'Accountancy'),
'b.sens' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeDirection', 'element' => 'Accountancy'),
);
diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
index 1e48a826257..66882166722 100644
--- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
@@ -622,7 +622,7 @@ class pdf_cyan extends ModelePDFPropales
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height'];
}
diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
index 8d8df36e088..2be12805685 100644
--- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
+++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
@@ -566,7 +566,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height'];
}
diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php
index c40f07716f2..e8dbec2ac77 100644
--- a/htdocs/core/tpl/objectline_title.tpl.php
+++ b/htdocs/core/tpl/objectline_title.tpl.php
@@ -71,7 +71,9 @@ if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || !empty($conf->global->FA
if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) {
global $mysoc;
- print '
id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').'';
+ if (empty($disableedit)) {
+ print '
id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').'';
+ }
//print '';
if (GETPOST('mode', 'aZ09') == 'vatforalllines') {
print '
';
diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php
index e8316392043..c2d81b81eb5 100644
--- a/htdocs/core/tpl/objectline_view.tpl.php
+++ b/htdocs/core/tpl/objectline_view.tpl.php
@@ -172,13 +172,13 @@ if (($line->info_bits & 2) == 2) {
print '
';
}
if ($line->date_start_fill) {
- print ''.$langs->trans('AutoFillDateFromShort').': '.yn($line->date_start_fill);
+ print ''.$langs->trans('AutoFillDateFromShort').': '.yn($line->date_start_fill);
}
if ($line->date_start_fill && $line->date_end_fill) {
print ' - ';
}
if ($line->date_end_fill) {
- print ''.$langs->trans('AutoFillDateToShort').': '.yn($line->date_end_fill);
+ print ''.$langs->trans('AutoFillDateToShort').': '.yn($line->date_end_fill);
}
if ($line->date_start_fill || $line->date_end_fill) {
print '
';
@@ -200,7 +200,16 @@ if (($line->info_bits & 2) == 2) {
}
}
- //print get_date_range($line->date_start, $line->date_end, $format);
+ // If we show the lines in a context to create a recurring sale invoice
+ if (basename($_SERVER["PHP_SELF"]) == 'card-rec.php') {
+ $default_start_fill = getDolGlobalInt('INVOICEREC_SET_AUTOFILL_DATE_START');
+ $default_end_fill = getDolGlobalInt('INVOICEREC_SET_AUTOFILL_DATE_END');
+ print '
';
+ print ''.$langs->trans('AutoFillDateFromShort').': '.yn($default_start_fill);
+ print ' - ';
+ print ''.$langs->trans('AutoFillDateToShort').': '.yn($default_end_fill);
+ print '
';
+ }
}
// Add description in form
diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php
index b47cfa263c0..baed7051ef8 100644
--- a/htdocs/fourn/class/fournisseur.class.php
+++ b/htdocs/fourn/class/fournisseur.class.php
@@ -106,7 +106,7 @@ class Fournisseur extends Societe
public function load_state_board()
{
// phpcs:enable
- global $conf, $user;
+ global $conf, $user, $hookmanager;
$this->nb = array();
$clause = "WHERE";
@@ -120,6 +120,12 @@ class Fournisseur extends Societe
}
$sql .= " ".$clause." s.fournisseur = 1";
$sql .= " AND s.entity IN (".getEntity('societe').")";
+ // Add where from hooks
+ if (is_object($hookmanager)) {
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $this); // Note that $action and $object may have been modified by hook
+ $sql .= $hookmanager->resPrint;
+ }
$resql = $this->db->query($sql);
if ($resql) {
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 839a9f18ba2..d87f60525e3 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -5682,7 +5682,7 @@ class Product extends CommonObject
public function load_state_board()
{
// phpcs:enable
- global $conf, $user, $hookmanager;
+ global $hookmanager;
$this->nb = array();
@@ -5692,7 +5692,7 @@ class Product extends CommonObject
// Add where from hooks
if (is_object($hookmanager)) {
$parameters = array();
- $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
+ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $this); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
}
$sql .= ' GROUP BY fk_product_type';
diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php
index 2e77c29cd01..4f7ea9d777c 100644
--- a/htdocs/salaries/list.php
+++ b/htdocs/salaries/list.php
@@ -260,12 +260,19 @@ if ($search_user) {
if ($search_label) {
$sql .= natural_search(array('s.label'), $search_label);
}
-if (!empty($search_date_start_from) && !empty($search_date_start_to)) {
- $sql .= " AND s.datesp BETWEEN '".$db->idate($search_date_start_from)."' AND '".$db->idate($search_date_start_to)."'";
+if (!empty($search_date_start_from)) {
+ $sql .= " AND s.datesp >= '".$db->idate($search_date_start_from)."'";
}
-if (!empty($search_date_end_from) && !empty($search_date_end_to)) {
- $sql .= " AND s.dateep BETWEEN '".$db->idate($search_date_end_from)."' AND '".$db->idate($search_date_end_to)."'";
+if (!empty($search_date_end_from)) {
+ $sql .= " AND s.dateep >= '".$db->idate($search_date_end_from)."'";
}
+if (!empty($search_date_start_to)) {
+ $sql .= " AND s.datesp <= '".$db->idate($search_date_start_to)."'";
+}
+if (!empty($search_date_end_to)) {
+ $sql .= " AND s.dateep <= '".$db->idate($search_date_end_to)."'";
+}
+
if ($search_amount) {
$sql .= natural_search("s.amount", $search_amount, 1);
}
diff --git a/htdocs/societe/class/client.class.php b/htdocs/societe/class/client.class.php
index 4e55a914339..eeae4e77731 100644
--- a/htdocs/societe/class/client.class.php
+++ b/htdocs/societe/class/client.class.php
@@ -57,7 +57,7 @@ class Client extends Societe
public function load_state_board()
{
// phpcs:enable
- global $user;
+ global $user, $hookmanager;
$this->nb = array("prospects" => 0, "customers" => 0);
$clause = "WHERE";
@@ -71,6 +71,12 @@ class Client extends Societe
}
$sql .= " ".$clause." s.client IN (1,2,3)";
$sql .= ' AND s.entity IN ('.getEntity($this->element).')';
+ // Add where from hooks
+ if (is_object($hookmanager)) {
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $this); // Note that $action and $object may have been modified by hook
+ $sql .= $hookmanager->resPrint;
+ }
$sql .= " GROUP BY s.client";
$resql = $this->db->query($sql);