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

489 lines
20 KiB
PHP

<?php
include_once 'php/thermometer.class.php';
function fxGetchamps($clef, $eve_id_don) {
global $objDatabase;
if ($eve_id_don == 895)
{
$sql = "SELECT * FROM config_tableau WHERE clef = '" . $objDatabase->fxEscape($clef) . "' ORDER BY trie";
$rec = $objDatabase->fxGetResults($sql);
} else {
if ($eve_id_don != 0) {
$sql = "SELECT * FROM config_tableau WHERE clef = 'LISTEPARTICIPANTEVEGENERIQUEDONS' ORDER BY trie";
$rec = $objDatabase->fxGetResults($sql);
} else {
$sql = "SELECT * FROM config_tableau WHERE clef = '" . $objDatabase->fxEscape($clef) . "' ORDER BY trie";
$rec = $objDatabase->fxGetResults($sql);
if ($rec === null){
$sql = "SELECT * FROM config_tableau WHERE clef = 'LISTEPARTICIPANTEVEGENERIQUE' ORDER BY trie";
$rec = $objDatabase->fxGetResults($sql);
}
}
}
return $rec;
}
function fxchecklangue($strtab,$i,$langues) {
if ($strtab[$i]['info1langue'] == 1)
return $strtab[$i]['info1'] . "_" . $langues;
else
return $strtab[$i]['info1'];
}
function fxGetquery($clef, $eve_id, $eve_id_don) {
global $objDatabase;
if ($eve_id_don == 895)
{
$sql = "SELECT * FROM config_query WHERE query_clef = 'rapportinscriptionGENERIQUEDONS895' limit 1";
$rec = $objDatabase->fxGetRow($sql);
} else {if ($eve_id_don != 0) {
$sql = "SELECT * FROM config_query WHERE query_clef = 'rapportinscriptionGENERIQUEDONS' limit 1";
$rec = $objDatabase->fxGetRow($sql);
$rec = str_replace('%eve_id%', $eve_id, $rec);
} else {
$sql = "SELECT * FROM config_query WHERE query_clef = '" . $objDatabase->fxEscape($clef) . "' limit 1";
$rec = $objDatabase->fxGetRow($sql);
if ($rec===null){
$sql = "SELECT * FROM config_query WHERE query_clef = 'rapportinscriptionGENERIQUE' limit 1";
$rec = $objDatabase->fxGetRow($sql);
$rec = str_replace('%eve_id%', $eve_id, $rec);
}
}
}
return $rec;
}
function fxlistepreuves($evenement,$langue,$mem_selected) {
global $objDatabase;
$list_exeption='';
require_once('php/inc_dons.php');
$sqlex = "SELECT * from config_query_exep where type_exep='remove' and eve_id= " . $evenement;
$recex = $objDatabase->fxGetRow($sqlex);
if ($recex)
$list_exeption="ipe.epr_id not in (". $recex['sql'].") and " ;
$sqlex = "SELECT * from config_query_exep where type_exep='add' and eve_id= " . $evenement;
$list_exeptionadd = $objDatabase->fxGetResults($sqlex);
$sql = "SELECT * FROM inscriptions_panier_epreuves_commandees ipec LEFT JOIN inscriptions_panier_epreuves ipe on ipe.epr_id= ipec.epr_id where ".$list_exeption." eve_id= " . $evenement . " group by ipec.epr_id ORDER BY epr_type_" . $langue;
$rec = $objDatabase->fxGetResults($sql);
if ($mem_selected == "")
$mem_select = ' selected="selected"';
else
$mem_select = '';
$output = '<select name="rech_epreuve" id="epreuves" class="form-control rounded-0">';
$output .= '<option value=""' . $mem_select . '>'. afficheTexte('tousinscription', 0) .'</option>';
for ($x = 1; $x <= count($rec); $x++) {
if ($mem_selected == $rec[$x]['epr_id'])
$mem_select = ' selected="selected"';
else
$mem_select = '';
$output .= '
<option value="' . $rec[$x]['epr_id'] . '"' . $mem_select . '>
';
if (trim($rec[$x]['epr_categorie_' . $langue]) != '') {
$output .= $rec[$x]['epr_categorie_' . $langue] . " - ";
}
$output .= $rec[$x]['epr_type_' . $langue];
if (trim($rec[$x]['epr_nom_' . $langue]) != '') {
$output .= " - " . $rec[$x]['epr_nom_' . $langue];
}
$output .= '
</option>
';
}
for ($x = 1; $x <= count($list_exeptionadd); $x++) {
if ($mem_selected =="exp:".$list_exeptionadd[$x]['sql']. ':'.$list_exeptionadd[$x]['desc'])
$mem_select = ' selected="selected"';
else
$mem_select = '';
$output .= '<option value="' . "exp:".$list_exeptionadd[$x]['sql']. ':'.$list_exeptionadd[$x]['desc'].'"' . $mem_select . '> '.$list_exeptionadd[$x]['desc'].'</option>';
}
$output .='</select>';
return $output;
}
global $vDomaine, $strLangue, $tabEvenement, $strCode, $objDatabase;
$strEpreuve = afficheTexte('toutlesepreuves',0);
$mem_where = '';
$mem_rech_epreuve = '';
// v?rifier les form POST
if (isset($_GET['order'])) {
$mem_orderby=" order by ".$_GET['order'] ;
$mem_orderget=$_GET['order'];
}else{
$mem_orderby="";
$mem_orderget="";
}
if (isset($_GET['rech_epreuve'])) {
if ($_GET['rech_epreuve'] != '') {
$mem_rech_epreuve=$_GET['rech_epreuve'];
$exep=explode(":",$_GET['rech_epreuve']);
if (isset($exep[0]))
$expsuite= $exep[0];
else
$expsuite="";
if ($exep[0] == 'exp') {
$mem_where .= ' and rec.epr_id in( ' .$exep[1].')';
$strEpreuve = $exep[2];
$mem_rech_epreuve= $_GET['rech_epreuve'];
} else {
$mem_where .= ' and rec.epr_id = ' . $_GET['rech_epreuve'];
$mem_rech_epreuve = $_GET['rech_epreuve'];
$mem_tabformat = "LISTEPARTICIPANT".$tabEvenement['general']['eve_id'];
$intEpreuve = $_GET['rech_epreuve'];
// trouver le nom de l'?preuve
foreach ($tabEvenement['epreuves'] as $tabEpreuves) {
if ($tabEpreuves['epr_id'] == $intEpreuve) {
$strEpreuve = fxUnescape($tabEpreuves['epr_type_' . $strLangue]);
if (trim($tabEpreuves['epr_nom_' . $strLangue]) != '')
$strEpreuve .= ' - ' . fxUnescape($tabEpreuves['epr_nom_' . $strLangue]);
}
}
}
} else {
$mem_tabformat = "LISTEPARTICIPANT".$tabEvenement['general']['eve_id'];
}
}
$mem_rech_nom="";
$sql = fxGetquery("rapportinscription".$tabEvenement['general']['eve_id'],$tabEvenement['general']['eve_id'], $tabEvenement['general']['eve_id_don']);
$mem_equipe=$sql['query_equipe'];
if (isset($_GET['rech_nom'])) {
if($_GET['rech_nom'] != '') {
if ($mem_equipe==0){
$mem_where .= " and concat(par_prenom,' ',par_nom) like '%" . $_GET['rech_nom'] . "%'" ;
$mem_rech_nom = $_GET['rech_nom'];
} else {
$mem_where .= " and (concat(par_prenom,' ',par_nom) like '%" . $_GET['rech_nom'] . "%' or pec_nom_equipe like '%" . $_GET['rech_nom'] . "%')" ;
$mem_rech_nom = $_GET['rech_nom'];
}
}
}
// MSIN-4172
// text
if (intval($tabEvenement['general']['eve_id_don']) > 0) {
$sqlText_dons = "SELECT * from inscriptions_evenements WHERE eve_id = " . intval($tabEvenement['general']['eve_id_don']);
$arrText_dons = $objDatabase->fxGetRow($sqlText_dons);
$strText = $arrText_dons["eve_details_reserver_" . $strLangue];
echo("<div class='m-3 text-left'>");
echo $strText;
echo("</div>");
?>
<h1>
<?php afficheTexte('titrelisteparticipantdon'); ?> </h1>
<?php
}
if (intval($tabEvenement['general']['eve_id_don']) > 0) { // affiche therdmomètre dons global
// calculer les dons équipes
$sqlTotalDonsEquipes = "SELECT COUNT(d.pd_id) AS nb, SUM(d.pd_montant) AS total FROM inscriptions_panier_acheteurs a, inscriptions_panier_dons d, resultats_epreuves_commandees e WHERE d.eve_id_don = " . intval($tabEvenement['general']['eve_id_don']) . " AND d.no_panier = a.no_panier AND d.pec_id = e.pec_id_original AND d.par_id = 0 AND e.is_cancelled = 0 AND a.sta_id = 3";
$arrTotalDonsEquipes = $objDatabase->fxGetRow($sqlTotalDonsEquipes);
// calculer les dons particicpants
$sqlTotalDonsParticipants = "SELECT COUNT(d.pd_id) AS nb, SUM(d.pd_montant) AS total FROM inscriptions_panier_acheteurs a, inscriptions_panier_dons d, resultats_epreuves_commandees e, resultats_participants p WHERE d.eve_id_don = " . intval($tabEvenement['general']['eve_id_don']) . " AND d.no_panier = a.no_panier AND d.pec_id = e.pec_id_original AND d.par_id = p.par_id_original AND d.pec_id = p.pec_id AND e.is_cancelled = 0 AND p.is_cancelled = 0 AND a.sta_id = 3";
$arrTotalDonsParticipants = $objDatabase->fxGetRow($sqlTotalDonsParticipants);
// trouverd l'objectif dons global et dons offline
$sqlTotalObjectifDonsGlobal = "SELECT SUM(c.epr_objectif_dons_global) AS objectif, SUM(c.epr_montant_dons_offline) AS dons_offine FROM inscriptions_evenements e, inscriptions_epreuves c WHERE e.eve_id = " . intval($tabEvenement['general']['eve_id']) . " AND e.eve_id = c.eve_id";
$arrTotalObjectifDonsGlobal = $objDatabase->fxGetRow($sqlTotalObjectifDonsGlobal);
$fltTotalObjectifDons = $arrTotalObjectifDonsGlobal['objectif'];
if (floatval($fltTotalObjectifDons) <= 0) { // si objectif global = 0, calculer les obectifs de dons
// calculer les oobjectifs équipes
$sqlTotalObjectifDonsEquipes = "SELECT SUM(e.epr_objectif_dons) AS objectif FROM resultats_epreuves_commandees e WHERE e.eve_id = " . intval($tabEvenement['general']['eve_id']) . " AND e.is_cancelled = 0";
$fltTotalObjectifDonsEquipes = $objDatabase->fxGetVar($sqlTotalObjectifDonsEquipes);
// calculer les oobjectifs particicpants
$sqlTotalObjectifDonsParticipants = "SELECT SUM(p.epr_objectif_dons) AS objectif FROM resultats_epreuves_commandees e, resultats_participants p WHERE e.eve_id = " . intval($tabEvenement['general']['eve_id']) . " AND e.pec_id_original = p.pec_id AND e.is_cancelled = 0 AND p.is_cancelled = 0";
$fltTotalObjectifDonsParticipants = $objDatabase->fxGetVar($sqlTotalObjectifDonsParticipants);
$fltTotalObjectifDons = $fltTotalObjectifDonsEquipes + $fltTotalObjectifDonsParticipants;
}
$arrTotalDons = array(
'nb' => intval($arrTotalDonsEquipes['nb']) + intval($arrTotalDonsParticipants['nb']),
'objectif' => intval($fltTotalObjectifDons),
'total' => floatval($arrTotalDonsEquipes['total']) + floatval($arrTotalDonsParticipants['total'] + floatval($arrTotalObjectifDonsGlobal['dons_offine']))
);
if ($strLangue == 'fr') {
$strObjectif = "Objectif";
$strMontant = "Montant amassé";
$strTitre = 'Total des dons';
} else {
$strObjectif = "Goal";
$strMontant = "Gathered";
$strTitre = 'Donations total';
}
?>
<h2><?php echo $strTitre; ?> <span class="badge badge-primary"><?php echo $arrTotalDons['nb']; ?></span></h2>
<?php
$objThermometer = new \clsThermometer\clsThermometer($arrTotalDons['objectif'], $arrTotalDons['total']);
echo $objThermometer->fxShow('h', 0, 'money', '', $strMontant, $strObjectif, $strLangue);
}else{
?><h1><?php afficheTexte('titrelisteparticipants'); ?></h1>
<?php
}
?>
<div class="card box_participant rounded-0">
<div class="card-header">
<h2><?php if ($strLangue == 'fr') { ?>Recherche :<?php } else { ?>Search :<?php } ?></h2>
</div>
<div class="card-body">
<form action="<?php echo $vDomaine; ?>/<?php echo $strCode; ?>/<?php if ($strLangue == 'fr') { ?>inscrits<?php } else { ?>registered<?php } ?>" id="frm_search" name="frm_search" method="get">
<input type="hidden" name="adm" value="<?php echo($stradm);?>">
<div class="form-group row">
<label for="rech_nom" class="control-label col-12 col-lg-4 text-lg-right"><?php if ($strLangue == 'fr') { echo('Nom du participant'); } else { echo('Participant name');}; if ($mem_equipe == 1) { if ($strLangue == 'fr') { echo(" ou d'équipe"); } else { echo(" or Team");};; } ?> </label>
<div class="col-12 col-lg-7">
<input class="form-control rounded-0" type="text" id="rech_nom" name="rech_nom" value="<?php echo $mem_rech_nom; ?>">
</div>
</div>
<div class="form-group row">
<label for="rech_evenement" class="control-label col-12 col-lg-4 text-lg-right"><?php afficheTexte('rech_evenement'); ?> :</label>
<div class="col-12 col-lg-7">
<?php echo fxlistepreuves($tabEvenement['general']['eve_id'], $strLangue, $mem_rech_epreuve); ?>
</div>
</div>
<div class="form-group row">
<div class="col-12 col-lg-7 offset-lg-4">
<button class="btn btn-primary rounded-0" type="submit" id="btn_recherche" name="btn_recherche"><?php if ($strLangue == 'fr') { ?>Recherche<?php } else { ?>Search<?php } ?></button>
</div>
</div>
</form>
</div>
</div>
<?php
if ($stradm != "") {
?>
<script type="text/javascript">
$(function() {
var $btn = $("#btn_resume");
$btn.text("(<?php if ($strLangue == 'fr') { ?>cacher<?php } else { ?>hide<?php } ?>)");
$btn.click(function(e){
e.preventDefault();
$btn.slideToggle(function() {
if ($(this).is(":visible"))
$btn.text("(<?php if ($strLangue == 'fr') { ?>cacher<?php } else { ?>hide<?php } ?>)");
else if ($(this).is(":hidden"))
$btn.text("(<?php if ($strLangue == 'fr') { ?>afficher<?php } else { ?>show<?php } ?>)");
});
});
});
</script>
<?php
//r?sumer par evenement
$sql = fxGetquery("totalinscription".$tabEvenement['general']['eve_id'], $tabEvenement['general']['eve_id'], $tabEvenement['general']['eve_id_don']);
$strliste = $objDatabase->fxGetResults($sql['query_query']);
$strtab = fxGetchamps("LISTETOTALEVE".$tabEvenement['general']['eve_id'], $tabEvenement['general']['eve_id_don']);
$strResults = '
<h2 class="mb-3">' . afficheTexte('listeparticipantsresume', 0) . ' <a id="btn_resume" href="#"></a></h2>
<div class="table-responsive" id="bloc_resume">
<table class="table table-striped">
<thead>
<tr>
';
//entete pour le tableau
for ($i = 1; $i <= count($strtab); $i++) {
$strResults .= '
<th class="text-left" id="' . $strtab[$i]['info1'] . '" style=" width: ' . $strtab[$i]['info3'] . ';">
' . $strtab[$i]['info2_' . $strLangue] . '
</th>
';
}
$strResults .= '
</tr>
</thead>
<tbody>
';
//contenue le tableau
for ($x = 1; $x <= count($strliste); $x++) {
$strResults .= '<tr>';
for ($i = 1; $i <= count($strtab); $i++) {
if ($strtab[$i]['multiple'] == 1) {
$mem_field = preg_split('/,/', $strtab[$i]['info1']);
$mem_affiche = $strliste[$x][$mem_field[0]] . ' ' . $strliste[$x][$mem_field[1]];
} else {
$mem_affiche = $strliste[$x][fxchecklangue($strtab, $i, $strLangue)];
}
if ($strLangue == 'fr')
$MEM_SUITE = 'inscrits';
else
$MEM_SUITE='registered';
$strResults .= '
<td class="text-left">
<a href="' . $vDomaine . '/' . $code . '/' . $MEM_SUITE . '?rech_epreuve=' . $strliste[$x]['epr_id'] . '">' . $mem_affiche . '</a>
</td>
';
}
$strResults .= "</tr>";
}
$strResults .= "
</tbody>
</table>
</div>
";
echo $strResults;
}
//liste des participants
$sql = fxGetquery("rapportinscription".$tabEvenement['general']['eve_id'],$tabEvenement['general']['eve_id'], $tabEvenement['general']['eve_id_don']);
$sql = str_replace('%where%', $mem_where, $sql['query_query']);
$sql = str_replace('%orderby%', $mem_orderby,$sql);
$mem_equipe=$sql['query_equipe'];
$strliste = $objDatabase->fxGetResults($sql);
$strtab = fxGetchamps($mem_tabformat, $tabEvenement['general']['eve_id_don']);
//echo($mem_tabformat);
echo '<br><h2>' . $strEpreuve . '</h2>';
if ($stradm!="")
echo '<h2>' . afficheTexte('nombreinscription', 0) . ' ' . count($strliste) . '</h2><br>';
$strResults = '
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
';
//entete pour le tableau
for ($i = 1; $i <= count($strtab); $i++){
if ($strtab[$i]['info2']=="trie") {
if ($strLangue == 'fr')
$MEM_SUITE = 'inscrits';
else
$MEM_SUITE='registered';
if ($strtab[$i]['info1langue']==0) {
$mem_order=$strtab[$i]['field_order'];
} else {
$mem_order = $strtab[$i]['field_order'] . "_" . $strLangue;
}
$fa_trie='fa-sort-asc';
if ($mem_order==$mem_orderget) {
$fa_trie='fa-sort-desc';
if ($strtab[$i]['multiple'] == 1) {
$mem_field=preg_split('/,/',$strtab[$i]['info1']);
$mem_order = $mem_field[0] .' desc, '. $mem_field[1] .' desc';
} else {
$mem_order=$mem_order. " desc";
}
}
$strResults .= '<th class="text-left" id="' . $strtab[$i]['info1'] . '" style="width: ' . $strtab[$i]['info3'] . ';">' . $strtab[$i]['info2_' . $strLangue] . ' <a class="trie" href="' . $vDomaine . '/' . $code . '/' . $MEM_SUITE . '?rech_epreuve=' .$mem_rech_epreuve . '&order='.$mem_order.'"><i style="color:#01080f" class="fa '.$fa_trie.'" aria-hidden="true"></i></a> </th>';
} else {
$strResults .= '<th class="text-left" id="' . $strtab[$i]['info1'] . '" style="width: ' . $strtab[$i]['info3'] . ';">' . $strtab[$i]['info2_' . $strLangue] . '</th>';
}
}
$strResults .= '
</tr>
</thead>
<tbody>
';
// contenue le tableau
for ($x = 1; $x <= count($strliste); $x++) {
$strResults .= '<tr>';
for ($i = 1; $i <= count($strtab); $i++) {
$mem_affiche="";
if ($strtab[$i]['convert']=='donsequipe') {
if (intval($tabEvenement['general']['eve_id']) != 646) { // patch pour défi 808 2021
$mem_field = preg_split('/,/',$strtab[$i]['info1']);
if ($strliste[$x][ $mem_field[1]]==1 && $strliste[$x]['epr_id_don'] != '0') {
// stephan MSIN-2002
if ($strLangue == 'fr')
$MEM_donsequipe = ' à l\'équipe';
else
$MEM_donsequipe=' to the team';
$mem_affiche = fxGetLinksDonationParticipant($strliste[$x][$mem_field[0]], 0, $strLangue);
$mem_affiche = '
<a class="btn btn-primary rounded-pill" href="' . $vDomaine . '/' . $mem_affiche['link'] . '">
' . $mem_affiche['label'].$MEM_donsequipe . '
</a>
';
}
}
} else {
if ($strtab[$i]['convert']=='dons') {
if ($strliste[$x]['epr_id_don'] != '0') {
$mem_field = preg_split('/,/',$strtab[$i]['info1']);
$mem_affiche = fxGetLinksDonationParticipant($strliste[$x][ $mem_field[0]], $strliste[$x][ $mem_field[1]], $strLangue);
$mem_affiche = '
<a class="btn btn-primary rounded-pill" href="' . $vDomaine . '/' . $mem_affiche['link'] . '">
' . $mem_affiche['label'] . '
</a>';
}
} else {
if ($strtab[$i]['multiple']==1) {
$mem_field=preg_split('/,/',$strtab[$i]['info1']);
$mem_affiche = $strliste[$x][ $mem_field[0]].' '.$strliste[$x][ $mem_field[1]];
} else
$mem_affiche = $strliste[$x][ fxchecklangue($strtab,$i,$strLangue)];
}
}
$strResults .= '<td class="text-left">' . $mem_affiche . '</td>';
}
$strResults .= "</tr>";
}
$strResults .= "
</tbody>
</table>
</div>
";
echo $strResults;