368 lines
16 KiB
PHP
368 lines
16 KiB
PHP
<?php
|
|
function fxGetTabInscription($str_select, $int_id, $str_type, $str_key) {
|
|
global $objDatabase;
|
|
|
|
$query = "select " . $str_select . " from inscriptions_" . $str_type . " where " . $objDatabase->fxEscape($str_key) . "_id =" . intval($int_id);
|
|
return $objDatabase->fxGetVar($query);
|
|
}
|
|
|
|
/**
|
|
* @param $intParId
|
|
* @return bool
|
|
*/
|
|
function fxIsParEquipe($intPecId, $intEprId) {
|
|
global $objDatabase;
|
|
$return = false;
|
|
|
|
$query = 'select pec_equipe from resultats_epreuves_commandees where pec_id_original =' . intval($intPecId) . ' and epr_id = ' . intval($intEprId);
|
|
$rec = $objDatabase->fxGetResults($query);
|
|
|
|
for ($i = 1; $i <= count($rec); $i++) {
|
|
if ($rec[$i]['pec_equipe'] == 1)
|
|
$return = true;
|
|
}
|
|
|
|
return $return;
|
|
}
|
|
|
|
/**
|
|
* @param $intEveId
|
|
* @param $intPecId
|
|
* @param $intEprId
|
|
* @param int $intShow 0 = rien afficher, 1 = afficher un div et <ul> des membres de l'equipe
|
|
* @param int $intMod 0 = ne pas afficher les input de modification du no dossard, 1 = permettre modif no. dossard des participants
|
|
* @return mixed
|
|
*/
|
|
function fxGetMembresEquipe($intEveId, $intPecId, $intEprId, $intShow = 0, $intMod = 0) {
|
|
global $objDatabase;
|
|
|
|
$query = "
|
|
SELECT
|
|
p.com_id,
|
|
c.epr_id,
|
|
c.pec_id_original,
|
|
c.pec_nom_equipe,
|
|
c.eve_id,
|
|
p.par_id,
|
|
p.par_prenom,
|
|
p.par_nom,
|
|
p.par_nom_equipe,
|
|
c.no_equipe,
|
|
p.no_bib,
|
|
p.rol_id,
|
|
p.pec_id
|
|
FROM resultats_epreuves_commandees c
|
|
INNER JOIN resultats_participants p
|
|
ON p.pec_id = c.pec_id_original
|
|
WHERE c.pec_id = " . intval($intPecId) . "
|
|
AND c.epr_id = " . intval($intEprId) . "
|
|
ORDER BY p.no_bib
|
|
"; $rec = $objDatabase->fxGetResults($query);
|
|
|
|
if ($intShow == 1) {
|
|
echo "<b><i>" . afficheTexte('promoteur_epr_equipe', 0) . " : " . $rec[1]['pec_nom_equipe'] . "</i></b><br />";
|
|
|
|
for ($i = 1; $i <= count($rec); $i++) {
|
|
if($rec[$i]['rol_id'] == 1)
|
|
$strRole = "(C)";
|
|
else
|
|
$strRole = '(P)';
|
|
$strTooltip = fxGetRoleTab($rec[$i]['rol_id']);
|
|
echo '<li data-toggle="tooltip" title="' . $strTooltip['rol_txt'] . '">' . $rec[$i]['par_prenom'] . ' ' . $rec[$i]['par_nom'] . " " . $strRole;
|
|
|
|
if($intMod == 1) {
|
|
echo "<input style='width:5%' type='text' id='txt_no_bib_" . $rec[$i]['par_id'] . "' name='txt_no_bib_" . $rec[$i]['par_id'] . "' data-action='no_bib' data-pec_id='" . $rec[$i]['pec_id_original'] . "' value='" . $rec[$i]['no_bib'] . "' />";
|
|
echo '<input type="submit" data-pec_id="' . $intPecId . '" data-eve_id="' . $intEveId . '" data-par_id="' . $rec[$i]['par_id'] . '" data-epr_id="' . $intEprId . '" id="btn_no_bib_' . $rec[$i]['par_id'] . '" name="btn_no_bib_' . $rec[$i]['par_id'] . '" class="btn_bib tooltip" title="" value="ok" />';
|
|
}
|
|
|
|
echo "</li>";
|
|
}
|
|
}
|
|
|
|
return $rec;
|
|
}
|
|
function fxGetMembresEquipeold($intEveId, $intPecId, $intEprId, $intShow = 0, $intMod = 0) {
|
|
global $objDatabase;
|
|
|
|
$query = 'select p.com_id, c.epr_id, c.pec_id_original, c.pec_nom_equipe, c.eve_id, p.par_id, p.par_prenom, p.par_nom, p.par_nom_equipe, c.no_equipe, p.no_bib, p.rol_id from resultats_epreuves_commandees c, resultats_participants p where c.pec_id =' . intval($intPecId) . ' and c.epr_id =' . intval($intEprId) . ' and p.pec_id = c.pec_id_original ORDER BY p.no_bib';
|
|
$rec = $objDatabase->fxGetResults($query);
|
|
|
|
if ($intShow == 1) {
|
|
echo "<b><i>" . afficheTexte('promoteur_epr_equipe', 0) . " : " . $rec[1]['pec_nom_equipe'] . "</i></b><br />";
|
|
|
|
for ($i = 1; $i <= count($rec); $i++) {
|
|
if($rec[$i]['rol_id'] == 1)
|
|
$strRole = "(C)";
|
|
else
|
|
$strRole = '(P)';
|
|
$strTooltip = fxGetRoleTab($rec[$i]['rol_id']);
|
|
echo '<li data-toggle="tooltip" title="' . $strTooltip['rol_txt'] . '">' . $rec[$i]['par_prenom'] . ' ' . $rec[$i]['par_nom'] . " " . $strRole;
|
|
|
|
if($intMod == 1) {
|
|
echo "<input style='width:5%' type='text' id='txt_no_bib_" . $rec[$i]['par_id'] . "' name='txt_no_bib_" . $rec[$i]['par_id'] . "' data-action='no_bib' data-pec_id='" . $rec[$i]['pec_id_original'] . "' value='" . $rec[$i]['no_bib'] . "' />";
|
|
echo '<input type="submit" data-pec_id="' . $intPecId . '" data-eve_id="' . $intEveId . '" data-par_id="' . $rec[$i]['par_id'] . '" data-epr_id="' . $intEprId . '" id="btn_no_bib_' . $rec[$i]['par_id'] . '" name="btn_no_bib_' . $rec[$i]['par_id'] . '" class="btn_bib tooltip" title="" value="ok" />';
|
|
}
|
|
|
|
echo "</li>";
|
|
}
|
|
}
|
|
|
|
return $rec;
|
|
}
|
|
|
|
function fxGetCapitaine($int_pec_id, $int_epr_id) {
|
|
global $objDatabase;
|
|
$return = false;
|
|
|
|
$sql = 'select * from resultats_epreuves_commandees e, resultats_participants r where e.pec_id =' . intval($int_pec_id) . ' and e.epr_id =' . intval($int_epr_id) . ' and r.pec_id = e.pec_id_original';
|
|
$tabEquipe = $objDatabase->fxGetResults($sql);
|
|
|
|
|
|
|
|
if (is_array($tabEquipe)) {
|
|
for ($i = 1; $i <= count($tabEquipe); $i++) {
|
|
if (isset($tabEquipe[$i]['rol_id']) && $tabEquipe[$i]['rol_id'] == 1) {
|
|
$return = $tabEquipe[$i];
|
|
}
|
|
}
|
|
}
|
|
|
|
return $return;
|
|
}
|
|
|
|
function fxGetRole($intComId, $intPecId, $intEprId) {
|
|
global $objDatabase, $strLangue;
|
|
|
|
if($strLangue == 'fr')
|
|
$strEcho = 'Rôle : ';
|
|
else
|
|
$strEcho = 'Role: ';
|
|
$qry = "select rol_id from resultats_participants where com_id = " . $intComId . " and pec_id = " . $intPecId;
|
|
$rec = $objDatabase->fxGetRow($qry);
|
|
if($rec != null){
|
|
switch ($rec['rol_id']){
|
|
case 1:
|
|
return $strEcho . afficheTexte("role_captain", 0);
|
|
break;
|
|
case 3:
|
|
return $strEcho . afficheTexte("role_volunteer", 0);
|
|
break;
|
|
case 4:
|
|
return $strEcho . afficheTexte("role_pitmanager", 0);
|
|
break;
|
|
default:
|
|
return $strEcho . afficheTexte("role_participant", 0);
|
|
break;
|
|
}
|
|
}
|
|
else {
|
|
// return afficheTexte('no_participant', 0);
|
|
$tabOwner = fxGetOwner($intEprId, $intPecId);
|
|
if($tabOwner != null)
|
|
return $strEcho . " Owner";
|
|
else
|
|
return $strEcho . " Error fetching role.";
|
|
}
|
|
}
|
|
|
|
function fxCheckMAJ($int_pec_id, $int_par_id, $str_langue) {
|
|
global $objDatabase, $vDomaine;
|
|
|
|
// $qryParticipantsMAJ = 'SELECT par_mod_via_form, par_modification_promoteur, par_maj from resultats_participants where pec_id = ' . intval($int_pec_id) . " AND par_id = " . intval($int_par_id);
|
|
$qryParticipantsMAJ = 'select par_modification_promoteur, par_maj from resultats_participants where pec_id = ' . intval($int_pec_id) . " AND par_id = " . intval($int_par_id);
|
|
$tabParticipantsMAJ = $objDatabase->fxGetRow($qryParticipantsMAJ);
|
|
|
|
if($str_langue == 'fr')
|
|
$return = "<img class='tooltip' title='Modifiée le : " . fxShowDate($tabParticipantsMAJ['par_maj'], $str_langue) . " à " . fxShowTime($tabParticipantsMAJ['par_maj']) . "' src='". $vDomaine . "/images/error.png'/> Modifiée";
|
|
else
|
|
$return = "<img class='tooltip' title='Modified on: " . fxShowDate($tabParticipantsMAJ['par_maj'], $str_langue) . " at " . fxShowTime($tabParticipantsMAJ['par_maj']) . "' src='". $vDomaine . "/images/error.png'/> Modified";
|
|
|
|
// if($tabParticipantsMAJ['par_mod_via_form'] == 0 && $tabParticipantsMAJ['par_modification_promoteur'] == 0)
|
|
if($tabParticipantsMAJ['par_modification_promoteur'] == 0)
|
|
$return = "<img src='". $vDomaine . "/images/tick.png'/> " . afficheTexte('inc_modif_nonmodifiee', 0);
|
|
return $return;
|
|
}
|
|
|
|
|
|
function fxShowManageButton($tabData, $int_pec_equipe) {
|
|
global $objDatabase, $strLangue;
|
|
|
|
$sqlEpreuve = "SELECT * FROM inscriptions_epreuves WHERE epr_id = " . intval($tabData['epr_id']);
|
|
$tabEpreuve = $objDatabase->fxGetRow($sqlEpreuve);
|
|
if ($tabEpreuve['epr_invitation'] != 1) {
|
|
// if ($tabData['eve_id'] != 175) {
|
|
?>
|
|
<td id="td_bouton">
|
|
<?php
|
|
if (fxIsParEquipe($tabData['pec_id'], $tabData['epr_id'])) {
|
|
?>
|
|
<div class="div_teammates_<?php echo $tabData['pec_id']; ?>" sid="<?php echo $tabData['pec_id']; ?>">
|
|
<input type="image" style="background: transparent;border: none" src="images/information.png"/>
|
|
<div class="teammates_<?php echo $tabData['pec_id']; ?>"
|
|
data-test="<?php echo $tabData['pec_id']; ?>"
|
|
style="text-align: left;display: none" sid="<?php echo $tabData['epr_id']; ?>">
|
|
<?php fxGetMembresEquipe($tabEpreuve['eve_id'], $tabData['pec_id'], $tabData['epr_id'], 1); ?>
|
|
</div>
|
|
<?php
|
|
} else {
|
|
afficheTexte('epreuve_individuelle');
|
|
}
|
|
?>
|
|
</div>
|
|
<?php
|
|
} else {
|
|
?>
|
|
<td>
|
|
<?php
|
|
$qry = 'select eve_actif from inscriptions_evenements where eve_id = ' . intval($tabData['eve_id']);
|
|
$tabEveActif = $objDatabase->fxGetRow($qry);
|
|
if ($tabEveActif['eve_actif'] != 0) {
|
|
?>
|
|
<button type="button" value="<?php echo $tabData['pec_id']; ?>"
|
|
class="btn_canmore" name="btn_canmore"
|
|
data-pec_id_original="<?php echo $tabData['pec_id']; ?>"
|
|
data-epr_id="<?php echo $tabData['epr_id']; ?>"
|
|
data-eve_code="<?php
|
|
// get eve_label_url
|
|
$sqlEveURL = "SELECT eve_label_url FROM inscriptions_evenements WHERE eve_id = " . intval($tabData['eve_id']);
|
|
$strEveURL = $objDatabase->fxGetVar($sqlEveURL);
|
|
echo $strEveURL;
|
|
|
|
?>">
|
|
<?php
|
|
if (fxIsParEquipe($tabData['pec_id'], $tabData['epr_id']))
|
|
afficheTexte('btn_canmore');
|
|
else
|
|
if($tabData['rol_id'] == 2 && $int_pec_equipe == 1) // participant = "view team"
|
|
afficheTexte('btn_canmore');
|
|
//
|
|
else
|
|
afficheTexte('btn_canmore_solo')
|
|
?>
|
|
</button></td>
|
|
<?php
|
|
} else
|
|
if ($strLangue == 'fr') {
|
|
echo "Événement inactif.</td>";
|
|
} else {
|
|
echo "Inactive event.</td>";
|
|
}
|
|
}
|
|
// }
|
|
}
|
|
|
|
/*
|
|
* function qui annule ou retablit une inscription dans le tableau promoteur
|
|
* param $tabEpreuve un tableau de l'epreuve a modifier
|
|
* param $int_pec_id le no. de l'epreuve commandee
|
|
* */
|
|
function fxAnnulerRetablirInscription($tabEpreuve, $int_pec_id) {
|
|
global $objDatabase;
|
|
$tabRetour = array('state' => 'success');
|
|
|
|
// check registration status
|
|
$query = "select is_cancelled from resultats_epreuves_commandees where pec_id_original = " . intval($int_pec_id) . " and epr_id = " . intval($tabEpreuve['epr_id']);
|
|
$blnIsCancelled = $objDatabase->fxGetVar($query);
|
|
|
|
$query = "select * from resultats_epreuves_commandees where pec_id_original = " . intval($int_pec_id) . " and epr_id = " . intval($tabEpreuve['epr_id']);
|
|
$qryEpreuve = $objDatabase->fxGetRow($query);
|
|
|
|
// desactive l'abonnement
|
|
if (intval($tabEpreuve['tep_id']) == 4) {
|
|
if (intval($blnIsCancelled) == 1) {
|
|
// ajuster abonnement non actif
|
|
$sqlEpreuve = "UPDATE memberships SET mem_actif = 1 WHERE pec_id = " . intval($int_pec_id);
|
|
$qryEpreuve = $objDatabase->fxQuery($sqlEpreuve);
|
|
|
|
if (!$qryEpreuve) {
|
|
$tabRetour['state'] = 'error';
|
|
fxcreer_log("Erreur de gestion UPDATE memberships " . $_SESSION['com_info']['com_courriel']);
|
|
}
|
|
} else {
|
|
|
|
$sqlEpreuve = "UPDATE memberships SET mem_actif = 0 WHERE pec_id = " . intval($int_pec_id);
|
|
$qryEpreuve = $objDatabase->fxQuery($sqlEpreuve);
|
|
|
|
if (!$qryEpreuve) {
|
|
$tabRetour['state'] = 'error';
|
|
fxcreer_log("Erreur de gestion UPDATE memberships " . $_SESSION['com_info']['com_courriel']);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (intval($blnIsCancelled) == 0) {
|
|
$tabRetour['action'] = 'annuler';
|
|
// ajuster qte epreuve
|
|
$sqlEpreuve = "UPDATE inscriptions_epreuves SET epr_qte = epr_qte + 1 WHERE epr_id = " . intval($tabEpreuve['epr_id']);
|
|
$qryEpreuve = $objDatabase->fxQuery($sqlEpreuve);
|
|
|
|
if (!$qryEpreuve) {
|
|
$tabRetour['state'] = 'error';
|
|
fxcreer_log("Erreur de gestion des quantités de l'épreuve." . $_SESSION['com_info']['com_courriel']);
|
|
}
|
|
|
|
$sqlInscription = "update resultats_epreuves_commandees set is_cancelled = 1 where pec_id_original = '" . intval($int_pec_id) . "' and epr_id =" . intval($tabEpreuve['epr_id']);
|
|
$qryInscription = $objDatabase->fxQuery($sqlInscription);
|
|
|
|
$sqlParticipants = "UPDATE resultats_participants SET is_cancelled = 1 WHERE pec_id = " . intval($int_pec_id);
|
|
$qryParticipants = $objDatabase->fxQuery($sqlParticipants);
|
|
|
|
if (!$qryInscription || !$qryParticipants) {
|
|
$tabRetour['state'] = 'error';
|
|
fxcreer_log("Erreur d'annulation d'inscription : " . $_SESSION['com_info']['com_courriel']);
|
|
} else {
|
|
// MSIN-4464 — audit annulation
|
|
if (!function_exists('fxFicheAuditRecordCancelRestoreForPec')) {
|
|
require_once dirname(__FILE__) . '/inc_fx_fiche_audit.php';
|
|
}
|
|
fxFicheAuditRecordCancelRestoreForPec(
|
|
intval($int_pec_id),
|
|
'0',
|
|
'1',
|
|
'annuler',
|
|
intval($tabEpreuve['eve_id'] ?? 0)
|
|
);
|
|
}
|
|
} else {
|
|
$tabRetour['action'] = 'retablir';
|
|
|
|
if (intval($tabEpreuve['epr_qte_limitee']) == 1 && intval($tabEpreuve['epr_qte']) < 0) { // check remaining qty
|
|
$tabRetour['state'] = 'error';
|
|
echo fxMessage('m135');
|
|
} else {
|
|
$sqlInscription = "update resultats_epreuves_commandees set is_cancelled = 0 where pec_id_original = '" . intval($int_pec_id) . "' and epr_id =" . intval($tabEpreuve['epr_id']);
|
|
$qryInscription = $objDatabase->fxQuery($sqlInscription);
|
|
|
|
$sqlParticipants = "UPDATE resultats_participants SET is_cancelled = 0 where pec_id = '" . intval($int_pec_id) . "' and epr_id =" . intval($tabEpreuve['epr_id']);
|
|
$qryParticipants = $objDatabase->fxQuery($sqlParticipants);
|
|
|
|
if (!$qryInscription || !$qryParticipants) {
|
|
$tabRetour['state'] = 'error';
|
|
fxcreer_log("Erreur d'annulation d'inscription : " . $_SESSION['com_info']['com_courriel']);
|
|
} else {
|
|
// MSIN-4464 — audit rétablissement
|
|
if (!function_exists('fxFicheAuditRecordCancelRestoreForPec')) {
|
|
require_once dirname(__FILE__) . '/inc_fx_fiche_audit.php';
|
|
}
|
|
fxFicheAuditRecordCancelRestoreForPec(
|
|
intval($int_pec_id),
|
|
'1',
|
|
'0',
|
|
'retablir',
|
|
intval($tabEpreuve['eve_id'] ?? 0)
|
|
);
|
|
}
|
|
|
|
// ajuster qte epreuve
|
|
$sqlEpreuve = "UPDATE inscriptions_epreuves SET epr_qte = epr_qte - 1 WHERE epr_id = " . intval($tabEpreuve['epr_id']);
|
|
$qryEpreuve = $objDatabase->fxQuery($sqlEpreuve);
|
|
|
|
if (!$qryEpreuve) {
|
|
$tabRetour['state'] = 'error';
|
|
fxcreer_log("Erreur de gestion des quantités de l'épreuve." . $_SESSION['com_info']['com_courriel']);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $tabRetour;
|
|
}
|