Merge branch '15.0' of git@github.com:Dolibarr/dolibarr.git into 15.0

This commit is contained in:
Laurent Destailleur 2022-04-30 17:20:07 +02:00
commit 08461957b5
5 changed files with 17 additions and 12 deletions

View File

@ -8404,7 +8404,7 @@ class Form
public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array()) public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array())
{ {
global $conf, $langs, $hookmanager; global $conf, $langs, $hookmanager;
global $bc, $action; global $action;
$linktoelem = ''; $linktoelem = '';
$linktoelemlist = ''; $linktoelemlist = '';
@ -8450,11 +8450,10 @@ class Form
); );
} }
if (!empty($listofidcompanytoscan)) { // If empty, we don't have criteria to scan the object we can link to
// Can complete the possiblelink array // Can complete the possiblelink array
$hookmanager->initHooks(array('commonobject')); $hookmanager->initHooks(array('commonobject'));
$parameters = array('listofidcompanytoscan' => $listofidcompanytoscan); $parameters = array('listofidcompanytoscan' => $listofidcompanytoscan, 'possiblelinks' => $possiblelinks);
if (!empty($listofidcompanytoscan)) { // If empty, we don't have criteria to scan the object we can link to
$reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
} }

View File

@ -125,14 +125,14 @@ class mod_project_simple extends ModeleNumRefProjects
*/ */
public function getNextValue($objsoc, $project) public function getNextValue($objsoc, $project)
{ {
global $db, $conf; global $db;
// First, we get the max value // First, we get the max value
$posindice = strlen($this->prefix) + 6; $posindice = strlen($this->prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql .= " FROM ".MAIN_DB_PREFIX."projet"; $sql .= " FROM ".MAIN_DB_PREFIX."projet";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; $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); $resql = $db->query($sql);
if ($resql) { if ($resql) {
@ -147,7 +147,7 @@ class mod_project_simple extends ModeleNumRefProjects
return -1; 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",time());
$yymm = strftime("%y%m", $date); $yymm = strftime("%y%m", $date);

View File

@ -136,8 +136,11 @@ class mod_project_universal extends ModeleNumRefProjects
return 0; return 0;
} }
$date = empty($project->date_c) ?dol_now() : $project->date_c; // Get entities
$numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); $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; return $numFinal;
} }

View File

@ -129,7 +129,7 @@ class mod_ticket_simple extends ModeleNumRefTicket
$sql .= " FROM ".MAIN_DB_PREFIX."ticket"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket";
$search = $this->prefix."____-%"; $search = $this->prefix."____-%";
$sql .= " WHERE ref LIKE '".$db->escape($search)."'"; $sql .= " WHERE ref LIKE '".$db->escape($search)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity IN (".getEntity('ticketnumber', 1, $ticket).")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {

View File

@ -134,8 +134,11 @@ class mod_ticket_universal extends ModeleNumRefTicket
return 0; return 0;
} }
// Get entities
$entity = getEntity('ticketnumber', 1, $ticket);
$date = empty($ticket->datec) ? dol_now() : $ticket->datec; $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; return $numFinal;
} }