From dfab71601497fb0306aa1df0de609784579dd725 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 22 Jul 2026 11:53:21 -0400 Subject: [PATCH] =?UTF-8?q?MSIN-4328=20=E2=80=94=20Implement=20new=20funct?= =?UTF-8?q?ion=20to=20derive=20registration=20choice=20names=20from=20entr?= =?UTF-8?q?ies,=20enhancing=20race=20data=20handling.=20Update=20race=20la?= =?UTF-8?q?bel=20formatting=20to=20include=20registration=20choice=20when?= =?UTF-8?q?=20available,=20improving=20clarity=20in=20dropdown=20options.?= =?UTF-8?q?=20Increment=20version=20code.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- php/chronotrack_api/fx_chronotrack_admin.php | 10 +++++- php/chronotrack_api/fx_chronotrack_events.php | 36 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) 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. */