';
}
$strRetour .= '
';
//MSIN-4245
// bug si pas promoteur vois pas les rapport
if (trim($arrCompteClient['com_eve_promoteur']) == '' && trim($arrCompteClient['com_rapports']) != '') {
$tabPromoRapport[] = $arrCompteClient['com_rapports'];
if ($tabPromoRapport[0] != "") {
$strRetour .="
';
$qry = 'select com_eve_promoteur,com_rapports, com_eve_modifiable from inscriptions_comptes where com_id = ' . intval($arrCompteClient['com_id']);
$arrPromoteur = $objDatabase->fxGetRow($qry);
// verifier si evenement est modifiable pour l'usager courant
$strEveModifiable = $arrPromoteur['com_eve_modifiable'];
if ($arrPromoteur['com_eve_promoteur'] != '') {
if (stripos($arrPromoteur['com_eve_promoteur'], ',') > 0) {
$tabPromoEveId = explode(',', $arrPromoteur['com_eve_promoteur']);
// --- Réordonner la liste par date de fin d'événement (plus récent -> plus vieux) ---
$ids = array_filter(array_map('intval', $tabPromoEveId), function($v){ return $v > 0; });
if (!empty($ids)) {
$in = implode(',', $ids);
// On ne garde que les actifs (comme ta requête dans la boucle) et on trie par eve_date_fin desc
$qrySort = "
SELECT e.eve_id,e.eve_date_fin
FROM inscriptions_evenements e
WHERE e.eve_actif = 1
AND e.eve_id IN ($in)
ORDER BY e.eve_date_fin DESC
";
// Si tu as fxGetResults :
$rowsSort = $objDatabase->fxGetResults($qrySort);
// Reconstituer la liste d'IDs dans le bon ordre
$sortedIds = [];
if (!empty($rowsSort)) {
foreach ($rowsSort as $r) {
if (isset($r['eve_id'])) $sortedIds[] = (int)$r['eve_id'];
}
}
// Si la requête a renvoyé au moins 1 ID, on remplace la liste d'origine
if (!empty($sortedIds)) {
$tabPromoEveId = $sortedIds;
}
}
// --- Fin du patch de tri ---
} else {
$tabPromoEveId[] = $arrPromoteur['com_eve_promoteur'];
}
?>
fxGetResults($qry);
$strRetour .= '
';
}
}
$strRetour .= ' ';
return $strRetour;
}
function fxGetCommandes($arrCompteClient, $tep_id, $strLangue)
{ // trouver les commandes
global $objDatabase;
$arrEpreuvesCommandeesActives = $arrEpreuvesCommandeesTerminees = array();
$intCtrEpreuvesCommandeesActives = $intCtrEpreuvesCommandeesTerminees = 1;
$arrRetour = null;
if (intval($tep_id) > 0) { // trouver les épreuves selon le type
if ($tep_id == 1) {
$sqlEpreuvesCommandeesold = "
SELECT *
FROM resultats_epreuves_commandees ec
JOIN inscriptions_evenements e ON ec.eve_id = e.eve_id
JOIN inscriptions_epreuves c ON ec.epr_id = c.epr_id
JOIN inscriptions_panier_acheteurs a ON ec.no_panier = a.no_panier
WHERE ec.pec_actif = 1 AND ec.com_id = " . intval($arrCompteClient['com_id']) . " AND ec.tep_id IN(1, 3)
GROUP BY ec.pec_id
ORDER BY a.ach_maj DESC, e.eve_date_debut, ec.no_commande DESC limit 100
";
$sqlEpreuvesCommandees= "
SELECT *
FROM resultats_epreuves_commandees ec
JOIN inscriptions_evenements e ON ec.eve_id = e.eve_id
JOIN inscriptions_epreuves c ON ec.epr_id = c.epr_id
JOIN inscriptions_panier_acheteurs a ON ec.no_panier = a.no_panier
JOIN inscriptions_panier_participants p ON p.pec_id = ec.pec_id_original
WHERE ec.pec_actif = 1
AND ec.com_id = " . intval($arrCompteClient['com_id']) . "
AND ec.tep_id IN(1, 3)
GROUP BY ec.pec_id
ORDER BY a.ach_maj DESC, e.eve_date_debut, ec.no_commande DESC
LIMIT 100";
//echo($sqlEpreuvesCommandees);
} else {
$sqlEpreuvesCommandees = "
SELECT *
FROM resultats_epreuves_commandees ec
JOIN inscriptions_evenements e ON ec.eve_id = e.eve_id
JOIN inscriptions_epreuves c ON ec.epr_id = c.epr_id
JOIN inscriptions_panier_acheteurs a ON ec.no_panier = a.no_panier
WHERE ec.pec_actif = 1 AND ec.com_id = " . intval($arrCompteClient['com_id']) . " AND ec.tep_id = " . intval($tep_id) . "
GROUP BY ec.pec_id
ORDER BY a.ach_maj DESC, e.eve_date_debut, ec.no_commande DESC
";
}
//$sqlEpreuvesCommandees = "SELECT * FROM resultats_epreuves_commandees ec, inscriptions_evenements e, inscriptions_epreuves c WHERE ec.eve_id = e.eve_id AND ec.epr_id = c.epr_id AND ec.pec_actif = 1 AND ec.com_id = " . intval($arrCompteClient['com_id']) . " AND ec.tep_id = " . intval($tep_id) . " GROUP BY ec.pec_id ORDER BY e.eve_date_debut, ec.no_commande DESC";
$arrEpreuvesCommandees = $objDatabase->fxGetResults($sqlEpreuvesCommandees);
} else { // trouver les épreuves de dons
$sqlEpreuvesCommandees = "
SELECT *
FROM resultats_epreuves_commandees ec
JOIN inscriptions_evenements e ON ec.eve_id = e.eve_id
JOIN inscriptions_epreuves c ON ec.epr_id = c.epr_id
JOIN inscriptions_panier_acheteurs a ON ec.no_panier = a.no_panier
WHERE ec.pec_actif = 1 AND c.epr_id_don <> 0 AND ec.com_id = " . intval($arrCompteClient['com_id']) . " AND ec.tep_id IN(1,3) AND (e.eve_id_don <> 0 OR c.epr_genere_don = 1)
GROUP BY ec.pec_id
ORDER BY a.ach_maj DESC, e.eve_date_debut, ec.no_commande DESC
";
$arrEpreuvesCommandees = $objDatabase->fxGetResults($sqlEpreuvesCommandees);
}
if ($arrEpreuvesCommandees != null) {
for ($intCtrEpreuvesCommandees = 1; $intCtrEpreuvesCommandees <= fxcount($arrEpreuvesCommandees); $intCtrEpreuvesCommandees++) {
if ($arrEpreuvesCommandees[$intCtrEpreuvesCommandees]['eve_date_fin'] <= fxGetDate()) { // si l'événement terminé
$arrEpreuvesCommandeesTerminees[$intCtrEpreuvesCommandeesTerminees] = $arrEpreuvesCommandees[$intCtrEpreuvesCommandees];
$intCtrEpreuvesCommandeesTerminees++;
} else { // sinon, l'événement est actif
$arrEpreuvesCommandeesActives[$intCtrEpreuvesCommandeesActives] = $arrEpreuvesCommandees[$intCtrEpreuvesCommandees];
$intCtrEpreuvesCommandeesActives++;
}
}
$arrRetour['actives'] = $arrEpreuvesCommandeesActives;
$arrRetour['terminées'] = $arrEpreuvesCommandeesTerminees;
}
return $arrRetour;
}
function fxShowCommandes($arrEpreuvesCommandees, $arrCompteClient, $tep_id, $strLangue)
{ // afficher les commandes
global $objDatabase, $strEveModifiable, $vDomaine, $arrFormsTransfert, $arrFormsObjectifsDons, $arrFormsLogSettings, $arrFormsAddLogs;
$strRetour = '';
if ($arrEpreuvesCommandees != null) {
?>
';
if (intval($arrEpreuvesCommandees[$intCtrEpreuvesCommandees]['is_cancelled']) == 1) {
$strRetour .= '
' . afficheTexte('levee_fonds_annulée', 0) . '
';
} else {
// trouver les participants de l'éreuve
$sqlParticipants = "SELECT par_nom, par_prenom, par_id_original FROM resultats_participants WHERE is_cancelled = 0 AND pec_id = " . $arrEpreuvesCommandees[$intCtrEpreuvesCommandees]['pec_id_original'] . " GROUP BY par_id_original ORDER BY par_nom, par_prenom, par_id";
$arrParticipants = $objDatabase->fxGetResults($sqlParticipants);
$strLink = $vDomaine . '/' . $strPage . '/' . fxUnescape($arrEpreuvesCommandees[$intCtrEpreuvesCommandees]['eve_label_url']) . '/';
if (intval($arrEpreuvesCommandees[$intCtrEpreuvesCommandees]['pec_equipe']) == 1) { // afficher le lien vers la page de don de l'équipe
$strRetour .= '