From 7d403a2fff8c263247efca4274908d993c4758ad Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 24 Nov 2025 19:15:04 +0100 Subject: [PATCH 1/8] FIX getEntity use element instead table_element (#36405) --- htdocs/core/actions_extrafields.inc.php | 2 +- htdocs/core/class/html.form.class.php | 2 +- htdocs/webportal/class/html.formwebportal.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 2b16bd9faa0..d3ab24dd932 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -492,7 +492,7 @@ if ($action == 'encrypt') { $sql .= " AND te.".$attributekey." IS NOT NULL"; $sql .= " AND te.".$attributekey." <> ''"; if ($extrafields->attributes[$elementtype]['entityid'][$attributekey] == $conf->entity) { - $sql .= " AND t.entity = ".getEntity($arrayofelement['table_element'], 0); + $sql .= " AND t.entity = ".getEntity($arrayofelement['element'], 0); } //print $sql; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 40baa9d6fd7..baf3a476cfc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -9180,7 +9180,7 @@ class Form // If table need a multientity restriction if (!empty($objecttmp->ismultientitymanaged)) { if ($objecttmp->ismultientitymanaged == 1) { - $sql .= " AND t.entity IN (" . getEntity($objecttmp->table_element) . ")"; + $sql .= " AND t.entity IN (" . getEntity($objecttmp->element) . ")"; } if (!is_numeric($objecttmp->ismultientitymanaged)) { $sql .= " AND parenttable.entity = t." . $this->db->sanitize($tmparray[0]); diff --git a/htdocs/webportal/class/html.formwebportal.class.php b/htdocs/webportal/class/html.formwebportal.class.php index e246d54491c..6da1b08e9d2 100644 --- a/htdocs/webportal/class/html.formwebportal.class.php +++ b/htdocs/webportal/class/html.formwebportal.class.php @@ -536,7 +536,7 @@ class FormWebPortal extends Form $sql .= " WHERE 1=1"; if (isset($objecttmp->ismultientitymanaged)) { if ($objecttmp->ismultientitymanaged == 1) { - $sql .= " AND t.entity IN (" . getEntity($objecttmp->table_element) . ")"; + $sql .= " AND t.entity IN (" . getEntity($objecttmp->element) . ")"; } if (!is_numeric($objecttmp->ismultientitymanaged)) { $sql .= " AND parenttable.entity = t." . $tmparray[0]; From 71dc6dc1dbe84d6a79d450fbe1d49d7b193decab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Nov 2025 19:18:31 +0100 Subject: [PATCH 2/8] Fix #35096 #36393 --- htdocs/core/customreports.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 75ee1126897..ca00f4fe84e 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -121,6 +121,7 @@ $hookmanager->initHooks(array('customreport')); // Note that conf->hooks_modules $title = ''; $picto = ''; +$errormessage = null; $head = array(); $ObjectClassName = ''; // Objects available by default From d24b8b62215ec8a1e9adcc572d5d19c5b7874f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Tue, 25 Nov 2025 14:14:58 +0100 Subject: [PATCH 3/8] FIX do not force rowid to int (#36412) * do not force rowid to int * Update commonobject.class.php --------- Co-authored-by: Laurent Destailleur --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cef1558a5ed..d45f07f6a7e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8315,7 +8315,7 @@ abstract class CommonObject $isDependList = 1; } - $data[(int) $obj->rowid] = $labeltoshow; + $data[$obj->rowid] = $labeltoshow; // Warning: $obj->rowid is an alias and can be an int, but also a string ref. } $i++; From 244b6f04732374fe9c024c51dad8de9a63a6492b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Tue, 25 Nov 2025 14:14:58 +0100 Subject: [PATCH 4/8] FIX do not force rowid to int (#36412) * do not force rowid to int * Update commonobject.class.php --------- Co-authored-by: Laurent Destailleur --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 48afd79db8c..a0489c76653 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8232,7 +8232,7 @@ abstract class CommonObject $isDependList = 1; } - $data[(int) $obj->rowid] = $labeltoshow; + $data[$obj->rowid] = $labeltoshow; // Warning: $obj->rowid is an alias and can be an int, but also a string ref. } $i++; From 7f27552a95af2c61d680be469de6b01026f04408 Mon Sep 17 00:00:00 2001 From: Florian Mortgat <50440633+atm-florianm@users.noreply.github.com> Date: Tue, 25 Nov 2025 14:18:12 +0100 Subject: [PATCH 5/8] FIX: empty origin type passed to addline when creating invoices from expeditions using massaction (confirm_createbills) (#36413) --- htdocs/expedition/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 776e9d592c6..4527c8189c5 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -429,7 +429,7 @@ if (empty($reshook)) { $product_type, $rang, $lines[$i]->special_code, - $objecttmp->origin, + $objecttmp->origin_type, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, From d9b8abe3e4080b17732ecccb614d9dceece657d1 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 25 Nov 2025 14:20:05 +0100 Subject: [PATCH 6/8] FIX #36310 Accountancy - Data - Wrong account labels (cache) on write bookkeeping action (#36410) * FIX #36310 Accountancy - Data - Wrong account labels (cache) on writebookkeeping action (#36379) * Fix --- .../journal/expensereportsjournal.php | 20 ++++++++++++++----- .../accountancy/journal/purchasesjournal.php | 9 ++++++++- htdocs/accountancy/journal/sellsjournal.php | 18 +++++++++++++++-- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 34abad53a40..2e62bdacc29 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -321,6 +321,16 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b if (!$errorforline) { foreach ($tabht[$key] as $k => $mt) { if ($mt) { + if (empty($conf->cache['accountingaccountincurrententity'][$k])) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(0, $k, true); + $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount; + } else { + $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k]; + } + + $account_label = $accountingaccount->label; + // get compte id and label if ($accountingaccount->fetch(null, $k, true)) { $bookkeeping = new BookKeeping($db); @@ -335,9 +345,9 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->label_compte = $account_label; - $bookkeeping->label_operation = $accountingaccount->label; + $bookkeeping->label_operation = $account_label; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -383,12 +393,12 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { - if (empty($conf->cache['accountingaccountincurrententity'][$k])) { + if (empty($conf->cache['accountingaccountincurrententity_vat'][$k])) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(0, $k, true); - $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount; + $conf->cache['accountingaccountincurrententity_vat'][$k] = $accountingaccount; } else { - $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k]; + $accountingaccount = $conf->cache['accountingaccountincurrententity_vat'][$k]; } $account_label = $accountingaccount->label; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 91ac6b97ad8..324d45c62bb 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -616,7 +616,14 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { - $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label + if (empty($conf->cache['accountingaccountincurrententity_vat'][$k])) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(0, $k, true); + $conf->cache['accountingaccountincurrententity_vat'][$k] = $accountingaccount; + } else { + $accountingaccount = $conf->cache['accountingaccountincurrententity_vat'][$k]; + } + $label_account = $accountingaccount->label; $bookkeeping = new BookKeeping($db); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index d46d7e8ff31..b7da60a23af 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -679,7 +679,14 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { - $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label + if (empty($conf->cache['accountingaccountincurrententity_vat'][$k])) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(0, $k, true); + $conf->cache['accountingaccountincurrententity_vat'][$k] = $accountingaccount; + } else { + $accountingaccount = $conf->cache['accountingaccountincurrententity_vat'][$k]; + } + $label_account = $accountingaccount->label; $bookkeeping = new BookKeeping($db); @@ -740,7 +747,14 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) { foreach ($tabrevenuestamp[$key] as $k => $mt) { if ($mt) { - $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label + if (empty($conf->cache['accountingaccountincurrententity_rs'][$k])) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(0, $k, true); + $conf->cache['accountingaccountincurrententity_rs'][$k] = $accountingaccount; + } else { + $accountingaccount = $conf->cache['accountingaccountincurrententity_rs'][$k]; + } + $label_account = $accountingaccount->label; $bookkeeping = new BookKeeping($db); From 5044b3a102368a892d6667b1320a87468190bcd8 Mon Sep 17 00:00:00 2001 From: Jon Bendtsen Date: Tue, 25 Nov 2025 17:40:07 +0100 Subject: [PATCH 7/8] Qual: Undefined variable $errormessage in /var/www/html/core/customreports.php on line 951 (#36392) * checking if variable is set before testing the contents * more PHP warnings fixes detected during #35096 * using the fixed set above * backport eldy's fix --------- Co-authored-by: Jon Bendtsen --- htdocs/core/class/cleadstatus.class.php | 4 ++++ htdocs/core/customreports.php | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/cleadstatus.class.php b/htdocs/core/class/cleadstatus.class.php index f72f9dddc7d..7f6c0b9d0da 100644 --- a/htdocs/core/class/cleadstatus.class.php +++ b/htdocs/core/class/cleadstatus.class.php @@ -57,6 +57,10 @@ class CLeadStatus extends CommonDict */ public $percent; + public $fields = array( + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => "Id"), + 'label' => array('type' => 'varchar(128)', 'label' => 'Label', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'showoncombobox' => 1, 'comment' => "Label of status"), + ); /** * Constructor diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index ca00f4fe84e..9486b02e5b2 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -202,7 +202,11 @@ if ($user->socid > 0) { // Protection if external user $extrafields->fetch_name_optionals_label('all'); // We load all extrafields definitions for all objects //$extrafields->fetch_name_optionals_label($object->table_element_line); -$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +if (!empty($object->table_element)) { + $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +} else { + $search_array_options = array(); +} $search_component_params = array(''); $search_component_params_hidden = trim(GETPOST('search_component_params_hidden', 'alphanohtml')); @@ -310,7 +314,11 @@ $arrayofgroupby = array(); $arrayofyaxis = array(); $arrayofvaluesforgroupby = array(); -$features = $object->element; +if (!empty($object->element)) { + $features = $object->element; +} else { + $features = ''; +} if (!empty($object->element_for_permission)) { $features = $object->element_for_permission; } else { @@ -1134,10 +1142,14 @@ if ($mode == 'graph') { $dir = $conf->user->dir_temp; dol_mkdir($dir); // $customreportkey may be defined when using customreports.php as an include - $filenamekey = $dir.'/customreport_'.$object->element.(empty($customreportkey) ? '' : $customreportkey).'.png'; - $fileurlkey = DOL_URL_ROOT.'/viewimage.php?modulepart=user&file=customreport_'.$object->element.(empty($customreportkey) ? '' : $customreportkey).'.png'; + if (!empty($object->element)) { + $filenamekey = $dir.'/customreport_'.$object->element.(empty($customreportkey) ? '' : $customreportkey).'.png'; + $fileurlkey = DOL_URL_ROOT.'/viewimage.php?modulepart=user&file=customreport_'.$object->element.(empty($customreportkey) ? '' : $customreportkey).'.png'; + } - $px1->draw($filenamekey, $fileurlkey); + if (isset($filenamekey) && isset($fileurlkey)) { + $px1->draw($filenamekey, $fileurlkey); + } $texttoshow = $langs->trans("NoRecordFound"); if (!GETPOSTISSET('search_measures') || !GETPOSTISSET('search_xaxis')) { From e4070aeb97f3450ce9bb8571b7e93b376785fbb9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 25 Nov 2025 18:52:45 +0100 Subject: [PATCH 8/8] FIX avoid php warnings (or not ?) (#36411) * FIX avoid php warnings (or not ?) * FIX wrong check --- htdocs/core/class/dolgraph.class.php | 8 +++-- htdocs/core/customreports.php | 46 +++++++++++++++------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 79cff89f228..0f6f7b48b68 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -732,7 +732,9 @@ class DolGraph foreach ($this->data as $x) { // Loop on each x for ($i = 0; $i < $nbseries; $i++) { // Loop on each series if (is_null($max)) { - $max = $x[$i + 1]; // $i+1 because the index 0 is the legend + if (isset($x[$i + 1])) { + $max = $x[$i + 1]; // $i+1 because the index 0 is the legend + } } elseif ($max < $x[$i + 1]) { $max = $x[$i + 1]; } @@ -762,7 +764,9 @@ class DolGraph foreach ($this->data as $x) { // Loop on each x for ($i = 0; $i < $nbseries; $i++) { // Loop on each series if (is_null($min)) { - $min = $x[$i + 1]; // $i+1 because the index 0 is the legend + if (isset($x[$i + 1])) { + $min = $x[$i + 1]; // $i+1 because the index 0 is the legend + } } elseif ($min > $x[$i + 1]) { $min = $x[$i + 1]; } diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index bab97029c5f..1f713475096 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -493,28 +493,30 @@ if (is_array($search_groupby) && count($search_groupby)) { } $regs = array(); - if (!empty($object->fields[$gvalwithoutprefix]['arrayofkeyval'])) { - $valuetranslated = $object->fields[$gvalwithoutprefix]['arrayofkeyval'][$obj->val]; - if (is_null($valuetranslated)) { - $valuetranslated = $langs->transnoentitiesnoconv("UndefinedKey"); - } - $valuetranslated = $langs->trans($valuetranslated); - } elseif (preg_match('/integer:([^:]+):([^:]+)$/', $object->fields[$gvalwithoutprefix]['type'], $regs)) { - $classname = $regs[1]; - $classpath = $regs[2]; - dol_include_once($classpath); - if (class_exists($classname)) { - $tmpobject = new $classname($db); - '@phan-var-force CommonObject $tmpobject'; - $tmpobject->fetch($obj->val); - foreach ($tmpobject->fields as $fieldkey => $field) { - if ($field['showoncombobox']) { - $valuetranslated = $tmpobject->$fieldkey; - //if ($valuetranslated == '-') $valuetranslated = $langs->transnoentitiesnoconv("Unknown") - break; - } + if (isset($object->fields[$gvalwithoutprefix])) { + if (!empty($object->fields[$gvalwithoutprefix]['arrayofkeyval'])) { + $valuetranslated = $object->fields[$gvalwithoutprefix]['arrayofkeyval'][$obj->val]; + if (is_null($valuetranslated)) { + $valuetranslated = $langs->transnoentitiesnoconv("UndefinedKey"); + } + $valuetranslated = $langs->trans($valuetranslated); + } elseif (preg_match('/integer:([^:]+):([^:]+)$/', $object->fields[$gvalwithoutprefix]['type'], $regs)) { + $classname = $regs[1]; + $classpath = $regs[2]; + dol_include_once($classpath); + if (class_exists($classname)) { + $tmpobject = new $classname($db); + '@phan-var-force CommonObject $tmpobject'; + $tmpobject->fetch($obj->val); + foreach ($tmpobject->fields as $fieldkey => $field) { + if ($field['showoncombobox']) { + $valuetranslated = $tmpobject->$fieldkey; + //if ($valuetranslated == '-') $valuetranslated = $langs->transnoentitiesnoconv("Unknown") + break; + } + } + //$valuetranslated = $tmpobject->ref.'eee'; } - //$valuetranslated = $tmpobject->ref.'eee'; } } @@ -522,7 +524,7 @@ if (is_array($search_groupby) && count($search_groupby)) { } // Add also the possible NULL value if field is a parent field that is not a strict join $tmpfield = explode('.', $gval); - if ($tmpfield[0] != 't' || (is_array($object->fields[$tmpfield[1]]) && empty($object->fields[$tmpfield[1]]['notnull']))) { + if ($tmpfield[0] != 't' || (isset($object->fields[$tmpfield[1]]) && is_array($object->fields[$tmpfield[1]]) && empty($object->fields[$tmpfield[1]]['notnull']))) { dol_syslog("The group by field ".$gval." may be null (because field is null or it is a left join), so we add __NULL__ entry in list of possible values"); //var_dump($gval); var_dump($object->fields); $arrayofvaluesforgroupby['g_'.$gkey]['__NULL__'] = $langs->transnoentitiesnoconv("NotDefined");