Files
ms1inscription-v5/php/inc_logs_course.php
2026-05-13 09:43:32 -04:00

692 lines
32 KiB
PHP

<?php
/**********************
* *
* Courses virtuelles *
* *
**********************/
function fxGetEpreuvesLogs($intEvenement) { // trouver les épreuves virtuelles selon l'événement
global $objDatabase;
$sqlEpreuvesLogs = "SELECT * FROM inscriptions_epreuves WHERE epr_actif = 1 AND tep_id = 3 AND eve_id = " . intval($intEvenement);
$arrEpreuvesLogs = $objDatabase->fxGetResults($sqlEpreuvesLogs);
return $arrEpreuvesLogs;
}
function fxGetLogSettings($intEpreuve) { // trouver les paramètres à fournir
global $objDatabase;
$sqlLogSettings = "SELECT epr_objectif_distance_equipe, epr_objectif_temps_equipe, epr_photo, epr_pseudo, epr_objectif_distance_participant, epr_objectif_temps_participant FROM inscriptions_epreuves WHERE epr_id = " . intval($intEpreuve);
$arrLogSettings = $objDatabase->fxGetRow($sqlLogSettings);
return $arrLogSettings;
}
function fxGetLogFields($intEpreuve, $pec_id = 0) { // trouver les infos à fournir pour ajouter un log
global $objDatabase;
if ($pec_id != 0) {
$sqlLogFields = "SELECT DISTINCT c.*, e.lqe_infobulle_fr, e.lqe_infobulle_en, e.lqe_etapes_incluses FROM logs_questions_epreuves e, logs_questions_champs c, resultats_epreuves_commandees ec WHERE c.lqc_id = e.lqc_id AND e.lqe_actif = 1 AND ec.pec_id_original = " . intval($pec_id) . " AND e.eve_id = ec.eve_id AND (find_in_set(ec.epr_id, e.lqe_epreuves_incluses) OR e.lqe_epreuves_incluses = '') ORDER BY e.lqe_tri";
$arrLogFields = $objDatabase->fxGetResults($sqlLogFields);
} else {
$sqlLogFields = "SELECT DISTINCT c.*, e.lqe_infobulle_fr, e.lqe_infobulle_en, e.lqe_etapes_incluses FROM logs_questions_epreuves e, logs_questions_champs c WHERE c.lqc_id = e.lqc_id AND e.lqe_actif = 1 AND (find_in_set('" . intval($intEpreuve) . "', e.lqe_epreuves_incluses) OR e.lqe_epreuves_incluses = '') ORDER BY e.lqe_tri";
$arrLogFields = $objDatabase->fxGetResults($sqlLogFields);
}
return $arrLogFields;
}
function fxShowBoutonStats($pec_id, $strLangue) { // affiche le bouton pour aller à la page de stats
global $objDatabase, $vDomaine;
$arrLink = array(
'fr' => array(
'url' =>'suivez-resultats',
'label' => 'suivez les résultats'
),
'en' => array(
'url' => 'track-results',
'label' => 'track results'
)
);
$strRetour = '';
$sqlEvenementURL = "SELECT e.eve_label_url FROM inscriptions_evenements e, resultats_epreuves_commandees ec WHERE e.eve_id = ec.eve_id AND ec.pec_id_original = " . intval($pec_id);
$strEvenementURL = $objDatabase->fxGetVar($sqlEvenementURL);
if (trim($strEvenementURL) != '') {
$strRetour = '
<div class="text-center">
<a class="btn btn-primary rounded-pill" href="' . $vDomaine . '/' . $strEvenementURL . '/' . $arrLink[$strLangue]['url'] . '">
<i class="fa fa-line-chart mr-2" aria-hidden="true"></i>
' . $arrLink[$strLangue]['label'] . '
</a>
</div>
';
}
return $strRetour;
}
// fonction qui récupère les logs
// param : id de l'epreuve commandee
function fxGetLogsCourse($pec_id) {
global $objDatabase;
$sqlLogsCourse = "
SELECT * FROM resultats_logs_questions l
LEFT JOIN inscriptions_etapes e ON (l.eta_id = e.eta_id)
JOIN resultats_epreuves_commandees ec ON (l.pec_id = ec.pec_id_original)
JOIN resultats_participants p ON (l.par_id = p.par_id_original)
WHERE l.pec_id = " . intval($pec_id) . "
ORDER BY l.rlq_date, l.rlq_timestamp, l.rlq_id
";
$arrLogsCourse = $objDatabase->fxGetResults($sqlLogsCourse);
return $arrLogsCourse;
}
// fonction pour modifier les demandes de transferts envoyées pour une épreuve
// param : action, données post, langue d'affichage
function fxSetLogsCourse($strAction, $arrData, $strLangue) {
global $objDatabase;
$arrRetour = array('a' => $strAction);
switch ($strAction) {
case 'add':
// trouver les infos fournies
// $arrLogFields = fxGetLogFields(0, $arrData['pec_id']);
if ($arrData!= null) {
$strSet = '';
foreach ($arrData as $field => $value) {
if (trim($strSet) != '') {
$strSet .= ', ';
}
switch ($field) {
case 'pec_id':
case 'par_id':
case 'eta_id':
$strSet .= $field . " = " . intval($value);
break;
case 'rlq_distance':
$strSet .= $field . " = " . floatval($value);
break;
default:
$strSet .= $field . " = '" . $objDatabase->fxEscape($value) . "'";
}
}
$sqlInsert = "INSERT INTO resultats_logs_questions SET " . $strSet;
$qryInsert = $objDatabase->fxQuery($sqlInsert);
if (!$qryInsert) {
$arrRetour['state'] = 'error';
$arrRetour['message'] = fxMessage('e220', '', $strLangue) . $sqlInsert;
$_SESSION['msg'] = 'e220';
fxcreer_log("Erreur lors de l'ajout du log course:\n" . $sqlInsert);
} else {
$arrLogsCourse = fxGetLogsCourse($arrData['pec_id']);
$arrRetour['state'] = 'success';
$arrRetour['message'] = fxMessage('p221', '', $strLangue);
$_SESSION['msg'] = 'p221';
$arrRetour['liste'] = fxShowLogsCourse($arrLogsCourse, $strLangue);
$arrRetour['reset'] = true;
$arrRetour['redirect'] = '';
}
}
break;
case 'del':
$sqlInfos = "SELECT * FROM resultats_logs_questions WHERE rlq_id = " . intval($arrData['id']);
$arrInfos = $objDatabase->fxGetRow($sqlInfos);
if ($arrInfos != null) {
$sqlDelete = "DELETE FROM resultats_logs_questions WHERE rlq_id = " . intval($arrData['id']);
$qryDelete = $objDatabase->fxQuery($sqlDelete);
if (!$qryDelete) {
$arrRetour['state'] = 'error';
$arrRetour['message'] = fxMessage('e222', '', $strLangue);
$_SESSION['msg'] = 'e222';
fxcreer_log("Erreur lors de l'effaçage du log course:\n" . $sqlDelete);
} else {
$arrRetour['state'] = 'success';
$arrRetour['message'] = fxMessage('p223', '', $strLangue);
$_SESSION['msg'] = 'p223';
}
$arrLogsCourse = fxGetLogsCourse($arrInfos['pec_id']);
$arrRetour['liste'] = fxShowLogsCourse($arrLogsCourse, $strLangue);
}
break;
}
return $arrRetour;
}
function fxShowLogsCourse($arrLogsCourse, $strLangue) {
$intNbColonnes = 1;
$strRetour = '
<div class="table-responsive">
<table class="table table-striped">
';
if ($arrLogsCourse != null) {
$arrLogFields = fxGetLogFields(0, $arrLogsCourse[1]['pec_id']);
$strRetour .= '
<thead>
<tr>
<th class="text-center">&nbsp;</th>
';
if (intval($arrLogsCourse[1]['pec_equipe']) == 1) { // sî l'épreuve est en équipe, afficher le nom du participant
$intNbColonnes++;
$strRetour .= '
<th class="text-left">Participant</th>
';
}
if ($arrLogFields != null) {
$intNbColonnes += count($arrLogFields);
for ($intCtrField = 1; $intCtrField <= count($arrLogFields); $intCtrField++) {
$strRetour .= '
<th class="text-left">' . $arrLogFields[$intCtrField]['lqc_label_' . $strLangue] . '</th>
';
}
}
$strRetour .= '
</tr>
</thead>
<tbody>
';
for ($intCtr = 1; $intCtr <= count($arrLogsCourse); $intCtr++) {
$strRetour .= '
<tr>
<td class="text-center">
<button class="btn btn-sm btn-danger rounded-0 btn_delete_log_course" data-rlq_id="' . $arrLogsCourse[$intCtr]['rlq_id'] . '" data-toggle="tooltip" title="' . afficheTexte('tooltip_effacer_log_course', 0, 0) . '" type="button"><i class="fa fa-trash"></i></button>
</td>
';
if (intval($arrLogsCourse[1]['pec_equipe']) == 1) { // sî l'épreuve est en équipe, afficher le nom du participant
$strRetour .= '
<td class="text-left">' . fxUnescape($arrLogsCourse[$intCtr]['par_nom']) . ', ' . fxUnescape($arrLogsCourse[$intCtr]['par_prenom']) . '</td>
';
}
if ($arrLogFields != null) {
for ($intCtrField = 1; $intCtrField <= count($arrLogFields); $intCtrField++) {
$strSuffixe = (trim($arrLogFields[$intCtrField]['lqc_suffixe_' . $strLangue]) != '') ? ' ' . $arrLogFields[$intCtrField]['lqc_suffixe_' . $strLangue] : ''; // afficher le suffixe s'il y en a un
if (strval($arrLogFields[$intCtrField]['lqc_nom']) == 'eta_id') {
$strData = $arrLogsCourse[$intCtr]['eta_nom_' . $strLangue];
} else {
$strData = $arrLogsCourse[$intCtr][$arrLogFields[$intCtrField]['lqc_nom']];
}
switch ($arrLogFields[$intCtrField]['lqc_format']) {
case 'date':
if (trim($strData) != '' && trim($strData) != '0000-00-00') {
$strData = fxShowDate($strData, $strLangue);
} else {
$strData = afficheTexte('msg-short-date-nd', 0);
}
}
$strRetour .= '
<td class="text-left">' . $strData . $strSuffixe . '</td>
';
}
}
$strRetour .= '
</tr>
';
}
$strRetour .= '
</tbody>
<tfoot>
<tr>
<th class="text-center" colspan="' . $intNbColonnes . '">' . count($arrLogsCourse) . '&nbsp;
';
if (count($arrLogsCourse) > 1)
$strRetour .= strtolower(afficheTexte('title_logs_course_pluriel', 0, 0));
else
$strRetour .= strtolower(afficheTexte('title_logs_course', 0, 0));
$strRetour .= '</th>
</tr>
</tfoot>
';
} else {
$strRetour .= '
<tr>
<td class="text-center">
<p><span></span></p>
' . afficheTexte('msg_no_logs_course', 0, 0) . '
<p><span></span></p>
</td>
</tr>
';
}
$strRetour .= '
</table>
</div>
';
return $strRetour;
}
/**
* Crée un tableau qui retrouve les infos du don
* @author Jean-Sébastien Proulx
* @version 1.0
* @param string $intEpreuveCommandee id de l'épreuve commandée (en md5)
* @param string $intParticipant id du participant (en md5)
* @return null or array
*/
function fxGetStatsLogsCourse($intEpreuveCommandee, $intParticipant) {
global $objDatabase;
$arrOutput = null;
return $arrOutput;
}
function fxShowFormLogSettings($recEpreuvesCommandees, $strLangue) {
global $objDatabase, $vDomaine;
$strHTML = '';
$arrForms = null;
$pec_id = $recEpreuvesCommandees['pec_id_original'];
$arrLogSettings = fxGetLogSettings($recEpreuvesCommandees['epr_id']);
// Afficher l'équipe, s'il y a lieu- N'EST PLUS UTILISÉ
/*if ($recEpreuvesCommandees['pec_equipe'] == 1) {
$arrForms[$pec_id][] = 'frm_log_setting_e' . $pec_id;
$strHTML .= '
<div class="table-responsive-sm">
<table class="table table-striped">
<thead>
<tr>
<th class="text-left">' . afficheTexte('objectif_dons_equipe', 0) . '</th>
<th class="text-left">' . afficheTexte('objectif_vr_type', 0) . '</th>
<th class="text-right">' . afficheTexte('objectif_dons_montant_actuel', 0) . '</th>
<th>' . afficheTexte('objectif_dons_montant_original', 0) . '</th>
</tr>
</thead>
<tbody>
<tr>
<td class="text-left">' . fxUnescape($recEpreuvesCommandees['pec_nom_equipe']) . '</td>
<td class="text-left">' . afficheTexte('objectif_vr_type_distance', 0) . '</td>
<td class="text-right">
<form action="' . $vDomaine . '/ajax_logs_course.php' . '" id="frm_log_setting_e' . $pec_id . '">
<input type="hidden" name="pec_id" value="' . $pec_id . '">
<input type="hidden" name="lang" value="' . $strLangue . '">
<input type="hidden" name="objectif_distance_avant" value="' . $recEpreuvesCommandees['epr_objectif_distance_original'] . '">
<input style="text-align: right;" type="number" name="montant" step="1" min="' . $recEpreuvesCommandees['epr_objectif_distance_original'] . '" value="' . $recEpreuvesCommandees['epr_objectif_distance'] . '">
<button class="btn-small tooltip" type="submit" title="' . afficheTexte('objectif_dons_bouton_tooltip', 0) . '">OK</button>
</form>
</td>
<td class="text-right">' . $recEpreuvesCommandees['epr_objectif_distance_original'] . ' km</td>
</tr>
</tbody>
</table>
</div>
';
}*/
// récupérer le participants
$sqlEpreuvesParticipants = 'SELECT * FROM resultats_participants p WHERE p.pec_id = ' . intval($pec_id) . " ORDER BY rol_id, par_nom, par_prenom";
$arrEpreuvesParticipants = $objDatabase->fxGetResults($sqlEpreuvesParticipants);
// afficher les participants
if ($arrEpreuvesParticipants != null) {
$strHTML .= '
<div class="table-responsive-sm">
<table class="table table-striped">
<thead>
<tr>
<th class="text-left" style="width: 40%;">' . afficheTexte('objectif_dons_participant', 0) . '</th>
<th class="text-left">' . afficheTexte('objectif_vr_type', 0) . '</th>
<th class="text-left" style="width: 35%;">' . afficheTexte('objectif_dons_montant_actuel', 0) . '</th>
</tr>
</thead>
<tbody>
';
for ($intCtr3 = 1; $intCtr3 <= count($arrEpreuvesParticipants); $intCtr3++) {
foreach ($arrLogSettings as $setting => $value) {
$blnShow = false;
$strColonne1 = fxUnescape($arrEpreuvesParticipants[$intCtr3]['par_nom']) . ', ' . fxUnescape($arrEpreuvesParticipants[$intCtr3]['par_prenom']);
if (intval($arrEpreuvesParticipants[$intCtr3]['rol_id']) == 1) {
$strColonne1 = "<strong>" . $strColonne1 . "</strong>";
}
$strColonne2 = afficheTexte('objectif_vr_type_' . $setting, 0);
$strColonne3 = $strColonne4 = '';
$strForm = 'frm_log_setting_' . $setting . '_p' . $arrEpreuvesParticipants[$intCtr3]['par_id'];
switch ($setting) {
case 'epr_pseudo':
if (intval($value) == 1) {
$blnShow = true;
$setting_p = $setting;
$strColonne3 = '
<input type="text" name="' . $setting . '" value="' . $arrEpreuvesParticipants[$intCtr3][$setting] . '" required>
<button class="btn-small tooltip" type="submit" title="' . afficheTexte('objectif_dons_bouton_tooltip', 0) . '">OK</button>
';
}
break;
case 'epr_photo':
if (intval($value) == 1) {
$blnShow = true;
$strColonne3 = '
';
$strColonne4 = '';
}
break;
case 'epr_objectif_distance_participant':
$blnShow = true;
$setting_p = str_replace('_participant', '', $setting);
$strColonne3 = '
<input type="hidden" name="' . $setting_p . '_original" value="' . $arrEpreuvesParticipants[$intCtr3][$setting_p . '_original'] . '">
<input class="form-control form-control-sm rounded-0" style="text-align: right;" type="number" name="' . $setting_p . '" min="0" value="' . $arrEpreuvesParticipants[$intCtr3][$setting_p] . '" required>
<button class="btn btn-sm btn-primary rounded-0" data-toggle="tooltip" type="submit" title="' . afficheTexte('objectif_dons_bouton_tooltip', 0) . '">OK</button>
';
$strColonne4 = $arrEpreuvesParticipants[$intCtr3][$setting_p . '_original'] . ' km';
break;
case 'epr_objectif_temps_participant':
if (trim($value) != '' && trim($value) != '00:00:00') {
$blnShow = true;
$setting_p = str_replace('_participant', '', $setting);
$strColonne3 = '
<input type="hidden" name="' . $setting_p . '_original" value="' . $arrEpreuvesParticipants[$intCtr3][$setting_p . '_original'] . '">
<input style="text-align: right;" type="number" name="' . $setting_p . '" step="1" min="' . $arrEpreuvesParticipants[$intCtr3][$setting_p . '_original'] . '" value="' . $arrEpreuvesParticipants[$intCtr3][$setting_p] . '" required>
<button class="btn-small tooltip" type="submit" title="' . afficheTexte('objectif_dons_bouton_tooltip', 0) . '">OK</button>
';
$strColonne4 = $arrEpreuvesParticipants[$intCtr3][$setting_p . '_original'];
}
break;
}
if ($blnShow) { // si le paramètre est demandé => le faire afficher
$arrForms[$pec_id][] = $strForm;
$strHTML .= '
<tr>
<td class="text-left">' . $strColonne1 . '</td>
<td class="text-left">' . $strColonne2 . '</td>
<td class="text-left">
<form class="form-inline" action="' . $vDomaine . '/ajax_logs_course.php' . '" id="' . $strForm . '" enctype="multipart/form-data">
<input type="hidden" name="a" value="' . urlencode(base64_encode('settings')) . '">
<input type="hidden" name="setting" value="' . $setting_p . '">
<input type="hidden" name="par_id" value="' . $arrEpreuvesParticipants[$intCtr3]['par_id'] . '">
<input type="hidden" name="lang" value="' . $strLangue . '">
' . $strColonne3 . '
</form>
</td>
</tr>
';
}
}
}
$strHTML .= '
</tbody>
</table>
</div>
';
}
$arrOutput = array(
'HTML' => $strHTML,
'forms' => $arrForms
);
return $arrOutput;
}
function fxShowFormAddLog($recEpreuvesCommandees, $strLangue) {
global $objDatabase, $vDomaine;
$strHTML = '';
$arrForms = null;
$pec_id = $recEpreuvesCommandees['pec_id_original'];
$arrLogFields = fxGetLogFields($recEpreuvesCommandees['epr_id'], $pec_id);
$strForm = 'frm_add_log_' . $pec_id;
$arrForms[$pec_id][] = $strForm;
$strHTML .= '
<form action="' . $vDomaine . '/ajax_logs_course.php' . '" id="' . $strForm . '" method="post">
<input type="hidden" name="pec_id" value="' . $pec_id . '">
<input type="hidden" name="a" value="' . urlencode(base64_encode('add')) . '">
<input type="hidden" name="lang" value="' . $strLangue . '">
';
if ($arrLogFields != null) {
for ($intCtrField = 1; $intCtrField <= count($arrLogFields); $intCtrField++) {
$strInfobulle = '';
if (trim($arrLogFields[$intCtrField]['lqe_infobulle_' . $strLangue]) != '') { // infobulle
$strInfobulle = '
<button class="btn btn-sm rounded-circle" type="button" data-toggle="popover" data-content="' . htmlspecialchars(fxUnescape(trim($arrLogFields[$intCtrField]['lqe_infobulle_' . $strLangue]))) . '">
<i class="fa fa-question-circle fa-2x text-info" aria-hidden="true"></i>
</button>
';
}
$strInputCode = '
<div class="form-group row">
<label class="col-form-label col-12 col-lg-3 text-lg-right" for="' . $arrLogFields[$intCtrField]['lqc_nom'] . '_' . $pec_id . '">
' . $arrLogFields[$intCtrField]['lqc_label_' . $strLangue] . ':
<span class="d-inline-block d-lg-none">' . $strInfobulle . '</span>
</label>
';
switch ($arrLogFields[$intCtrField]['lqc_type']) {
case 'text':
if (($arrLogFields[$intCtrField]['lqc_nom'] == 'rlq_temps')) {
// préparer les options de temps
$strOptions1 = $strOptions2 = '';
for ($h = 0; $h < 24; $h++) {
$strOptions1 .= '
<option value="' . $h . '">' . $h . '</option>
';
}
for ($m = 0; $m < 60; $m++) {
$strOptions2 .= '
<option value="' . $m . '">' . $m . '</option>
';
}
$strInputCode .= '
<div class="col-4 col-lg-2">
<select class="form-control rounded-0" name="' . $arrLogFields[$intCtrField]['lqc_nom'] . '-h">
' . $strOptions1 . '
</select>
</div>
';
$strInputCode .= '
<div class="col-4 col-lg-2">
<select class="form-control rounded-0" name="' . $arrLogFields[$intCtrField]['lqc_nom'] . '-m">
' . $strOptions2 . '
</select>
</div>
';
$strInputCode .= '
<div class="col-4 col-lg-2">
<select class="form-control rounded-0" name="' . $arrLogFields[$intCtrField]['lqc_nom'] . '-s">
' . $strOptions2 . '
</select>
</div>
<div class="col-12 col-lg-1">
<small class="form-text text-muted">
H:M:s
</small>
</div>
';
} else {
$strPlaceholder = (trim($arrLogFields[$intCtrField]['lqc_placeholder_' . $strLangue]) != '') ? ' placeholder="' . $arrLogFields[$intCtrField]['lqc_placeholder_' . $strLangue] . '"' : ''; // afficher le placeholder s'il y en a un
if ($arrLogFields[$intCtrField]['lqc_nom'] == 'rlq_distance') {
$strInputCode .= '
<div class="col-12 col-lg-7">
<input class="form-control rounded-0" type="number" id="' . $arrLogFields[$intCtrField]['lqc_nom'] . '_' . $pec_id . '" name="' . $arrLogFields[$intCtrField]['lqc_nom'] . '"' . $strPlaceholder . ' required>
</div>
';
} else {
$strDefault = ($arrLogFields[$intCtrField]['lqc_nom'] == 'rlq_date') ? ' value="' . fxGetDate() . '"' : ''; // afficher la date du jour par défaut
$strInputType = ($arrLogFields[$intCtrField]['lqc_nom'] == 'rlq_date') ? 'text' : 'text'; // mettre le type de input
$strInputCode .= '
<div class="col-12 col-lg-7">
<input class="form-control rounded-0" type="' . $strInputType . '" id="' . $arrLogFields[$intCtrField]['lqc_nom'] . '_' . $pec_id . '" name="' . $arrLogFields[$intCtrField]['lqc_nom'] . '"' . $strPlaceholder . $strDefault . 'required>
</div>
';
}
}
break;
case'select':
$arrChoix = array();
if ($arrLogFields[$intCtrField]['lqc_nom'] == 'eta_id') {
$sqlChoix = "SELECT e.eta_id AS id, e.eta_nom_$strLangue AS label FROM inscriptions_etapes e WHERE e.eta_actif = 1 AND e.eta_id IN(" . $arrLogFields[$intCtrField]['lqe_etapes_incluses'] . ") ORDER BY e.eta_nom_$strLangue";
$arrChoix = $objDatabase->fxGetResults($sqlChoix);
} else {
if (trim($arrLogFields[$intCtrField]['lqc_sql_' . $strLangue]) != '') {
$sqlChoix = str_replace('%pec_id%', $pec_id, $arrLogFields[$intCtrField]['lqc_sql_' . $strLangue]);
$arrChoix = $objDatabase->fxGetResults($sqlChoix);
} elseif (trim($arrLogFields[$intCtrField]['lqc_choix_' . $strLangue]) != '') {
$arrChoix = json_decode($arrLogFields[$intCtrField]['lqc_choix_' . $strLangue]);
}
}
$strInputCode .= '
<div class="col-12 col-lg-7">
<select class="form-control rounded-0" id="' . $arrLogFields[$intCtrField]['lqc_nom'] . '_' . $pec_id . '" name="' . $arrLogFields[$intCtrField]['lqc_nom'] . '">
';
for ($intCtrChoix = 1; $intCtrChoix <= count($arrChoix); $intCtrChoix++) {
$strInputCode .= '
<option value="' . fxUnescape($arrChoix[$intCtrChoix]['id']) . '">' . fxUnescape($arrChoix[$intCtrChoix]['label']) . '</option>
';
}
$strInputCode .= '
</select>
</div>
';
break;
}
$strHTML .= '
' . $strInputCode . '
<div class="d-none d-lg-inline-block col-12 col-lg-2">
' . $strInfobulle . '
</div>
</div>
';
}
}
// Info participant (par_id)
$sqlLogFields = "SELECT DISTINCT c.* FROM logs_questions_champs c WHERE c.lqc_id = 5";
$arrLogFields = $objDatabase->fxGetRow($sqlLogFields);
if ($arrLogFields != null) { // récupérer le(s) participant(s) de l'épreuve
$sqlParticipants = str_replace('%pec_id%', $pec_id, $arrLogFields['lqc_sql_' . $strLangue]);
$arrParticipants = $objDatabase->fxGetResults($sqlParticipants);
if ($arrParticipants != null) {
if (intval($recEpreuvesCommandees['pec_equipe']) == 1) { // si épreuves équipe, afficher la liste des participants
$strHTML .= '
<div class="form-group row">
<label class="col-form-label col-12 col-lg-3 text-lg-right" for="par_id_' . $pec_id . '">' . $arrLogFields['lqc_label_' . $strLangue] . ':</label>
<div class="col-12 col-lg-7">
<select class="form-control rounded-0" id="par_id_' . $pec_id . '" name="par_id">
';
for ($intCtrParticipant = 1; $intCtrParticipant <= count($arrParticipants); $intCtrParticipant++) {
$strHTML .= '
<option value="' . $arrParticipants[$intCtrParticipant]['id'] . '">' . $arrParticipants[$intCtrParticipant]['label'] . '</option>
';
}
$strHTML .= '
</select>
</div>
</div>
';
} else { // si solo, mettre le par_id dans un champs caché
$strHTML .= '
<input type="hidden" name="par_id" value="' . $arrParticipants[1]['id'] . '">
';
}
}
}
$strHTML .= '
<div class="col-12 col-lg-7 offset-lg-3">
<button class="btn btn-primary rounded-0" type="submit">' . afficheTexte('btn_ajout_logs', 0) . '</button>
</div>
</form>
';
$arrOutput = array(
'HTML' => $strHTML,
'forms' => $arrForms
);
return $arrOutput;
}
function fxSetFormLogSettings($arrData, $strLangue) {
global $objDatabase;
$arrRetour = array();
$qryUpdate = false;
if (isset($arrData[$arrData['setting'] . '_original'])) {
switch ($arrData['setting']) {
case 'epr_objectif_temps':
break;
default:
}
}
if (1==1) {
if (isset($arrData['pec_id'])) { // modification de l'objectif d'équipe
$sqlUpdate = "UPDATE resultats_epreuves_commandees SET " . $arrData['setting'] . " = '" . $objDatabase->fxEscape($arrData[$arrData['setting']]) . "' WHERE pec_id_original = " . intval($arrData['pec_id']);
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
} elseif (isset($arrData['par_id'])) { // modification de l'objectif d'un participant
$sqlUpdate = "UPDATE resultats_participants SET " . $arrData['setting'] . " = '" . $objDatabase->fxEscape($arrData[$arrData['setting']]) . "' WHERE par_id = " . intval($arrData['par_id']);
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
}
if ($qryUpdate) {
$arrRetour['state'] = 'success';
$arrRetour['message'] = fxMessage('p224', '', $strLangue);
$_SESSION['msg'] = 'p224';
$arrRetour['nouvel_objectif'] = $arrData['setting'];
} else {
$arrRetour['state'] = 'error';
$arrRetour['message'] = fxMessage('e101', '', $strLangue) . $sqlUpdate;
$_SESSION['msg'] = 'e101';
}
} else {
$arrRetour['state'] = 'error';
$arrRetour['message'] = fxMessage('e101', '', $strLangue);
$_SESSION['msg'] = 'e101';
}
return $arrRetour;
}