MSIN-4328 — Implement new function to derive registration choice names from entries, enhancing race data handling. Update race label formatting to include registration choice when available, improving clarity in dropdown options. Increment version code.

This commit is contained in:
2026-07-22 11:53:21 -04:00
parent aa61dfef15
commit dfab716014
2 changed files with 45 additions and 1 deletions

View File

@ -650,7 +650,15 @@ function fxChronotrackApiAdminRenderPageScript($intEveId, $arrConfig, $blnClosed
var intCurrent = tabMapCurrent[intEprId] || 0;
$sel.find('option:not(:first)').remove();
$.each(arrRaces, function (_, race) {
var strText = race.label || race.name || 'Course';
// MSIN-4328 — colonne CT : race_name (reg_choice) (ID race_id)
var strName = race.name || 'Course';
var strRc = race.reg_choice_label || '';
var strText = strName;
if (strRc) {
strText += ' (' + strRc + ')';
} else if (race.label && race.label !== strName) {
strText = race.label;
}
strText += ' (ID ' + race.ct_race_id + ')';
var $opt = $('<option></option>').val(race.ct_race_id).text(strText);
$sel.append($opt);

View File

@ -358,6 +358,42 @@ function fxChronotrackApiRegChoiceNamesByRaceId($mixPayload) {
return $arrByRace;
}
/**
* MSIN-4328 — Filet : déduit race_id → reg_choice_name depuis les entries CT.
*
* @return array<int, string[]>
*/
function fxChronotrackApiRegChoiceNamesFromEntriesPayload($mixPayload) {
$arrByRace = array();
$arrEntries = fxChronotrackApiNormalizeEntityList($mixPayload, 'entry');
if (count($arrEntries) === 0 && is_array($mixPayload) && isset($mixPayload['event']) && is_array($mixPayload['event'])) {
$arrEntries = fxChronotrackApiNormalizeEntityList($mixPayload['event'], 'entry');
}
foreach ($arrEntries as $arrEntry) {
if (!is_array($arrEntry)) {
continue;
}
$intRaceId = intval(fxChronotrackApiRaceField($arrEntry, array('race_id', 'event_race_id')));
if ($intRaceId <= 0) {
continue;
}
$strName = fxChronotrackApiRaceField($arrEntry, array(
'reg_choice_name', 'registration_choice_name', 'choice_name',
));
if ($strName === '') {
continue;
}
if (!isset($arrByRace[$intRaceId])) {
$arrByRace[$intRaceId] = array();
}
$arrByRace[$intRaceId][] = $strName;
}
foreach ($arrByRace as $intRaceId => $arrNames) {
$arrByRace[$intRaceId] = array_values(array_unique($arrNames));
}
return $arrByRace;
}
/**
* MSIN-4328 — Ajoute « (reg_choice) » au label de chaque course du mapping.
*/