529 lines
27 KiB
PHP
529 lines
27 KiB
PHP
<?php #dons2017 #MSIN-1987
|
|
|
|
// patch a corrigé ne pas enlever
|
|
error_reporting(0);
|
|
/**
|
|
* Crée un tableau de tous les liens de donation
|
|
* @author Jean-Sébastien Proulx
|
|
* @version 1.0
|
|
* @param string $strNoPanier Numéro de pannier
|
|
* @return null or array
|
|
*/
|
|
function fxGetLinksDonation($strNoPanier, $strLangue) {
|
|
global $objDatabase, $vtexte_page;
|
|
$arrOutput = null;
|
|
$vtexte_page = obtenirTextepage("global", $strLangue, 2);
|
|
if (trim($strNoPanier) != '') { // vérifier si le panier est lié à un événement de donation
|
|
$sqlDonation = "SELECT * FROM inscriptions_evenements WHERE eve_id IN(SELECT eve_id FROM inscriptions_panier_acheteurs WHERE no_panier = '" . $objDatabase->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 .= '
|
|
<br>
|
|
<table class="table" style="font-size: 1em; width: 100%;">
|
|
<tbody>
|
|
<tr style="background: #' . $strColor . '; color: #fff; padding: 0.5rem;">
|
|
<th style="font-weight: bold; text-align: left; padding: 0.5rem;">
|
|
' . afficheTexte('don_facture_header', 0, 0, 1) . '
|
|
</th>
|
|
</tr>
|
|
<tr style="font-weight: bold; padding: 0.5rem; text-align: left;">
|
|
<td>
|
|
<p>' . afficheTexte('don_facture_texte', 0, 0, 1) . '</p>
|
|
';
|
|
|
|
foreach ($arrLinksDonation as $arrLinks) {
|
|
foreach ($arrLinks as $arrData) {
|
|
switch ($strType) {
|
|
case 'mail':
|
|
$strOutput .= '
|
|
<p><a href="' . $strLink . $arrData['link'] . '">' . $strLabel . '</a> <strong>' . $arrData['label'] . '</strong></p>
|
|
';
|
|
break;
|
|
case 'web':
|
|
default:
|
|
$strOutput .= '
|
|
<p><a href="' . $strLink . $arrData['link'] . '">' . $strLabel . '</a> <strong>' . $arrData['label'] . '</strong></p>
|
|
';
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
$strOutput .= '
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<br>
|
|
';
|
|
}
|
|
|
|
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 .= '
|
|
<dt class="col-6 text-right">' . fxUnescape($strQuestion['que_don_label_' . $strLangue]) . '</dt>
|
|
<dd class="col-6">' . fxUnescape($strQuestion['que_choix_' . $strLangue]) . '</dd>
|
|
';
|
|
}
|
|
}
|
|
|
|
if (isset($arrDonation['participant'])) {
|
|
$strOutput = '
|
|
<dl class="row">
|
|
<dt class="col-6 text-right">' . $strNomParticipant . '</dt>
|
|
<dd class="col-6">' . fxUnescape($arrDonation['participant']['par_prenom']) . ' ' . fxUnescape($arrDonation['participant']['par_nom']) . '</dd>
|
|
' . $strQuestions . '
|
|
</dl>
|
|
';
|
|
$fltObjectif = floatval($arrDonation['participant']['epr_objectif_dons']);
|
|
$fltMontantAmasse = floatval($arrDonation['participant']['montant_amasse']);
|
|
} elseif (isset($arrDonation['equipe']) && $arrDonation['equipe']['pec_equipe'] == 1) {
|
|
$strOutput = '
|
|
<dl class="row">
|
|
<dt class="col-6 text-right">' . $strNomEquipe . '</dt>
|
|
<dd class="col-6">' . fxUnescape($arrDonation['equipe']['pec_nom_equipe']) . '</dd>
|
|
' . $strQuestions . '
|
|
</dl>
|
|
';
|
|
$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 .= '
|
|
<div class="table-responsive">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th class="text-left">' . afficheTexte('objectif_dons_equipe', 0) . '</th>
|
|
<th class="text-right">' . afficheTexte('objectif_dons_montant_actuel', 0) . '</th>
|
|
<th>' . afficheTexte('objectif_dons_montant_original', 0) . '</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td class="text-left">' . fxUnescape($recEpreuvesCommandees['pec_nom_equipe']) . '</td>
|
|
<td class="text-right">
|
|
<form class="form-inline justify-content-end" action="' . $vDomaine . '/ajax_donation.php' . '" id="frm_donation_e' . $pec_id . '">
|
|
<input type="hidden" name="pec_id" value="' . $pec_id . '">
|
|
<input type="hidden" name="objectif_avant" value="' . $recEpreuvesCommandees['epr_objectif_dons_original'] . '">
|
|
<input type="hidden" name="lang" value="' . $strLangue . '">
|
|
<input class="form-control form-control-sm rounded-0" style="text-align: right;" type="number" name="montant" step="5" min="' . $recEpreuvesCommandees['epr_objectif_dons_original'] . '" value="' . $recEpreuvesCommandees['epr_objectif_dons'] . '">
|
|
<button class="btn_obj_don btn btn-sm btn-primary rounded-0" type="submit" title="' . afficheTexte('objectif_dons_bouton_tooltip', 0) . '">OK</button>
|
|
</form>
|
|
</td>
|
|
<td class="text-right">' . fxShowPrix($recEpreuvesCommandees['epr_objectif_dons_original'], $strLangue) . '</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
';
|
|
}
|
|
|
|
// 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 .= '
|
|
<div class="table-responsive">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th class="text-left">' . afficheTexte('objectif_dons_participant', 0) . '</th>
|
|
<th class="text-right">' . afficheTexte('objectif_dons_montant_actuel', 0) . '</th>
|
|
<th class="text-right">' . afficheTexte('objectif_dons_montant_original', 0) . '</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
';
|
|
for ($intCtr3 = 1; $intCtr3 <= count($arrEpreuvesParticipants); $intCtr3++) {
|
|
$arrForms[$pec_id][] = 'frm_donation_p' . $arrEpreuvesParticipants[$intCtr3]['par_id'];
|
|
$strHTML .= '
|
|
<tr>
|
|
<td class="text-left">' . fxUnescape($arrEpreuvesParticipants[$intCtr3]['par_nom']) . ', ' . fxUnescape($arrEpreuvesParticipants[$intCtr3]['par_prenom']) . '</td>
|
|
<td class="text-right">
|
|
<form class="form-inline justify-content-end" action="' . $vDomaine . '/ajax_donation.php' . '" id="frm_donation_p' . $arrEpreuvesParticipants[$intCtr3]['par_id'] . '">
|
|
<input type="hidden" name="par_id" value="' . $arrEpreuvesParticipants[$intCtr3]['par_id'] . '">
|
|
<input type="hidden" name="objectif_avant" value="' . $arrEpreuvesParticipants[$intCtr3]['epr_objectif_dons_original'] . '">
|
|
<input type="hidden" name="lang" value="' . $strLangue . '">
|
|
<input class="form-control form-control-sm rounded-0" style="text-align: right;" type="number" name="montant" step="5" min="' . $arrEpreuvesParticipants[$intCtr3]['epr_objectif_dons_original'] . '" value="' . $arrEpreuvesParticipants[$intCtr3]['epr_objectif_dons'] . '" required>
|
|
<button class="btn_obj_don btn btn-sm btn-primary rounded-0" type="submit" title="' . afficheTexte('objectif_dons_bouton_tooltip', 0) . '">OK</button>
|
|
</form>
|
|
</td>
|
|
<td class="text-right">' . fxShowPrix($arrEpreuvesParticipants[$intCtr3]['epr_objectif_dons_original'], $strLangue) . '</td>
|
|
</tr>
|
|
';
|
|
}
|
|
|
|
$strHTML .= '
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
';
|
|
}
|
|
|
|
$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 .= '<p><strong>Montant:</strong> ' . fxShowPrix($arrDon[1]['pd_montant'], $strLangue) . '</p>';
|
|
$strDetails .= '<p><strong>Date:</strong> ' . fxShowDate($arrAcheteur['ach_maj'], $strLangue) . '</p>';
|
|
$strDetails .= '<p><strong>Donateur:</strong> ' . $from_name . '</p>';
|
|
$strDetails .= '<p><strong>Courriel:</strong> ' . $from_mail . '</p>';
|
|
$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 .= '<p><strong>Amount:</strong> ' . fxShowPrix($arrDon[1]['pd_montant'], $strLangue) . '</p>';
|
|
$strDetails .= '<p><strong>Date:</strong> ' . fxShowDate($arrAcheteur['ach_maj'], $strLangue) . '</p>';
|
|
$strDetails .= '<p><strong>Donor:</strong> ' . $from_name . '</p>';
|
|
$strDetails .= '<p><strong>Email:</strong> ' . $from_mail . '</p>';
|
|
$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 .= '<p><strong>Équipe:</strong> ' . fxUnescape($arrReceveur['par_nom_equipe']) . '</p>';
|
|
$strDetails .= '<p><strong>Montant:</strong> ' . fxShowPrix($arrDon[1]['pd_montant'], $strLangue) . '</p>';
|
|
$strDetails .= '<p><strong>Date:</strong> ' . fxShowDate($arrAcheteur['ach_maj'], $strLangue) . '</p>';
|
|
$strDetails .= '<p><strong>Donateur:</strong> ' . $from_name . '</p>';
|
|
$strDetails .= '<p><strong>Courriel:</strong> ' . $from_mail . '</p>';
|
|
$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 .= '<p><strong>Team:</strong> ' . fxUnescape($arrReceveur['par_nom_equipe']) . '</p>';
|
|
$strDetails .= '<p><strong>Amount:</strong> ' . fxShowPrix($arrDon[1]['pd_montant'], $strLangue) . '</p>';
|
|
$strDetails .= '<p><strong>Date:</strong> ' . fxShowDate($arrAcheteur['ach_maj'], $strLangue) . '</p>';
|
|
$strDetails .= '<p><strong>Donor:</strong> ' . $from_name . '</p>';
|
|
$strDetails .= '<p><strong>Email:</strong> ' . $from_mail . '</p>';
|
|
$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%', '<a href="' . $arrEvenement['eve_siteweb'] . '" target="_blank">' . $arrEvenement['eve_siteweb'] . '</a>', $body);
|
|
$body = str_replace('%contact_evenement%', '<a href="mailto:' . $arrEvenement['eve_contact'] . '" target="_blank">' . $arrEvenement['eve_contact'] . '</a>', $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;
|
|
} |