Merge pull request #20683 from hregis/fix_missing_getentity

FIX compatibility with multicompany sharings
This commit is contained in:
Laurent Destailleur 2022-04-29 18:35:26 +02:00 committed by GitHub
commit e5aa4afabd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 7 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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) {

View File

@ -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;
}