From afff43abd6c1f93dc60b5a4808e4c249778caf59 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 29 Jun 2026 13:31:28 -0400 Subject: [PATCH] MSIN-4405 Implement cancellation cause logic and UI enhancements This commit introduces a new function, `fxGetAnnulationCause`, to determine the reason for a cancelled registration (e.g., transfer, modification, or true cancellation) without altering the database. Additionally, it adds CSS styles for displaying cancellation badges in the UI, enhancing the visual representation of registration statuses. The changes improve user experience by providing clear and informative feedback on registration cancellations throughout the management interface. --- css/style.css | 24 +++++++++++++++ php/inc_fonctions.php | 45 +++++++++++++++++++++++++++++ php/inc_fx_inscriptions_gestion.php | 28 +++++++++++++++--- php/inc_fx_promoteur.php | 18 ++++++++++-- 4 files changed, 108 insertions(+), 7 deletions(-) diff --git a/css/style.css b/css/style.css index ab502fa..8813549 100644 --- a/css/style.css +++ b/css/style.css @@ -2707,6 +2707,30 @@ a.ms1-trad-link.btn-aide-trad{ border-color:#f1b0b7; } +/* MSIN-4405 — pastille de cause d'annulation (annulee / transferee / modifiee) */ +.inscr-gestion-cancel-badge{ + display:inline-block; + margin-left:6px; + padding:1px 7px; + border-radius:10px; + font-size:.72rem; + font-weight:600; + line-height:1.4; + vertical-align:middle; + white-space:nowrap; + color:#fff; + background:#dc3545; +} +.inscr-gestion-cancel-badge--transfert{ + background:#0d6efd; +} +.inscr-gestion-cancel-badge--modif{ + background:#fd7e14; +} +.inscr-gestion-cancel-badge--annule{ + background:#dc3545; +} + .inscr-gestion-list-item__main{ display:contents; } diff --git a/php/inc_fonctions.php b/php/inc_fonctions.php index d30cccc..60a636c 100644 --- a/php/inc_fonctions.php +++ b/php/inc_fonctions.php @@ -174,6 +174,51 @@ function fxcount($memarray) } +/** + * MSIN-4405 — Determine, en LECTURE SEULE, pourquoi une inscription annulee (is_cancelled = 1) + * porte ce statut. Aucune ecriture : on ne touche ni is_cancelled, ni pec_actif, ni la base. + * + * Regles (cf. fxMajEpreuvesCommandees / annuler_inscription.php) : + * - vraie annulation : l'ancien pec reste actif (pec_actif = 1) + * - transfert complete: ligne dans inscriptions_transferts (ts_id = 2) pour ce pec + * - changement d'epreuve / upgrade : ligne dans inscriptions_panier_epreuves_commandees_upgrade + * + * @param int $intPecId pec_id_original de l'inscription + * @param int|null $intPecActif valeur de pec_actif si deja connue (evite une requete) + * @return string 'annule' | 'transfert' | 'modif' + */ +function fxGetAnnulationCause($intPecId, $intPecActif = null) { + global $objDatabase; + + $intPecId = intval($intPecId); + if ($intPecId <= 0) { + return 'annule'; + } + + // Une vraie annulation laisse l'inscription active (pec_actif = 1). + if ($intPecActif !== null && intval($intPecActif) === 1) { + return 'annule'; + } + + // Transfert complete vers une autre personne. + $varTransfert = $objDatabase->fxGetVar( + "SELECT 1 FROM inscriptions_transferts WHERE pec_id = " . $intPecId . " AND ts_id = 2 LIMIT 1" + ); + if ($varTransfert) { + return 'transfert'; + } + + // Changement d'epreuve / upgrade (ancien pec remplace par un nouveau). + $varUpgrade = $objDatabase->fxGetVar( + "SELECT 1 FROM inscriptions_panier_epreuves_commandees_upgrade WHERE pec_id_old = " . $intPecId . " LIMIT 1" + ); + if ($varUpgrade) { + return 'modif'; + } + + return 'annule'; +} + // fonction qui retourne les infos des champs de la table (SL / JSP) // param : nom de la table, nom de la base de données diff --git a/php/inc_fx_inscriptions_gestion.php b/php/inc_fx_inscriptions_gestion.php index a74b8af..ef1de5f 100644 --- a/php/inc_fx_inscriptions_gestion.php +++ b/php/inc_fx_inscriptions_gestion.php @@ -229,6 +229,11 @@ function fxInscrGestionFallbackTexte($strClef, $strLangue) { 'inscr_gestion_search_prompt' => $blnFr ? 'Utilisez la recherche ci-dessus pour afficher les inscriptions. Laissez les champs vides et lancez la recherche pour toutes les afficher.' : 'Use the search above to display registrations. Leave the fields empty and search to show them all.', + // MSIN-4405 — Detail du statut annule (transfere / modifie / vraie annulation), derive en lecture. + 'inscr_gestion_annulation_titre' => $blnFr ? 'Statut de l\'inscription' : 'Registration status', + 'inscr_gestion_statut_annule' => $blnFr ? 'Annulée' : 'Cancelled', + 'inscr_gestion_statut_transfert' => $blnFr ? 'Transférée' : 'Transferred', + 'inscr_gestion_statut_modif' => $blnFr ? 'Modifiée (changement d\'épreuve)' : 'Modified (race change)', ); } @@ -516,7 +521,7 @@ function fxInscrGestionFetchRows($intEveId, $arrReq) { $strWhere = fxInscrGestionBuildWhere($intEveId, $arrReq); $sql = 'SELECT p.no_bib, p.no_bib_remis, p.no_bib_remis_date, p.no_bib_remis_par, p.par_statut_course, p.par_id, p.par_equipe,' - . ' p.par_prenom, p.par_nom, e.pec_id_original, e.epr_id, e.eve_id, e.pec_id, e.is_cancelled, p.rol_id,' + . ' p.par_prenom, p.par_nom, e.pec_id_original, e.epr_id, e.eve_id, e.pec_id, e.is_cancelled, e.pec_actif, p.rol_id,' . ' e.no_commande, e.no_panier, e.no_equipe, e.pec_equipe' . ' FROM resultats_epreuves_commandees e, resultats_participants p' . ' WHERE ' . $strWhere . ' AND p.pec_id = e.pec_id_original' @@ -530,7 +535,7 @@ function fxInscrGestionFetchRowByPec($intPecId, $intEveId) { global $objDatabase; $sql = 'SELECT p.no_bib, p.no_bib_remis, p.no_bib_remis_date, p.no_bib_remis_par, p.par_statut_course, p.par_id, p.par_equipe,' - . ' p.par_prenom, p.par_nom, e.pec_id_original, e.epr_id, e.eve_id, e.pec_id, e.is_cancelled, p.rol_id,' + . ' p.par_prenom, p.par_nom, e.pec_id_original, e.epr_id, e.eve_id, e.pec_id, e.is_cancelled, e.pec_actif, p.rol_id,' . ' e.no_commande, e.no_panier, e.no_equipe, e.pec_equipe' . ' FROM resultats_epreuves_commandees e, resultats_participants p' . ' WHERE e.eve_id = ' . intval($intEveId) @@ -1277,12 +1282,17 @@ function fxInscrGestionRenderList($intEveId, $strLangue, $strBaseUrl, $arrReq) { $strName = fxUnescape($row['par_nom']) . ', ' . fxUnescape($row['par_prenom']); $strRace = fxInscrGestionEpreuveLabel($row['epr_id'], $strLangue); $strCardClass = 'inscr-gestion-list-item'; + $strCancelBadge = ''; if ($row['is_cancelled'] == '1') { - $strCardClass .= ' inscr-gestion-list-item--cancelled'; + // MSIN-4405 — Cause derivee en lecture seule (aucune ecriture en base). + $strCause = fxGetAnnulationCause($row['pec_id_original'], $row['pec_actif']); + $strCardClass .= ' inscr-gestion-list-item--cancelled inscr-gestion-list-item--' . $strCause; + $strCancelBadge = ' ' + . fxInscrGestionEsc(fxInscrGestionT('inscr_gestion_statut_' . $strCause)) . ''; } echo ''; - echo '' . fxInscrGestionEsc($strName) . ''; + echo '' . fxInscrGestionEsc($strName) . $strCancelBadge . ''; echo '' . fxInscrGestionEsc($strRace) . ''; echo '' . fxInscrGestionEsc($row['no_commande']) . ''; echo ''; @@ -1361,6 +1371,16 @@ function fxInscrGestionRenderFiche($intEveId, $strLangue, $strBaseUrl, $arrReq, fxInscrGestionRenderKvListOpen(); fxInscrGestionRenderKvRow(fxInscrGestionT('inscr_gestion_epreuve'), fxInscrGestionEpreuveLabel($arrRow['epr_id'], $strLangue)); fxInscrGestionRenderKvRow(fxInscrGestionT('inscr_gestion_type'), $strDetailsType); + if ($blnCancelled) { + // MSIN-4405 — Detail de l'annulation (transfere / modifie / annule) derive en lecture seule. + $strCause = fxGetAnnulationCause($arrRow['pec_id_original'], $arrRow['pec_actif']); + fxInscrGestionRenderKvRow( + fxInscrGestionT('inscr_gestion_annulation_titre'), + '' + . fxInscrGestionEsc(fxInscrGestionT('inscr_gestion_statut_' . $strCause)) . '', + true + ); + } fxInscrGestionRenderKvRow(fxInscrGestionT('inscr_gestion_modified'), fxCheckMAJ($arrRow['pec_id_original'], $intParId, $strLangue), true); fxInscrGestionRenderFicheProfileKvRows($arrRow, $strLangue); fxInscrGestionRenderKvListClose(); diff --git a/php/inc_fx_promoteur.php b/php/inc_fx_promoteur.php index eb5c93f..a6512ab 100644 --- a/php/inc_fx_promoteur.php +++ b/php/inc_fx_promoteur.php @@ -229,7 +229,7 @@ function fxShowRecherche($str_code, $int_promoteur_id, $blnDon, $strLangue, $int $strWhere .= ' AND e.is_cancelled = 0 AND e.pec_actif = 1'; // MSIN-3522 } - $sqlInscriptionsParPage = 'select p.no_bib,p.no_bib_remis,p.no_bib_remis_date,p.no_bib_remis_par, p.par_id, p.par_equipe, p.par_prenom, p.par_nom, e.pec_id_original, e.epr_id, e.eve_id, e.pec_id, e.is_cancelled, p.rol_id, e.no_commande, e.no_panier, e.no_equipe, e.pec_equipe from resultats_epreuves_commandees e, resultats_participants p where ' . $strWhere . ' and p.pec_id = e.pec_id_original group by e.pec_id_original'; + $sqlInscriptionsParPage = 'select p.no_bib,p.no_bib_remis,p.no_bib_remis_date,p.no_bib_remis_par, p.par_id, p.par_equipe, p.par_prenom, p.par_nom, e.pec_id_original, e.epr_id, e.eve_id, e.pec_id, e.is_cancelled, e.pec_actif, p.rol_id, e.no_commande, e.no_panier, e.no_equipe, e.pec_equipe from resultats_epreuves_commandees e, resultats_participants p where ' . $strWhere . ' and p.pec_id = e.pec_id_original group by e.pec_id_original'; $tabInscriptionsParPage = $objDatabase->fxGetResults($sqlInscriptionsParPage); } @@ -558,7 +558,7 @@ function fxShowRechercheinscription($str_code, $int_promoteur_id, $blnDon, $strL $strWhere .= ' AND e.is_cancelled = 0 AND e.pec_actif = 1'; // MSIN-3522 } - $sqlInscriptionsParPage = 'select p.no_bib,p.no_bib_remis,p.no_bib_remis_date,p.no_bib_remis_par, p.par_id, p.par_equipe, p.par_prenom, p.par_nom, e.pec_id_original, e.epr_id, e.eve_id, e.pec_id, e.is_cancelled, p.rol_id, e.no_commande, e.no_panier, e.no_equipe, e.pec_equipe from resultats_epreuves_commandees e, resultats_participants p where ' . $strWhere . ' and p.pec_id = e.pec_id_original group by e.pec_id_original'; + $sqlInscriptionsParPage = 'select p.no_bib,p.no_bib_remis,p.no_bib_remis_date,p.no_bib_remis_par, p.par_id, p.par_equipe, p.par_prenom, p.par_nom, e.pec_id_original, e.epr_id, e.eve_id, e.pec_id, e.is_cancelled, e.pec_actif, p.rol_id, e.no_commande, e.no_panier, e.no_equipe, e.pec_equipe from resultats_epreuves_commandees e, resultats_participants p where ' . $strWhere . ' and p.pec_id = e.pec_id_original group by e.pec_id_original'; $tabInscriptionsParPage = $objDatabase->fxGetResults($sqlInscriptionsParPage); } @@ -2034,15 +2034,27 @@ function fxShowColumnPromoteur($arrColonnes, $arrListeParticipants, $x, $strLang case 'management': $strCode = fxGetEvenementsUrl($arrListeParticipants[$x]['eve_id']); + $strCancelBadge = ''; if ($arrListeParticipants[$x]['is_cancelled'] == '' || $arrListeParticipants[$x]['is_cancelled'] == '0') { $strStyleEdit = $strStyleCancel = ''; $strStyleRetablir = ' d-none'; } else { $strStyleEdit = $strStyleCancel = ' d-none'; $strStyleRetablir = ''; + + // MSIN-4405 — Cause de l'annulation derivee en lecture seule (transfere / modifie / annule). + $strCause = fxGetAnnulationCause($arrListeParticipants[$x]['pec_id_original'], isset($arrListeParticipants[$x]['pec_actif']) ? $arrListeParticipants[$x]['pec_actif'] : null); + if ($strCause == 'transfert') { + $strBadgeLbl = ($strLangue == 'fr') ? 'Transférée' : 'Transferred'; + } elseif ($strCause == 'modif') { + $strBadgeLbl = ($strLangue == 'fr') ? 'Modifiée (changement d\'épreuve)' : 'Modified (race change)'; + } else { + $strBadgeLbl = ($strLangue == 'fr') ? 'Annulée' : 'Cancelled'; + } + $strCancelBadge = '
' . htmlspecialchars($strBadgeLbl, ENT_QUOTES, 'UTF-8') . '
'; } - $strAffichage = ' + $strAffichage = $strCancelBadge . '