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 = '
' . $arrLink[$strLangue]['label'] . '
'; } 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 = '
'; if ($arrLogsCourse != null) { $arrLogFields = fxGetLogFields(0, $arrLogsCourse[1]['pec_id']); $strRetour .= ' '; if (intval($arrLogsCourse[1]['pec_equipe']) == 1) { // sî l'épreuve est en équipe, afficher le nom du participant $intNbColonnes++; $strRetour .= ' '; } if ($arrLogFields != null) { $intNbColonnes += count($arrLogFields); for ($intCtrField = 1; $intCtrField <= count($arrLogFields); $intCtrField++) { $strRetour .= ' '; } } $strRetour .= ' '; for ($intCtr = 1; $intCtr <= count($arrLogsCourse); $intCtr++) { $strRetour .= ' '; if (intval($arrLogsCourse[1]['pec_equipe']) == 1) { // sî l'épreuve est en équipe, afficher le nom du participant $strRetour .= ' '; } 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 .= ' '; } } $strRetour .= ' '; } $strRetour .= ' '; } else { $strRetour .= ' '; } $strRetour .= '
 Participant' . $arrLogFields[$intCtrField]['lqc_label_' . $strLangue] . '
' . fxUnescape($arrLogsCourse[$intCtr]['par_nom']) . ', ' . fxUnescape($arrLogsCourse[$intCtr]['par_prenom']) . '' . $strData . $strSuffixe . '
' . count($arrLogsCourse) . '  '; if (count($arrLogsCourse) > 1) $strRetour .= strtolower(afficheTexte('title_logs_course_pluriel', 0, 0)); else $strRetour .= strtolower(afficheTexte('title_logs_course', 0, 0)); $strRetour .= '

' . afficheTexte('msg_no_logs_course', 0, 0) . '

'; 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 .= '
' . afficheTexte('objectif_dons_equipe', 0) . ' ' . afficheTexte('objectif_vr_type', 0) . ' ' . afficheTexte('objectif_dons_montant_actuel', 0) . ' ' . afficheTexte('objectif_dons_montant_original', 0) . '
' . fxUnescape($recEpreuvesCommandees['pec_nom_equipe']) . ' ' . afficheTexte('objectif_vr_type_distance', 0) . '
' . $recEpreuvesCommandees['epr_objectif_distance_original'] . ' km
'; }*/ // 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 .= '
'; 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 = "" . $strColonne1 . ""; } $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 = ' '; } 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 = ' '; $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 = ' '; $strColonne4 = $arrEpreuvesParticipants[$intCtr3][$setting_p . '_original']; } break; } if ($blnShow) { // si le paramètre est demandé => le faire afficher $arrForms[$pec_id][] = $strForm; $strHTML .= ' '; } } } $strHTML .= '
' . afficheTexte('objectif_dons_participant', 0) . ' ' . afficheTexte('objectif_vr_type', 0) . ' ' . afficheTexte('objectif_dons_montant_actuel', 0) . '
' . $strColonne1 . ' ' . $strColonne2 . '
' . $strColonne3 . '
'; } $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 .= '
'; if ($arrLogFields != null) { for ($intCtrField = 1; $intCtrField <= count($arrLogFields); $intCtrField++) { $strInfobulle = ''; if (trim($arrLogFields[$intCtrField]['lqe_infobulle_' . $strLangue]) != '') { // infobulle $strInfobulle = ' '; } $strInputCode = '
'; 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 .= ' '; } for ($m = 0; $m < 60; $m++) { $strOptions2 .= ' '; } $strInputCode .= '
'; $strInputCode .= '
'; $strInputCode .= '
H:M:s
'; } 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 .= '
'; } 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 .= '
'; } } 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 .= '
'; break; } $strHTML .= ' ' . $strInputCode . '
' . $strInfobulle . '
'; } } // 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 .= '
'; } else { // si solo, mettre le par_id dans un champs caché $strHTML .= ' '; } } } $strHTML .= '
'; $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; }