fxEscape($strNoPanier) . "')"; $arrDonation = $objDatabase->fxGetRow($sqlDonation); if ($arrDonation != null && $arrDonation['eve_id_don'] > 0) { // si événement de donation, vérifier si le panier est concerné $sqlEpreuvePanier = "SELECT * FROM inscriptions_epreuves WHERE epr_id IN(SELECT epr_id FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AND epr_id_don <> 0"; $arrEpreuvePanier = $objDatabase->fxGetResultsKey($sqlEpreuvePanier); if ($arrEpreuvePanier != null) { $sqlInfoPanier = "SELECT * FROM inscriptions_panier_epreuves_commandees e, inscriptions_panier_participants p WHERE e.pec_id = p.pec_id AND e.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND e.epr_id IN(" . implode(',', array_keys($arrEpreuvePanier)) . ") ORDER BY e.pec_id, p.par_id"; $arrInfoPanier = $objDatabase->fxGetResults($sqlInfoPanier); if ($arrInfoPanier != null) { for ($intCtr = 1; $intCtr <= count($arrInfoPanier); $intCtr++) { $strLink = '/' . fxUnescape($arrDonation['eve_label_url']) . '/'; if ($arrInfoPanier[$intCtr]['pec_equipe'] == 1) { if (intval($arrDonation['eve_id']) != 646) { // patch pour défi 808 2021 $arrOutput['equipe'][$arrInfoPanier[$intCtr]['pec_id']] = array( 'link' => $strLink . md5($arrInfoPanier[$intCtr]['pec_id']), 'label' => afficheTexte('don_facture_team', 0, 0, 1) . ' ' . fxUnescape($arrInfoPanier[$intCtr]['pec_nom_equipe']), 'race' => $arrEpreuvePanier[$arrInfoPanier[$intCtr]['epr_id']] ); } } $arrOutput['participant'][$arrInfoPanier[$intCtr]['par_id']] = array( 'link' => $strLink . md5($arrInfoPanier[$intCtr]['pec_id']) . '/' . md5($arrInfoPanier[$intCtr]['par_id']), 'label' => afficheTexte('don_facture_participant', 0, 0, 1) . ' ' . fxUnescape($arrInfoPanier[$intCtr]['par_nom']) . ', ' . fxUnescape($arrInfoPanier[$intCtr]['par_prenom']), 'race' => $arrEpreuvePanier[$arrInfoPanier[$intCtr]['epr_id']] ); } } } } } return $arrOutput; } /** * doner le lien donnation (liste des personnes inscrites) * @author Stéphan Leith, Jean-Sébastien Proulx * @version 1.0 * @param integer $mem_pec_id * @param integer $mem_par_id * @param string $strLangue Langue d'affichage * @return array */ function fxGetLinksDonationParticipant($mem_pec_id, $mem_par_id, $strLangue) { #MSIN-2002 global $tabEvenement; $strParticipant = ''; if ($strLangue == 'fr') { $strPage = 'don'; $strLabel = "Faire un don"; } else { $strPage = 'donate'; $strLabel = "Donate"; } if (intval($mem_par_id) > 0) { $strParticipant = '/' . md5($mem_par_id); } $strLink = $strPage . '/' . fxUnescape($tabEvenement['general']['eve_label_url']) . '/'; $arrOutput = array( 'link' => $strLink . md5($mem_pec_id) . $strParticipant, 'label' => $strLabel ); return $arrOutput; } /** * Affiche les liens de donation * @author Jean-Sébastien Proulx * @version 1.0 * @param string $strType Type d'affichage: web ou mail * @param array $arrLinksDonation Tableau des liens issue de fxGetLinksDonation() * @param string $strLangue Langue d'affichage * @return string */ function fxShowLinksDonation($strType, $arrLinksDonation, $strLangue, $strColor) { global $vDomaine,$vtexte_page; $strOutput = ''; $vPage='panier.php'; $vtexte_page = obtenirTextepage( $vPage, $strLangue, 2,1); if ($strLangue == 'fr') { $strPage = 'don'; $strLabel = "Faire un don"; } else { $strPage = 'donate'; $strLabel = "Donate"; } $strLink = $vDomaine . '/' . $strPage; if ($arrLinksDonation != null) { $strOutput .= '
' . afficheTexte('don_facture_header', 0, 0, 1) . '

' . afficheTexte('don_facture_texte', 0, 0, 1) . '

'; foreach ($arrLinksDonation as $arrLinks) { foreach ($arrLinks as $arrData) { switch ($strType) { case 'mail': $strOutput .= '

' . $strLabel . ' ' . $arrData['label'] . '

'; break; case 'web': default: $strOutput .= '

' . $strLabel . ' ' . $arrData['label'] . '

'; break; } } } $strOutput .= '

'; } return $strOutput; } /** * 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 fxGetDonation($intEpreuveCommandee, $intParticipant) { global $objDatabase; $arrOutput = null; $strParticipant = ''; if ($intEpreuveCommandee != '') { $sqlDonation = "SELECT *, (SELECT SUM(d.pd_montant) FROM inscriptions_panier_acheteurs a, inscriptions_panier_dons d WHERE d.no_panier = a.no_panier AND a.sta_id = 3 AND d.pec_id = pec_id_original/* AND d.par_id = 0*/) AS montant_amasse FROM resultats_epreuves_commandees WHERE MD5(pec_id_original) = '" . $objDatabase->fxEscape($intEpreuveCommandee) . "'"; $arrOutput['equipe'] = $objDatabase->fxGetRow($sqlDonation); $sqlEvenement = "SELECT e.eve_id_don, c.epr_id_don FROM inscriptions_evenements e, inscriptions_epreuves c WHERE c.eve_id = e.eve_id AND e.eve_id = " . intval($arrOutput['equipe']['eve_id']) . " AND c.epr_id = " . intval($arrOutput['equipe']['epr_id']); $arrOutput['evenement'] = $objDatabase->fxGetRow($sqlEvenement); if ($intParticipant != '') { $sqlDonation = "SELECT e.pec_nom_equipe, p.*, (SELECT SUM(d.pd_montant) FROM inscriptions_panier_acheteurs a, inscriptions_panier_dons d WHERE d.no_panier = a.no_panier AND a.sta_id = 3 AND d.par_id = p.par_id_original) AS montant_amasse FROM resultats_epreuves_commandees e, resultats_participants p WHERE e.pec_id_original = p.pec_id AND MD5(e.pec_id_original) = '" . $objDatabase->fxEscape($intEpreuveCommandee) . "' AND MD5(p.par_id_original) = '" . $objDatabase->fxEscape($intParticipant) . "'"; $arrOutput['participant'] = $objDatabase->fxGetRow($sqlDonation); if ($arrOutput['participant'] != null) { $strParticipant = " AND r.par_id = " . intval($arrOutput['participant']['par_id_original']); } } else { // TODOsl; récupérer TOUS les participants de l'équipe } $sqlQuestions = "SELECT q.que_don_label_fr, q.que_don_label_en, r.que_choix_fr, r.que_choix_en FROM inscriptions_questions q, resultats_questions r WHERE r.que_actif = 1 AND q.que_don_show = 1 AND q.que_id = r.que_id AND MD5(r.pec_id) = '" . $objDatabase->fxEscape($intEpreuveCommandee) . "'" . $strParticipant; $arrOutput['questions'] = $objDatabase->fxGetResults($sqlQuestions); } return $arrOutput; } /** * Affiche les infos et le visuel du don * @author Jean-Sébastien Proulx * @version 1.0 * @param array $arrDonation Tableau des données issue de fxGetDonation() * @param string $strLangue Langue d'affichage * @return string */ function fxShowDonation($arrDonation, $strLangue) { $strOutput = $strQuestions = ''; $fltObjectif = $fltMontantAmasse = 0; if ($strLangue == 'fr') { $strNomEquipe = "Nom de l'équipe"; $strNomParticipant = "Nom du participant"; $strObjectif = "Objectif"; $strMontant = "Montant amassé"; } else { $strNomEquipe = "Name of the team"; $strNomParticipant = "Name of the participant"; $strObjectif = "Goal"; $strMontant = "Gathered"; } if ($arrDonation['questions'] != null) { foreach ($arrDonation['questions'] as $strQuestion) { $strQuestions .= '
' . fxUnescape($strQuestion['que_don_label_' . $strLangue]) . '
' . fxUnescape($strQuestion['que_choix_' . $strLangue]) . '
'; } } if (isset($arrDonation['participant'])) { $strOutput = '
' . $strNomParticipant . '
' . fxUnescape($arrDonation['participant']['par_prenom']) . ' ' . fxUnescape($arrDonation['participant']['par_nom']) . '
' . $strQuestions . '
'; $fltObjectif = floatval($arrDonation['participant']['epr_objectif_dons']); $fltMontantAmasse = floatval($arrDonation['participant']['montant_amasse']); } elseif (isset($arrDonation['equipe']) && $arrDonation['equipe']['pec_equipe'] == 1) { $strOutput = '
' . $strNomEquipe . '
' . fxUnescape($arrDonation['equipe']['pec_nom_equipe']) . '
' . $strQuestions . '
'; $fltObjectif = floatval($arrDonation['equipe']['epr_objectif_dons']); $fltMontantAmasse = floatval($arrDonation['equipe']['montant_amasse']); } include_once 'thermometer.class.php'; $objThermometer = new \clsThermometer\clsThermometer($fltObjectif, $fltMontantAmasse); $strOutput = $strOutput . $objThermometer->fxShow('h', 0, 'money', '', $strMontant, $strObjectif, $strLangue); return $strOutput; } /** * Récupère les donateurs d'une épreuve donnée * @author Jean-Sébastien Proulx * @version 1.0 * @param integer $intEvenement id de l'événement * @param string $intEpreuveCommandee id de l'épreuve commandée (en md5)* * @param string $intParticipant id du participant (en md5) * @return null or array */ function fxGetDonateurs($intEvenement, $intEpreuveCommandee = '', $intParticipant = '') { global $objDatabase; $arrOutput = null; $strWhere = ''; if (trim($intEvenement) != '') { $strWhere .= " AND a.eve_id = " . intval($intEvenement); } if (trim($intEpreuveCommandee) != '') { $strWhere .= " AND MD5(d.pec_id) = '" . $objDatabase->fxEscape($intEpreuveCommandee) . "'"; } if (trim($intParticipant) != '') { $strWhere .= " AND MD5(d.par_id) = '" . $objDatabase->fxEscape($intParticipant) . "'"; } else { //$strWhere .= " AND d.par_id = 0"; } // $sqlDonateurs = "SELECT d.pd_montant, a.com_nom, a.com_prenom FROM inscriptions_panier_dons d, inscriptions_panier_acheteurs a WHERE MD5(d.pec_id) = '" . $objDatabase->fxEscape($intEpreuveCommandee) . "' AND a.no_panier = d.no_panier AND a.sta_id = 3 AND d.pd_anonyme = 0" . $strWhere; // $sqlDonateurs = "SELECT a.com_nom, a.com_prenom, a.eve_id, a.no_panier, a.no_commande, d.pd_montant, d.pd_recu, d.pd_recu_pdf, d.pd_recu_numero, d.pec_id, d.par_id, e.pec_nom_equipe, e.pec_equipe, e.epr_id, IF(d.par_id <> 0, (SELECT p.par_nom FROM resultats_participants p WHERE d.par_id = p.par_id_original), '') AS par_nom, IF(d.par_id <> 0, (SELECT p.par_prenom FROM resultats_participants p WHERE d.par_id = p.par_id_original), '') AS par_prenom FROM inscriptions_panier_acheteurs a, resultats_epreuves_commandees e, inscriptions_panier_dons d WHERE a.no_panier = d.no_panier AND a.sta_id = 3 AND d.pd_anonyme = 0" . $strWhere; $sqlDonateurs = "SELECT a.com_nom, a.com_prenom, a.eve_id, a.no_panier, a.no_commande, d.pd_montant, d.pd_recu, d.pd_anonyme, d.pd_recu_pdf, d.pd_recu_numero, d.pec_id, d.par_id, e.pec_nom_equipe, e.pec_equipe, e.epr_id, IF(d.par_id <> 0, (SELECT p.par_nom FROM resultats_participants p WHERE d.par_id = p.par_id_original), '') AS par_nom, IF(d.par_id <> 0, (SELECT p.par_prenom FROM resultats_participants p WHERE d.par_id = p.par_id_original), '') AS par_prenom, d.pd_nom FROM inscriptions_panier_acheteurs a, resultats_epreuves_commandees e, inscriptions_panier_dons d WHERE a.no_panier = d.no_panier AND d.pec_id = e.pec_id_original AND a.sta_id = 3" . $strWhere . " ORDER BY a.ach_maj DESC"; $arrOutput = $objDatabase->fxGetResults($sqlDonateurs); return $arrOutput; } function fxShowFormObjectifsDons($recEpreuvesCommandees, $strLangue) { global $objDatabase, $vDomaine; $strHTML = ''; $arrForms = null; $pec_id = $recEpreuvesCommandees['pec_id_original']; // Afficher l'équipe, s'il y a lieu if (intval($recEpreuvesCommandees['pec_equipe']) == 1) { $arrForms[$pec_id][] = 'frm_donation_e' . $pec_id; $strHTML .= '
' . afficheTexte('objectif_dons_equipe', 0) . ' ' . afficheTexte('objectif_dons_montant_actuel', 0) . ' ' . afficheTexte('objectif_dons_montant_original', 0) . '
' . fxUnescape($recEpreuvesCommandees['pec_nom_equipe']) . '
' . fxShowPrix($recEpreuvesCommandees['epr_objectif_dons_original'], $strLangue) . '
'; } // récupérer le participants $sqlEpreuvesParticipants = 'SELECT * FROM resultats_participants WHERE is_cancelled = 0 AND pec_id = ' . intval($pec_id) . " GROUP BY par_id_original ORDER BY par_nom, par_prenom, par_id"; $arrEpreuvesParticipants = $objDatabase->fxGetResults($sqlEpreuvesParticipants); // afficher les participants if ($arrEpreuvesParticipants != null) { $strHTML .= '
'; for ($intCtr3 = 1; $intCtr3 <= count($arrEpreuvesParticipants); $intCtr3++) { $arrForms[$pec_id][] = 'frm_donation_p' . $arrEpreuvesParticipants[$intCtr3]['par_id']; $strHTML .= ' '; } $strHTML .= '
' . afficheTexte('objectif_dons_participant', 0) . ' ' . afficheTexte('objectif_dons_montant_actuel', 0) . ' ' . afficheTexte('objectif_dons_montant_original', 0) . '
' . fxUnescape($arrEpreuvesParticipants[$intCtr3]['par_nom']) . ', ' . fxUnescape($arrEpreuvesParticipants[$intCtr3]['par_prenom']) . '
' . fxShowPrix($arrEpreuvesParticipants[$intCtr3]['epr_objectif_dons_original'], $strLangue) . '
'; } $arrOutput = array( 'HTML' => $strHTML, 'forms' => $arrForms ); return $arrOutput; } function fxSetObjectifsDons($arrData, $strLangue) { global $objDatabase; $arrRetour = array(); $qryUpdate = false; if (intval($arrData['montant']) >= intval($arrData['objectif_avant'])) { if (isset($arrData['pec_id'])) { // modification de l'objectif d'équipe $sqlUpdate = "UPDATE resultats_epreuves_commandees SET epr_objectif_dons = " . intval($arrData['montant']) . " 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 epr_objectif_dons = " . intval($arrData['montant']) . " WHERE par_id = " . intval($arrData['par_id']); $qryUpdate = $objDatabase->fxQuery($sqlUpdate); } if ($qryUpdate) { $arrRetour['state'] = 'success'; $arrRetour['message'] = fxMessage('p208', '', $strLangue); $_SESSION['msg'] = 'p208'; $arrRetour['nouvel_objectif'] = intval($arrData['montant']); } else { $arrRetour['state'] = 'error'; $arrRetour['message'] = fxMessage('e101', '', $strLangue); $_SESSION['msg'] = 'e101'; } } else { $arrRetour['state'] = 'error'; $arrRetour['message'] = fxMessage('e101', '', $strLangue); $_SESSION['msg'] = 'e101'; } return $arrRetour; } function fxSendConfirmationDon($arrDon, $strLangue) { global $vDomaine, $vRepertoireFichiers; $arrEvenement = fxGetEvenementsId($arrDon[1]['eve_id']); $arrEvenementDon = fxGetEvenementsId($arrDon[1]['eve_id_don']); $arrReceveur = fxGetReceveur($arrDon[1]['pec_id'], $arrDon[1]['par_id']); $arrPanier = fxListPanier($arrDon[1]['no_panier']); $arrAcheteur = $arrPanier[0]; $strDetails = ''; $from_mail = $arrAcheteur['com_courriel']; $from_name = fxUnescape($arrAcheteur['com_prenom']) . ' ' . fxUnescape($arrAcheteur['com_nom']); $to_mail = $arrReceveur['par_courriel']; $to_name = fxUnescape($arrReceveur['par_prenom']) . ' ' . fxUnescape($arrReceveur['par_nom']); if ($arrDon[1]['par_id'] != 0 ) { $strDetails = fxUnescape($arrEvenementDon['eve_courriel_don_participant_' . $strLangue], 1); if ($strLangue == 'fr') { $subject = 'Vous avez reçu un nouveau don pour ' . fxUnescape($arrEvenement['eve_nom_fr']); $strDetails .= '

Montant: ' . fxShowPrix($arrDon[1]['pd_montant'], $strLangue) . '

'; $strDetails .= '

Date: ' . fxShowDate($arrAcheteur['ach_maj'], $strLangue) . '

'; $strDetails .= '

Donateur: ' . $from_name . '

'; $strDetails .= '

Courriel: ' . $from_mail . '

'; $attachment_label = 'Accéder à la page de don'; $attachment_url = $vDomaine . '/don/' . $arrEvenement['eve_label_url'] . '/' . md5($arrDon[1]['pec_id']) . '/' . md5($arrDon[1]['par_id']); } else { $subject = 'You have received a new donation for ' . fxUnescape($arrEvenement['eve_nom_en']); $strDetails .= '

Amount: ' . fxShowPrix($arrDon[1]['pd_montant'], $strLangue) . '

'; $strDetails .= '

Date: ' . fxShowDate($arrAcheteur['ach_maj'], $strLangue) . '

'; $strDetails .= '

Donor: ' . $from_name . '

'; $strDetails .= '

Email: ' . $from_mail . '

'; $attachment_label = 'Access the donation page'; $attachment_url = $vDomaine . '/donate/' . $arrEvenement['eve_label_url'] . '/' . md5($arrDon[1]['pec_id']) . '/' . md5($arrDon[1]['par_id']); } } else { $strDetails = fxUnescape($arrEvenementDon['eve_courriel_don_equipe_' . $strLangue], 1); if ($strLangue == 'fr') { $subject = 'Votre équipe a reçu un nouveau don pour ' . fxUnescape($arrEvenement['eve_nom_fr']); $strDetails .= '

Équipe: ' . fxUnescape($arrReceveur['par_nom_equipe']) . '

'; $strDetails .= '

Montant: ' . fxShowPrix($arrDon[1]['pd_montant'], $strLangue) . '

'; $strDetails .= '

Date: ' . fxShowDate($arrAcheteur['ach_maj'], $strLangue) . '

'; $strDetails .= '

Donateur: ' . $from_name . '

'; $strDetails .= '

Courriel: ' . $from_mail . '

'; $attachment_label = 'Accéder à la page de don'; $attachment_url = $vDomaine . '/don/' . $arrEvenement['eve_label_url'] . '/' . md5($arrDon[1]['pec_id']); } else { $subject = 'Your team has received a new donation for ' . fxUnescape($arrEvenement['eve_nom_en']); $strDetails .= '

Team: ' . fxUnescape($arrReceveur['par_nom_equipe']) . '

'; $strDetails .= '

Amount: ' . fxShowPrix($arrDon[1]['pd_montant'], $strLangue) . '

'; $strDetails .= '

Date: ' . fxShowDate($arrAcheteur['ach_maj'], $strLangue) . '

'; $strDetails .= '

Donor: ' . $from_name . '

'; $strDetails .= '

Email: ' . $from_mail . '

'; $attachment_label = 'Access the donation page'; $attachment_url = $vDomaine . '/donate/' . $arrEvenement['eve_label_url'] . '/' . md5($arrDon[1]['pec_id']); } } // Confirmation commande NEW - BEGIN $body = fxGetMailFormat(true, true, true, false, $strLangue); $body = str_replace('%nom_evenement%', fxUnescape($arrEvenement['eve_nom_' . $strLangue]), $body); $body = str_replace('%logo_evenement%', $vDomaine . $vRepertoireFichiers . '/images/evenements/' . $arrEvenement['eve_logo_facture_' . $strLangue], $body); $body = str_replace('%web_evenement%', '' . $arrEvenement['eve_siteweb'] . '', $body); $body = str_replace('%contact_evenement%', '' . $arrEvenement['eve_contact'] . '', $body); $body = str_replace('%attachment_url%', $attachment_url, $body); $body = str_replace('%attachment_label%', $attachment_label, $body); $body = str_replace('%to_mail%', $to_mail, $body); $body = str_replace('%subject%', $subject, $body); $body = str_replace('%message%', $strDetails, $body); // Confirmation commande NEW - END fxSendMail($subject, $body, $to_mail, $to_name, $from_mail, $from_name, true, 1, 0); return true; } /** * Récupère les infos du receveur de don d'une épreuve donnée * @author Jean-Sébastien Proulx * @version 1.0 * @param integer $intEpreuveCommandee id de l'épreuve commandée * @param integer $intParticipant id du participant * @return null or array */ function fxGetReceveur($intEpreuveCommandee = 0, $intParticipant = 0) { global $objDatabase; $arrOutput = null; if ($intParticipant != 0) { $sqlReceveur = "SELECT par_nom, par_prenom, par_courriel, eve_id, pec_id FROM resultats_participants WHERE pec_id = " . intval($intEpreuveCommandee) . " AND par_id_original = " . intval($intParticipant); } else { $sqlReceveur = "SELECT par_nom, par_prenom, par_courriel, eve_id, pec_id, par_nom_equipe FROM resultats_participants WHERE rol_id = 1 AND pec_id = " . intval($intEpreuveCommandee); } $arrOutput = $objDatabase->fxGetRow($sqlReceveur); return $arrOutput; } function fxGetParticipantSolo($intEpreuveCommandee) { global $objDatabase; $intParticipant = ''; $sqlEpreuvesParticipants = "SELECT * FROM resultats_participants WHERE is_cancelled = 0 AND MD5(pec_id) = '" . $intEpreuveCommandee . "'"; $arrEpreuvesParticipants = $objDatabase->fxGetResults($sqlEpreuvesParticipants); if ($arrEpreuvesParticipants != null && count($arrEpreuvesParticipants) == 1) { $intParticipant = md5($arrEpreuvesParticipants[1]['par_id_original']); } return $intParticipant; }