1097 lines
55 KiB
PHP
1097 lines
55 KiB
PHP
<?php
|
|
// fonction qui affiche le formulaire d'ajout de participant
|
|
// param : tableau contenant les infos de l'événement, action (add/mod), langue d'affichage
|
|
// créé : 2013-03-29
|
|
function fxShowFormParticipant($tabEvenement, $strAction, $strLangue, $intEpreuve, $intpec_id = 0, $intquestechue = 0)
|
|
{
|
|
global $objDatabase, $vDomaine, $strHintModal;
|
|
$strNoTransfert = '';
|
|
|
|
if (isset($_GET['t'])) {
|
|
$strNoTransfert = $_GET['t'];
|
|
}
|
|
if (!empty($_GET['promoteur']) && $_GET['promoteur'] == 1) {
|
|
$intPromoteur = 1;
|
|
} else {
|
|
$intPromoteur = 0;
|
|
}
|
|
|
|
// vérifier si la personne a le droit d'accéder à cette épreuve
|
|
|
|
|
|
// if (fxCheckAccesEpreuve($strAction, $intEpreuve, $tabEvenement['general']['eve_id'], $intpec_id, $intPromoteur, $strNoTransfert)) { // si l'épreuve est accessible
|
|
if (1==1) { // si l'épreuve est accessible
|
|
$tabInscription = $tabParticipant = $tabPartQuestions = $tabEpreuveQuestions = $tabInfosEpreuve = array();
|
|
$tabChampsValues = fxGetInfosChamps($tabEvenement['general']['eve_id'], 'com');
|
|
|
|
// trouver les infos de l'épreuve
|
|
$tabEpreuve = fxGetEpreuve($intEpreuve);
|
|
|
|
// Ajout sans participant
|
|
if ($tabEpreuve['epr_invitation'] == 1) {
|
|
$intInvitation = 1;
|
|
$intNbParticipants = 1;
|
|
$intNbParticipantsOriginal = $tabEpreuve['epr_nb_participants'];
|
|
$intNbParticipantsMin = 1;
|
|
$strDisabled = ' disable';
|
|
$strReadonly = ' readonly';
|
|
$strStyle = ' style="background-color: #8b8989;"';
|
|
|
|
fxCreateJavaChange($tabChampsValues['champs'] . ",com_id_1", $tabChampsValues['values'] . ",com_id", $_SESSION['com_id'], 'compte', $_SESSION['com_info']);
|
|
} else { // Inscription normal
|
|
$intInvitation = 0;
|
|
$intNbParticipants = $intNbParticipantsOriginal = $tabEpreuve['epr_nb_participants'];
|
|
$intNbParticipantsMin = $tabEpreuve['epr_nb_participants_min'];
|
|
$strDisabled = '';
|
|
$strReadonly = '';
|
|
$strStyle = '';
|
|
}
|
|
|
|
// sortir les données du participant si en mode "mod"ification.
|
|
if ($strAction == 'mod' || $strAction == 'auto' || trim($strNoTransfert) != '') {
|
|
if ($strAction == 'auto') { // récupérer un pec_id existant pour cette épreuve
|
|
$sqlEpreuvesCommandee = "SELECT pec_id_original FROM resultats_epreuves_commandees WHERE epr_id = " . intval($intEpreuve) . " ORDER BY RAND()";
|
|
$intEpreuveCommandee = $objDatabase->fxGetVar($sqlEpreuvesCommandee);
|
|
|
|
if ($intEpreuveCommandee != null) {
|
|
$intpec_id = $_GET['pec_id'] = $intEpreuveCommandee;
|
|
} else {
|
|
die('erreur');
|
|
}
|
|
}
|
|
|
|
if (isset($_SESSION['no_panier'])) {
|
|
$boolTable = false;
|
|
$intId = $intpec_id;
|
|
} else {
|
|
$boolTable = true;
|
|
$intId = $_GET['pec_id'];
|
|
}
|
|
|
|
$tabInscription = fxGetPanierParticipantsEpreuve($intId, $boolTable, $intpec_id);
|
|
$tabParticipant = $tabInscription['participants'];
|
|
|
|
$tabPartQuestions = $tabInscription['questions'];
|
|
// enlever reponce tq;
|
|
//MSIN-4313
|
|
|
|
if(trim($strNoTransfert) != ''){
|
|
|
|
if (trim($strNoTransfert) !== '') {
|
|
foreach ($tabPartQuestions[1] as $que_id => $question) {
|
|
if (!empty($question['que_transfert_bloquer']) && (int)$question['que_transfert_bloquer'] === 1) {
|
|
unset($tabPartQuestions[1][$que_id]);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
$tabEpreuveQuestions = $tabInscription['questions_epreuve'];
|
|
$tabInfosEpreuve = $tabInscription['epreuve'];
|
|
|
|
if ($tabParticipant == null)
|
|
$intNbParticipants = 0;
|
|
}
|
|
|
|
$tabDates = fxGetDatesAge($intEpreuve);
|
|
|
|
// initialiser les variables
|
|
$strRules = $strMessages = '';
|
|
$tabCalendriers = $tabCodepostal = $tabTelephones = array();
|
|
if ($tabEpreuve['tep_id'] == 4){
|
|
echo afficheTexte('participant-text-membre', 0);
|
|
echo('<br>');
|
|
}
|
|
|
|
if ($strAction != 'mod' && $intInvitation == 0) {// bouton copier les infos...
|
|
if (isset($_SESSION['com_id'])) {
|
|
$strFirstName = fxUnescape($_SESSION['com_info']['com_prenom']);
|
|
$intDateAge = $tabEpreuve['epr_date_age'];
|
|
$intAge = filter_var(fxGetAge($_SESSION['com_info']['com_naissance'], $intDateAge), FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
// vérifier si on peut copier les infos du compte
|
|
echo $strBouton = fxShowCopyButtons($tabEvenement, $tabEpreuve, $tabChampsValues, $strFirstName, $intAge, $intDateAge, $_SESSION['com_id'], $_SESSION['com_info'], 'compte', $strLangue);
|
|
|
|
// ajouter les bouton copy pour membres affilier (sl)
|
|
// liste des compte affilie
|
|
$infoAffilie = fxGetInfosAffilies($_SESSION['com_id']);
|
|
|
|
// print("<pre>".print_r($infoAffilie,true)."</pre>");
|
|
if ($infoAffilie != null){
|
|
foreach ($infoAffilie as $intCtr => $arrAff) {
|
|
$intDateAge = $tabEpreuve['epr_date_age'];
|
|
$blnShowButton = true;
|
|
$strMessageUser = '';
|
|
$strFirstName = fxUnescape($arrAff['com_prenom']);
|
|
$intAge = filter_var(fxGetAge($arrAff['com_naissance'], $intDateAge), FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
echo $strBouton = fxShowCopyButtons($tabEvenement, $tabEpreuve, $tabChampsValues, $strFirstName, $intAge, $intDateAge, $arrAff['com_id'], $arrAff, 'affilie', $strLangue);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// si ces un abbonement mettre en read (sl)
|
|
if ($tabEpreuve['tep_id'] == 4) {
|
|
$strReadonly = ' readonly';
|
|
$strDisabled = ' disabled';
|
|
}
|
|
if (isset($_SESSION['no_panier']) && $strAction != 'mod' && $intInvitation == 0) {
|
|
$tabParticipants = fxGetPanierParticipants($_SESSION['no_panier']);
|
|
$tabChampsValues = fxGetInfosChamps($tabEvenement['general']['eve_id'], 'par');
|
|
|
|
// si abonnement pas de Copier les informations d'un participant du panier:
|
|
if ($tabParticipants != null && $tabEpreuve['tep_id'] != 4) {
|
|
?>
|
|
<table class="table table-striped mb-3">
|
|
<thead>
|
|
<tr>
|
|
<th class="text-left" colspan="2">
|
|
<?php echo afficheTexte('label_copy_info_panier', 0); ?>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$x = 1;
|
|
|
|
foreach ($tabParticipants as $key => $value) {
|
|
echo $strBouton = fxShowCopyButtons($tabEvenement, $tabEpreuve, $tabChampsValues, $value['nom'], 0, 0, $x, $_SESSION['panier_info'][$x], 'panier', $strLangue);
|
|
$x++;
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
<form action="<?php echo $GLOBALS['vDomaine']; ?>/<?php if ($strLangue == 'fr') { ?>reserver<?php } else { ?>book<?php } ?>/<?php echo $tabEvenement['general']['eve_label_url']; ?>/<?php echo $GLOBALS['intEpreuve']; if ($intpec_id > 0) { echo "?action=" . $strAction . "&pec_id=" . $intpec_id; } else { echo "?action=" . $strAction; } if ($intPromoteur == 1) { ?>&promoteur=1<?php } ?>" autocomplete="off" id="frm_participant" name="frm_participant" method="post" enctype="multipart/form-data">
|
|
<?php
|
|
if (($tabEvenement['general']['eve_epreuve_modifiable'] == 1 || $tabEvenement['general']['eve_epreuve_modifiable_client'] == 1) && $strAction == 'mod' && !isset($_SESSION['no_panier'])) { // si le promoteur ou le participant peut changer l'épreuve
|
|
if ($tabEvenement['general']['eve_epreuve_modifiable_client'] == 1 && $intPromoteur == 0) {
|
|
$strWhere = " AND epr_qte > 0 AND CONCAT(epr_date_limite, ' ', epr_heure_limite) >= NOW()";
|
|
|
|
// récupérer le coût du frais pour le switch d'épreuve
|
|
$tabFraisAutres = fxGetFraisAutres('switch', $tabEvenement['general']['eve_frais'], $tabEvenement['general']['eve_id'], $tabEpreuve['tep_id']);
|
|
$strPrixSwitch = fxShowPrix($tabFraisAutres['fa_montant'], $strLangue, 1);
|
|
|
|
//MSIN-4276
|
|
// valide si produit frais transfert
|
|
|
|
$intEpreuve=$tabEpreuve['epr_id'];
|
|
$intEvenement=$tabEpreuve['eve_id'];
|
|
$sqlProduitsAuto = "SELECT * FROM inscriptions_produits_new WHERE pro_actif = 1 AND pt_id = 7
|
|
AND (pro_date_limite = '0000-00-00' OR pro_date_limite = '' OR pro_date_limite IS NULL OR pro_date_limite >= '" . fxGetDate() . "')
|
|
AND (pro_date_debut = '0000-00-00' OR pro_date_debut = '' OR pro_date_debut IS NULL OR pro_date_debut <= '" . fxGetDate() . "')
|
|
|
|
AND eve_id IN(" . intval($intEvenement) . " ) AND (FIND_IN_SET(" . intval($intEpreuve) . ", pro_epreuves) OR pro_epreuves = '') " . "ORDER BY pro_id limit 1 ";
|
|
|
|
$tabProduitsAuto = $objDatabase->fxGetResults($sqlProduitsAuto);
|
|
|
|
$strPrixSwitch=$strPrixSwitch+$tabProduitsAuto[1]['pro_prix'];
|
|
$strPrixSwitch=fxShowPrix($strPrixSwitch, $strLangue, 1);
|
|
if($tabProduitsAuto[1]['pro_taxable']==1)
|
|
// $strPrixSwitch .= " +tx";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($tabEvenement['general']['tt_id'] > 1) {
|
|
$strPrixSwitch .= " +tx";
|
|
}
|
|
|
|
if ($tabEpreuve['epr_upgradable_billed'] != null && trim($tabEpreuve['epr_upgradable_billed']) != '' && trim($tabEpreuve['epr_upgradable_billed']) != '0') {
|
|
$strWhere .= " AND epr_id IN(" . trim($tabEpreuve['epr_upgradable_billed']) . ")";
|
|
}
|
|
} else {
|
|
$strWhere = $strPrixSwitch = '';
|
|
}
|
|
|
|
$sqlEpreuves = "SELECT * FROM inscriptions_epreuves WHERE eve_id = " . intval($tabEvenement['general']['eve_id']) . " AND epr_actif = 1 AND tep_id = (SELECT tep_id FROM inscriptions_epreuves WHERE epr_id = " . intval($tabEpreuve['epr_id']) . ")" . $strWhere . " ORDER BY epr_tri";
|
|
$tabEpreuves = $objDatabase->fxGetResults($sqlEpreuves);
|
|
|
|
$strSelected = '';
|
|
?>
|
|
<div class="card box_participant rounded-0">
|
|
<div class="card-header">
|
|
<h2><?php afficheTexte('frm_switch_epreuve'); ?></h2>
|
|
</div>
|
|
<div class="card-body">
|
|
<input type="hidden" id="old_epr_id" name="old_epr_id" value="<?php echo $tabEpreuve['epr_id']; ?>">
|
|
<input type="hidden" id="new_epr_id" name="new_epr_id" value="">
|
|
<input type="hidden" id="eve_label_url" name="eve_label_url" value="<?php echo $tabEvenement['general']['eve_label_url']; ?>">
|
|
<?php
|
|
if ($intPromoteur != 1) {
|
|
?>
|
|
<div class="alert alert-info mb-3">
|
|
<i class="fa fa-info-circle mr-2" aria-hidden="true"></i><?php echo str_replace('%prix%', $strPrixSwitch, afficheTexte('msg_switch_epreuve', 0)); ?>
|
|
</div>
|
|
<?php
|
|
}
|
|
?>
|
|
<div class="form-group row">
|
|
<label for="sel_epreuve" class="control-label col-12 col-lg-3 text-lg-right"><?php afficheTexte('frm_part_changer_epreuve'); ?></label>
|
|
<div class="col-12 col-lg-7">
|
|
<select class="form-control rounded-0" id="sel_epreuve" name="sel_epreuve">
|
|
<?php
|
|
for ($i = 1; $i <= count($tabEpreuves); $i++) {
|
|
if ($tabEpreuves[$i]['epr_id'] == $tabEpreuve['epr_id'])
|
|
$strSelected = 'selected="selected"';
|
|
else
|
|
$strSelected = '';
|
|
?>
|
|
<option <?php echo $strSelected ?> value="<?php echo $tabEpreuves[$i]['epr_id']; ?>">
|
|
<?php
|
|
if (trim($tabEpreuves[$i]['epr_categorie_' . $strLangue]) != '') {
|
|
echo $tabEpreuves[$i]['epr_categorie_' . $strLangue] . " - ";
|
|
}
|
|
|
|
echo $tabEpreuves[$i]['epr_type_' . $strLangue];
|
|
|
|
if (trim($tabEpreuves[$i]['epr_nom_' . $strLangue]) != '') {
|
|
echo " - " . $tabEpreuves[$i]['epr_nom_' . $strLangue];
|
|
}
|
|
?>
|
|
</option>
|
|
<?php
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="text-center mb-3">
|
|
<button class="btn btn-primary rounded-0" type="button" id="btn_changer_epreuve" name="btn_changer_epreuve" style="display: none"><?php afficheTexte('btn_next'); ?></button>
|
|
<button class="btn btn-secondary rounded-0" type="button" id="btn_changer_epreuve_cancel" name="btn_changer_epreuve_cancel" style="display: none"><?php afficheTexte('btn_cancel'); ?></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
?>
|
|
<input type="hidden" id="epr_id" name="epr_id" value="<?php echo $GLOBALS['intEpreuve']; ?>">
|
|
<input type="hidden" id="pec_id" name="pec_id" value="<?php if (isset($_GET['pec_id'])) { echo $_GET['pec_id']; } else { echo 0; } ?>">
|
|
<input type="hidden" id="promoteur" name="promoteur" value="<?php echo $intPromoteur; ?>">
|
|
<input type="hidden" id="switch_epreuve" name="switch_epreuve" value="<?php if (isset($_GET['switch'])) { echo 1; } else { echo 0; } ?>">
|
|
<input type="hidden" id="no_transfert" name="no_transfert" value="<?php if (isset($_GET['t'])) { echo $_GET['t']; } else { echo ''; } ?>">
|
|
<?php
|
|
$tabRules = $tabMessages = array(); // initialiser les variables
|
|
|
|
$tabProvinces = fxGetProvinces(0, $strLangue); // récupérer les provinces
|
|
$tabInfos = fxGetInfosParticipants($tabEvenement['general']['eve_id']); // récupérer les infos à demander aux participants
|
|
$tabPays = fxGetPays(0, $strLangue); // récupérer les pays
|
|
|
|
|
|
$tabQuestionsParticipant = fxGetQuestions('par', $tabEvenement['general']['eve_id'], $intEpreuve, $strAction, $intPromoteur, $intquestechue); // récupérer les questions à demander aux participants
|
|
$tabQuestionsEpreuve = fxGetQuestions('epr', $tabEvenement['general']['eve_id'], $intEpreuve, $strAction, $intPromoteur, $intquestechue); // récupérer les questions à demander pour l'épreuve
|
|
|
|
|
|
if ($tabQuestionsEpreuve != null) {
|
|
|
|
?>
|
|
<div class="card box_participant rounded-0">
|
|
<?php
|
|
fxShowQuestions($tabRules, $tabMessages, $tabQuestionsEpreuve, $tabEpreuve, $tabEpreuveQuestions, 0, $intNbParticipantsMin, $strAction, $strLangue, 0, $intPromoteur, $tabCodepostal, $tabTelephones);
|
|
|
|
|
|
?>
|
|
</div>
|
|
<div class="sep"><span></span></div>
|
|
<br>
|
|
<?php
|
|
}
|
|
|
|
for ($intCtr = 1; $intCtr <= $intNbParticipants; $intCtr++) {
|
|
if ($tabEpreuve['tep_id'] == 4 && $intCtr>1) {
|
|
$strReadonly = '';
|
|
$strDisabled = '';
|
|
}
|
|
?>
|
|
<div class="card box_participant rounded-0">
|
|
<div class="card-header">
|
|
<h2>
|
|
<?php
|
|
$mem_offset=0;
|
|
// premier participant
|
|
if ($intCtr == 1) {
|
|
if ($intNbParticipants > 1 && intval($tabEpreuve['mt_id']) == 4) {
|
|
afficheTexte('participant-titre-responsable');}
|
|
elseif (intval($tabEpreuve['tep_id']) == 4 && $intNbParticipants == 1) {
|
|
afficheTexte('participant-titre-membre');
|
|
} else {
|
|
if (intval($tabEpreuve['epr_equipe']) == 1) {
|
|
afficheTexte('participant-titre-capitaine');
|
|
} else {
|
|
afficheTexte('participant-titre-participant');
|
|
}
|
|
}
|
|
} else {
|
|
if ( $intNbParticipants > 1 && intval($tabEpreuve['mt_id']) == 4) {
|
|
afficheTexte('participant-titre-entraineur');
|
|
$mem_offset=-1;}
|
|
else {
|
|
afficheTexte('participant-titre-participant');
|
|
}
|
|
|
|
if ($intCtr != 1) {
|
|
if ($strLangue == 'fr') {
|
|
?> no. <?php
|
|
} else {
|
|
?> #<?php
|
|
}
|
|
echo $intCtr+$mem_offset;
|
|
}
|
|
}
|
|
|
|
if ($intCtr > $intNbParticipantsMin && isset($tabParticipant[$intCtr])) {
|
|
echo '
|
|
<a class="btn btn-secondary roundeed-0 btn_delete_part_supplementaire" href="' . $vDomaine . '/delete.php?k=par&id=' . $tabParticipant[$intCtr]['par_id'] . '&lang=' . $strLangue . '&epr_id=' . $intEpreuve .'&pec_id=' . $_GET['pec_id'] . '" title="'. afficheTexte('del_participant', 0) .'" style="display: inline;position: absolute">
|
|
<i class="fa fa-times mr-2" aria-hidden="true"></i>
|
|
' . afficheTexte('del_participant', 0) . '
|
|
</a>
|
|
';
|
|
}
|
|
?>
|
|
</h2>
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
<input type="hidden" id="rol_id_<?php echo $intCtr; ?>" name="rol_id_<?php echo $intCtr; ?>" value="<?php if (($intInvitation == 1 && $intNbParticipantsOriginal > 1) || ($intInvitation == 0 && $intNbParticipantsOriginal > 1 && $intCtr == 1) || $tabEpreuve['epr_equipe'] == 0) { ?>1<?php } else { ?>2<?php } ?>" />
|
|
<input type="hidden" id="com_id_<?php echo $intCtr; ?>" name="com_id_<?php echo $intCtr; ?>" value="" />
|
|
<?php
|
|
fxShowInfosParticipants($tabRules, $tabMessages, $tabCalendriers, $tabInfos, $tabDates, $tabProvinces, $tabPays, $tabEpreuve, $tabParticipant, $intCtr, $intNbParticipantsMin, $strAction, $strDisabled, $strReadonly, $strStyle, $strLangue, $intPromoteur, false, $tabCodepostal, $tabTelephones );
|
|
?>
|
|
</div>
|
|
<?php
|
|
|
|
if (isset($tabInscription['participants']))
|
|
$intNbInscriptions = count($tabInscription['participants']);
|
|
else
|
|
$intNbInscriptions = 0;
|
|
|
|
fxShowQuestions($tabRules, $tabMessages, $tabQuestionsParticipant, $tabEpreuve, $tabPartQuestions, $intCtr, $intNbParticipantsMin, $strAction, $strLangue, $intNbInscriptions, $intPromoteur, $tabCodepostal, $tabTelephones);
|
|
|
|
//print("<pre>".print_r($tabRules,true)."</pre>");
|
|
if (intval($tabEpreuve['epr_sante']) == 1) {
|
|
?>
|
|
<div class="card-body">
|
|
<div class="form-group text-center">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="chk_sante_<?php echo $intCtr; ?>" name="chk_sante_<?php echo $intCtr; ?>" value="1"<?php if (trim($strAction) == 'mod') { ?> checked <?php } ?>>
|
|
<label class="form-check-label" for="chk_sante_<?php echo $intCtr; ?>">
|
|
<?php if ($strLangue == 'fr') { ?>Je confirme que ce participant est en bon état de santé et a la condition physique requise pour participer à cette épreuve.<?php } else { ?>I confirm that the participant is in proper health and physical condition to participate in this event.<?php } ?>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
if ($intCtr <= $intNbParticipantsMin) {
|
|
$tabRules[] = 'chk_sante_' . $intCtr . ': { required: true }';
|
|
} else {
|
|
$tabRules[] = 'chk_sante_' . $intCtr . ': { required: function(element){ return $("#' . $tabInfos[1]['cha_nom'] . '_' . $intCtr . '").val().length + $("#' . $tabInfos[2]['cha_nom'] . '_' . $intCtr . '").val().length > 0; } }';
|
|
}
|
|
|
|
if ($strLangue == 'fr')
|
|
$tabMessages[] = 'chk_sante_' . $intCtr . ': { required: "Veuillez confirmer l\'état de santé du participant" }';
|
|
else
|
|
$tabMessages[] = 'chk_sante_' . $intCtr . ': { required: "Please confirm the health condition of the participant" }';
|
|
}
|
|
?>
|
|
</div>
|
|
<?php
|
|
if ($intNbParticipants > 1 && $intCtr != $intNbParticipants) {
|
|
?>
|
|
<div class="sep"><span></span></div>
|
|
<br>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
<div class="text-center my-3">
|
|
<?php
|
|
if ($strAction == 'add') {
|
|
if ($tabEvenement['general']['eve_bouton_add_new'] == 1) {
|
|
?>
|
|
<button type="submit" id="btn_participant" name="btn_participant" class="btn btn-primary rounded-0" value="add_new">
|
|
<i class="fa fa-cart-plus mr-2" aria-hidden="true"></i>
|
|
<?php if ($strLangue == 'fr') { ?>Ajouter au Panier et inscrire une autre personne dans cette distance<?php } else { ?>Add to Cart and add another person in the same distance<?php } ?>
|
|
</button>
|
|
<?php
|
|
}
|
|
?>
|
|
<button type="submit" id="btn_participant" name="btn_participant" class="btn btn-primary rounded-0" value="add">
|
|
<i class="fa fa-cart-plus mr-2" aria-hidden="true"></i>
|
|
<?php if ($strLangue == 'fr') { ?>Ajouter et aller au panier<?php } else { ?>Add and go to cart<?php } ?>
|
|
</button>
|
|
<?php
|
|
} elseif ($strAction == 'auto') {
|
|
?>
|
|
<button type="submit" id="btn_participant" name="btn_participant" class="btn btn-primary rounded-0">
|
|
<i class="fa fa-cart-plus mr-2" aria-hidden="true"></i>
|
|
<?php if ($strLangue == 'fr') { ?>Ajouter au panier<?php } else { ?>Add to cart<?php } ?>
|
|
</button>
|
|
<?php
|
|
} elseif ($strAction == 'mod') {
|
|
?>
|
|
<input type="hidden" id="promoteur_eve_id" name="promoteur_eve_id" value="<?php echo $tabEvenement['general']['eve_id']; ?>">
|
|
<button class="btn btn-primary rounded-0" id="btn_enregistrer_modif" name="btn_enregistrer_modif" type="submit">
|
|
<i class="fa fa-check mr-2" aria-hidden="true"></i>
|
|
<?php echo afficheTexte('btn_enregistrer', 0, 1, 1) ?>
|
|
</button>
|
|
<button class="btn btn-secondary rounded-0 btn_page_prec" data-code="<?php echo fxGetReferer(); ?>" type="button">
|
|
<i class="fa fa-cart-plus mr-2" aria-hidden="true"></i>
|
|
<?php afficheTexte('btn_annulerinscriptions'); ?>
|
|
</button>
|
|
<?php
|
|
}
|
|
?>
|
|
</div>
|
|
</form>
|
|
|
|
<div class="alert alert-warning my-3">
|
|
<strong><?php echo afficheTexte('alert-mandatory-field', 0, 1, 1) ?></strong>
|
|
</div>
|
|
<?php
|
|
// si ces un abbonement replire les champs auto avec le compte actif (sl)
|
|
if ($tabEpreuve['tep_id']==4) {
|
|
?><script> change_value_compte();</script>
|
|
<?php
|
|
}
|
|
|
|
if ($strLangue == 'fr') {
|
|
?>
|
|
<p><a href="<?php if($strAction == 'add') { echo $GLOBALS['vDomaine'];?>/<?php echo $tabEvenement['general']['eve_label_url']; } elseif($strAction == 'mod'){ echo $GLOBALS['vDomaine']; ?>/compte <?php } ?>">« Retour</a></p>
|
|
<?php
|
|
} else {
|
|
?> <p><a href="<?php if($strAction == 'add') { echo $GLOBALS['vDomaine'];?>/<?php echo $tabEvenement['general']['eve_label_url']; ?>/en<?php } elseif($strAction == 'mod'){ echo $GLOBALS['vDomaine']; ?>/account <?php } ?>">« Back</a></p>
|
|
|
|
<?php
|
|
}
|
|
?>
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
var $form = $("#frm_participant");
|
|
|
|
var validator = $form.validate({
|
|
ignore: ":disabled,[readonly=readonly],.ignore,:hidden:not(input[type='hidden'])",
|
|
rules: {
|
|
<?php echo implode(',', $tabRules); ?>
|
|
},
|
|
messages: {
|
|
<?php echo implode(',', $tabMessages); ?>
|
|
},
|
|
errorPlacement: function (error, element) {
|
|
error.appendTo(element.parent("div"));
|
|
},
|
|
submitHandler: function (form) {
|
|
var $preloader = $('#preloader');
|
|
var $preloader_text = $('#preloader_text');
|
|
$preloader_text.html('<?php afficheTexte('preloader_wait',1,0,1); ?>');
|
|
$preloader.show();
|
|
$('body').css('cursor', 'wait');
|
|
<?php
|
|
if ($strAction == 'add' && intval($tabEpreuve['tep_id']) == 4) {
|
|
?>
|
|
$(':disabled').each(function(e) {
|
|
$(this).removeAttr('disabled');
|
|
});
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
return true;
|
|
}
|
|
});
|
|
$('#pay_id_1').on('blur change', function() {
|
|
fxSetValidation($(this).val());
|
|
});
|
|
<?php
|
|
if ($tabEpreuve['epr_invitation'] != 1) {
|
|
$intCtr = 1;
|
|
|
|
foreach ($tabCalendriers as $strCalendrier) {
|
|
?>
|
|
function checkDays<?php echo $intCtr; ?>() {
|
|
var daysInMonth = new Date($('#<?php echo $strCalendrier; ?>-year').val(), $('#<?php echo $strCalendrier; ?>-month').val(), 0).getDate();
|
|
|
|
if ($('#<?php echo $strCalendrier; ?>-day').val() > daysInMonth) {
|
|
$('#<?php echo $strCalendrier; ?>-day').val(daysInMonth);
|
|
}
|
|
|
|
$('#<?php echo $strCalendrier; ?>-day option:gt(' + (daysInMonth) + ')').attr('disabled', true);
|
|
}
|
|
|
|
function fxSetDateInput<?php echo $intCtr; ?>() { // mettre la date modifiée dans le input du calendrier
|
|
$('#<?php echo $strCalendrier; ?>').val($('#<?php echo $strCalendrier; ?>-year').val() + '-' + $('#<?php echo $strCalendrier; ?>-month').val() + '-' + $('#<?php echo $strCalendrier; ?>-day').val());
|
|
}
|
|
|
|
$('#<?php echo $strCalendrier; ?>-year').change(function() {
|
|
$('#<?php echo $strCalendrier; ?>-month option').removeAttr('disabled'); // Enable all months
|
|
|
|
$('#<?php echo $strCalendrier; ?>-month').change(); // Cascade changes
|
|
|
|
checkDays<?php echo $intCtr; ?>(); // Ensure only valid dates
|
|
fxSetDateInput<?php echo $intCtr; ?>();
|
|
validator.element("#<?php echo $strCalendrier; ?>");
|
|
});
|
|
$('#<?php echo $strCalendrier; ?>-month').change(function() {
|
|
$('#<?php echo $strCalendrier; ?>-day option').removeAttr('disabled'); // Enable all days
|
|
|
|
checkDays<?php echo $intCtr; ?>(); // Ensure only valid dates
|
|
fxSetDateInput<?php echo $intCtr; ?>();
|
|
validator.element("#<?php echo $strCalendrier; ?>");
|
|
});
|
|
$('#<?php echo $strCalendrier; ?>-day').change(function() {
|
|
fxSetDateInput<?php echo $intCtr; ?>();
|
|
validator.element("#<?php echo $strCalendrier; ?>");
|
|
});
|
|
<?php
|
|
$intCtr++;
|
|
}
|
|
|
|
foreach ($tabTelephones as $strTelephone) {
|
|
?>
|
|
$("#<?php echo $strTelephone; ?>").mask('000-000-0000');
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
$('select,input:file').each(function(){
|
|
$(this).bind('change', function (e) {
|
|
if ($(this).data('type') == "par_sexe") {
|
|
$("#" + $(this).data('field')).val($(this).val());
|
|
}
|
|
validator.resetForm();
|
|
validator.element($(this));
|
|
validator.form();
|
|
});
|
|
});
|
|
<?php
|
|
if ($strAction == 'mod' || $strAction == 'auto' || trim($strNoTransfert) != '') {
|
|
?>
|
|
validator.resetForm();
|
|
validator.form();
|
|
<?php
|
|
}
|
|
?>
|
|
});
|
|
</script>
|
|
<?php
|
|
if ($strAction == 'auto') {
|
|
?>
|
|
<script type="text/javascript">
|
|
$('#btn_participant').click();
|
|
</script>
|
|
<?php
|
|
}
|
|
} else { // sinon, afficher un message d'erreur
|
|
echo fxMessage('e0', afficheTexte('modifier_epreuve_msg_erreur', 0));
|
|
}
|
|
}
|
|
|
|
// fonction qui récupère le prix que doit payer le partcipant sleon son âge (JSP)
|
|
// param : id de l'épreuve, date de nax
|
|
function fxGetPrixParticipant($intEpreuve) {
|
|
// MSIN-4296
|
|
global $objDatabase;
|
|
// vérifier la catégorie de prix
|
|
$strWhere = " AND c.cp_id = 1";
|
|
|
|
if (isset($_SESSION['com_id'])) {
|
|
$intCompte = $_SESSION['com_id'];
|
|
|
|
$sqlCategoriePrix = "SELECT cp.cp_id FROM inscriptions_categories_prix_comptes cp, inscriptions_epreuves c, inscriptions_epreuves_prix p WHERE c.epr_id = p.epr_id AND c.eve_id = cp.eve_id AND cp.cp_id = p.cp_id AND c.epr_id = " . intval($intEpreuve) . " AND cp.com_id = " . intval($intCompte);
|
|
$intCategoriePrix = $objDatabase->fxGetVar($sqlCategoriePrix);
|
|
|
|
if ($intCategoriePrix != NULL)
|
|
$strWhere = " AND c.cp_id = " . intval($intCategoriePrix);
|
|
}
|
|
|
|
$sqlPrix = "SELECT p.eve_id,p.ep_montant, p.ep_frais_montant, p.ep_frais_tps, p.ep_frais_tvq, p.ep_id, p.ep_prix_participant, c.cp_id, c.cp_details_fr, c.cp_details_en, p.ep_montant_don FROM inscriptions_epreuves_prix p, inscriptions_categories_prix c WHERE p.cp_id = c.cp_id AND p.epr_id = " . intval($intEpreuve) . " AND p.ep_date_limite >= '" . fxGetDate() . "'" . $strWhere . " ORDER BY p.ep_date_limite LIMIT 1";
|
|
$tabPrix = $objDatabase->fxGetRow($sqlPrix);
|
|
|
|
// MSIN-4296
|
|
// caculer les frais d'administration
|
|
|
|
// info événements
|
|
$sqlEvenements = "SELECT * FROM inscriptions_panier_evenements WHERE eve_id = " . intval($tabPrix['eve_id']);
|
|
$tabEvenements = $objDatabase->fxGetRow($sqlEvenements);
|
|
|
|
$fltSousTotal2=$tabPrix['ep_montant']+$tabPrix['ep_frais_montant']+$tabPrix['ep_frais_tps']+$tabPrix['ep_frais_tvq'];
|
|
|
|
|
|
// afaire fxCalculerFrais(
|
|
if ($tabEvenements['eve_frais'] > 0) {
|
|
$fltTotalTaxesFrais=0;
|
|
$sqlFrais = "SELECT fra_avant_tx, fra_avant_tx AS fra_total, fra_pourcent FROM inscriptions_frais WHERE fra_actif = 1 AND fra_montant_max >= " . floatval($fltSousTotal2) . " AND fra_montant_min <= " . floatval($fltSousTotal2) . " AND eve_frais = " . intval($tabEvenements['eve_frais']);
|
|
$tabFrais2 = $objDatabase->fxGetRow($sqlFrais);
|
|
$fltFraisAvantTaxes = 0;
|
|
if ($tabFrais2 != null) {
|
|
if ($tabFrais2['fra_pourcent'] > 0) {
|
|
$fltFraisAvantTaxes = round($fltSousTotal2 * ($tabFrais2['fra_pourcent'] / 100), 2);
|
|
$fltPourcent = $tabFrais2['fra_pourcent'];
|
|
} else {
|
|
$fltFraisAvantTaxes = $tabFrais2['fra_avant_tx'];
|
|
$fltPourcent = 0;
|
|
}
|
|
|
|
|
|
|
|
if ($tabEvenements['tt_id'] > 1) {
|
|
$sqlTaux = "SELECT t.tau_nom_fr, t.tau_nom_en, t.tau_taux, t.tau_numero_client, t.tau_numero_ms1 FROM inscriptions_taux t, inscriptions_taux_types_taux ttt WHERE t.tau_id = ttt.tau_id AND ttt.tt_id = " . intval($tabEvenements['tt_id']) . " ORDER BY ttt.ttt_tri";
|
|
$tabTaux = $objDatabase->fxGetResults($sqlTaux);
|
|
|
|
if ($tabTaux != null) {
|
|
for ($intCtr = 1; $intCtr <= count($tabTaux); $intCtr++) {
|
|
$fltMontantTaxesFrais = round($fltFraisAvantTaxes * ($tabTaux[$intCtr]['tau_taux'] / 100), 2);
|
|
$tabTaxesFrais[$intCtr] = array('label_fr' => $tabTaux[$intCtr]['tau_nom_fr'] . ' (' . $tabTaux[$intCtr]['tau_taux'] . '%)', 'label_en' => $tabTaux[$intCtr]['tau_nom_en'] . ' (' . $tabTaux[$intCtr]['tau_taux'] . '%)', 'montant' => $fltMontantTaxesFrais, 'taux' => $tabTaux[$intCtr]['tau_taux'], 'numero' => $tabTaux[$intCtr]['tau_numero_ms1']);
|
|
$fltTotalTaxesFrais += $fltMontantTaxesFrais;
|
|
}
|
|
} else {
|
|
fxcreer_log("Il y a eu une erreur lors de la récupération des taxes:\n" . $sqlTaux);
|
|
}
|
|
}
|
|
|
|
$tabFrais = array('fra_avant_tx' => $fltFraisAvantTaxes, 'fra_total' => $fltFraisAvantTaxes + $fltTotalTaxesFrais, 'fra_pourcent' => $fltPourcent);
|
|
$tabPrix["fra_avant_tx"]=$fltFraisAvantTaxes;
|
|
$tabPrix["fra_total"]=$fltFraisAvantTaxes + $fltTotalTaxesFrais;
|
|
$tabPrix["fra_pourcent"]=$fltPourcent;
|
|
|
|
|
|
} else {
|
|
fxcreer_log("Il y a eu une erreur lors de la récupération des frais de l'événement:\n" . $sqlFrais);
|
|
$tabFrais = array('fra_avant_tx' => 0, 'fra_total' => 0, 'fra_pourcent' => 0);
|
|
}
|
|
|
|
} else {
|
|
$tabPrix["fra_avant_tx"]=0;
|
|
$tabPrix["fra_total"]=0;
|
|
$tabPrix["fra_pourcent"]=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $tabPrix;
|
|
}
|
|
|
|
function fxCheckNomEquipe($intEpreuve, $strNomEquipe, $int_Pecid = 0) {
|
|
global $objDatabase;
|
|
|
|
$sqlNbEquipe = "SELECT COUNT(e.pec_nom_equipe) FROM inscriptions_panier_epreuves_commandees e, inscriptions_panier_acheteurs a WHERE e.no_panier = a.no_panier AND e.epr_id = " . intval($intEpreuve) . " AND (a.sta_id = 3 OR a.sta_id = 1) AND e.pec_nom_equipe = '" . $objDatabase->fxEscape($strNomEquipe) . "' AND e.pec_id <> " . intval($int_Pecid);
|
|
$intNbEquipe = $objDatabase->fxGetVar($sqlNbEquipe);
|
|
|
|
return $intNbEquipe;
|
|
}
|
|
|
|
function fxChecktriathlon($strNumero, $strNaissancee) {
|
|
global $objDatabase;
|
|
|
|
$sqltriathlon = "SELECT count(tq_no) FROM inscriptions_tq WHERE tq_no = '" . trim($strNumero) . "' AND tq_naissance = '" . trim($strNaissancee) . "'";
|
|
$inttriathlon = $objDatabase->fxGetVar($sqltriathlon);
|
|
|
|
return $inttriathlon;
|
|
}
|
|
function fxCheckfnq($strNumero, $strNaissancee) {
|
|
global $objDatabase;
|
|
|
|
$sqltriathlon = "SELECT count(tq_no) FROM inscriptions_fnq WHERE tq_no = '" . trim($strNumero) . "' AND tq_naissance = '" . trim($strNaissancee) . "'";
|
|
$inttriathlon = $objDatabase->fxGetVar($sqltriathlon);
|
|
|
|
return $inttriathlon;
|
|
}
|
|
|
|
/* Description : fxchangevalueparticipant (SL/JSP)
|
|
* Parametres : champs, donnnés, provenance (compte, participant)
|
|
* Date : 2013-04-24
|
|
* : 2013-11-21
|
|
*/
|
|
function fxCreateJavaChange($mem_change, $mem_value, $provenance, $strFunctionName, $arrData) {
|
|
$list_change = explode(",", $mem_change);
|
|
$list_value = explode(",", $mem_value);
|
|
$tabDate = array();
|
|
$intCountryKey = 0;
|
|
$strOutput = '
|
|
<script type="text/javascript">
|
|
function ' . $strFunctionName . ' {
|
|
';
|
|
|
|
foreach ($list_change as $key => $value ) {
|
|
if ($list_change[$key] == 'par_naissance_1')
|
|
$tabDate = explode('-', $arrData[$list_value[$key]]);
|
|
|
|
$strOutput .= "
|
|
document.getElementById('" . $list_change[$key] . "').value = '" . addslashes($arrData[$list_value[$key]]) . "';
|
|
";
|
|
|
|
if ($list_change[$key] == 'par_sexe_1') {
|
|
$strOutput .= "
|
|
document.getElementById('" . $list_change[$key] . "-list').value = '" . $arrData[$list_value[$key]] . "';
|
|
";
|
|
}
|
|
|
|
if ($list_change[$key] == 'pay_id_1') {
|
|
$intCountryKey = $key;
|
|
}
|
|
|
|
if ($list_change[$key] == 'par_naissance_1') {
|
|
$strOutput .= "
|
|
document.getElementById('" . $list_change[$key] . '-year' . "').value = '" . $tabDate[0] . "';
|
|
document.getElementById('" . $list_change[$key] . '-month' . "').value = '" . $tabDate[1] . "';
|
|
document.getElementById('" . $list_change[$key] . '-day' . "').value = '" . $tabDate[2] . "';
|
|
";
|
|
}
|
|
}
|
|
|
|
$strOutput .= "
|
|
fxSetValidation('" . $arrData[$list_value[$intCountryKey]] . "');
|
|
";
|
|
|
|
|
|
//$("#que_3762_1").val(1).change();
|
|
|
|
if (isset($GLOBALS['strPage']) && $GLOBALS['strPage'] == 'reserver.php') {
|
|
$strOutput .= "
|
|
$('#frm_participant').valid();
|
|
";
|
|
} else {
|
|
$strOutput .= "
|
|
$('#frm_dons').valid();
|
|
";
|
|
}
|
|
|
|
$strOutput .= '
|
|
}
|
|
</script>
|
|
';
|
|
|
|
return $strOutput;
|
|
}
|
|
function fxCreateJavaChangeaffilie($mem_change, $mem_value, $provenance, $intIndex = 0, $arrAff) {
|
|
$list_change = explode(",", $mem_change);
|
|
$list_value = explode(",", $mem_value);
|
|
$tabDate = array();
|
|
$intCountryKey = 0;
|
|
?>
|
|
<script type="text/javascript">
|
|
function change_value_<?php echo $provenance; if ($intIndex > 0) { echo '_' . $intIndex; } ?>() {
|
|
<?php
|
|
foreach ($list_change as $key => $value ) {
|
|
if ($list_change[$key] == 'par_naissance_1')
|
|
$tabDate = explode('-', $arrAff[$list_value[$key]]);
|
|
?>
|
|
document.getElementById('<?php echo $list_change[$key]; ?>').value='<?php echo addslashes($arrAff[$list_value[$key]]); ?>';
|
|
<?php
|
|
if ($list_change[$key] == 'pay_id_1') {
|
|
$intCountryKey = $key;
|
|
}
|
|
|
|
if ($list_change[$key] == 'par_sexe_1') {
|
|
?>
|
|
$('#<?php echo $list_change[$key] . '-list'; ?>').val('<?php echo $arrAff[$list_value[$key]]; ?>');
|
|
<?php
|
|
}
|
|
|
|
if ($list_change[$key] == 'par_naissance_1') {
|
|
?>
|
|
document.getElementById('<?php echo $list_change[$key] . '-year'; ?>').value='<?php echo $tabDate[0]; ?>';
|
|
document.getElementById('<?php echo $list_change[$key] . '-month'; ?>').value='<?php echo $tabDate[1]; ?>';
|
|
document.getElementById('<?php echo $list_change[$key] . '-day'; ?>').value='<?php echo $tabDate[2]; ?>';
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
}
|
|
</script>
|
|
<?php
|
|
}
|
|
|
|
// fonction pour trouver les dates à respecter pour l'inscription d'un participant (JSP)
|
|
// param : id de l'épreuve
|
|
function fxGetDatesAge($intEpreuve) {
|
|
global $objDatabase;
|
|
|
|
$sqlAges = "SELECT epr_age_min AS ep_age_min, epr_age_max AS ep_age_max, epr_date_age, (epr_date_age - INTERVAL epr_age_min YEAR) AS max_date, (epr_date_age - INTERVAL (epr_age_max + 1) YEAR) + INTERVAL 1 DAY AS min_date FROM inscriptions_epreuves WHERE epr_id = " . intval($intEpreuve) . " LIMIT 1";
|
|
$tabAges = $objDatabase->fxGetRow($sqlAges);
|
|
|
|
return $tabAges;
|
|
}
|
|
|
|
// fonction pour trouver le data des participants a une epreuve
|
|
// le parametre resultat va servir plus tard pour choisir si on modifie le cart ou resultat
|
|
function fxGetPanierParticipantsEpreuve($par_id, $resultat = 'true', $intpec_id) {
|
|
global $objDatabase;
|
|
$tabQuestions = $tabQuestionsEpreuve = $tabEpreuve = null;
|
|
|
|
// parametrer table pour requete sql; quelle table interroger selon que l'on est dans le cart ou dans la liste d'inscriptions
|
|
if ($resultat == 'true') {
|
|
$strTablePart = "resultats_participants";
|
|
$strTableQuestion = "resultats_questions";
|
|
$strTableEpreuve = "resultats_epreuves_commandees";
|
|
|
|
$sqlParticipants = "SELECT * FROM " . $strTablePart . " WHERE pec_id = " . intval($intpec_id) . " ORDER BY par_id";
|
|
$tabParticipants = $objDatabase->fxGetResults($sqlParticipants);
|
|
|
|
|
|
} else {
|
|
$strTablePart = "inscriptions_panier_participants";
|
|
$strTableQuestion = "inscriptions_panier_questions";
|
|
$strTableEpreuve = "inscriptions_panier_epreuves_commandees";
|
|
|
|
$sqlParticipants = "SELECT * FROM " . $strTablePart . " WHERE pec_id = " . intval($intpec_id) . " ORDER BY par_id";
|
|
$tabParticipants = $objDatabase->fxGetResults($sqlParticipants);
|
|
}
|
|
|
|
if ($tabParticipants != null) {
|
|
for ($intCtr = 1; $intCtr <= count($tabParticipants); $intCtr++) {
|
|
// info questions
|
|
if ($resultat == 'true') {
|
|
|
|
//MSIN-4313
|
|
$sqlQuestions = "SELECT rq.que_id, rq.pqu_id, rq.par_id, rq.pec_id, rq.que_choix_fr, rq.que_choix_en, rq.que_modifiable, rq.no_panier,
|
|
iq.que_transfert_bloquer FROM " . $strTableQuestion . " rq LEFT JOIN inscriptions_questions iq
|
|
ON iq.que_id = rq.que_id WHERE rq.que_actif = 1 AND rq.pec_id = " . intval($intpec_id) . " AND rq.par_id = " . intval($tabParticipants[$intCtr]['par_id_original']);
|
|
|
|
|
|
|
|
} else {
|
|
$sqlQuestions = "SELECT que_id, pqu_id, par_id, pec_id, que_choix_fr, que_choix_en, que_modifiable, no_panier FROM " . $strTableQuestion . " WHERE pec_id = " . intval($intpec_id) . " AND par_id = " . intval($tabParticipants[$intCtr]['par_id']);
|
|
}
|
|
|
|
$recQuestions = $objDatabase->fxGetResultsKey($sqlQuestions);
|
|
$tabQuestions[$intCtr] = $recQuestions;
|
|
}
|
|
}
|
|
|
|
// sortir les questions de l'épreuve
|
|
if ($resultat == 'true') {
|
|
$sqlQuestionsEpreuve = "SELECT que_id, pqu_id, par_id, pec_id, que_choix_fr, que_choix_en, que_modifiable, no_panier FROM " . $strTableQuestion . " WHERE que_actif = 1 AND pec_id = " . intval($intpec_id) . " AND par_id = 0";
|
|
$sqlEpreuve = "SELECT * FROM " . $strTableEpreuve . " WHERE pec_id_original = " . intval($intpec_id);
|
|
|
|
|
|
} else {
|
|
$sqlQuestionsEpreuve = "SELECT que_id, pqu_id, par_id, pec_id, que_choix_fr, que_choix_en, que_modifiable, no_panier FROM " . $strTableQuestion . " WHERE pec_id = " . intval($intpec_id) . " AND par_id = 0";
|
|
$sqlEpreuve = "SELECT * FROM " . $strTableEpreuve . " WHERE pec_id = " . intval($intpec_id);
|
|
}
|
|
|
|
$tabQuestionsEpreuve = $objDatabase->fxGetResultsKey($sqlQuestionsEpreuve);
|
|
|
|
// sortir les infos de l'épreuve
|
|
$tabEpreuve = $objDatabase->fxGetResults($sqlEpreuve);
|
|
|
|
$mem_return['participants'] = $tabParticipants;
|
|
$mem_return['questions'] = $tabQuestions;
|
|
$mem_return['questions_epreuve'] = $tabQuestionsEpreuve;
|
|
$mem_return['epreuve'] = $tabEpreuve;
|
|
|
|
return $mem_return;
|
|
}
|
|
|
|
// fonction qui vérifie le nombre max de réservation d'épreuves par client pour un événement (JSP)
|
|
// param : id de l'événement, id du compte client, langue d'affichage
|
|
// créé : 2014-07-16
|
|
function fxCheckMaxEpreuves($intEvenement, $intCompte, $strLangue) {
|
|
global $objDatabase;
|
|
|
|
$sqlMax = "SELECT eve_nb_max AS max, (SELECT COUNT(e.pec_id) FROM inscriptions_panier_epreuves_commandees e, inscriptions_panier_acheteurs a WHERE a.no_panier = e.no_panier AND a.sta_id IN(1,3) AND e.eve_id = " . intval($intEvenement) . " AND e.com_id = " . intval($intCompte) . ") AS nb, eve_label_url FROM inscriptions_evenements WHERE eve_id = " . intval($intEvenement);
|
|
$tabMax = $objDatabase->fxGetRow($sqlMax);
|
|
|
|
if ($tabMax != null) {
|
|
if ($tabMax['max'] != 0 && $tabMax['nb'] >= $tabMax['max']) {
|
|
// message d'erreur et redirection
|
|
if ($strLangue == 'fr')
|
|
$_SESSION['msg'] = 'e129';
|
|
else
|
|
$_SESSION['msg'] = 'e529';
|
|
|
|
header('Location: ' . $GLOBALS['vDomaine'] . '/' . $tabMax['eve_label_url'] . '/' . $strLangue);
|
|
exit;
|
|
} else
|
|
return true;
|
|
} else
|
|
return true;
|
|
}
|
|
function fxCheckAccesEpreuve($strAction, $intEpreuve, $intEvenement, $intpec_id, $intPromoteur, $strNoTransfert) {
|
|
global $objDatabase;
|
|
$strWhere = "";
|
|
$blnReturn = false;
|
|
|
|
if ($strAction == 'add' && intval($intpec_id) == 0) {
|
|
$sqlEpreuve = "SELECT COUNT(*) FROM inscriptions_epreuves WHERE eve_id = " . intval($intEvenement) . " AND epr_id = " . intval($intEpreuve);
|
|
$nbEpreuve = $objDatabase->fxGetVar($sqlEpreuve);
|
|
|
|
if ($nbEpreuve != null && intval($nbEpreuve) == 1) {
|
|
$blnReturn = true;
|
|
}
|
|
} else {
|
|
if (!isset($_GET['switch'])) {
|
|
$strWhere = " AND epr_id = " . intval($intEpreuve);
|
|
}
|
|
if (trim($strNoTransfert) != '' && intval($intpec_id) != 0) {
|
|
$strWhere = str_replace('epr_id', 'e.epr_id', $strWhere);
|
|
|
|
$sqlTransfert = "SELECT COUNT(*) FROM inscriptions_transferts t, resultats_epreuves_commandees e WHERE t.ts_id IN(1, 5) AND t.pec_id = " . intval($intpec_id) . " AND t.pec_id = e.pec_id_original AND t.no_transfert = '" . $objDatabase->fxEscape($strNoTransfert) . "'" . $strWhere;
|
|
$nbTransfert = $objDatabase->fxGetVar($sqlTransfert);
|
|
|
|
if ($nbTransfert != null && intval($nbTransfert) == 1) {
|
|
$blnReturn = true;
|
|
}
|
|
} elseif (intval($intPromoteur) == 1 && isset($_SESSION['com_info']) && intval($intpec_id) != 0) { // si modif par promoteur
|
|
$arrEvenements = explode(',', $_SESSION['com_info']['com_eve_promoteur']);
|
|
|
|
if (in_array($intEvenement, $arrEvenements)) {
|
|
$blnReturn = true;
|
|
}
|
|
} elseif (intval($intPromoteur) == 0 && isset($_SESSION['com_info']) && !isset($_SESSION['no_panier']) && intval($intpec_id) != 0) { // si modif d'une épreuve déjà commandée
|
|
$sqlEpreuve = "SELECT COUNT(*) FROM resultats_epreuves_commandees WHERE pec_id_original = " . intval($intpec_id) . " AND com_id = " . intval($_SESSION['com_info']['com_id']) . $strWhere;
|
|
$nbEpreuve = $objDatabase->fxGetVar($sqlEpreuve);
|
|
|
|
if ($nbEpreuve != null && intval($nbEpreuve) == 1) {
|
|
$blnReturn = true;
|
|
}
|
|
} elseif (intval($intPromoteur) == 0 && isset($_SESSION['no_panier']) && intval($intpec_id) != 0) { // si modif d'une épreuve du panier en cours
|
|
$sqlEpreuve = "SELECT COUNT(*) FROM inscriptions_panier_epreuves_commandees WHERE pec_id = " . intval($intpec_id) . " AND no_panier = '" . $objDatabase->fxEscape($_SESSION['no_panier']) . "'";
|
|
$nbEpreuve = $objDatabase->fxGetVar($sqlEpreuve);
|
|
|
|
if ($nbEpreuve != null && intval($nbEpreuve) == 1) {
|
|
$blnReturn = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $blnReturn;
|
|
}
|
|
function fxShowCopyButtons($tabEvenement, $tabEpreuve, $tabChampsValues, $strFirstName, $intAge, $intDateAge, $intCompte, $arrData, $strProvenance, $strLangue) {
|
|
global $vDomaine;
|
|
$blnShowButton = true;
|
|
$strOutput = $strButton = $strMessageUser = $strClass = '';
|
|
|
|
if (trim($strProvenance) == 'panier') {
|
|
$strFunctionName = "change_value_" . $strProvenance . "_" . $intCompte . "()";
|
|
$strOutput = fxCreateJavaChange($tabChampsValues['champs'], $tabChampsValues['values'], $strProvenance, $strFunctionName, $arrData);
|
|
$strOutput .= '
|
|
<tr>
|
|
<td class="align-middle" style="width: 30%;">
|
|
' . $strFirstName . '
|
|
</td>
|
|
<td class="align-middle" style="width: 70%;">
|
|
<button class="btn btn-secondary rounded-0" onclick="' . $strFunctionName . '">
|
|
<i class="fa fa-files-o mr-2" aria-hidden="true"></i>
|
|
' . afficheTexte('btn_copy_info_panier', 0) . '
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
';
|
|
} else {
|
|
if (intval($tabEvenement['general']['eve_id_membership']) != 0) {
|
|
$arrEvenemenMembership = fxGetEvenementsId($tabEvenement['general']['eve_id_membership']);
|
|
$strLangueLink = ($strLangue) == 'fr' ? '' : '/en';
|
|
|
|
// valide l'âge de la personne
|
|
if ($intAge >= $tabEpreuve['epr_age_min'] && $intAge <= $tabEpreuve['epr_age_max']) {
|
|
$mem_abon = fxGetAbonnement(0, 1, $intCompte, 0);
|
|
|
|
if ($mem_abon == null) { //pas membre
|
|
$blnShowButton = true;
|
|
$strClass = 'warning';
|
|
$strMessageUser .= afficheTexte('participant-text-non-membre-athlete', 0);
|
|
$strMessageUser = str_replace('%membership%', '<strong>' . $arrEvenemenMembership['eve_nom_' . $strLangue] . '</strong>', $strMessageUser);
|
|
$strMessageUser = str_replace('%link%', $vDomaine . '/' . $arrEvenemenMembership['eve_label_url'] . $strLangueLink, $strMessageUser);
|
|
} else { // si déjà membre
|
|
// vérifier si l'adhésion est valide à la date de l'épreuve
|
|
if ($mem_abon['mem_date_debut'] <= $tabEpreuve['epr_date'] && $mem_abon['mem_date_fin'] >= $tabEpreuve['epr_date']) {
|
|
$blnShowButton = true;
|
|
$strClass = 'success';
|
|
$strMessageUser .= afficheTexte('participant-text-membre-athlete', 0);
|
|
$strMessageUser = str_replace('%membership%', '<strong>' . $arrEvenemenMembership['eve_nom_' . $strLangue] . '</strong>', $strMessageUser);
|
|
$strMessageUser = str_replace('%number%', '<strong>#' . $mem_abon['mem_numero'] . '</strong>', $strMessageUser);
|
|
$strMessageUser = str_replace('%date_debut%', '<strong>' . fxShowDate($mem_abon['mem_date_debut'], $strLangue) . '</strong>', $strMessageUser);
|
|
$strMessageUser = str_replace('%date_fin%', '<strong>' . fxShowDate($mem_abon['mem_date_fin'], $strLangue) . '</strong>', $strMessageUser);
|
|
} else {
|
|
$blnShowButton = true;
|
|
$strClass = 'warning';
|
|
$strMessageUser .= afficheTexte('participant-text-non-membre-athlete-date', 0);
|
|
$strMessageUser = str_replace('%membership%', '<strong>' . $arrEvenemenMembership['eve_nom_' . $strLangue] . '</strong>', $strMessageUser);
|
|
$strMessageUser = str_replace('%link%', $vDomaine . '/' . $arrEvenemenMembership['eve_label_url'] . $strLangueLink, $strMessageUser);
|
|
}
|
|
}
|
|
} else {
|
|
$blnShowButton = false;
|
|
$strClass = 'danger';
|
|
$strMessageUser .= afficheTexte('participant-text-insription-age', 0);
|
|
$strMessageUser = str_replace('%age%', '<strong>' . $tabEpreuve['epr_age_min'] . '-' . $tabEpreuve['epr_age_max'] . '</strong>', $strMessageUser);
|
|
$strMessageUser = str_replace('%date%', '<strong>' . fxShowDate($intDateAge, $strLangue) . '</strong>', $strMessageUser);
|
|
}
|
|
} elseif ($tabEpreuve['tep_id'] == 4) { // si c'est un abonnement, voir s'il est valide
|
|
$mem_abon = fxGetAbonnement(0, $tabEpreuve['mt_id'], $intCompte, $tabEpreuve['epr_id']);
|
|
|
|
if ($mem_abon == null) { //pas membre
|
|
// valide l'âge de la personne
|
|
if ($intAge >= $tabEpreuve['epr_age_min'] && $intAge <= $tabEpreuve['epr_age_max']) {
|
|
$blnShowButton = true;
|
|
} else {
|
|
$blnShowButton = false;
|
|
$strClass = 'danger';
|
|
$strMessageUser .= afficheTexte('participant-text-membre-age', 0);
|
|
$strMessageUser = str_replace('%age%', '<strong>' . $tabEpreuve['epr_age_min'] . '-' . $tabEpreuve['epr_age_max'] . '</strong>', $strMessageUser);
|
|
$strMessageUser = str_replace('%date%', '<strong>' . fxShowDate($intDateAge, $strLangue) . '</strong>', $strMessageUser);
|
|
}
|
|
} else { // si déjà membre
|
|
$blnShowButton = false;
|
|
$strClass = 'success';
|
|
$strMessageUser .= afficheTexte('participant-text-membre-deja', 0);
|
|
$strMessageUser = str_replace('%date%', '<strong>' . fxShowDate($mem_abon['mem_date_fin'], $strLangue) . '</strong>', $strMessageUser);
|
|
}
|
|
} else {
|
|
// valide l'âge de la personne
|
|
if ($intAge >= $tabEpreuve['epr_age_min'] && $intAge <= $tabEpreuve['epr_age_max']) {
|
|
$blnShowButton = true;
|
|
} else {
|
|
$blnShowButton = false;
|
|
$strClass = 'danger';
|
|
$strMessageUser .= afficheTexte('participant-text-insription-age', 0);
|
|
$strMessageUser = str_replace('%age%', '<strong>' . $tabEpreuve['epr_age_min'] . '-' . $tabEpreuve['epr_age_max'] . '</strong>', $strMessageUser);
|
|
$strMessageUser = str_replace('%date%', '<strong>' . fxShowDate($intDateAge, $strLangue) . '</strong>', $strMessageUser);
|
|
}
|
|
}
|
|
|
|
if ($blnShowButton) {
|
|
$strFunctionName = "change_value_" . $strProvenance;
|
|
|
|
if (trim($strProvenance) == 'affilie') {
|
|
$strFunctionName .= "_" . $intCompte;
|
|
}
|
|
|
|
$strFunctionName .= "()";
|
|
$strOutput = fxCreateJavaChange($tabChampsValues['champs'] . ",com_id_1", $tabChampsValues['values'] . ",com_id", $strProvenance, $strFunctionName, $arrData);
|
|
$strButton .= '
|
|
<button class="btn btn-secondary rounded-0 mb-3" onclick="' . $strFunctionName . '">
|
|
<i class="fa fa-files-o mr-2" aria-hidden="true"></i>' . afficheTexte('btn_copy_info_compte', 0) . $strFirstName . '
|
|
</button>
|
|
';
|
|
}
|
|
if (trim($strMessageUser) != '') {
|
|
$strMessageUser = str_replace('%nom%', '<strong>' . $strFirstName . '</strong>', $strMessageUser);
|
|
$strButton = str_replace('mb-3', 'mr-3', $strButton);
|
|
$strOutput .= '
|
|
<div class="alert alert-' . $strClass . ' my-3">
|
|
' . $strButton . '
|
|
<strong>' . $strMessageUser . '</strong>
|
|
</div>
|
|
';
|
|
} else {
|
|
$strOutput .= $strButton;
|
|
}
|
|
}
|
|
|
|
return $strOutput;
|
|
}
|