test
This commit is contained in:
@ -4,6 +4,7 @@ require_once('inc_fx_options.php'); // inclure les fonctions des options
|
||||
require_once('inc_fx_participants.php'); // inclure les fonctions des participants
|
||||
require_once('inc_fx_code_qr.php');
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/inc_fx_panier_js.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/inc_fx_promoteur.php';
|
||||
|
||||
// Retourner le numéro du panier ou en générer un (JSP)
|
||||
// param : langue
|
||||
@ -3041,6 +3042,16 @@ function fxMajCommande($strNoPanier, $strLangue = 'fr', $blnResend = false)
|
||||
$sqlInsert = "INSERT INTO resultats_participants(eve_id, epr_id, par_prenom, par_nom, par_naissance, par_age, par_sexe, par_adresse, par_adresse2, par_ville, pro_id, par_codepostal, pay_id, par_telephone1, par_telephone1_ext, par_telephone2, par_courriel, par_capitaine, com_id, par_nom_equipe, no_panier, par_note, par_maj, no_commande, par_id_original, par_no_equipe, par_equipe, pec_id, rol_id, no_invitation, epr_objectif_dons, epr_objectif_dons_original, par_categorie_1_long_fr, par_categorie_1_long_en,par_categorie_1_court_fr, par_categorie_1_court_en, par_categorie_2_long_fr, par_categorie_2_long_en, par_categorie_2_court_fr, par_categorie_2_court_en, par_categorie_3_long_fr, par_categorie_3_long_en, par_categorie_3_court_fr, par_categorie_3_court_en, epr_objectif_distance, epr_objectif_distance_original, epr_objectif_temps, epr_objectif_temps_original, par_contact_urgence_nom, par_contact_urgence_telephone) SELECT eve_id, epr_id, par_prenom, par_nom, par_naissance, par_age, par_sexe, par_adresse, par_adresse2, par_ville, pro_id, par_codepostal, pay_id, par_telephone1, par_telephone1_ext, par_telephone2, par_courriel, par_capitaine, com_id, par_nom_equipe, no_panier, par_note, '" . fxGetDateTime() . "', '" . $no_commande . "', par_id, par_no_equipe, par_equipe, pec_id, rol_id, no_invitation, epr_objectif_dons, epr_objectif_dons, par_categorie_1_long_fr, par_categorie_1_long_en,par_categorie_1_court_fr, par_categorie_1_court_en, par_categorie_2_long_fr, par_categorie_2_long_en, par_categorie_2_court_fr, par_categorie_2_court_en, par_categorie_3_long_fr, par_categorie_3_long_en, par_categorie_3_court_fr, par_categorie_3_court_en, epr_objectif_distance, epr_objectif_distance, epr_objectif_temps, epr_objectif_temps, par_contact_urgence_nom, par_contact_urgence_telephone FROM inscriptions_panier_participants WHERE par_id = " . intval($tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_id']);
|
||||
$qryInsert = $objDatabase->fxQuery($sqlInsert);
|
||||
|
||||
// MSIN-4379 — Étape 7 : assignation auto du dossard après création du participant (achat).
|
||||
if ($qryInsert !== false) {
|
||||
$intNewParId = (int)$objDatabase->fxGetLastId();
|
||||
$intEprIdAutoBib = (int)$tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['epr_id'];
|
||||
|
||||
if ($intNewParId > 0 && $intEprIdAutoBib > 0) {
|
||||
fxAssignAutoBibForParticipant($intEprIdAutoBib, $intNewParId);
|
||||
}
|
||||
}
|
||||
|
||||
// insérer les questions
|
||||
if (isset($tabQuestions[$tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_id']])) {
|
||||
$list_file = [];
|
||||
|
||||
@ -3050,6 +3050,211 @@ function fxSaveBibAutoConfig($epr_id, $ranges, $active = true) {
|
||||
return ['success' => true, 'auto_active' => true];
|
||||
}
|
||||
|
||||
/**
|
||||
* MSIN-4379 — Étape 6
|
||||
* Liste des epr_bib_id marqués epr_bib_auto = 1 pour une épreuve.
|
||||
*/
|
||||
function fxGetAutoBibRangeIds($epr_id) {
|
||||
global $objDatabase;
|
||||
|
||||
$epr_id = intval($epr_id);
|
||||
|
||||
if ($epr_id <= 0 || !fxIsBibAutoActive($epr_id)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT epr_bib_id
|
||||
FROM inscriptions_epreuves_bib
|
||||
WHERE epr_id = $epr_id
|
||||
AND epr_bib_auto = 1
|
||||
ORDER BY epr_bib_start
|
||||
";
|
||||
|
||||
$rows = $objDatabase->fxGetResults($sql);
|
||||
$ids = [];
|
||||
|
||||
if (is_array($rows)) {
|
||||
foreach ($rows as $r) {
|
||||
$id = (int)($r['epr_bib_id'] ?? 0);
|
||||
if ($id > 0) {
|
||||
$ids[] = $id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* MSIN-4379 — Étape 6
|
||||
* Charge un participant resultats pour l'assignation auto (même jointures que le batch).
|
||||
*/
|
||||
function fxLoadParticipantForAutoBib($epr_id, $par_id) {
|
||||
global $objDatabase;
|
||||
|
||||
$epr_id = intval($epr_id);
|
||||
$par_id = intval($par_id);
|
||||
|
||||
if ($epr_id <= 0 || $par_id <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
p.*,
|
||||
p.pec_id,
|
||||
c.pec_id_original,
|
||||
c.pec_nom_equipe,
|
||||
c.no_equipe
|
||||
FROM resultats_participants p
|
||||
LEFT JOIN resultats_epreuves_commandees c
|
||||
ON c.pec_id_original = p.pec_id
|
||||
AND c.epr_id = p.epr_id
|
||||
WHERE p.epr_id = $epr_id
|
||||
AND p.par_id = $par_id
|
||||
AND p.is_cancelled = 0
|
||||
LIMIT 1
|
||||
";
|
||||
|
||||
return $objDatabase->fxGetRow($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* MSIN-4379 — Étape 6
|
||||
* Assigne un dossard à un participant à l'achat (pools epr_bib_auto = 1).
|
||||
* Réutilise fxFindNextBatchBib / fxApplyBatchParticipantBib et la logique équipe du batch.
|
||||
*/
|
||||
function fxAssignAutoBibForParticipant($epr_id, $par_id) {
|
||||
global $objDatabase;
|
||||
|
||||
$epr_id = intval($epr_id);
|
||||
$par_id = intval($par_id);
|
||||
|
||||
if ($epr_id <= 0 || $par_id <= 0) {
|
||||
return ['success' => false, 'message' => 'paramètres invalides'];
|
||||
}
|
||||
|
||||
if (!fxIsBibAutoActive($epr_id)) {
|
||||
return ['success' => false, 'skipped' => true, 'message' => 'auto inactif'];
|
||||
}
|
||||
|
||||
$tabRanges = fxGetRangesForBatchAssign($epr_id, fxGetAutoBibRangeIds($epr_id));
|
||||
|
||||
if (empty($tabRanges)) {
|
||||
return ['success' => false, 'message' => 'aucune plage auto'];
|
||||
}
|
||||
|
||||
$p = fxLoadParticipantForAutoBib($epr_id, $par_id);
|
||||
|
||||
if (!$p) {
|
||||
return ['success' => false, 'message' => 'participant introuvable'];
|
||||
}
|
||||
|
||||
if (in_array((int)$p['rol_id'], [3, 4], true)) {
|
||||
return ['success' => false, 'skipped' => true, 'message' => 'rôle exclu'];
|
||||
}
|
||||
|
||||
$currentBib = trim((string)($p['no_bib'] ?? ''));
|
||||
|
||||
if ($currentBib !== '' && $currentBib !== '0') {
|
||||
return [
|
||||
'success' => true,
|
||||
'skipped' => true,
|
||||
'no_bib' => (int)$currentBib,
|
||||
];
|
||||
}
|
||||
|
||||
$sqlEpreuve = "
|
||||
SELECT epr_equipe, epr_bib_team_mode
|
||||
FROM inscriptions_epreuves
|
||||
WHERE epr_id = $epr_id
|
||||
LIMIT 1
|
||||
";
|
||||
$tabEpreuve = $objDatabase->fxGetRow($sqlEpreuve);
|
||||
|
||||
$isTeamEvent = $tabEpreuve && (int)$tabEpreuve['epr_equipe'] === 1;
|
||||
$teamMode = (int)($tabEpreuve['epr_bib_team_mode'] ?? 1);
|
||||
|
||||
if ($teamMode <= 0) {
|
||||
$teamMode = 1;
|
||||
}
|
||||
|
||||
$teamKey = fxGetBatchTeamKey($p);
|
||||
$foundBib = null;
|
||||
$teamNumber = 0;
|
||||
$usedBib = [];
|
||||
|
||||
if ($isTeamEvent && $teamMode === 3 && $teamKey > 0) {
|
||||
$sqlTeamBib = "
|
||||
SELECT no_bib
|
||||
FROM resultats_participants
|
||||
WHERE epr_id = $epr_id
|
||||
AND pec_id = $teamKey
|
||||
AND is_cancelled = 0
|
||||
AND no_bib IS NOT NULL
|
||||
AND no_bib <> ''
|
||||
AND no_bib <> 0
|
||||
AND par_id <> $par_id
|
||||
LIMIT 1
|
||||
";
|
||||
$existingBib = (int)$objDatabase->fxGetVar($sqlTeamBib);
|
||||
|
||||
if ($existingBib > 0) {
|
||||
$foundBib = $existingBib;
|
||||
$teamNumber = $existingBib;
|
||||
}
|
||||
}
|
||||
|
||||
if ($foundBib === null) {
|
||||
$findTeamMode = $isTeamEvent ? $teamMode : 1;
|
||||
$foundBib = fxFindNextBatchBib($epr_id, $tabRanges, 'execute', $usedBib, $findTeamMode);
|
||||
}
|
||||
|
||||
if ($foundBib === null) {
|
||||
if (function_exists('fxcreer_log')) {
|
||||
fxcreer_log('MSIN-4379: aucun dossard libre (epr_id=' . $epr_id . ', par_id=' . $par_id . ')');
|
||||
}
|
||||
|
||||
return ['success' => false, 'message' => 'aucun dossard disponible'];
|
||||
}
|
||||
|
||||
fxApplyBatchParticipantBib($epr_id, $par_id, $foundBib);
|
||||
|
||||
if ($isTeamEvent && $teamKey > 0) {
|
||||
$updatedTeams = [];
|
||||
|
||||
if ($teamMode === 3) {
|
||||
fxApplyBatchTeamNumber($epr_id, $teamKey, $foundBib, $updatedTeams);
|
||||
} else {
|
||||
$sqlEquipe = "
|
||||
SELECT no_equipe
|
||||
FROM resultats_epreuves_commandees
|
||||
WHERE pec_id_original = $teamKey
|
||||
AND epr_id = $epr_id
|
||||
LIMIT 1
|
||||
";
|
||||
$teamNumber = (int)$objDatabase->fxGetVar($sqlEquipe);
|
||||
|
||||
if ($teamNumber <= 0) {
|
||||
$sqlMaxTeam = "
|
||||
SELECT MAX(CAST(no_equipe AS UNSIGNED))
|
||||
FROM resultats_epreuves_commandees
|
||||
WHERE epr_id = $epr_id
|
||||
";
|
||||
$teamNumber = (int)$objDatabase->fxGetVar($sqlMaxTeam) + 1;
|
||||
}
|
||||
|
||||
fxApplyBatchTeamNumber($epr_id, $teamKey, $teamNumber, $updatedTeams);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'no_bib' => (int)$foundBib,
|
||||
];
|
||||
}
|
||||
|
||||
function fxInfosBibEpreuve($epr_id){
|
||||
global $objDatabase;
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
* Constantes *
|
||||
*
|
||||
**************/
|
||||
define('_VERSION_CODE', '4.72.60');
|
||||
define('_VERSION_CODE', '4.72.61');
|
||||
define('_DATE_CODE', '2026-06-02');
|
||||
//MSIN-4290
|
||||
define('QR_SECRET_KEY', 'ms1_qr_2026_cle_secrete_longue_et_fixe');
|
||||
|
||||
Reference in New Issue
Block a user