diff --git a/php/chronotrack_api/fx_chronotrack_admin.php b/php/chronotrack_api/fx_chronotrack_admin.php index 2618c65..810296a 100644 --- a/php/chronotrack_api/fx_chronotrack_admin.php +++ b/php/chronotrack_api/fx_chronotrack_admin.php @@ -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 = $('').val(race.ct_race_id).text(strText); $sel.append($opt); diff --git a/php/chronotrack_api/fx_chronotrack_events.php b/php/chronotrack_api/fx_chronotrack_events.php index 797752d..7c667de 100644 --- a/php/chronotrack_api/fx_chronotrack_events.php +++ b/php/chronotrack_api/fx_chronotrack_events.php @@ -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 + */ +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. */