diff --git a/php/inc_fx_inscriptions_gestion.php b/php/inc_fx_inscriptions_gestion.php index 0143ee0..877f3dc 100644 --- a/php/inc_fx_inscriptions_gestion.php +++ b/php/inc_fx_inscriptions_gestion.php @@ -1305,9 +1305,21 @@ function fxInscrGestionFetchFicheProfile($arrRow, $strLangue) { $strBirthGender = ''; $strNaissance = trim((string)$tabProfile['par_naissance']); if ($strNaissance !== '' && $strNaissance !== '0000-00-00') { + // MSIN-4521 — import hors-tx stocke M/F/N ; fxGetGender attend h/f/n/a. + $strSexeDisp = trim((string)$tabProfile['par_sexe']); + $strSexeLow = mb_strtolower($strSexeDisp, 'UTF-8'); + if ($strSexeDisp === 'M' || $strSexeLow === 'm') { + $strSexeDisp = 'h'; + } elseif ($strSexeDisp === 'F' || $strSexeLow === 'f') { + $strSexeDisp = 'f'; + } elseif ($strSexeDisp === 'N' || $strSexeLow === 'n') { + $strSexeDisp = 'n'; + } elseif ($strSexeDisp === 'A' || $strSexeLow === 'a') { + $strSexeDisp = 'a'; + } $strBirthGender = fxShowDate($strNaissance, $strLangue) . ' - ' - . fxGetGender($tabProfile['par_sexe'], $strLangue); + . fxGetGender($strSexeDisp, $strLangue); } $intParIdOriginal = (int)$tabProfile['par_id_original']; diff --git a/php/inc_fx_inscriptions_gestion_hors_tx.php b/php/inc_fx_inscriptions_gestion_hors_tx.php index 2126b55..b585f3e 100644 --- a/php/inc_fx_inscriptions_gestion_hors_tx.php +++ b/php/inc_fx_inscriptions_gestion_hors_tx.php @@ -149,6 +149,39 @@ function fxInscrGestionHorsTxLoadQuestions($arrRow, $strLangue) return $tabOut; } +/** + * MSIN-4521 — normalise sexe pour la fiche hors-tx (import = M/F/N, formulaire MS1 = h/f/n/a). + * @return string M|F|N|A|'' + */ +function fxInscrGestionHorsTxNormalizeSexe($strSexe) +{ + $str = trim((string)$strSexe); + if ($str === '') { + return ''; + } + if (function_exists('fxImportResultatsNormalizeSex')) { + $strImp = fxImportResultatsNormalizeSex($str); + if ($strImp !== '') { + return $strImp; + } + } + $strLow = mb_strtolower($str, 'UTF-8'); + if ($strLow === 'f' || $strLow === 'female' || $strLow === 'femme' || $str === 'F') { + return 'F'; + } + if ($strLow === 'h' || $strLow === 'm' || $strLow === 'male' || $strLow === 'homme' + || $str === 'M' || $str === 'H') { + return 'M'; + } + if ($strLow === 'n' || $strLow === 'x' || $str === 'N') { + return 'N'; + } + if ($strLow === 'a' || $strLow === 'autre' || $strLow === 'other' || $str === 'A') { + return 'A'; + } + return ''; +} + /** * @return array{ok:bool,needs_confirm?:bool,code?:string,message?:string} */ @@ -222,12 +255,13 @@ function fxInscrGestionHorsTxSaveProfile($intParId, $intEveId, array $arrFields) $strPrenom = trim((string)($arrFields['par_prenom'] ?? '')); $strNom = trim((string)($arrFields['par_nom'] ?? '')); - $strSexe = trim((string)($arrFields['par_sexe'] ?? '')); + $strSexe = fxInscrGestionHorsTxNormalizeSexe($arrFields['par_sexe'] ?? ''); $strNaissance = trim((string)($arrFields['par_naissance'] ?? '')); if ($strPrenom === '' || $strNom === '') { return array('state' => 'error', 'message' => 'required'); } - if ($strSexe !== '' && !in_array($strSexe, array('h', 'f', 'n', 'a'), true)) { + // Codes acceptés : M/F/N/A (import/CT) — vide = non renseigné. + if ($strSexe !== '' && !in_array($strSexe, array('M', 'F', 'N', 'A'), true)) { return array('state' => 'error', 'message' => 'sexe_invalid'); } if ($strNaissance !== '' && $strNaissance !== '0000-00-00' @@ -483,7 +517,7 @@ function fxInscrGestionRenderHorsTxEditableFields( if ($strNaissance === '0000-00-00') { $strNaissance = ''; } - $strSexe = is_array($rowExtra) ? trim((string)($rowExtra['par_sexe'] ?? '')) : ''; + $strSexe = fxInscrGestionHorsTxNormalizeSexe(is_array($rowExtra) ? ($rowExtra['par_sexe'] ?? '') : ''); if ($blnCanEdit) { echo '