From 731d85130c702fc9414490a1784e65d9eda3ba7e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 21 Apr 2022 09:49:00 +0200 Subject: [PATCH 1/3] FIX missing hook parameter --- htdocs/core/class/html.form.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d656fbde897..6a7bd9a688f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8404,7 +8404,7 @@ class Form public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array()) { global $conf, $langs, $hookmanager; - global $bc, $action; + global $action; $linktoelem = ''; $linktoelemlist = ''; @@ -8450,11 +8450,10 @@ class Form ); } - // Can complete the possiblelink array - $hookmanager->initHooks(array('commonobject')); - $parameters = array('listofidcompanytoscan' => $listofidcompanytoscan); - if (!empty($listofidcompanytoscan)) { // If empty, we don't have criteria to scan the object we can link to + // Can complete the possiblelink array + $hookmanager->initHooks(array('commonobject')); + $parameters = array('listofidcompanytoscan' => $listofidcompanytoscan, 'possiblelinks' => $possiblelinks); $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } From 8878eb6d76445653bac28817006877d5d163f237 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 21 Apr 2022 14:52:06 +0200 Subject: [PATCH 2/3] FIX compatibility with multicompany sharings --- htdocs/core/modules/project/mod_project_simple.php | 6 +++--- htdocs/core/modules/project/mod_project_universal.php | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index b1dbe4bae48..921b68f492b 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -125,14 +125,14 @@ class mod_project_simple extends ModeleNumRefProjects */ public function getNextValue($objsoc, $project) { - global $db, $conf; + global $db; // First, we get the max value $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql .= " FROM ".MAIN_DB_PREFIX."projet"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql .= " AND entity = ".$conf->entity; + $sql .= " AND entity IN (".getEntity('projectnumber', 1, $project).")"; $resql = $db->query($sql); if ($resql) { @@ -147,7 +147,7 @@ class mod_project_simple extends ModeleNumRefProjects return -1; } - $date = empty($project->date_c) ?dol_now() : $project->date_c; + $date = (empty($project->date_c) ? dol_now() : $project->date_c); //$yymm = strftime("%y%m",time()); $yymm = strftime("%y%m", $date); diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 550d72c4f68..47fd83842ed 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -136,8 +136,11 @@ class mod_project_universal extends ModeleNumRefProjects return 0; } - $date = empty($project->date_c) ?dol_now() : $project->date_c; - $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); + // Get entities + $entity = getEntity('projectnumber', 1, $project); + + $date = (empty($project->date_c) ? dol_now() : $project->date_c); + $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc : ''), $date, 'next', false, null, $entity); return $numFinal; } From 2a5c54d4e4deb51439531e8561e5b151e84789e0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 21 Apr 2022 16:02:41 +0200 Subject: [PATCH 3/3] FIX compatibility for ticket number sharing --- htdocs/core/modules/ticket/mod_ticket_simple.php | 2 +- htdocs/core/modules/ticket/mod_ticket_universal.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/ticket/mod_ticket_simple.php b/htdocs/core/modules/ticket/mod_ticket_simple.php index 523da47191d..76d8e4f8d79 100644 --- a/htdocs/core/modules/ticket/mod_ticket_simple.php +++ b/htdocs/core/modules/ticket/mod_ticket_simple.php @@ -129,7 +129,7 @@ class mod_ticket_simple extends ModeleNumRefTicket $sql .= " FROM ".MAIN_DB_PREFIX."ticket"; $search = $this->prefix."____-%"; $sql .= " WHERE ref LIKE '".$db->escape($search)."'"; - $sql .= " AND entity = ".$conf->entity; + $sql .= " AND entity IN (".getEntity('ticketnumber', 1, $ticket).")"; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php index 176af782dc7..2c46376eea1 100644 --- a/htdocs/core/modules/ticket/mod_ticket_universal.php +++ b/htdocs/core/modules/ticket/mod_ticket_universal.php @@ -134,8 +134,11 @@ class mod_ticket_universal extends ModeleNumRefTicket return 0; } + // Get entities + $entity = getEntity('ticketnumber', 1, $ticket); + $date = empty($ticket->datec) ? dol_now() : $ticket->datec; - $numFinal = get_next_value($db, $mask, 'ticket', 'ref', '', $objsoc->code_client, $date); + $numFinal = get_next_value($db, $mask, 'ticket', 'ref', '', $objsoc->code_client, $date, 'next', false, null, $entity); return $numFinal; }