fxEscape($strNoPanier) . "', '" . fxGetDateTime() . "', 1, '" . $strLangue . "', '" . $_SERVER['REMOTE_ADDR'] . "', " . intval($intEvenement) . ")";
$qryInsert = $objDatabase->fxQuery($sqlInsert);
if ($intCompte != 0) { // si le client est loggé, entrer ses infos comme acheteur
fxMajCopieParticipantAcheteurCompte($strNoPanier, $intCompte);
}
} else {
$strNoPanier = $_SESSION['no_panier'];
}
return $strNoPanier;
}
// fonction qui vérifie si l'événement fait déjà partie du panier et retourner le pan_id
// param : no panier, infos de l'événement
// créé : 2013-04-11
function fxCheckEvenement($strNoPanier, $intEvenement)
{
global $objDatabase;
// $sqlCheck = "SELECT pan_id FROM inscriptions_panier_evenements WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND eve_id = " . intval($intEvenement);
$sqlCheck = "SELECT pan_id FROM inscriptions_panier_evenements WHERE eve_id = " . intval($intEvenement) . " ORDER BY pan_id LIMIT 1";
$intPanierEvenement = $objDatabase->fxGetVar($sqlCheck);
// insérer l'événénement dans le panier s'il n'est pas présent
$sqlEvenement = "SELECT e.*, s.ser_nom_fr, s.ser_nom_en FROM inscriptions_evenements e LEFT JOIN inscriptions_series s ON s.ser_id = e.ser_id WHERE e.eve_id = " . intval($intEvenement);
$recEvenement = $objDatabase->fxGetRow($sqlEvenement);
// sauvegarder le code de l'événement dans la session
if (!isset($_SESSION['eve_label_url']))
$_SESSION['eve_label_url'] = $recEvenement['eve_label_url'];
if ($intPanierEvenement == NULL) {
if ($recEvenement != null) {
$sqlInsert = "INSERT INTO inscriptions_panier_evenements SET pan_maj = '" . fxGetDateTime() . "', eve_id = " . intval($intEvenement) . ", ser_id = " . intval($recEvenement['ser_id']) . ", ser_nom_fr = '" . $objDatabase->fxEscape($recEvenement['ser_nom_fr']) . "', ser_nom_en = '" . $objDatabase->fxEscape($recEvenement['ser_nom_en']) . "', eve_nom_fr = '" . $objDatabase->fxEscape($recEvenement['eve_nom_fr']) . "', eve_nom_en = '" . $objDatabase->fxEscape($recEvenement['eve_nom_en']) . "', eve_date_debut = '" . $objDatabase->fxEscape($recEvenement['eve_date_debut']) . "', eve_date_fin = '" . $objDatabase->fxEscape($recEvenement['eve_date_fin']) . "', eve_trousses_fr = '" . $objDatabase->fxEscape($recEvenement['eve_trousses_fr']) . "', eve_trousses_en = '" . $objDatabase->fxEscape($recEvenement['eve_trousses_en']) . "', eve_photo_fr = '" . $objDatabase->fxEscape($recEvenement['eve_photo_fr']) . "', eve_photo_en = '" . $objDatabase->fxEscape($recEvenement['eve_photo_en']) . "', eve_siteweb = '" . $objDatabase->fxEscape($recEvenement['eve_siteweb']) . "', eve_prive = '" . $objDatabase->fxEscape($recEvenement['eve_prive']) . "', eve_facture_fr = '" . $objDatabase->fxEscape($recEvenement['eve_facture_fr']) . "', eve_facture_en = '" . $objDatabase->fxEscape($recEvenement['eve_facture_en']) . "', eve_paypal = " . intval($recEvenement['eve_paypal']) . ", eve_frais = " . intval($recEvenement['eve_frais']) . ", tt_id = " . intval($recEvenement['tt_id']) . ", eve_msg_approbation_fr = '" . $objDatabase->fxEscape($recEvenement['eve_msg_approbation_fr']) . "', eve_msg_approbation_en = '" . $objDatabase->fxEscape($recEvenement['eve_msg_approbation_en']) . "', eve_couleur = '" . $objDatabase->fxEscape($recEvenement['eve_couleur']) . "', eve_gratuit = " . intval($recEvenement['eve_gratuit']);
$qryInsert = $objDatabase->fxQuery($sqlInsert);
// récupérer le id ajouté
$intPanierEvenement = $objDatabase->fxGetLastId();
}
}
return $intPanierEvenement;
}
function fxGenererNotes($tableau, $cleFr, $cleEn, $maxLength = 1000)
{
$noteFr = '';
$noteEn = '';
foreach ($tableau as $ligne) {
/* ======================
Français
====================== */
if (!empty($ligne[$cleFr])) {
$ajout = ($noteFr === '' ? '' : ' / ') . $ligne[$cleFr];
if (mb_strlen($noteFr . $ajout, 'UTF-8') <= $maxLength) {
$noteFr .= $ajout;
} else {
break;
}
}
/* ======================
Anglais
====================== */
if (!empty($ligne[$cleEn])) {
$ajout = ($noteEn === '' ? '' : ' / ') . $ligne[$cleEn];
if (mb_strlen($noteEn . $ajout, 'UTF-8') <= $maxLength) {
$noteEn .= $ajout;
}
}
}
return [
'note_fr' => $noteFr,
'note_en' => $noteEn
];
}
function fxCheckEpreuve($intPanierEvenement, $intEpreuve)
{
global $objDatabase;
$sqlCheck = "SELECT pep_id FROM inscriptions_panier_epreuves WHERE epr_id = " . intval($intEpreuve) . " ORDER BY pan_id LIMIT 1";
$intPanierEpreuve = $objDatabase->fxGetVar($sqlCheck);
if ($intPanierEpreuve == NULL) {
// insérer l'épreuve dans le panier si elle n'est pas présente
$sqlEpreuve = "SELECT * FROM inscriptions_epreuves WHERE epr_id = " . intval($intEpreuve);
$recEpreuve = $objDatabase->fxGetRow($sqlEpreuve);
if ($recEpreuve != null) { // NOTE: nouvraux champs épreuve #NCEPR
$sqlInsert = "INSERT INTO inscriptions_panier_epreuves SET pan_id = " . intval($intPanierEvenement) . ", pep_maj = '" . fxGetDateTime() . "', epr_id = " . intval($intEpreuve) . ", tep_id = " . intval($recEpreuve['tep_id']) . ", epr_type_fr = '" . $objDatabase->fxEscape($recEpreuve['epr_type_fr']) . "', epr_type_en = '" . $objDatabase->fxEscape($recEpreuve['epr_type_en']) . "', epr_nom_fr = '" . $objDatabase->fxEscape($recEpreuve['epr_nom_fr']) . "', epr_nom_en = '" . $objDatabase->fxEscape($recEpreuve['epr_nom_en']) . "', epr_description_fr = '" . $objDatabase->fxEscape($recEpreuve['epr_description_fr']) . "', epr_description_en = '" . $objDatabase->fxEscape($recEpreuve['epr_description_en']) . "', epr_date = '" . $objDatabase->fxEscape($recEpreuve['epr_date']) . "', epr_heure = '" . $objDatabase->fxEscape($recEpreuve['epr_heure']) . "', epr_taxes_incluses = " . intval($recEpreuve['epr_taxes_incluses']) . ", epr_equipe = " . intval($recEpreuve['epr_equipe']) . ", epr_nb_participants = " . intval($recEpreuve['epr_nb_participants']) . ", epr_categorie_fr = '" . $objDatabase->fxEscape($recEpreuve['epr_categorie_fr']) . "', epr_categorie_en = '" . $objDatabase->fxEscape($recEpreuve['epr_categorie_en']) . "', epr_code = '" . $objDatabase->fxEscape($recEpreuve['epr_code']) . "', epr_tandem = " . intval($recEpreuve['epr_tandem']) . ", epr_qte_limitee = " . intval($recEpreuve['epr_qte_limitee']) . ", epr_nb_camping = " . intval($recEpreuve['epr_nb_camping']) . ", epr_nb_benevole = " . intval($recEpreuve['epr_nb_benevole']) . ", epr_nb_pit_manager = " . intval($recEpreuve['epr_nb_pit_manager']) . ", epr_nb_participants_min = " . intval($recEpreuve['epr_nb_participants_min']) . ", epr_invitation = " . intval($recEpreuve['epr_invitation']) . ", epr_sexe = '" . $recEpreuve['epr_sexe'] . "', epr_genere_don = " . intval($recEpreuve['epr_genere_don']) . ", epr_montant_min_don = " . floatval($recEpreuve['epr_montant_min_don']) . ", mt_id = " . intval($recEpreuve['mt_id']) . ", mst_id = " . intval($recEpreuve['mst_id']);
$qryInsert = $objDatabase->fxQuery($sqlInsert);
// récupérer le id ajouté
$intPanierEpreuve = $objDatabase->fxGetLastId();
}
}
return $intPanierEpreuve;
}
// fonction qui ajoute, modifie ou supprime un item du panier (JSP)
// param : action (add/mod/del), tableau contenant les infos de l'événement, données POST, langue
// créé : 2013-04-17
function fxSetPanier($strAction, $tabEvenement, $tabData, $tabFiles, $strLangue, $intpec_id = 0, $intquestechue = 0)
{
global $objDatabase, $vDomaine;
//error_reporting(E_ALL);
//ini_set("display_errors", 1);
// mettre le no de compte si existant
if (isset($_SESSION['com_id']))
$intCompte = $_SESSION['com_id'];
else
$intCompte = 0;
// vérifier l'action demandée
switch ($strAction) {
case 'add':
case 'auto':
// AJOUT AU PANIER
if (isset($_SESSION['no_panier'])) {
// mettre a jour le eve_id dans le panier si on vient d'un événement abonnement
$mem_panierinfo = fxNbItemsPanier($_SESSION['no_panier']);
if (intval($tabEvenement['general']['eve_id_membership']) == intval($mem_panierinfo['eve_id'])) {
$sqlUpdate = "UPDATE inscriptions_panier_acheteurs SET eve_id = " . intval($tabEvenement['general']['eve_id']) . " WHERE no_panier = '" . $objDatabase->fxEscape($_SESSION['no_panier']) . "'";
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
}
}
// vérifier si un panier existe déjà
$strNoPanier = fxNumPanier($tabEvenement['general']['eve_id'], $strLangue);
// Ajout d'une épreuve avec ou sans participant
if (isset($tabData['epr_id'])) {
// trouver les infos de l'épreuve
$tabEpreuve = fxGetEpreuve($tabData['epr_id']);
$strNomEquipe = '';
$mem_tq_temp = 0;
if (isset($tabData['TQ_numero'])) {
if ($tabData['TQ_numero'] <> '') {
$mem_tq_temp = $tabData['TQ_numero'];
}
}
// ajouter l'événement et l'épreuve
$intPanier = fxCheckEvenement($strNoPanier, $tabEvenement['general']['eve_id']);
$intPanierEpreuve = fxCheckEpreuve($intPanier, $tabData['epr_id']);
// trouver le prix de l'épreuve
$tabPrix = fxGetPrixParticipant($tabData['epr_id']);
if ($tabPrix != null) {
$fltPrix = $tabPrix['ep_montant'];
$fltDon = $tabPrix['ep_montant_don'];
$fltFrais = $tabPrix['ep_frais_montant'];
$fltFraisTps = $tabPrix['ep_frais_tps'];
$fltFraisTvq = $tabPrix['ep_frais_tvq'];
$intEpreuvePrix = $tabPrix['ep_id'];
$intCategoriePrix = $tabPrix['cp_id'];
$strCategoriePrixFr = $tabPrix['cp_details_fr'];
$strCategoriePrixEn = $tabPrix['cp_details_en'];
$intPrixParticipant = $tabPrix['ep_prix_participant'];
$intNbParticipantsTotal = 0;
$strCategorieFr = $strCategorieEn = '';
// ajouter numero de membre au panier (sl)
$mem_com_id = $objDatabase->fxEscape($tabData['com_id_1']);
// Ajouter l'épreuve au panie
// NOTE: nouvraux champs épreuve #NCEPR
$sqlInsert = "INSERT INTO inscriptions_panier_epreuves_commandees SET mem_com_id=" . intval($mem_com_id) . ", eve_id = " . intval($tabEvenement['general']['eve_id']) . ", epr_id = " . intval($tabData['epr_id']) . ", no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pec_label = '', pec_nom_equipe = '" . $objDatabase->fxEscape($tabData['par_prenom_1']) . " " . $objDatabase->fxEscape($tabData['par_nom_1']) . "', pec_equipe = " . intval($tabEpreuve['epr_equipe']) . ", pec_prix = " . floatval($fltPrix) . ", par_frais_montant = " . floatval($fltFrais) . ", par_frais_tps = " . floatval($fltFraisTps) . ", par_frais_tvq = " . floatval($fltFraisTvq) . ", ep_id = " . intval($intEpreuvePrix) . ", ep_prix_participant = " . intval($intPrixParticipant) . ", cp_id = " . intval($intCategoriePrix) . ", cp_details_fr = '" . $objDatabase->fxEscape($strCategoriePrixFr) . "', cp_details_en = '" . $objDatabase->fxEscape($strCategoriePrixEn) . "', com_id = " . intval($intCompte) . ", epr_objectif_dons = " . intval($tabEpreuve['epr_objectif_dons_equipe']) . ", tep_id = " . intval($tabEpreuve['tep_id']) . ", pec_montant_don = " . floatval($fltDon) . ", epr_objectif_distance = " . floatval($tabEpreuve['epr_objectif_distance_equipe']) . ", epr_objectif_temps = '" . floatval($tabEpreuve['epr_objectif_temps_equipe']) . "', mt_id = " . intval($tabEpreuve['mt_id']) . ", mst_id = " . intval($tabEpreuve['mst_id']) . ", pec_membership_start = '" . $tabEpreuve['epr_membership_start'] . "', pec_membership_end = '" . $tabEpreuve['epr_membership_end'] . "', tq_temp = " . $mem_tq_temp;
$qryInsert = $objDatabase->fxQuery($sqlInsert);
if (intval($tabEpreuve['tep_id']) == 2 && intval($tabEvenement['general']['te_id']) != 10) {
$_SESSION['last_race'] = 'bénévole';
} else {
$_SESSION['last_race'] = 'race';
}
// récupérer le id ajouté
$intEpreuveCommandee = $objDatabase->fxGetLastId();
$mem_type_transaction="";
fxSetProduitsAuto('add', $tabEvenement['general']['eve_id'], $tabEvenement['general']['eve_id_membership'], $tabData['epr_id'], $strNoPanier, $intEpreuveCommandee,$mem_type_transaction); // Ajouter les produits automatiques
// Insérer les questions de l'épreuve
// sortir les questions de l'épreuve
$tabQuestions = fxGetQuestions('epr', $tabEvenement['general']['eve_id'], $tabData['epr_id'], 'mod', 0, $intquestechue); // récupérer les questions à demander pour l'épreuve
// insérer les réponses des questions
$arrCategorie = fxSetQuestions('add', $tabQuestions, $tabData, $tabFiles, $strNoPanier, $intEpreuveCommandee, 0, 0, $strLangue);
if (trim($arrCategorie['categorie_fr']) != '') {
$strCategorieFr = $arrCategorie['categorie_fr'];
$strCategorieEn = $arrCategorie['categorie_en'];
}
// Ajout sans participant
if ($strAction == 'add' && $tabEpreuve['epr_invitation'] == 1) {
$intInvitation = 1;
if ($tabData['sel_participant'] == 1)
$intNbParticipants = $intNbParticipantsMin = 1;
else
$intNbParticipants = $intNbParticipantsMin = 0;
} else { // Inscription normal
$intInvitation = 0;
$intNbParticipants = $tabEpreuve['epr_nb_participants'];
$intNbParticipantsMin = $tabEpreuve['epr_nb_participants_min'];
}
$tabParticipants = array();
$intNoEquipe = 0;
// Boucle parmi le nb de participants
for ($intCtr = 1; $intCtr <= $intNbParticipants; $intCtr++) {
// vérifier que les champs obligatoires ne sont pas vide
if (trim($tabData['par_prenom_' . $intCtr]) != '' && trim($tabData['par_nom_' . $intCtr]) != '') {
// AJOUTER LE PARTICIPANT
// initialiser les variables
$strNaissance = '0000-00-00';
$intProvince = $intPays = 0;
$strAdresse = $strAdresse2 = $strVille = $strCodepostal = $strTelephone1 = $strTelephone2 = $strCourriel = $strUrgenceNom = $strUrgenceTel = '';
// vérifier si champs existant
if (isset($tabData['par_naissance_' . $intCtr]))
$strNaissance = $tabData['par_naissance_' . $intCtr];
if (isset($tabData['pro_id_' . $intCtr]))
$intProvince = $tabData['pro_id_' . $intCtr];
if (isset($tabData['h-pro_id_' . $intCtr]))
$intProvince = $tabData['h-pro_id_' . $intCtr];
if (isset($tabData['pay_id_' . $intCtr]))
$intPays = $tabData['pay_id_' . $intCtr];
if (isset($tabData['h-pay_id_' . $intCtr]))
$intPays = $tabData['h-pay_id_' . $intCtr];
if (isset($tabData['par_adresse_' . $intCtr]))
$strAdresse = $tabData['par_adresse_' . $intCtr];
if (isset($tabData['par_adresse2_' . $intCtr]))
$strAdresse2 = $tabData['par_adresse2_' . $intCtr];
if (isset($tabData['par_ville_' . $intCtr]))
$strVille = $tabData['par_ville_' . $intCtr];
if (isset($tabData['par_telephone1_' . $intCtr]))
$strTelephone1 = $tabData['par_telephone1_' . $intCtr];
if (isset($tabData['par_telephone2_' . $intCtr]))
$strTelephone2 = $tabData['par_telephone2_' . $intCtr];
if (isset($tabData['par_courriel_' . $intCtr]))
$strCourriel = $tabData['par_courriel_' . $intCtr];
if (isset($tabData['par_contact_urgence_nom_' . $intCtr]))
$strUrgenceNom = $tabData['par_contact_urgence_nom_' . $intCtr];
if (isset($tabData['par_contact_urgence_telephone_' . $intCtr]))
$strUrgenceTel = $tabData['par_contact_urgence_telephone_' . $intCtr];
// trouver l'âge du participant
$intAge = fxGetAge($strNaissance, $tabEpreuve['epr_date_age']);
$strPostSexe = $objDatabase->fxEscape($tabData['par_sexe_' . $intCtr]);
// insérer les infos du participants
$sqlInsert = "INSERT INTO inscriptions_panier_participants SET eve_id = " . intval($tabEvenement['general']['eve_id']) . ", epr_id = " . intval($tabData['epr_id']) . ", pec_id = " . intval($intEpreuveCommandee) . ", rol_id = " . intval($tabData['rol_id_' . $intCtr]) . ", no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', par_prenom = '" . ucfirst($objDatabase->fxEscape($tabData['par_prenom_' . $intCtr])) . "', par_nom = '" . ucfirst($objDatabase->fxEscape($tabData['par_nom_' . $intCtr])) . "', par_naissance = '" . $objDatabase->fxEscape($strNaissance) . "', par_sexe = '" . $strPostSexe . "', par_codepostal = '" . strtoupper($objDatabase->fxEscape($tabData['par_codepostal_' . $intCtr])) . "', par_courriel = '" . strtolower($objDatabase->fxEscape($strCourriel)) . "', par_langue = '" . $objDatabase->fxEscape($strLangue) . "', par_prix = " . floatval($fltPrix) . ", pep_id = " . intval($intPanierEpreuve) . ", par_age = " . intval($intAge) . ", par_complet = 1, par_maj = '" . fxGetDateTime() . "', par_frais_montant = " . floatval($fltFrais) . ", par_frais_tps = " . floatval($fltFraisTps) . ", par_frais_tvq = " . floatval($fltFraisTvq) . ", ep_id = " . intval($intEpreuvePrix) . ", cp_id = " . intval($intCategoriePrix) . ", cp_details_fr = '" . $strCategoriePrixFr . "', cp_details_en = '" . $strCategoriePrixEn . "', com_id = " . intval($intCompte) . ", par_adresse = '" . ucwords($objDatabase->fxEscape($strAdresse)) . "', par_adresse2 = '" . ucwords($objDatabase->fxEscape($strAdresse2)) . "', par_ville = '" . ucwords($objDatabase->fxEscape($strVille)) . "', pro_id = " . intval($intProvince) . ", pay_id = " . intval($intPays) . ", par_telephone1 = '" . $objDatabase->fxEscape($strTelephone1) . "', par_telephone2 = '" . $objDatabase->fxEscape($strTelephone2) . "', epr_objectif_dons = " . intval($tabEpreuve['epr_objectif_dons_participant']) . ", epr_objectif_distance = " . floatval($tabEpreuve['epr_objectif_distance_participant']) . ", epr_objectif_temps = '" . floatval($tabEpreuve['epr_objectif_temps_participant']) . "', par_contact_urgence_nom = '" . $objDatabase->fxEscape($strUrgenceNom) . "', par_contact_urgence_telephone = '" . $objDatabase->fxEscape($strUrgenceTel) . "'";
$qryInsert = $objDatabase->fxQuery($sqlInsert);
$intNbParticipantsTotal++;
// récupérer le id ajouté
$intParticipant = $objDatabase->fxGetLastId();
$tabParticipants[] = $intParticipant;
if ($tabEvenement['general']['eve_categorie_auto'] == 1) {
fxregles_niveau_update(intval($intParticipant), 'inscriptions_panier_participants', 'par_id');
}
// calculer le montant dans panier participants
fxMajRabais($strNoPanier);
if ($intCtr == 1)
$intNoEquipe = $intParticipant;
// AJOUTER LES QUESTIONS
// sortir les questions de l'événement
$tabQuestions = fxGetQuestions('par', $tabEvenement['general']['eve_id'], $tabData['epr_id'], 'mod', 0, $intquestechue); // récupérer les questions à demander aux participants
// insérer les réponses des questions
$arrCategorie = fxSetQuestions('add', $tabQuestions, $tabData, $tabFiles, $strNoPanier, $intEpreuveCommandee, $intParticipant, $intCtr, $strLangue);
if (trim($arrCategorie['categorie_fr']) != '') {
$strCategorieFr = $arrCategorie['categorie_fr'];
$strCategorieEn = $arrCategorie['categorie_en'];
}
// mettre à jour le prix par participant (si cas échéant)
if ($intPrixParticipant == 1 && $intNbParticipantsTotal > 1) {
$sqlUpdate = "UPDATE inscriptions_panier_epreuves_commandees SET pec_prix = " . floatval($fltPrix * $intNbParticipantsTotal) . " WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND pec_id = " . intval($intEpreuveCommandee);
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
}
$_SESSION['date_maj'] = time();
} elseif ($intCtr <= $intNbParticipantsMin) {
// définir le message d'erreur
if ($strLangue == 'fr') {
$strPage = 'reserver';
$_SESSION['msg'] = 'e102';
} else {
$strPage = 'book';
$_SESSION['msg'] = 'e502';
}
header("Location: " . $vDomaine . '/' . $strPage . '/' . $tabEvenement['general']['eve_label_url'] . '/' . $tabData['epr_id']);
exit;
}
}
if ($intNbParticipants > 1 && $strNomEquipe != '') {
$sqlUpdate = "UPDATE inscriptions_panier_participants SET par_no_equipe = " . intval($intNoEquipe) . ", par_equipe = 1, par_nom_equipe = '" . $objDatabase->fxEscape($strNomEquipe) . "' WHERE par_id IN(" . implode(',', $tabParticipants) . ")";
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
}
// mettre à jour la catégorie pour les participants
if (trim($strCategorieFr) != '') {
$sqlUpdate = "UPDATE inscriptions_panier_participants SET par_categorie_1_long_fr = '" . $objDatabase->fxEscape($strCategorieFr) . "', par_categorie_1_long_en = '" . $objDatabase->fxEscape($strCategorieEn) . "', par_categorie_1_court_fr = '" . $objDatabase->fxEscape($strCategorieFr) . "', par_categorie_1_court_en = '" . $objDatabase->fxEscape($strCategorieEn) . "' WHERE par_id IN(" . implode(',', $tabParticipants) . ")";
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
}
//MSIN-4234
$mem_produit_changement="";
// CHANGEMENT D'ÉPREUVE
$mem_type_transaction="";
if ($intpec_id != 0) { // 2016-05-04 - MSIN-1814
$_SESSION['pec_id_old'] = $intpec_id;
$_SESSION['pec_id_new'] = $intEpreuveCommandee;
$_SESSION['no_transfert'] = $tabData['no_transfert'];
// ancien no. panier
$sqlOldPanier = "SELECT no_panier, no_commande FROM resultats_epreuves_commandees WHERE pec_id_original = " . intval($intpec_id);
$tabOldPanier = $objDatabase->fxGetRow($sqlOldPanier);
$_SESSION['ancien_no_panier'] = $tabOldPanier['no_panier'];
if (trim($tabData['no_transfert']) != '') {
//MSIN-4234
$mem_produit_changement=" p.pro_transfert_client=1 and ";
$mem_type_transaction="transfert";
// ajouter le coût du frais pour le transfert d'épreuve
$tabFraisAutres = fxGetFraisAutres('transfert', $tabEvenement['general']['eve_frais'], $tabEvenement['general']['eve_id'], $tabEpreuve['tep_id']);
} else{
//MSIN-4234
$mem_produit_changement="p.pro_switch_epreuve=1 and ";
$mem_type_transaction="modif";
// ajouter le coût du frais pour le switch d'épreuve
$tabFraisAutres = fxGetFraisAutres('switch', $tabEvenement['general']['eve_frais'], $tabEvenement['general']['eve_id'], $tabEpreuve['tep_id']);
}
//MSIN-4276
fxSetProduitsAuto('addtransfert', $tabEvenement['general']['eve_id'], $tabEvenement['general']['eve_id_membership'], $tabData['epr_id'], $strNoPanier, $intEpreuveCommandee,$mem_type_transaction); // Ajouter les produits automatiques
if ($tabFraisAutres != null) {
// insérer le frais dans le panier
$sqlUpdate = "UPDATE inscriptions_panier_acheteurs SET fa_nom_fr = '" . $objDatabase->fxEscape($tabFraisAutres['fa_nom_fr']) . "', fa_nom_en = '" . $objDatabase->fxEscape($tabFraisAutres['fa_nom_en']) . "', fa_montant = " . floatval($tabFraisAutres['fa_montant']) . ", ach_maj = '" . fxGetDateTime() . "' WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
if (!$qryUpdate)
fxcreer_log("Il y a eu une erreur lors du frais autre:\n" . $sqlUpdate);
}
// trouver les prix des produits
// MSIN-4173
//$sqlproduits = "SELECT SUM(pro_prix) AS total
// FROM inscriptions_panier_produits_new
// WHERE no_panier = '" . $_SESSION['ancien_no_panier'] . "'";
// pas tq taxable
$sqlproduits = "SELECT SUM(pp.pro_prix) AS total
FROM inscriptions_panier_produits_new pp LEFT JOIN inscriptions_produits_new p on p.pro_id = pp.pro_id
WHERE ". $mem_produit_changement." pp.no_panier = '" . $_SESSION['ancien_no_panier'] . "' AND pp.pro_taxable=1 AND pp.eve_id!=649 AND (p.pro_date_limite IS NULL OR p.pro_date_limite = '0000-00-00' OR p.pro_date_limite >= CURDATE())
";
//MSIN-4234 ajout p.pro_switch_epreuve=1 and p.pro_transfert_client=1 and
$fltproduits_taxable = $objDatabase->fxGetVar($sqlproduits);
//MSIN-4316
// pour notes
$sqlproduits_tab = "SELECT *
FROM inscriptions_panier_produits_new pp LEFT JOIN inscriptions_produits_new p on p.pro_id = pp.pro_id
WHERE ". $mem_produit_changement." pp.no_panier = '" . $_SESSION['ancien_no_panier'] . "' AND pp.pro_taxable=1 AND pp.eve_id!=649 AND (p.pro_date_limite IS NULL OR p.pro_date_limite = '0000-00-00' OR p.pro_date_limite >= CURDATE())
";
$fltproduits_taxable_tab=$objDatabase->fxGetResults($sqlproduits_tab);
$result = fxGenererNotes($fltproduits_taxable_tab, 'pro_nom_fr', 'pro_nom_en');
$fltproduits_taxable_note_fr = $result['note_fr'];
$fltproduits_taxable_note_en = $result['note_en'];
// pas tq
$sqlproduits = "SELECT SUM(pp.pro_prix) AS total
FROM inscriptions_panier_produits_new pp LEFT JOIN inscriptions_produits_new p on p.pro_id = pp.pro_id
WHERE ". $mem_produit_changement." pp.no_panier = '" . $_SESSION['ancien_no_panier'] . "' AND pp.pro_taxable=0 AND pp.eve_id!=649 AND (p.pro_date_limite IS NULL OR p.pro_date_limite = '0000-00-00' OR p.pro_date_limite >= CURDATE())
";
//MSIN-4234 ajout p.pro_switch_epreuve=1 and p.pro_transfert_client=1 and
$fltproduits = $objDatabase->fxGetVar($sqlproduits);
//MSIN-4316
// pour notes
$sqlproduits_tab = "SELECT *
FROM inscriptions_panier_produits_new pp LEFT JOIN inscriptions_produits_new p on p.pro_id = pp.pro_id
WHERE ". $mem_produit_changement." pp.no_panier = '" . $_SESSION['ancien_no_panier'] . "' AND pp.pro_taxable=0 AND pp.eve_id!=649 AND (p.pro_date_limite IS NULL OR p.pro_date_limite = '0000-00-00' OR p.pro_date_limite >= CURDATE())
";
$fltproduits_tab=$objDatabase->fxGetResults($sqlproduits_tab);
$result = fxGenererNotes($fltproduits_tab, 'pro_nom_fr', 'pro_nom_en');
$fltproduits_note_fr = $result['note_fr'];
$fltproduits_note_en = $result['note_en'];
///// tq ancien
$sqlproduitstq = "SELECT SUM(pp.pro_prix) AS total
FROM inscriptions_panier_produits_new pp LEFT JOIN inscriptions_produits_new p on p.pro_id = pp.pro_id
WHERE ". $mem_produit_changement." pp.no_panier = '" . $_SESSION['ancien_no_panier'] . "' AND pp.eve_id = 649 AND (p.pro_date_limite IS NULL OR p.pro_date_limite = '0000-00-00' OR p.pro_date_limite >= CURDATE())
";
//MSIN-4234 ajout p.pro_switch_epreuve=1 and p.pro_transfert_client=1 and
$fltproduitstq = $objDatabase->fxGetVar($sqlproduitstq);
///// tq nouneau
$sqlproduitstqnew = "SELECT SUM(pp.pro_prix) AS total
FROM inscriptions_panier_produits_new pp LEFT JOIN inscriptions_produits_new p on p.pro_id = pp.pro_id
WHERE pp.no_panier = '" . $strNoPanier . "' AND pp.eve_id = 649 AND (p.pro_date_limite IS NULL OR p.pro_date_limite = '0000-00-00' OR p.pro_date_limite >= CURDATE())
";
$fltproduitstqnew = $objDatabase->fxGetVar($sqlproduitstqnew);
$tabProduitsExpires = array();
$strWhere = '';
// get prices
// AVANT MSIN-3724 // $sqlRabais = "SELECT (e.pec_prix - e.rab_montant) + COALESCE(SUM(p.pro_prix), 0) AS total FROM inscriptions_panier_epreuves_commandees e, inscriptions_panier_produits_new p WHERE e.pec_id = p.pec_id AND e.pec_upgraded = 0 AND e.pec_id = " . intval($intpec_id) . $strWhere;
$sqlRabais = "
SELECT (e.pec_prix - e.rab_montant) AS total
FROM inscriptions_panier_epreuves_commandees e
WHERE e.no_panier = '" . $strNoPanier . "'";;
$fltevetot = $objDatabase->fxGetVar($sqlRabais);
// MSIN-4218
//if ($tabEvenement['general']['eve_epreuve_transfert_client_sansfrais']) {
// MSIN-4233
if ($tabEvenement['general']['eve_epreuve_transfert_client_sansfrais'] && trim($tabData['no_transfert']) != '') {
// if (1==2) {
// get prices
// AVANT MSIN-3724 // $sqlRabais = "SELECT (e.pec_prix - e.rab_montant) + COALESCE(SUM(p.pro_prix), 0) AS total FROM inscriptions_panier_epreuves_commandees e, inscriptions_panier_produits_new p WHERE e.pec_id = p.pec_id AND e.pec_upgraded = 0 AND e.pec_id = " . intval($intpec_id) . $strWhere;
$sqltrouveRabais = "SELECT *
FROM inscriptions_panier_epreuves_commandees e
WHERE e.pec_upgraded = 0 AND e.pec_id = " . intval($intpec_id);
$trouve = $objDatabase->fxGetRow($sqltrouveRabais);
$mem_epr_id = $trouve["epr_id"];
$sqlRabais = "
SELECT (e.pec_prix - e.rab_montant) AS total
FROM inscriptions_panier_epreuves_commandees e
WHERE e.epr_id = " . intval($mem_epr_id) . " and e.no_panier = '" . $strNoPanier . "'";;
$fltRabais = $objDatabase->fxGetVar($sqlRabais);
//MSIN-4316
// pour notes
$sqlproduits_tab = "select *
FROM inscriptions_panier_epreuves_commandees e
LEFT JOIN inscriptions_panier_epreuves ee ON e.epr_id = ee.epr_id
WHERE e.epr_id = " . intval($mem_epr_id). " and e.no_panier = '" . $strNoPanier . "'";;
$fltproduits_tab=$objDatabase->fxGetResults($sqlproduits_tab);
$result = fxGenererNotes($fltproduits_tab, 'epr_type_fr', 'epr_type_en');
$fltRabais_note_fr = $result['note_fr'];
$fltRabais_note_en = $result['note_en'];
// 🔥 Nouvelle partie — aller chercher la VRAIE valeur des taxes
$sqlTaxes = "
SELECT ee.epr_taxes_incluses
FROM inscriptions_panier_epreuves_commandees e
LEFT JOIN inscriptions_panier_epreuves ee ON e.epr_id = ee.epr_id
WHERE e.pec_upgraded = 0
AND e.pec_id = " . intval($intpec_id);
$taxes_incluses = $objDatabase->fxGetVar($sqlTaxes);
} else {
// get prices
// AVANT MSIN-3724 // $sqlRabais = "SELECT (e.pec_prix - e.rab_montant) + COALESCE(SUM(p.pro_prix), 0) AS total FROM inscriptions_panier_epreuves_commandees e, inscriptions_panier_produits_new p WHERE e.pec_id = p.pec_id AND e.pec_upgraded = 0 AND e.pec_id = " . intval($intpec_id) . $strWhere;
// corection pour eve pas de taxe
// $sqlRabais = "
// SELECT (e.pec_prix - e.rab_montant) AS total
// FROM inscriptions_panier_epreuves_commandees e
// WHERE e.pec_upgraded = 0 AND e.pec_id = " . intval($intpec_id) . $strWhere;
// $fltRabais = $objDatabase->fxGetVar($sqlRabais);
$sqlRabais = "
SELECT (e.pec_prix - e.rab_montant) AS total FROM inscriptions_panier_epreuves_commandees e
LEFT JOIN inscriptions_panier_epreuves ee on e.epr_id=ee.epr_id
WHERE e.pec_upgraded = 0 AND e.pec_id = " . intval($intpec_id) . $strWhere;
$fltRabais = $objDatabase->fxGetVar($sqlRabais);
$sqlRabais = "
SELECT ee.epr_taxes_incluses AS taxes_incluses FROM inscriptions_panier_epreuves_commandees e
LEFT JOIN inscriptions_panier_epreuves ee on e.epr_id=ee.epr_id
WHERE e.pec_upgraded = 0 AND e.pec_id = " . intval($intpec_id) . $strWhere;
$taxes_incluses = $objDatabase->fxGetVar($sqlRabais);
}
if ($fltRabais > 0) { // ajouter le rabais de l'ancien épreuve + produits
// todojs: vérifier que le rabais ne dépasse pas le total du panier
if ($fltRabais > $fltevetot) {
$fltRabais = $fltevetot;
}
// MSIN-4217
if ($taxes_incluses == 1)
$mem_taxe = 0;
else
$mem_taxe = 1;
$fltRabais = $fltRabais;
$sqlInsert = "INSERT INTO inscriptions_panier_rabais SET rab_description_fr = 'Changement - Crédit montant original - " . $tabOldPanier['no_commande'] . "', rab_description_en = 'Change - Original amount credit - " . $tabOldPanier['no_commande'] . "', rab_code = '-', rab_montant = " . floatval($fltRabais) . ",rab_taxes=" . $mem_taxe . ", pra_maj = '" . fxGetDateTime() . "', rab_produits = '', rab_epreuves = '',rab_note_fr='".$objDatabase->fxEscape($fltRabais_note_fr)."',rab_note_en='".$objDatabase->fxEscape($fltRabais_note_en)."'";
$qryInsert = $objDatabase->fxQuery($sqlInsert);
// récupérer le pra_id
$intPanierRabais = $objDatabase->fxGetLastId();
// insérer panier_rabais_acheteur
$sqlInsert = "INSERT INTO inscriptions_panier_rabais_acheteurs SET rab_montant = " . floatval($fltRabais) . ", no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pra_id = " . intval($intPanierRabais);
$qryInsert = $objDatabase->fxQuery($sqlInsert);
}
// produit pas taxable
if ($fltproduits > 0) { // ajouter le rabais de l'ancien épreuve + produits
// todojs: vérifier que le rabais ne dépasse pas le total du panier
$fltRabais = $fltproduits;
$sqlInsert = "INSERT INTO inscriptions_panier_rabais SET rab_description_fr = 'Changement - Crédit montant original produit pas taxables - " . $tabOldPanier['no_commande'] . "', rab_description_en = 'Change - Original amount credit product - " . $tabOldPanier['no_commande'] . "', rab_code = '-', rab_montant = " . floatval($fltproduits) . ", pra_maj = '" . fxGetDateTime() . "', rab_produits = '',rab_taxes=0, rab_epreuves = '',rab_note_fr='".$objDatabase->fxEscape($fltproduits_note_fr)."',rab_note_en='".$objDatabase->fxEscape($fltproduits_note_en)."'";
$qryInsert = $objDatabase->fxQuery($sqlInsert);
// récupérer le pra_id
$intPanierRabais = $objDatabase->fxGetLastId();
// insérer panier_rabais_acheteur
$sqlInsert = "INSERT INTO inscriptions_panier_rabais_acheteurs SET rab_montant = " . floatval($fltRabais) . ", no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pra_id = " . intval($intPanierRabais);
$qryInsert = $objDatabase->fxQuery($sqlInsert);
}
if ($fltproduits_taxable > 0) { // ajouter le rabais de l'ancien épreuve + produits
// todojs: vérifier que le rabais ne dépasse pas le total du panier
$fltRabais = $fltproduits_taxable;
$sqlInsert = "INSERT INTO inscriptions_panier_rabais SET rab_description_fr = 'Changement - Crédit montant original produit taxables - " . $tabOldPanier['no_commande'] . "', rab_description_en = 'Change - Original amount credit product - " . $tabOldPanier['no_commande'] . "', rab_code = '-', rab_montant = " . floatval($fltproduits_taxable) . ", pra_maj = '" . fxGetDateTime() . "', rab_produits = '',rab_taxes=1, rab_epreuves = '',rab_note_fr='".$objDatabase->fxEscape($fltproduits_taxable_note_fr)."',rab_note_en='".$objDatabase->fxEscape($fltproduits_taxable_note_en)."'";
$qryInsert = $objDatabase->fxQuery($sqlInsert);
// récupérer le pra_id
$intPanierRabais = $objDatabase->fxGetLastId();
// insérer panier_rabais_acheteur
$sqlInsert = "INSERT INTO inscriptions_panier_rabais_acheteurs SET rab_montant = " . floatval($fltRabais) . ", no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pra_id = " . intval($intPanierRabais);
$qryInsert = $objDatabase->fxQuery($sqlInsert);
}
if (trim($tabData['no_transfert']) != '') {
$fltproduitstq = 0;
} else {
if ($fltproduitstqnew < $fltproduitstq) {
// $fltproduitstq=$fltproduitstq-$fltproduitstqnew;
$fltproduitstq = $fltproduitstqnew;
} else {
}
}
if ($fltproduitstq > 0) { // ajouter le rabais de l'ancien épreuve + produits
// todojs: vérifier que le rabais ne dépasse pas le total du panier
$fltRabais = $fltproduitstq;
$sqlInsert = "INSERT INTO inscriptions_panier_rabais SET rab_description_fr = 'Changement - Crédit montant original produit tq - " . $tabOldPanier['no_commande'] . "', rab_description_en = 'Change - Original amount credit tq product - " . $tabOldPanier['no_commande'] . "', rab_code = '-', rab_montant = " . floatval($fltproduitstq) . ", pra_maj = '" . fxGetDateTime() . "', rab_produits = '', rab_epreuves = ''";
$qryInsert = $objDatabase->fxQuery($sqlInsert);
// récupérer le pra_id
$intPanierRabais = $objDatabase->fxGetLastId();
// insérer panier_rabais_acheteur
$sqlInsert = "INSERT INTO inscriptions_panier_rabais_acheteurs SET rab_montant = " . floatval($fltRabais) . ", no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pra_id = " . intval($intPanierRabais);
$qryInsert = $objDatabase->fxQuery($sqlInsert);
}
}
} else { // définir le message d'erreur
if ($strLangue == 'fr') {
$_SESSION['msg'] = 'e158';
} else {
$_SESSION['msg'] = 'e558';
}
header("Location: " . $vDomaine . '/' . $tabEvenement['general']['eve_label_url']);
exit;
}
if (trim($tabEpreuve['epr_categorie_' . $strLangue]) != '') {
$strEpreuve = $tabEpreuve['epr_categorie_' . $strLangue] . ' - ';
} else {
$strEpreuve = '';
}
$strEpreuve .= fxUnescape($tabEpreuve['epr_type_' . $strLangue]);
if (trim($tabEpreuve['epr_nom_' . $strLangue]) != '')
$strEpreuve .= ' - ' . fxUnescape($tabEpreuve['epr_nom_' . $strLangue]);
$mem_pixcel = array("param1" => "track", "param2" => "AddToCart", "currency" => "CAD", "content_name" => $strEpreuve, "content_ids" => $tabData['epr_id'], "value" => $fltPrix, "content_type" => "product");
fxsessionpixelfacebook($mem_pixcel);
} elseif (isset($tabData['pro_id'])) { // Ajout de produits seuls
$sqlProduit = "SELECT * FROM inscriptions_produits_new WHERE pro_id = " . intval($tabData['pro_id']);
$tabProduit = $objDatabase->fxGetRow($sqlProduit);
if ($tabProduit != null) {
$strSetRabais = '';
if ($tabProduit['pt_id'] == 1) { // vérifier si c'est un camping et s'il y a un crédit/rabais à appliquer
$sqlCredit = "SELECT (pec_credit_camping - (SELECT COALESCE(SUM(rab_montant), 0) FROM inscriptions_panier_produits_new WHERE no_panier = '" . $strNoPanier . "' AND pt_id = 1 AND pec_id = " . intval($tabData['pec_id']) . ")) AS pec_credit_camping FROM resultats_epreuves_commandees WHERE pec_id_original = " . intval($tabData['pec_id']);
$tabCredit = $objDatabase->fxGetRow($sqlCredit);
if ($tabCredit != null) {
if ($tabCredit['pec_credit_camping'] > 0) { // insérer rabais au montant qui convient
if ($tabCredit['pec_credit_camping'] >= $tabProduit['pro_prix'])
$fltRabais = $tabProduit['pro_prix'];
else
$fltRabais = $tabCredit['pec_credit_camping'];
$sqlInsert = "INSERT INTO inscriptions_panier_rabais SET rab_description_fr = '" . $objDatabase->fxEscape("Crédit d'annulation") . "', rab_description_en = 'Cancellation credit', rab_code = 'CAMPING', rab_montant = " . floatval($fltRabais) . ", pra_maj = '" . fxGetDateTime() . "', rab_produits = '" . intval($tabData['pro_id']) . "'";
$qryInsert = $objDatabase->fxQuery($sqlInsert);
// récupérer le pra_id
$intPanierRabais = $objDatabase->fxGetLastId();
// insérer panier_rabais_acheteur
$sqlInsert = "INSERT INTO inscriptions_panier_rabais_acheteurs SET no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pra_id = " . intval($intPanierRabais);
$qryInsert = $objDatabase->fxQuery($sqlInsert);
$strSetRabais = ", pra_id = " . intval($intPanierRabais) . ", rab_montant = " . floatval($fltRabais);
}
} else
fxcreer_log("Il y a eu une erreur lors de la récupération des crédits camping:\n" . $sqlCredit);
}
$sqlInsert = "INSERT INTO inscriptions_panier_produits_new SET eve_id = " . intval($tabProduit['eve_id']) . ", pec_id = " . intval($tabData['pec_id']) . ", par_id = 0, pro_id = " . intval($tabData['pro_id']) . ", pt_id = " . intval($tabProduit['pt_id']) . ", pro_nom_fr = '" . $objDatabase->fxEscape($tabProduit['pro_nom_fr']) . "', pro_nom_en = '" . $objDatabase->fxEscape($tabProduit['pro_nom_en']) . "', pro_description_fr = '" . $objDatabase->fxEscape($tabProduit['pro_description_fr']) . "', pro_description_en = '" . $objDatabase->fxEscape($tabProduit['pro_description_en']) . "', pro_taille_fr = '" . $objDatabase->fxEscape($tabProduit['pro_taille_fr']) . "', pro_taille_en = '" . $objDatabase->fxEscape($tabProduit['pro_taille_en']) . "', pro_section_fr = '" . $objDatabase->fxEscape($tabProduit['pro_section_fr']) . "', pro_section_en = '" . $objDatabase->fxEscape($tabProduit['pro_section_en']) . "', pro_prix = " . floatval($tabProduit['pro_prix']) . ", pro_taxable = " . intval($tabProduit['pro_taxable']) . ", pro_effacable = " . intval($tabProduit['pro_effacable']) . ", pro_maj = '" . fxGetDateTime() . "', no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'" . $strSetRabais;
$qryInsert = $objDatabase->fxQuery($sqlInsert);
$mem_pixcel = array("param1" => "track", "param2" => "AddToCart", "currency" => "CAD", "content_name" => $tabProduit['pro_nom_' . $strLangue], "content_ids" => $tabData['pro_id'], "value" => $tabProduit['pro_prix'], "content_type" => "product");
fxsessionpixelfacebook($mem_pixcel);
} else
fxcreer_log("Il y a eu une erreur lors de l'ajout du produit:\n" . $sqlProduit);
} elseif (isset($tabData['md_id'])) { // Ajout de montants dus
$sqlMontantDu = "SELECT * FROM inscriptions_montants_dus WHERE md_id = " . intval($tabData['md_id']);
$tabMontantDu = $objDatabase->fxGetRow($sqlMontantDu);
if ($tabMontantDu != null) {
$sqlInsert = "INSERT INTO inscriptions_panier_montants_dus SET eve_id = " . intval($tabMontantDu['eve_id']) . ", pec_id = " . intval($tabData['pec_id']) . ", md_id = " . intval($tabData['md_id']) . ", md_montant = " . floatval($tabMontantDu['md_montant']) . ", pmd_maj = '" . fxGetDateTime() . "', no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', no_panier_original = '" . $objDatabase->fxEscape($tabMontantDu['no_panier']) . "', no_commande_original = '" . $objDatabase->fxEscape($tabMontantDu['no_commande']) . "'";
$qryInsert = $objDatabase->fxQuery($sqlInsert);
} else
fxcreer_log("Il y a eu une erreur lors de l'ajout du montant du:\n" . $sqlMontantDu);
}
break;
case 'mod': // MODIF DU PANIER
// old values pour le participant ayant soumis les modifs.
if (isset($_SESSION['no_panier']) && $tabData['promoteur'] == 0) {
$strNoPanier = $_SESSION['no_panier'];
$strTableSqlPart = "inscriptions_panier_participants";
$strTableSqlQuestions = "inscriptions_panier_questions";
$strTableSqlProduits = "inscriptions_panier_produits_new";
$strTableSqlEpreuveCommandees = "inscriptions_panier_epreuves_commandees";
$strWhereSql = "par_id";
$strModMarker = '';
// $strModMarkerForm = '';
$strKeyEpreuveCommandee = "pec_id";
} else {
$strNoPanier = '';
$strTableSqlPart = "resultats_participants";
$strTableSqlQuestions = "resultats_questions";
$strTableSqlProduits = "resultats_produits_new";
$strTableSqlEpreuveCommandees = "resultats_epreuves_commandees";
$strWhereSql = "par_id";
$strModMarker = 'par_modification_promoteur = 1, ';
// $strModMarkerForm = 'par_mod_via_form = 1, ';
$strKeyEpreuveCommandee = "pec_id_original";
}
$qry = 'SELECT * FROM ' . $strTableSqlPart . ' WHERE pec_id = ' . intval($intpec_id) . ' ORDER BY par_id';
$tabInscription = $objDatabase->fxGetResults($qry);
// trouver le nombre max de participants pour l'epreuve
$tabEpreuve = fxGetEpreuve($tabData['epr_id']);
// trouver le prix de l'épreuve
$tabPrix = fxGetPrixParticipant($tabData['epr_id']);
$fltPrix = $tabPrix['ep_montant'];
$fltDon = $tabPrix['ep_montant_don'];
$fltFrais = $tabPrix['ep_frais_montant'];
$fltFraisTps = $tabPrix['ep_frais_tps'];
$fltFraisTvq = $tabPrix['ep_frais_tvq'];
$intEpreuvePrix = $tabPrix['ep_id'];
$intCategoriePrix = $tabPrix['cp_id'];
$strCategoriePrixFr = $tabPrix['cp_details_fr'];
$strCategoriePrixEn = $tabPrix['cp_details_en'];
$intPrixParticipant = $tabPrix['ep_prix_participant'];
$intNbParticipantsTotal = 0;
$strCategorieFr = $strCategorieEn = '';
if (isset($tabData['TQ_numero'])) {
$mem_tq_temp = 0;
if ($tabData['TQ_numero'] <> '') {
$mem_tq_temp = $tabData['TQ_numero'];
}
$sqlUpdate = "UPDATE inscriptions_panier_epreuves_commandees SET tq_temp=" . $mem_tq_temp . " WHERE pec_id = " . intval($intpec_id);
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
}
// MSIN-1220
if ($tabInscription[1]['epr_id'] != $tabData['epr_id']) { // si nouvelle épreuve
$tabAncienneEpreuve = fxGetEpreuve($tabInscription[1]['epr_id']);
$tabNouvelleEpreuve = fxGetEpreuve($tabData['epr_id']);
$intDiff = ($tabAncienneEpreuve['epr_nb_participants'] - $tabNouvelleEpreuve['epr_nb_participants']);
for ($i = count($tabInscription); $i > $tabNouvelleEpreuve['epr_nb_participants']; $i--) {
$sqlUpdate = "UPDATE resultats_participants SET is_cancelled = 1, par_modification_promoteur = 1 WHERE par_id = " . intval($tabInscription[$i]['par_id']);
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
if (!$qryUpdate)
fxcreer_log("Erreur lors du changemenet d'épreuve par le promoteur.");
}
$sqlUpdate = "UPDATE resultats_epreuves_commandees SET pec_equipe = " . $tabNouvelleEpreuve['epr_equipe'] . " WHERE pec_id_original = " . $intpec_id;
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
if (!$qryUpdate)
fxcreer_log("Erreur lors du changemenet d'épreuve par le promoteur.");
//mettre a jour les stocks de l'ancienne épreuve a +1.
$sqlUpdate = "UPDATE inscriptions_epreuves SET epr_qte = (epr_qte + 1) WHERE epr_id = " . intval($tabAncienneEpreuve['epr_id']) . " AND epr_qte_limitee = 1";
$qryUpdateStocks = $objDatabase->fxQuery($sqlUpdate);
//mettre a jour les stocks de la nouvelle épreuve a -1.
$sqlUpdate = "UPDATE inscriptions_epreuves SET epr_qte = (epr_qte - 1) WHERE epr_id = " . intval($tabNouvelleEpreuve['epr_id']) . " AND epr_qte_limitee = 1";
$qryUpdateStocks = $objDatabase->fxQuery($sqlUpdate);
}
// fin MSIN-1220
// variables pour nouveau(x) part
$intParEquipe = $tabInscription[1]['par_no_equipe'];
$strNoPanierInsert = $tabInscription[1]['no_panier'];
if ($tabEpreuve['epr_equipe'] == 1)
$strParNomEquipe = $tabInscription[1]['par_nom_equipe'];
else
$strParNomEquipe = '';
if (isset($_SESSION['no_panier']))
$strNoCommande = '';
else
$strNoCommande = $tabInscription[1]['no_commande'];
if (isset($_SESSION['no_panier']))
$strNoPanier = $_SESSION['no_panier'];
else
$strNoPanier = $tabInscription[1]['no_panier'];
// tableau des equipiers
for ($j = 1; $j <= count($tabInscription); $j++) {
$tabEquipierID[] = $tabInscription[$j]['par_id'];
}
// initialiser les variables
for ($i = 1; $i <= $tabEpreuve['epr_nb_participants']; $i++) {
// MODIFIER LE PARTICIPANT
// initialiser les variables
$intParId = $intParIdOriginal = 0;
$strNaissance = '0000-00-00';
$intProvince = $intPays = 0;
$strFields = $strPrenom = $strNomFamille = $strSexe = $strAdresse = $strAdresse2 = $strVille = $strCodepostal = $strTelephone1 = $strTelephone2 = $strCourriel = $strCancel = $strUrgenceNom = $strUrgenceTel = '';
if (isset($tabData['epr_id']))
$intEprId = $tabData['epr_id'];
else
$intEprId = $tabInscription[$i]['epr_id'];
if (isset($tabData['par_prenom_' . $i]))
$strPrenom = $tabData['par_prenom_' . $i];
if (isset($tabData['par_nom_' . $i]))
$strNomFamille = $tabData['par_nom_' . $i];
if (isset($tabData['par_naissance_' . $i]))
$strNaissance = $tabData['par_naissance_' . $i];
if (isset($tabData['par_sexe_' . $i]))
$strSexe = $tabData['par_sexe_' . $i];
if (isset($tabData['pro_id_' . $i]))
$intProvince = $tabData['pro_id_' . $i];
if (isset($tabData['pay_id_' . $i]))
$intPays = $tabData['pay_id_' . $i];
if (isset($tabData['par_adresse_' . $i]))
$strAdresse = $tabData['par_adresse_' . $i];
if (isset($tabData['par_adresse2_' . $i]))
$strAdresse2 = $tabData['par_adresse2_' . $i];
if (isset($tabData['par_ville_' . $i]))
$strVille = $tabData['par_ville_' . $i];
if (isset($tabData['par_codepostal_' . $i]))
$strCodepostal = $tabData['par_codepostal_' . $i];
if (isset($tabData['par_telephone1_' . $i]))
$strTelephone1 = $tabData['par_telephone1_' . $i];
if (isset($tabData['par_telephone2_' . $i]))
$strTelephone2 = $tabData['par_telephone2_' . $i];
if (isset($tabData['par_courriel_' . $i]))
$strCourriel = $tabData['par_courriel_' . $i];
if (isset($tabData['par_capitaine']))
$strCapitaine = $tabData['par_capitaine'];
if (isset($tabData['par_contact_urgence_nom_' . $i]))
$strUrgenceNom = $tabData['par_contact_urgence_nom_' . $i];
if (isset($tabData['par_contact_urgence_telephone_' . $i]))
$strUrgenceTel = $tabData['par_contact_urgence_telephone_' . $i];
if (isset($tabData['promoteur']) && $tabData['promoteur'] == '1') {
if ($tabEpreuve['epr_equipe'] == 0 && $tabInscription[$i]['rol_id_' . $i] == '1') {
//$strCancel = ', is_cancelled = 1'; //TODOjs - vérifier pour ajout de participant équipe - MSIN-3270
}
}
if (isset($tabInscription[$i]['par_id'])) {
$intParId = $tabInscription[$i]['par_id'];
$tabParticipants[] = $intParId;
if (isset($tabInscription[$i]['par_id_original'])) {
$intParIdOriginal = $tabInscription[$i]['par_id_original'];
}
/*if (trim($strPrenom) == '' && trim($strNomFamille) == '') { //TODOjs - vérifier pour ajout de participant équipe - MSIN-3270
$strCancel = ', is_cancelled = 1';
} else {
$intNbParticipantsTotal++;
} */
$intAge = fxGetAge($strNaissance, $tabEpreuve['epr_date_age']);
// if ($strPrenom != '' && $strNomFamille != '' && $strSexe != '' && $strNaissance != '') {
if ((isset($_SESSION['no_panier']) && $tabData['promoteur'] == 0) || (!isset($_SESSION['no_panier']) && $tabData['promoteur'] == 1 && $tabEvenement['general']['te_id'] != 13) || (!isset($_SESSION['no_panier']) && $tabData['promoteur'] == 0 && $i > 1)) {
$strFields = ", par_prenom = '" . $objDatabase->fxEscape($strPrenom) . "', par_nom = '" . $objDatabase->fxEscape($strNomFamille) . "', par_naissance = '" . $objDatabase->fxEscape($strNaissance) . "', par_sexe = '" . $objDatabase->fxEscape($strSexe) . "'";
}
$sqlUpdatePart = "UPDATE " . $strTableSqlPart . " SET " . $strModMarker . "epr_id = " . intval($intEprId) . ", par_age = " . intval($intAge) . ", pro_id = " . intval($intProvince) . ", par_codepostal = '" . $objDatabase->fxEscape($strCodepostal) . "', pay_id = " . intval($intPays) . ", par_adresse = '" . $objDatabase->fxEscape($strAdresse) . "', par_adresse2 = '" . $objDatabase->fxEscape($strAdresse2) . "', par_ville = '" . $objDatabase->fxEscape($strVille) . "', par_maj = '" . fxGetDateTime() . "', par_telephone1 = '" . $objDatabase->fxEscape($strTelephone1) . "', par_telephone2 = '" . $objDatabase->fxEscape($strTelephone2) . "', par_nom_equipe = '" . $objDatabase->fxEscape($strParNomEquipe) . "', par_courriel = '" . $objDatabase->fxEscape($strCourriel) . "', par_equipe = " . intval($tabEpreuve['epr_equipe']) . $strCancel . $strFields . ", par_contact_urgence_nom = '" . $objDatabase->fxEscape($strUrgenceNom) . "', par_contact_urgence_telephone = '" . $objDatabase->fxEscape($strUrgenceTel) . "' WHERE " . $strWhereSql . " = " . intval($intParId);
$qryUpdate = $objDatabase->fxQuery($sqlUpdatePart);
if (!$qryUpdate) {
fxcreer_log('Erreur dans la mise à jour des participants.(' . $tabInscription[1]['par_courriel'] . ')');
}
// catégorie
if ($tabEvenement['general']['eve_categorie_auto'] == 1) {
fxregles_niveau_update(intval($intParId), $strTableSqlPart, $strWhereSql);
}
// msin-817
$sqlUpdateEpreuveCommandee = "UPDATE resultats_epreuves_commandees SET epr_id = " . intval($intEprId) . ", pec_maj = '" . fxGetDateTime() . "' WHERE pec_id_original = " . $intpec_id;
$qryUpdateEpreuveCommandee = $objDatabase->fxQuery($sqlUpdateEpreuveCommandee);
if (!$qryUpdateEpreuveCommandee) {
fxcreer_log('Erreur dans la mise à jour de l\'épreuve.(' . $tabInscription[1]['par_courriel'] . ')');
}
} else {
if (!isset($tabInscription[$i]['par_prenom']) && !(empty($tabData['par_prenom_' . $i]))) {
$intAge = fxGetAge($strNaissance, $tabEpreuve['epr_date_age']);
if ($strTableSqlPart == "inscriptions_panier_participants") {
$sqlInsertPartPanier = "INSERT INTO inscriptions_panier_participants SET pep_id = " . intval($tabInscription[1]['pep_id']) . ", eve_id = " . intval($tabEvenement['general']['eve_id']) . ", epr_id = " . intval($tabData['epr_id']) . ", pec_id = " . intval($intpec_id) . ", rol_id = 2, no_panier = '" . $objDatabase->fxEscape($_SESSION['no_panier']) . "', par_prenom = '" . ucfirst($objDatabase->fxEscape($strPrenom)) . "', par_nom = '" . ucfirst($objDatabase->fxEscape($strNomFamille)) . "', par_naissance = '" . $objDatabase->fxEscape($strNaissance) . "', par_sexe = '" . $strSexe . "', par_codepostal = '" . strtoupper($objDatabase->fxEscape($strCodepostal)) . "', par_courriel = '" . strtolower($objDatabase->fxEscape($strCourriel)) . "', par_langue = '" . $objDatabase->fxEscape($strLangue) . "', par_prix = " . floatval($fltPrix) . ", par_age = " . intval($intAge) . ", par_complet = 1, par_maj = '" . fxGetDateTime() . "', par_frais_montant = " . floatval($fltFrais) . ", par_frais_tps = " . floatval($fltFraisTps) . ", par_frais_tvq = " . floatval($fltFraisTvq) . ", ep_id = " . intval($intEpreuvePrix) . ", cp_id = " . intval($intCategoriePrix) . ", cp_details_fr = '" . $strCategoriePrixFr . "', cp_details_en = '" . $strCategoriePrixEn . "', com_id = " . intval($intCompte) . ", par_adresse = '" . ucwords($objDatabase->fxEscape($strAdresse)) . "', par_ville = '" . ucwords($objDatabase->fxEscape($strVille)) . "', pro_id = " . intval($intProvince) . ", pay_id = " . intval($intPays) . ", par_telephone1 = '" . $objDatabase->fxEscape($strTelephone1) . "', par_telephone2 = '" . $objDatabase->fxEscape($strTelephone2) . "', par_no_equipe = " . intval($intParEquipe) . ", par_equipe = 1, par_nom_equipe = '" . $objDatabase->fxEscape($strParNomEquipe) . "', epr_objectif_dons = " . intval($tabEpreuve['epr_objectif_dons_participant']);
//$sqlInsertPartPanier = "INSERT INTO inscriptions_panier_participants (pep_id, eve_id, epr_id, par_prenom, par_nom, par_naissance, par_sexe, par_courriel, pec_id, no_panier, par_no_equipe, par_equipe, par_maj, par_nom_equipe, par_codepostal, par_age, par_ajout_post) VALUES(1, " . intval($tabEvenement['general']['eve_id']) . ", " . intval($tabData['epr_id']) . ", '" . $objDatabase->fxEscape($strPrenom) . "', '" . $objDatabase->fxEscape($strNomFamille) . "', '" . $objDatabase->fxEscape($strNaissance) . "', '" . $objDatabase->fxEscape($strSexe) . "', '" . $objDatabase->fxEscape($strCourriel) . "', " . intval($intpec_id) . ", '" . $objDatabase->fxEscape($strNoPanierInsert) . "', " . intval($intParEquipe) . ", 1, '" . fxGetDateTime() . "', '" . $objDatabase->fxEscape($strParNomEquipe) . "', '" . $objDatabase->FxEscape($strCodepostal) . "', " . intval($intAge) . ", 1)";
$qryInsertPartPanier = $objDatabase->fxQuery($sqlInsertPartPanier);
$intParId = $intParIdOriginal = $objDatabase->fxGetLastId();
$intNbParticipantsTotal++;
if (!$qryInsertPartPanier) {
fxcreer_log('Erreur dans l\'ajout d\'un nouveau participant.(' . $tabInscription[1]['par_courriel'] . ')');
}
} else {
$sqlInsertPartPanier = "INSERT INTO inscriptions_panier_participants (pep_id, eve_id, epr_id, par_prenom, par_nom, par_naissance, par_sexe, par_courriel, pec_id, no_panier, par_no_equipe, par_equipe, par_maj, par_nom_equipe, par_codepostal, par_age, par_ajout_post) VALUES(1, " . intval($tabEvenement['general']['eve_id']) . ", " . intval($tabData['epr_id']) . ", '" . $objDatabase->fxEscape($strPrenom) . "', '" . $objDatabase->fxEscape($strNomFamille) . "', '" . $objDatabase->fxEscape($strNaissance) . "', '" . $objDatabase->fxEscape($strSexe) . "', '" . $objDatabase->fxEscape($strCourriel) . "', " . intval($intpec_id) . ", '" . $objDatabase->fxEscape($strNoPanierInsert) . "', " . intval($intParEquipe) . ", 1, '" . fxGetDateTime() . "', '" . $objDatabase->fxEscape($strParNomEquipe) . "', '" . $objDatabase->fxEscape($strCodepostal) . "', " . intval($intAge) . ", 1)";
$qryInsertPartPanier = $objDatabase->fxQuery($sqlInsertPartPanier);
$intParId = $intParIdOriginal = $objDatabase->fxGetLastId();
$sqlInsertPart = "INSERT INTO resultats_participants (eve_id, epr_id, par_prenom, par_nom, par_naissance, par_sexe, par_courriel, pec_id, no_panier, par_no_equipe, par_equipe, par_maj, par_nom_equipe, par_codepostal, par_age, par_id_original) VALUES(" . intval($tabEvenement['general']['eve_id']) . ", " . intval($tabData['epr_id']) . ", '" . $objDatabase->fxEscape($strPrenom) . "', '" . $objDatabase->fxEscape($strNomFamille) . "', '" . $objDatabase->fxEscape($strNaissance) . "', '" . $objDatabase->fxEscape($strSexe) . "', '" . $objDatabase->fxEscape($strCourriel) . "', " . intval($intpec_id) . ", '" . $objDatabase->fxEscape($strNoPanierInsert) . "', " . intval($intParEquipe) . ", 1, '" . fxGetDateTime() . "', '" . $objDatabase->fxEscape($strParNomEquipe) . "', '" . $objDatabase->FxEscape($strCodepostal) . "', " . intval($intAge) . ", " . intval($intParIdOriginal) . ")";
$qryInsertPart = $objDatabase->fxQuery($sqlInsertPart);
if (!$qryInsertPart || !$qryInsertPartPanier) {
fxcreer_log('Erreur dans l\'ajout d\'un nouveau participant.(' . $tabInscription[1]['par_courriel'] . ')');
}
}
}
}
if (isset($_SESSION['no_panier'])) {
$intParticipant = $intParId;
} else {
$intParticipant = $intParIdOriginal;
}
// MODIFIER LES QUESTIONS
// sortir les questions de l'événement
$tabQuestions = fxGetQuestions('par', $tabEvenement['general']['eve_id'], $tabData['epr_id'], 'mod', $tabData['promoteur'], $intquestechue); // récupérer les questions à demander aux participants
// insérer les réponses des questions
$arrCategorie = fxSetQuestions('mod', $tabQuestions, $tabData, $tabFiles, $strNoPanier, $intpec_id, $intParticipant, $i, $strLangue, $strTableSqlQuestions, $strTableSqlEpreuveCommandees, $strTableSqlPart, $strTableSqlProduits, $strKeyEpreuveCommandee);
if (trim($arrCategorie['categorie_fr']) != '') {
$strCategorieFr = $arrCategorie['categorie_fr'];
$strCategorieEn = $arrCategorie['categorie_en'];
}
}
// Modifier les questions de l'épreuve
// sortir les questions de l'épreuve
$tabQuestionsEpreuve = fxGetQuestions('epr', $tabEvenement['general']['eve_id'], $tabData['epr_id'], 'mod', $tabData['promoteur']); // récupérer les questions à demander pour l'épreuve
// insérer les réponses des questions
$arrCategorie = fxSetQuestions('mod', $tabQuestionsEpreuve, $tabData, $tabFiles, $strNoPanier, $intpec_id, 0, 0, $strLangue, $strTableSqlQuestions, $strTableSqlEpreuveCommandees, $strTableSqlPart, $strTableSqlProduits, $strKeyEpreuveCommandee);
if (trim($arrCategorie['categorie_fr']) != '') {
$strCategorieFr = $arrCategorie['categorie_fr'];
$strCategorieEn = $arrCategorie['categorie_en'];
}
// mettre à jour la catégorie si nécessaire
if (trim($strCategorieFr) != '') {
$sqlUpdate = "UPDATE " . $strTableSqlPart . " SET par_categorie_1_long_fr = '" . $objDatabase->fxEscape($strCategorieFr) . "', par_categorie_1_long_en = '" . $objDatabase->fxEscape($strCategorieEn) . "', par_categorie_1_court_fr = '" . $objDatabase->fxEscape($strCategorieFr) . "', par_categorie_1_court_en = '" . $objDatabase->fxEscape($strCategorieEn) . "' WHERE pec_id = " . intval($intpec_id);
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
}
if ($strTableSqlPart == "inscriptions_panier_participants") {
// mettre à jour le prix par participant (si cas échéant)
if ($intPrixParticipant == 1 && $intNbParticipantsTotal > 1) {
$sqlUpdate = "UPDATE inscriptions_panier_epreuves_commandees SET pec_prix = " . floatval($fltPrix * $intNbParticipantsTotal) . " WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND pec_id = " . intval($intpec_id);
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
}
}
break;
case 'upgrade':
$intNouvelleEpreuve = ($tabData['sel_epr_upgradable_billed'] != '') ? $tabData['sel_epr_upgradable_billed'] : $tabData['sel_epr_upgradable_free'];
if (isset($tabData['sel_epr_upgradable_free']))
$strDescriptionRabais = 'free';
else
$strDescriptionRabais = 'billed';
// ancien no. panier
$sqlNoPanier = "SELECT no_panier FROM resultats_epreuves_commandees WHERE pec_id_original = " . intval($intpec_id);
$strAncienNoPanier = $objDatabase->fxGetVar($sqlNoPanier);
$_SESSION['ancien_no_panier'] = $strAncienNoPanier;
$_SESSION['int_nouvelle_epreuve'] = $intNouvelleEpreuve;
$_SESSION['pec_id'] = $intpec_id;
$tabNouvelleEpr = fxGetEpreuve($intNouvelleEpreuve);
$tabAncienneEpr = fxGetEpreuve($_GET['id']);
// get prices
$sqlOldPrix = "select * from inscriptions_panier_epreuves_commandees where pec_id = " . intval($intpec_id);
$tabOldPrix = $objDatabase->fxGetResults($sqlOldPrix);
$sqlNewPrix = "SELECT * FROM inscriptions_epreuves_prix WHERE ep_date_limite > NOW() AND epr_id = " . intval($intNouvelleEpreuve) . " LIMIT 1";
$tabNewPrix = $objDatabase->fxGetRow($sqlNewPrix);
$intNewPrix = $tabNewPrix['ep_montant'];
$intOldPrix = $tabOldPrix[1]['pec_prix'];
$intDifference = ($intNewPrix - $intOldPrix);
// ajouter le credit/rabais a epreuve commandee
$sqlUpdate = "UPDATE resultats_epreuves_commandees SET pec_credit_upgrade = " . floatval($intOldPrix) . " WHERE pec_id_original = " . intval($intpec_id);
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
if (!$qryUpdate)
fxcreer_log("Erreur lors de l'ajout du crédit upgrade d'un capitaine.");
$strNoPanier = fxNumPanier($tabEvenement['general']['eve_id'], $strLangue);
// Ajout d'une épreuve avec ou sans participant
if (isset($tabData['epr_id'])) {
// trouver les infos de l'épreuve
$tabEpreuve = fxGetEpreuve($intNouvelleEpreuve);
// get info inscription
$sqlInscription = "SELECT * FROM resultats_epreuves_commandees WHERE pec_id_original = " . intval($intpec_id);
$tabInscription = $objDatabase->fxGetRow($sqlInscription);
$strNomEquipe = $tabInscription['pec_nom_equipe'];
// ajouter l'événement et l'épreuve
$intPanier = fxCheckEvenement($strNoPanier, $tabEvenement['general']['eve_id']);
$intPanierEpreuve = fxCheckEpreuve($intPanier, $intNouvelleEpreuve);
// mettre le no de compte si existant
if (isset($_SESSION['com_id']))
$intCompte = $_SESSION['com_id'];
else
$intCompte = 0;
// trouver le prix de l'épreuve
$tabPrix = fxGetPrixParticipant($intNouvelleEpreuve);
// $tabPrix = fxGetPrixParticipant($tabData['epr_id']);
$fltPrix = $tabPrix['ep_montant'];
$fltDon = $tabPrix['ep_montant_don'];
$fltFrais = $tabPrix['ep_frais_montant'];
$fltFraisTps = $tabPrix['ep_frais_tps'];
$fltFraisTvq = $tabPrix['ep_frais_tvq'];
$intEpreuvePrix = $tabPrix['ep_id'];
$intCategoriePrix = $tabPrix['cp_id'];
$strCategoriePrixFr = $tabPrix['cp_details_fr'];
$strCategoriePrixEn = $tabPrix['cp_details_en'];
// Ajouter l'épreuve au panier
// NOTE: nouvraux champs épreuve #NCEPR
$sqlInsert = "INSERT INTO inscriptions_panier_epreuves_commandees SET eve_id = " . intval($tabEvenement['general']['eve_id']) . ", epr_id = " . intval($intNouvelleEpreuve) . ", no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pec_label = '', pec_nom_equipe = '" . $objDatabase->fxEscape($strNomEquipe) . "', pec_equipe = " . intval($tabEpreuve['epr_equipe']) . ", pec_prix = " . floatval($fltPrix) . ", pec_montant_don = " . floatval($fltDon) . ", par_frais_montant = " . floatval($fltFrais) . ", par_frais_tps = " . floatval($fltFraisTps) . ", par_frais_tvq = " . floatval($fltFraisTvq) . ", ep_id = " . intval($intEpreuvePrix) . ", cp_id = " . intval($intCategoriePrix) . ", cp_details_fr = '" . $objDatabase->fxEscape($strCategoriePrixFr) . "', cp_details_en = '" . $objDatabase->fxEscape($strCategoriePrixEn) . "', com_id = " . intval($intCompte) . ", mt_id = " . intval($tabEpreuve['mt_id']);
$qryInsert = $objDatabase->fxQuery($sqlInsert);
// récupérer le id ajouté
$intEpreuveCommandee = $objDatabase->fxGetLastId();
$sqlCredit = "SELECT (pec_credit_upgrade - (SELECT COALESCE(SUM(rab_montant), 0) FROM inscriptions_panier_produits_new WHERE no_panier = '" . $strNoPanier . "' AND pt_id = 1 AND pec_id = " . intval($intpec_id) . ")) AS pec_credit_upgrade FROM resultats_epreuves_commandees WHERE pec_id_original = " . intval($intpec_id);
$tabCredit = $objDatabase->fxGetRow($sqlCredit);
if ($tabCredit != null) {
if ($tabCredit['pec_credit_upgrade'] > 0) { // insérer rabais au montant qui convient
if ($tabCredit['pec_credit_upgrade'] >= $tabPrix['ep_montant'] || $tabData['sel_epr_upgradable_billed'] == '')
$fltRabais = $tabPrix['ep_montant'];
else
$fltRabais = $tabCredit['pec_credit_upgrade'];
$sqlInsert = "INSERT INTO inscriptions_panier_rabais SET rab_description_fr = 'Crédit montant original(" . $objDatabase->fxEscape($strDescriptionRabais) . ")', rab_description_en = 'Original amount credit(" . $objDatabase->fxEscape($strDescriptionRabais) . ")', rab_code = 'CATEGORY CHANGE', rab_montant = " . floatval($fltRabais) . ", pra_maj = '" . fxGetDateTime() . "', rab_produits = '', rab_epreuves = ''";
$qryInsert = $objDatabase->fxQuery($sqlInsert);
// récupérer le pra_id
$intPanierRabais = $objDatabase->fxGetLastId();
// insérer panier_rabais_acheteur
$sqlInsert = "INSERT INTO inscriptions_panier_rabais_acheteurs SET rab_montant = " . floatval($fltRabais) . ", no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pra_id = " . intval($intPanierRabais);
$qryInsert = $objDatabase->fxQuery($sqlInsert);
$strSetRabais = ", pra_id = " . intval($intPanierRabais) . ", rab_montant = " . floatval($fltRabais);
}
} else
fxcreer_log("Il y a eu une erreur lors de la récupération des crédits camping:\n" . $sqlCredit);
}
// redirection au panier
header("Location: " . $vDomaine . "/cart/somaire/" . $_GET['code']);
exit;
break;
case 'del':
// vérifier le statut de la commande
$sqlAcheteur = "SELECT sta_id, ach_ack FROM inscriptions_panier_acheteurs WHERE no_panier = '" . $objDatabase->fxEscape($tabData['no_panier']) . "'";
$arrAcheteur = $objDatabase->fxGetRow($sqlAcheteur);
if (intval($arrAcheteur['sta_id']) < 3 && trim($arrAcheteur['ach_ack']) != 'Success') {
// supprimer les épreuves
if (isset($tabData["pec_id"])) {
fxSetProduitsAuto('del', 0, 0, 0, '', $tabData["pec_id"]); // Effacer les produits automatiques
$sqlParticipants = "SELECT par_id FROM inscriptions_panier_participants WHERE no_panier = '" . $objDatabase->fxEscape($tabData['no_panier']) . "' AND pec_id = " . intval($tabData['pec_id']);
$recParticipants = $objDatabase->fxGetResults($sqlParticipants);
$sqlDelete = "DELETE FROM inscriptions_panier_participants WHERE par_id IN(" . implode(',', array_map(function ($tab) {
return $tab['par_id'];
}, $recParticipants)) . ")";
$recDelete = $objDatabase->fxQuery($sqlDelete);
// récupérer les numéros de produits
$sqlQuestions = "SELECT pro_id, no_panier FROM inscriptions_panier_questions WHERE par_id IN(" . implode(',', array_map(function ($tab) {
return $tab['par_id'];
}, $recParticipants)) . ") OR pec_id = " . intval($tabData["pec_id"]);
$recQuestions = $objDatabase->fxGetResults($sqlQuestions);
for ($intCtr = 1; $intCtr <= count($recQuestions); $intCtr++) {
$sqlDelete = "DELETE FROM inscriptions_panier_produits_new WHERE pro_id = " . intval($recQuestions[$intCtr]['pro_id']) . " AND no_panier = '" . $recQuestions[$intCtr]['no_panier'] . "' AND pec_id = " . intval($tabData["pec_id"]);
$recDelete = $objDatabase->fxQuery($sqlDelete);
}
$sqlDelete = "DELETE FROM inscriptions_panier_questions WHERE par_id IN(" . implode(',', array_map(function ($tab) {
return $tab['par_id'];
}, $recParticipants)) . ")";
$recDelete = $objDatabase->fxQuery($sqlDelete);
// effacer les épreuves commandées
$sqlDelete = "DELETE FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($tabData['no_panier']) . "' AND pec_id = " . intval($tabData['pec_id']);
$qryDelete = $objDatabase->fxQuery($sqlDelete);
} elseif (isset($tabData["ppn_id"])) { // supprimer les produits autres
$sqlProduit = "SELECT pt_id, pra_id FROM inscriptions_panier_produits_new WHERE no_panier = '" . $objDatabase->fxEscape($tabData['no_panier']) . "' AND ppn_id = " . intval($tabData['ppn_id']);
$tabProduit = $objDatabase->fxGetRow($sqlProduit);
if ($tabProduit != null) {
if ($tabProduit['pt_id'] == 1) { // supprimer le rabais du camping
$sqlDelete = "DELETE FROM inscriptions_panier_rabais_acheteurs WHERE no_panier = '" . $objDatabase->fxEscape($tabData['no_panier']) . "' AND pra_id = " . intval($tabProduit['pra_id']);
$sqlDelete = $objDatabase->fxQuery($sqlDelete);
$sqlDelete = "DELETE FROM inscriptions_panier_rabais WHERE pra_id = " . intval($tabProduit['pra_id']);
$sqlDelete = $objDatabase->fxQuery($sqlDelete);
}
$sqlDelete = "DELETE FROM inscriptions_panier_produits_new WHERE no_panier = '" . $objDatabase->fxEscape($tabData['no_panier']) . "' AND ppn_id = " . intval($tabData['ppn_id']);
$sqlDelete = $objDatabase->fxQuery($sqlDelete);
}
} elseif (isset($tabData["pmd_id"])) { // supprimer les montants dus
$sqlDelete = "DELETE FROM inscriptions_panier_montants_dus WHERE no_panier = '" . $objDatabase->fxEscape($tabData['no_panier']) . "' AND pmd_id = " . intval($tabData['pmd_id']);
$sqlDelete = $objDatabase->fxQuery($sqlDelete);
}
// vérifier si le panier est vide, si oui, effacer no_panier dans la session
$mem_panierinfo = fxNbItemsPanier($_SESSION['no_panier']);
if ($mem_panierinfo['nbitem'] == 0) {
// supprimer l'entête vide
fxDelPanierVide($_SESSION['no_panier']);
unset($_SESSION['no_panier']);
}
} else { // sinon, effacer la variable SESSION
unset($_SESSION['no_panier']);
}
break;
case 'cancel':
// vérifier si un panier existe déjà
$strNoPanier = fxNumPanier($tabEvenement['general']['eve_id'], $strLangue);
if (isset($tabData['pro_id'])) { // Ajouter un produit au panier avec la mention annulation
$sqlProduit = "SELECT * FROM inscriptions_produits_new WHERE pro_id = " . intval($tabData['pro_id']);
$tabProduit = $objDatabase->fxGetRow($sqlProduit);
if ($tabProduit != null) {
$sqlInsert = "INSERT INTO inscriptions_panier_produits_new SET eve_id = " . intval($tabProduit['eve_id']) . ", pec_id = " . intval($tabData['pec_id']) . ", par_id = 0, pro_id = " . intval($tabData['pro_id']) . ", pt_id = " . intval($tabProduit['pt_id']) . ", pro_nom_fr = '" . $objDatabase->fxEscape($tabProduit['pro_nom_fr']) . "', pro_nom_en = '" . $objDatabase->fxEscape($tabProduit['pro_nom_en']) . "', pro_description_fr = '" . $objDatabase->fxEscape($tabProduit['pro_description_fr']) . "', pro_description_en = '" . $objDatabase->fxEscape($tabProduit['pro_description_en']) . "', pro_taille_fr = '" . $objDatabase->fxEscape($tabProduit['pro_taille_fr']) . "', pro_taille_en = '" . $objDatabase->fxEscape($tabProduit['pro_taille_en']) . "', pro_section_fr = '" . $objDatabase->fxEscape($tabProduit['pro_section_fr']) . "', pro_section_en = '" . $objDatabase->fxEscape($tabProduit['pro_section_en']) . "', pro_prix = " . floatval($tabProduit['pro_prix_annulation']) . ", pro_taxable = " . intval($tabProduit['pro_taxable']) . ", pro_effacable = " . intval($tabProduit['pro_effacable']) . ", pro_maj = '" . fxGetDateTime() . "', no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pro_annulation = 1";
$qryInsert = $objDatabase->fxQuery($sqlInsert);
} else
fxcreer_log("Il y a eu une erreur lors de l'annulation d'un produit:\n" . $sqlProduit);
$tabNbItems = fxNbItemsPanier($strNoPanier);
$tabTotal = fxTotalPanier($strNoPanier, $strLangue);
if ($tabNbItems['nbitem'] == 1 && $tabTotal['total'] <= 0) { // MSIN-1139 - si le produit est le seul item au panier et que le prix d'annulation est 0$, rediriger à paiement redirect
$_SESSION['lang'] = $strLangue;
header("Location: " . $vDomaine . '/paiement_redirect.php');
exit;
}
}
}
if (isset($_SESSION['no_panier'])) {
if (isset($_POST['btn_participant']) && $_POST['btn_participant'] == 'add_new') {
// rediriger vers le panier
if ($strLangue == 'fr')
$strPage = 'reserver';
else
$strPage = 'book';
header("Location: " . $vDomaine . '/' . $strPage . '/' . $tabEvenement['general']['eve_label_url'] . '/' . $tabData['epr_id']);
exit;
}
// rediriger vers le panier
if ($strLangue == 'fr')
$strPage = 'panier';
else
$strPage = 'cart';
if ($strAction == 'auto') {
unset($_SESSION['no_panier']);
}
header("Location: " . $vDomaine . '/' . $strPage . '/somaire/' . $tabEvenement['general']['eve_label_url']);
} else {
if (!isset($_GET['pt_id'])) {
if ($strLangue == 'fr')
$strPage = 'compte';
else
$strPage = 'account';
if ($_POST['promoteur'] == 1)
header("Location: " . $vDomaine . '/' . $strPage . '/inc_tableau_promoteur?promoteur_eve_id=' . urlencode(base64_encode($tabEvenement['general']['eve_id'])));
else
header("Location: " . $vDomaine . '/' . $strPage);
} else {
header("Location: " . $tabData['url']);
}
}
exit;
}
// fonction pour vider le panier (JSP)
// param : no panier, cron job (1 = oui, 0 = non)
// créé : 2013-04-22
function fxViderPanier($strNoPanier, $intCronJob = 0)
{
global $objDatabase;
// vérifier si le panier peut être effacé (commande non-approuvée par Desjardins) AND (receipt_text = '' OR receipt_text IS NULL)
$sqlPanier = "SELECT COUNT(ach_id) AS nb FROM inscriptions_panier_acheteurs WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND sta_id = 1";
$intNbPanier = $objDatabase->fxGetVar($sqlPanier);
if ($intNbPanier > 0) {
// effacer l'entête du panier
$sqlDelete1 = "DELETE FROM inscriptions_panier_acheteurs WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$qryDelete1 = $objDatabase->fxQuery($sqlDelete1);
// effacer les rabais
$sqlDelete2 = "DELETE FROM inscriptions_panier_rabais_acheteurs WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$qryDelete2 = $objDatabase->fxQuery($sqlDelete2);
// effacer les partcipants
$sqlDelete4 = "DELETE FROM inscriptions_panier_participants WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$qryDelete4 = $objDatabase->fxQuery($sqlDelete4);
// effacer les questions
$sqlDelete5 = "DELETE FROM inscriptions_panier_questions WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$qryDelete5 = $objDatabase->fxQuery($sqlDelete5);
// effacer les produits
$sqlDelete6 = "DELETE FROM inscriptions_panier_produits_new WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$qryDelete6 = $objDatabase->fxQuery($sqlDelete6);
// effacer les épreuves commandées
$sqlDelete7 = "DELETE FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$qryDelete7 = $objDatabase->fxQuery($sqlDelete7);
// effacer les options
$sqlDelete = "DELETE FROM inscriptions_panier_options WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$qryDelete = $objDatabase->fxQuery($sqlDelete);
// effacer les montants dus
$sqlDelete = "DELETE FROM inscriptions_panier_montants_dus WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$qryDelete = $objDatabase->fxQuery($sqlDelete);
}
if ($intCronJob == 0) {
if (isset($_SESSION['no_panier']))
unset($_SESSION['no_panier']);
if (isset($_SESSION['msg_erreur']))
unset($_SESSION['msg_erreur']);
setcookie("no_panier", '', time() - 36000, '/');
header("Location: " . $_SERVER['HTTP_REFERER']);
exit();
}
}
// récupère les données d'un panier et les retourne dans un tableau (JSP)
// param : no panier
// créé : 2013-12-19
function fxListPanier($strNoPanier)
{
global $objDatabase;
$tabAcheteur = $tabEvenements = $tabProduits = $tabProduits2 = $tabEpreuves = $tabParticipants = $tabQuestions = $tabRabais = $tabMontantsDus = $tabQuestionsEpreuve = $tabDons = $tabDonsAuto = null;
$intEvenement = 0;
// info acheteur pour une commande
$sqlAcheteur = "SELECT * FROM inscriptions_panier_acheteurs WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$tabAcheteur = $objDatabase->fxGetRow($sqlAcheteur);
// info épreuves
$sqlEpreuves = "SELECT * FROM inscriptions_panier_epreuves e, inscriptions_panier_epreuves_commandees c WHERE e.epr_id = c.epr_id AND c.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' ORDER BY e.epr_date, e.epr_heure";
$tabEpreuves = $objDatabase->fxGetResults($sqlEpreuves);
// info produits 2
if ($tabEpreuves != null) {
$intEvenement = $tabEpreuves[1]['eve_id'];
$sqlProduits2 = "SELECT p.*, t.pt_nom_fr, t.pt_nom_en, '' AS epr_type_fr, '' AS epr_type_en FROM inscriptions_panier_produits_new p, inscriptions_produits_types t WHERE p.pt_id = t.pt_id AND p.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND p.pec_id = 0 UNION SELECT p.*, t.pt_nom_fr, t.pt_nom_en, e.epr_type_fr, e.epr_type_en FROM inscriptions_panier_produits_new p, inscriptions_produits_types t, inscriptions_panier_epreuves e, inscriptions_panier_epreuves_commandees c WHERE p.pt_id = t.pt_id AND p.pec_id = c.pec_id AND c.epr_id = e.epr_id AND p.pec_id <> 0 AND p.pec_id NOT IN(" . implode(',', array_map(function ($tab) {
return $tab['pec_id'];
}, $tabEpreuves)) . ") AND p.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
} else {
$sqlProduits2 = "SELECT p.*, t.pt_nom_fr, t.pt_nom_en, '' AS epr_type_fr, '' AS epr_type_en, '' AS com_prenom, '' AS com_nom, '' AS pec_nom_equipe FROM inscriptions_panier_produits_new p, inscriptions_produits_types t WHERE p.pt_id = t.pt_id AND p.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND p.pec_id = 0 UNION SELECT p.*, t.pt_nom_fr, t.pt_nom_en, e.epr_type_fr, e.epr_type_en, u.com_prenom, u.com_nom, c.pec_nom_equipe FROM inscriptions_panier_produits_new p, inscriptions_produits_types t, inscriptions_panier_epreuves e, inscriptions_panier_epreuves_commandees c, inscriptions_comptes u WHERE p.pt_id = t.pt_id AND p.pec_id = c.pec_id AND c.epr_id = e.epr_id AND u.com_id = c.com_id AND p.pec_id <> 0 AND p.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
}
$recProduits2 = $objDatabase->fxGetResults($sqlProduits2);
if ($recProduits2 != null) {
$tabProduits2 = $recProduits2;
$intEvenement = $tabProduits2[1]['eve_id'];
// info questions
$sqlQuestions = "SELECT * FROM inscriptions_panier_questions WHERE pec_id <> 0 AND no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$recQuestions = $objDatabase->fxGetResults($sqlQuestions);
if ($recQuestions != null)
$tabQuestions = $recQuestions;
}
// info montants dus
$sqlMontantsDus = "SELECT m.*, e.epr_type_fr, e.epr_type_en, u.com_prenom, u.com_nom, c.pec_nom_equipe FROM inscriptions_panier_montants_dus m, inscriptions_panier_epreuves e, inscriptions_panier_epreuves_commandees c, inscriptions_comptes u WHERE m.pec_id = c.pec_id AND c.epr_id = e.epr_id AND u.com_id = c.com_id AND m.pec_id <> 0 AND m.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$recMontantsDus = $objDatabase->fxGetResults($sqlMontantsDus);
if ($recMontantsDus != null) {
$tabMontantsDus = $recMontantsDus;
$intEvenement = $tabMontantsDus[1]['eve_id'];
}
// info dons #dons2017 #MSIN-1987
$sqlDons = "SELECT d.*, e.pec_nom_equipe, e.no_commande, e.epr_objectif_dons, IF(d.par_id <> 0, (SELECT CONCAT(par_prenom, ' ', par_nom) FROM resultats_participants WHERE d.par_id = par_id_original), '') AS participant FROM inscriptions_panier_dons d, resultats_epreuves_commandees e WHERE d.pec_id = e.pec_id_original AND d.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$recDons = $objDatabase->fxGetResults($sqlDons);
if ($recDons != null) {
$tabDons = $recDons;
$intEvenement = $tabDons[1]['eve_id_don'];
}
// info dons #dons2017 #MSIN-1987
$sqlDonsAuto = "SELECT * FROM inscriptions_panier_dons_auto WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$recDonsAuto = $objDatabase->fxGetResults($sqlDonsAuto);
if ($recDonsAuto != null) {
$tabDonsAuto = $recDonsAuto;
}
// info événements
$sqlEvenements = "SELECT * FROM inscriptions_panier_evenements WHERE eve_id = " . intval($intEvenement);
$tabEvenements = $objDatabase->fxGetRow($sqlEvenements);
// info rabais
$sqlRabais = "SELECT r.* FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE a.pra_id = r.pra_id AND r.pra_depot = 0 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' ORDER BY r.rab_code, r.pra_maj";
$tabRabais = $objDatabase->fxGetResults($sqlRabais);
// info dépôt
$sqlDepots = "SELECT r.* FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE a.pra_id = r.pra_id AND r.pra_depot = 1 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' ORDER BY r.rab_code, r.pra_maj";
$tabDepots = $objDatabase->fxGetResults($sqlDepots);
// info options
$sqlOptions = "SELECT * FROM inscriptions_panier_options WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' ORDER BY pop_maj";
$tabOptions = $objDatabase->fxGetResults($sqlOptions);
if ($tabEpreuves != null) {
for ($intCtr = 1; $intCtr <= count($tabEpreuves); $intCtr++) {
// info questions épreuve
$sqlQuestions = "SELECT * FROM inscriptions_panier_questions WHERE par_id = 0 AND pec_id = " . intval($tabEpreuves[$intCtr]['pec_id']) . " AND no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$recQuestionsEpreuve = $objDatabase->fxGetResults($sqlQuestions);
if ($recQuestionsEpreuve != null)
$tabQuestionsEpreuve[$tabEpreuves[$intCtr]['pec_id']] = $recQuestionsEpreuve;
// info produits
$sqlProduits = "SELECT p.*, t.pt_nom_fr, t.pt_nom_en FROM inscriptions_panier_produits_new p, inscriptions_produits_types t WHERE p.pt_id = t.pt_id AND p.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND p.pec_id = " . intval($tabEpreuves[$intCtr]['pec_id']);
$recProduits = $objDatabase->fxGetResults($sqlProduits);
if ($recProduits != null)
$tabProduits[$tabEpreuves[$intCtr]['pec_id']] = $recProduits;
// info participants
$sqlParticipants = "SELECT p.*, r.rol_nom_fr, r.rol_nom_en FROM inscriptions_panier_participants p, inscriptions_panier_epreuves c, inscriptions_roles r WHERE p.pep_id = c.pep_id AND p.par_ajout_post = 0 AND r.rol_id = p.rol_id AND p.pec_id = " . intval($tabEpreuves[$intCtr]['pec_id']) . " ORDER BY c.epr_date, c.epr_heure, p.par_id";
//$sqlParticipants = "SELECT p.* FROM inscriptions_panier_participants p, inscriptions_panier_epreuves c WHERE p.pep_id = c.pep_id AND p.par_ajout_post = 0 AND p.rol_id = 1 AND p.pec_id = " . intval($tabEpreuves[$intCtr]['pec_id']) . " ORDER BY c.epr_date, c.epr_heure, p.par_id";
$recParticipants = $objDatabase->fxGetResults($sqlParticipants);
if ($recParticipants != null) {
$tabParticipants[$tabEpreuves[$intCtr]['pec_id']] = $recParticipants;
for ($intCtr2 = 1; $intCtr2 <= count($recParticipants); $intCtr2++) {
// info questions
$sqlQuestions = "SELECT * FROM inscriptions_panier_questions WHERE par_id = " . intval($recParticipants[$intCtr2]['par_id']) . " AND no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'";
$recQuestions = $objDatabase->fxGetResults($sqlQuestions);
if ($recQuestions != null)
$tabQuestions[$recParticipants[$intCtr2]['par_id']] = $recQuestions;
}
}
}
}
// sortir la couleur de l'événement
$sqlColor = "SELECT eve_couleur FROM inscriptions_evenements WHERE eve_id = " . intval($intEvenement);
$strColor = $objDatabase->fxGetVar($sqlColor);
//MSIN-4376
// sortir la switch qrcode
$sqlqrcode = "SELECT eve_code_qr FROM inscriptions_evenements WHERE eve_id = " . intval($intEvenement);
$strqrcode = $objDatabase->fxGetVar($sqlqrcode);
// si vide, couleur par défaut
if (empty($strColor)) {
$strColor = '#f3a566';
}
$strColor = str_replace('#', '', $strColor);
$tabRetour[0] = $tabAcheteur;
$tabRetour[1] = $tabEvenements;
$tabRetour[2] = $tabProduits;
$tabRetour[3] = $tabEpreuves;
$tabRetour[4] = $tabParticipants;
$tabRetour[5] = $tabQuestions;
$tabRetour[6] = $tabRabais;
$tabRetour[7] = $tabProduits2;
$tabRetour[8] = $tabOptions;
$tabRetour[9] = $tabDepots;
$tabRetour[10] = $tabMontantsDus;
$tabRetour[11] = $tabQuestionsEpreuve;
$tabRetour[12] = $tabDons;
$tabRetour[13] = $tabDonsAuto;
$tabRetour[14] = $strColor;
$tabRetour[15] = $strqrcode;
return $tabRetour;
}
// met dans deux tableaux les destination et les clients pour un panier (JSP)
// param : cart = 0 ou 1 (affiche la case à cocher pour supprimer), output = web ou log, resume = 0 ou 1 (affiche les infos finales lorsque l'achat est terminé), langue
// créé : 2013-04-20
function fxShowPanier($strNoPanier, $cart, $output, $resume, $strLangue)
{
global $objDatabase, $vblnEnvironementDev, $vDomaine;
// si $output = paypal le resultat est un tableau
$retour_output = $output;
if ($output == 'paypal')
$output = 'web';
$mem_paypal_boucle = 0;
$mem_paypal = $tabPaypal = array();
$strRetour = '';
$tabPanier = fxListPanier($strNoPanier);
$tabAcheteur = $tabPanier[0];
$tabEvenements = $tabPanier[1];
$tabProduits = $tabPanier[2];
$tabEpreuves = $tabPanier[3];
$tabParticipants = $tabPanier[4];
$tabQuestions = $tabPanier[5];
$tabRabais = $tabPanier[6];
$tabProduits2 = $tabPanier[7];
$tabOptions = $tabPanier[8];
$tabDepots = $tabPanier[9];
$tabMontantsDus = $tabPanier[10];
$tabQuestionsEpreuve = $tabPanier[11];
$tabDons = $tabPanier[12];
$strColor = $tabPanier[14];
$strcodeqr = $tabPanier[15];
$tabTotal = fxTotalPanier($strNoPanier, $strLangue);
if ($resume == 1) {
// récupérer le statut de la commande
$sqlStatut = "SELECT sta_nom_$strLangue, sta_description_$strLangue FROM inscriptions_panier_statuts WHERE sta_id = " . intval($tabAcheteur['sta_id']);
$recStatut = $objDatabase->fxGetRow($sqlStatut);
// récupérer le mode de paiement de la commande
$sqlPaiement = "SELECT pai_nom_$strLangue FROM inscriptions_paiements WHERE pai_id = " . intval($tabAcheteur['pai_id']);
$recPaiement = $objDatabase->fxGetRow($sqlPaiement);
if (intval($tabEvenements['eve_gratuit']) != 1) { // si l'événement n'est pas gratuit
if ($strLangue == 'fr') {
$strRetour .= '
Numéro de commande : ' . fxUnescape($tabAcheteur['no_commande']) . '
Statut de la transaction : ' . fxUnescape($tabAcheteur['receipt_text']) . '
Numéro de transaction : ' . $tabAcheteur['TransactionID'] . '
Mode de paiement : ' . fxUnescape($recPaiement['pai_nom_fr']) . '
Date de la commande : ' . fxShowDate($tabAcheteur['ach_maj'], 'fr') . ' @ ' . fxShowTime($tabAcheteur['ach_maj'], 1, 'fr') . '
Statut de la commande : ' . fxUnescape($recStatut['sta_nom_fr']) . ' ' . fxUnescape($recStatut['sta_description_fr']) . '
';
} else {
$strRetour .= '
Order number : ' . fxUnescape($tabAcheteur['no_commande']) . '
Transaction status : ' . fxUnescape($tabAcheteur['receipt_text']) . '
Transaction id : ' . $tabAcheteur['TransactionID'] . '
Payment method : ' . fxUnescape($recPaiement['pai_nom_en']) . '
Date of the order : ' . fxShowDate($tabAcheteur['ach_maj'], 'en') . ' @ ' . fxShowTime($tabAcheteur['ach_maj'], 1, 'en') . '
Order status : ' . fxUnescape($recStatut['sta_nom_en']) . ' ' . fxUnescape($recStatut['sta_description_en']) . '
';
}
} else { // si l'événement est gratuit
if ($strLangue == 'fr') {
$strRetour .= '
Numéro de l\'inscription : ' . fxUnescape($tabAcheteur['no_commande']) . '
Date de l\'inscription : ' . fxShowDate($tabAcheteur['ach_maj'], 'fr') . ' @ ' . fxShowTime($tabAcheteur['ach_maj'], 1, 'fr') . '
Statut de l\'inscription : ' . fxUnescape($recStatut['sta_nom_fr']) . ' ' . fxUnescape($recStatut['sta_description_fr']) . '
';
} else {
$strRetour .= '
Registration number : ' . fxUnescape($tabAcheteur['no_commande']) . '
Date of the registration : ' . fxShowDate($tabAcheteur['ach_maj'], 'en') . ' @ ' . fxShowTime($tabAcheteur['ach_maj'], 1, 'en') . '
Registration status : ' . fxUnescape($recStatut['sta_nom_en']) . ' ' . fxUnescape($recStatut['sta_description_en']) . '
';
}
}
}
if ($output == 'web') {
$strRetour .= '
| '; if (intval($tabEvenements['eve_gratuit']) != 1) { // si événement normal if ($strLangue == 'fr') { $strRetour .= ' | Produit | '; $strRetour .= 'Prix | '; } else { $strRetour .= 'Product | '; $strRetour .= 'Price | '; } } else { if ($strLangue == 'fr') { $strRetour .= 'Inscription | '; $strRetour .= ''; } else { $strRetour .= ' | Registration | '; $strRetour .= ''; } } $strRetour .= ' |
|---|---|---|---|---|---|---|---|---|
| '; $strRetour .= ' | ' . fxUnescape($tabEvenements['eve_nom_' . $strLangue]) . ' | '; $strRetour .= '|||||||
| '; $strEpreuve = ''; } else { // bouton carte membre $strEpreuve = ''; if ($resume == 1) { if (intval($tabEpreuves[$intCtr2]['tep_id']) == 4) { $arrMembership = fxGetAbonnement(0, 0, 0, 0, $tabEpreuves[$intCtr2]['pec_id']); $strNumero = $arrMembership["mem_numero"]; $strPage = ($strLangue == 'fr') ? 'compte' : 'account'; $strEpreuve = ' ' . afficheTexte('btn_acces_carte_de membre', 0, 1, 1) . $strNumero . ' | ' . $strEpreuve;
if ($tabEpreuves[$intCtr2]['epr_heure'] != '00:00:00')
$strRetour .= ' @ ' . fxShowTime($tabEpreuves[$intCtr2]['epr_heure']);
$strRetour .= $strTaxable;
// récupérer l'info de la catégorie d'âge ou la distance
$tabEpreuveHeader = array();
$strEpreuveHeader = '';
if (isset($tabQuestionsEpreuve[$tabEpreuves[$intCtr2]['pec_id']])) {
for ($intCtr5 = 1; $intCtr5 <= count($tabQuestionsEpreuve[$tabEpreuves[$intCtr2]['pec_id']]); $intCtr5++) {
if ($tabQuestionsEpreuve[$tabEpreuves[$intCtr2]['pec_id']][$intCtr5]['que_validation'] != 'capitaine') {
if ($tabQuestionsEpreuve[$tabEpreuves[$intCtr2]['pec_id']][$intCtr5]['que_cart_show'] == 1 || $tabQuestionsEpreuve[$tabEpreuves[$intCtr2]['pec_id']][$intCtr5]['que_validation'] == 'equipe' || $tabQuestionsEpreuve[$tabEpreuves[$intCtr2]['pec_id']][$intCtr5]['que_validation'] == 'categorie') {
switch ($tabQuestionsEpreuve[$tabEpreuves[$intCtr2]['pec_id']][$intCtr5]['que_validation']) {
case 'categorie':
if ($strLangue == 'fr')
$strLabel = "Catégorie";
else
$strLabel = "Category";
break;
case 'equipe':
if ($strLangue == 'fr')
$strLabel = "Nom d'équipe";
else
$strLabel = "Team name";
break;
default:
$strLabel = fxUnescape($tabQuestionsEpreuve[$tabEpreuves[$intCtr2]['pec_id']][$intCtr5]['que_cart_label_' . $strLangue]);
}
if (fxUnescape($tabQuestionsEpreuve[$tabEpreuves[$intCtr2]['pec_id']][$intCtr5]['que_choix_' . $strLangue]) != '')
$tabEpreuveHeader[] = fxUnescape($strLabel) . ': ' . fxUnescape($tabQuestionsEpreuve[$tabEpreuves[$intCtr2]['pec_id']][$intCtr5]['que_choix_' . $strLangue]);
}
}
}
}
$strEpreuveHeader .= implode(' ', $tabEpreuveHeader); // MSIN-1999 if ($strEpreuveHeader != '') { $strRetour .= ' ' . $strEpreuveHeader . ' '; } // génération de don MSIN-2566 if ($tabEpreuves[$intCtr2]['pec_montant_don'] > 0 && $tabEpreuves[$intCtr2]['pec_don_actif'] == 1) { if ($strLangue == 'fr') $strLabel = "Votre don en espèce:"; else $strLabel = "Your cash donation:"; $strRetour .= ' ' . $strLabel . fxShowPrix(($tabEpreuves[$intCtr2]['pec_montant_don'] - $tabEpreuves[$intCtr2]['rab_montant']), $strLangue, 1) . ' ';
}
$strRetour .= '
|
';
if ($tabEvenements['eve_gratuit'] != 1) { // si événement normal
if ($tabEpreuves[$intCtr2]['rab_montant'] > 0) {
$strRetour .= ' ' . fxShowPrix($tabEpreuves[$intCtr2]['pec_prix'], $strLangue, 1) . ' ';
$strRetour .= fxShowPrix($tabEpreuves[$intCtr2]['pec_prix'] - $tabEpreuves[$intCtr2]['rab_montant'], $strLangue, 1);
} else {
$strRetour .= fxShowPrix($tabEpreuves[$intCtr2]['pec_prix'], $strLangue, 1);
}
}
$strRetour .= '
|
||||||
| '; $strRetour .= ' | ' . $strEpreuveHeader . ' | '; $strRetour .= '|||||||
| '; $strRetour .= ' | ';
if ($tabEpreuves[$intCtr2]['epr_equipe'] == 1) {
// abonnement
if (intval($tabEpreuves[$intCtr2]['mt_id']) == 4) {
if (intval($tabParticipants[$intEpreuve][$intCtr3]['rol_id']) == 1) {
$strRetour .= '' . afficheTexte('participant-titre-responsable', 0, 1, 1) . ': ';
} else {
$strRetour .= '' . afficheTexte('participant-titre-entraineur', 0, 1, 1) . ': ';
}
} else {
$strRetour .= '' . fxUnescape($tabParticipants[$intEpreuve][$intCtr3]['rol_nom_' . $strLangue]) . ': ';
}
}
$strRetour .= fxUnescape($tabParticipants[$intEpreuve][$intCtr3]['par_nom']) . ', ' . fxUnescape($tabParticipants[$intEpreuve][$intCtr3]['par_prenom']);
if ($tabParticipants[$intEpreuve][$intCtr3]['par_courriel'] != '')
$strRetour .= ' (' . fxUnescape($tabParticipants[$intEpreuve][$intCtr3]['par_courriel']) . ')';
$strSexe = fxGetGender($tabParticipants[$intEpreuve][$intCtr3]['par_sexe'], $strLangue);
if ($strLangue == 'fr') {
$strNaissance = "Date de naissance: ";
} else {
$strNaissance = "Birthdate: ";
}
if ($tabParticipants[$intEpreuve][$intCtr3]['par_naissance'] != '' && $tabParticipants[$intEpreuve][$intCtr3]['par_naissance'] != '0000-00-00')
$strRetour .= ' ' . $strNaissance . fxShowDate($tabParticipants[$intEpreuve][$intCtr3]['par_naissance'], $strLangue) . ' - ' . $strSexe; else $strRetour .= ' ' . $strSexe; if (count($tabQuestionsCart) > 0) $strRetour .= ' ' . implode(' ', $tabQuestionsCart); // afficher les catégories, si pas vide $strCategories = ''; if ($strLangue == 'fr') $strLabel = "Catégorie"; else $strLabel = "Category"; if (trim($tabParticipants[$intEpreuve][$intCtr3]['par_categorie_1_long_fr']) != '') { if ($strLangue == 'fr') { $strCategories .= fxUnescape($tabParticipants[$intEpreuve][$intCtr3]['par_categorie_1_long_fr']) . ' '; } else { $strCategories .= fxUnescape($tabParticipants[$intEpreuve][$intCtr3]['par_categorie_1_long_en']) . ' '; } } if (trim($tabParticipants[$intEpreuve][$intCtr3]['par_categorie_2_long_fr']) != '') { if ($strLangue == 'fr') { $strCategories .= fxUnescape($tabParticipants[$intEpreuve][$intCtr3]['par_categorie_2_long_fr']) . ' '; } else { $strCategories .= fxUnescape($tabParticipants[$intEpreuve][$intCtr3]['par_categorie_2_long_en']) . ' '; } } if (trim($tabParticipants[$intEpreuve][$intCtr3]['par_categorie_3_long_fr']) != '') { if ($strLangue == 'fr') { $strCategories .= fxUnescape($tabParticipants[$intEpreuve][$intCtr3]['par_categorie_3_long_fr']) . ' '; } else { $strCategories .= fxUnescape($tabParticipants[$intEpreuve][$intCtr3]['par_categorie_3_long_en']) . ' '; } } if (trim($strCategories) != '') { $strRetour .= ' ' . $strLabel . ':' . $strCategories; } $strRetour .= ' | ';
//MSIN-4323 $tabEvenements['eve_code_qr']==1 &&
//MSIN-4376
if($strcodeqr!=1 ){
if( $resume==1){
$result = fxcreer_qr_token([
'par_id' => $tabParticipants[$intEpreuve][$intCtr3]["par_id"],
'pec_id_original' => $tabParticipants[$intEpreuve][$intCtr3]["pec_id"],
'ach_id' => $tabAcheteur["ach_id"],
'com_id' =>$tabParticipants[$intEpreuve][$intCtr3]["com_id"],
'eve_id' =>$tabParticipants[$intEpreuve][$intCtr3]["eve_id"],
'status' => 'actif'
]);
$token = fxdecrypt_token($result['token_enc']);
// $strRetour .= ' '.' | ';
$strRetour .= '||||||
| '; $strRetour .= ' | ||||||||
| '; } else $strRetour .= ' | '; } $strRetour .= ' | ' . fxUnescape($tabProduits[$intEpreuve][$intCtr4]['pro_nom_' . $strLangue]) . ' ' . fxUnescape($tabProduits[$intEpreuve][$intCtr4]['pro_taille_' . $strLangue]) . ' |
';
if ($tabEvenements['eve_gratuit'] != 1) { // si événement normal
if ($tabProduits[$intEpreuve][$intCtr4]['rab_montant'] > 0) {
$strRetour .= ' ' . fxShowPrix($tabProduits[$intEpreuve][$intCtr4]['pro_prix'], $strLangue, 1) . ' ';
$strRetour .= fxShowPrix($tabProduits[$intEpreuve][$intCtr4]['pro_prix'] - $tabProduits[$intEpreuve][$intCtr4]['rab_montant'], $strLangue, 1);
} else {
$strRetour .= fxShowPrix($tabProduits[$intEpreuve][$intCtr4]['pro_prix'], $strLangue, 1);
}
}
$strRetour .= '
|
|||||
| '; $strRetour .= ' | ||||||||
| '; } else $strRetour .= ' | '; } if ($tabProduits2[$intCtr]['pro_annulation'] != 0) { // mentionner si c'est une annulation if ($strLangue == 'fr') $strAnnulation = 'Annulation'; else $strAnnulation = ''; } else $strAnnulation = ''; if ($tabProduits2[$intCtr]['epr_type_' . $strLangue] != '') { if ($tabProduits2[$intCtr]['pec_nom_equipe'] != '') $strReservee = fxUnescape($tabProduits2[$intCtr]['pec_nom_equipe']); else $strReservee = fxUnescape($tabProduits2[$intCtr]['com_prenom']) . ' ' . fxUnescape($tabProduits2[$intCtr]['com_nom']); if ($strLangue == 'fr') $strEpreuveProduit = ' | ' . $strAnnulation . fxUnescape($tabProduits2[$intCtr]['pt_nom_' . $strLangue]) . ': ' . fxUnescape($tabProduits2[$intCtr]['pro_nom_' . $strLangue]) . ' ' . fxUnescape($tabProduits2[$intCtr]['pro_taille_' . $strLangue]) . $strEpreuveProduit . ' | '; if ($tabEvenements['eve_gratuit'] != 1) { // si événement normal $strRetour .= '' . fxShowPrix($tabProduits2[$intCtr]['pro_prix'], $strLangue, 1) . ' | '; } $strRetour .= '|||||
| ' . $strEpreuveMontant . ' | ' . fxShowPrix($tabDons[$intCtr]['pd_montant'], $strLangue, 1) . ' | |||||||
| '; } else $strRetour .= ' | '; } if ($tabRabais[$intCtr]['rab_montant'] > 0) $strRabaisValeur = fxShowPrix($tabRabais[$intCtr]['rab_montant'], $strLangue, 1); else $strRabaisValeur = $tabRabais[$intCtr]['rab_pourcent'] . '%'; $strCodeRabais = ''; if ($tabRabais[$intCtr]['rab_code'] != '-') { $strCodeRabais = fxUnescape($tabRabais[$intCtr]['rab_code']) . ' - '; } $strRetour .= ' | ' . $strCodeRabais . fxUnescape($tabRabais[$intCtr]['rab_description_' . $strLangue]) ;
//MSIN-4316
if($tabRabais[$intCtr]['rab_note_' . $strLangue]!=''){
$strRetour .= ' '.$tabRabais[$intCtr]['rab_note_' . $strLangue].''; } $strRetour .= ' | ';
$strRetour .= ' (' . $strRabaisValeur . ') | '; $strRetour .= '|||||
| '; $strRetour .= ' | ||||||||
| Rabais total : | '; else $strRetour .= 'Discount total : | '; $strRetour .= '(' . fxShowPrix($tabTotal["rabais_total"], $strLangue, 1) . ') | '; $strRetour .= '||||||
| Sous-total 1 (avant frais de services) : | '; else $strRetour .= 'Subtotal (before services fees) : | '; } else { if ($strLangue == 'fr') $strRetour .= 'Sous-total : | '; else $strRetour .= 'Subtotal : | '; } $strRetour .= '' . fxShowPrix($tabTotal["stotal"], $strLangue, 1) . ' | '; $strRetour .= '||||
| '; $strRetour .= ' | ||||||||
| ' . $tabTotal['taxes'][$intCtr]['label_' . $strLangue] . ' ' . $tabTotal['taxes'][$intCtr]['numero'] . ' : | '; $strRetour .= '' . fxShowPrix($tabTotal['taxes'][$intCtr]['montant'], $strLangue, 1) . ' | '; $strRetour .= '|||||||
| '; $strRetour .= ' | ||||||||
| Sous-total 2 (avant frais de services) : | '; else $strRetour .= 'Subtotal (before services fees) : | '; $strRetour .= '' . fxShowPrix($tabTotal["stotal2"], $strLangue, 1) . ' | '; $strRetour .= '||||||
| '; $strRetour .= ' | ||||||||
| Frais de service MS-1' . $strFraisPourcent . ' :' . $strFraisAutres . ' | '; else $strRetour .= 'MS-1 Processing Fees' . $strFraisPourcent . ' :' . $strFraisAutres . ' | '; $strRetour .= '' . fxShowPrix($tabTotal["fra_avant_tx"], $strLangue, 1) . ' | '; $strRetour .= '||||||
| ' . $tabTotal['taxes_frais'][$intCtr]['label_' . $strLangue] . ' ' . $tabTotal['taxes_frais'][$intCtr]['numero'] . ' : | '; $strRetour .= '' . fxShowPrix($tabTotal['taxes_frais'][$intCtr]['montant'], $strLangue, 1) . ' | '; $strRetour .= '|||||||
| '; $strRetour .= ' | ||||||||
| Total ' . $strPaid . $strTaxes . ': | ' . fxShowPrix($tabTotal["total"], $strLangue, 1) . ' | |||||||
' . $strLabel . fxShowPrix($tabTotal["total_don"], $strLangue, 1) . ' |
||||||||
| Adresse | '; else $adresse .= 'Address | '; $adresse .= '
|---|---|
| ';
}
$adresse .= fxUnescape($tabAcheteur['com_prenom']) . ' ' . fxUnescape($tabAcheteur['com_nom']) . ' '; $adresse .= fxUnescape($tabAcheteur['com_adresse']) . ' '; if (trim($tabAcheteur['com_adresse2']) != '') { $adresse .= fxUnescape($tabAcheteur['com_adresse2']) . ' '; } $mem_province = fxGetProvinces($tabAcheteur['pro_id'], $strLangue); $mem_pays = fxGetPays($tabAcheteur['pay_id'], $strLangue); $adresse .= fxUnescape($tabAcheteur['com_ville']) . ', ' . fxUnescape($mem_province['pro_nom_' . $strLangue]) . ' '; $adresse .= fxUnescape($mem_pays['pay_nom_' . $strLangue]) . ' '; $adresse .= fxUnescape($tabAcheteur['com_codepostal']); $adresse .= ' '; $adresse .= fxUnescape($tabAcheteur['com_telephone1']) . ' '; if ($tabAcheteur['com_telephone2'] != '') $adresse .= fxUnescape($tabAcheteur['com_telephone2']) . ' '; $adresse .= fxUnescape($tabAcheteur['com_courriel']) . ' '; if ($type == 'web') { $adresse .= ' | ';
$adresse .= '
' . $GLOBALS['vClient'] . '
'; $strAdresse .= '' . $GLOBALS['vNumero'] . ' | ' . $GLOBALS['vNumeroSF'] . '
'; $strAdresse .= '' . $GLOBALS['vEmail'] . '
'; } return $strAdresse; } // fonction pour afficher le ou les messsages d'approbation sur la facture (JSP) // param : no panier function fxShowApprobation($strNoPanier, $strLangue) { global $objDatabase; $strOutput = ''; if ($strLangue == 'fr') { $strMessageEtat = "Félicitations ! Vous êtes maintenant inscrit à une activité présentée dans le cadre du %nom_evenement%."; } else { $strMessageEtat = "Congratulations ! You are now registered in %nom_evenement%."; } if ($strNoPanier != '') { $sqlApprobation = "SELECT e.eve_nom_$strLangue AS nom, e.eve_msg_approbation_$strLangue AS msg FROM inscriptions_evenements e WHERE e.eve_id IN(SELECT a.eve_id FROM inscriptions_panier_acheteurs a WHERE a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "')"; $arrApprobation = $objDatabase->fxGetResults($sqlApprobation); foreach ($arrApprobation as $id => $arr) { if (intval($id) > 1) { $strOutput .= '".print_r($tabQuestions[$tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_id']][$intCtr3],true).""); // print("
".print_r($tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2],true).""); $list_file[] = $tabQuestions[$tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_id']][$intCtr3]['que_choix_fr']; $mem_panier_question = $tabQuestions[$tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_id']][$intCtr3]['no_panier']; } $sqlInsert = "INSERT INTO resultats_questions(par_id, pec_id, que_id, que_question_fr, que_question_en, que_choix_fr, pqu_note, que_choix_en, pqu_maj, no_panier, no_commande, pqu_id_original, que_modifiable,que_validation) SELECT par_id, pec_id, que_id, que_question_fr, que_question_en, que_choix_fr, '', que_choix_en, '" . fxGetDateTime() . "', no_panier, '" . $no_commande . "', pqu_id, que_modifiable,que_validation FROM inscriptions_panier_questions WHERE pqu_id = " . intval($tabQuestions[$tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_id']][$intCtr3]['pqu_id']); $qryInsert = $objDatabase->fxQuery($sqlInsert); } //print_r($list_file); //error_log("test"); if (!empty($list_file)) { // error_log("Début de la fonction ".$mem_panier_question); $mem_eve_id = $tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['eve_id']; fxtransfertfiles($list_file, $mem_panier_question, $mem_eve_id); fxdeletefiles('upload/temp/' . $mem_panier_question); } } } } } if ($tabProduits2 != null) { for ($intCtr = 1; $intCtr <= count($tabProduits2); $intCtr++) { if ($tabProduits2[$intCtr]['pro_annulation'] == 0) { // Si achat, ajouter à résultats et réduire le crédit pour futur achat // insérer les produits non rattachés à une épreuve $sqlInsert = "INSERT INTO resultats_produits_new(eve_id, pec_id, par_id, pro_id, pt_id, pro_section_fr, pro_section_en, pro_description_fr, pro_description_en, pro_maj, no_panier, ppn_id_original, pro_nom_fr, pro_nom_en, pro_taille_fr, pro_taille_en, no_commande) SELECT eve_id, pec_id, par_id, pro_id, pt_id, pro_section_fr, pro_section_en, pro_description_fr, pro_description_en, '" . fxGetDateTime() . "', no_panier, ppn_id, pro_nom_fr, pro_nom_en, pro_taille_fr, pro_taille_en, '" . $no_commande . "' FROM inscriptions_panier_produits_new WHERE ppn_id = " . intval($tabProduits2[$intCtr]['ppn_id']); $qryInsert = $objDatabase->fxQuery($sqlInsert); $sqlUpdate = "UPDATE resultats_epreuves_commandees SET pec_credit_camping = IF(pec_credit_camping - " . floatval($tabProduits2[$intCtr]['pro_prix']) . " > 0, pec_credit_camping - " . floatval($tabProduits2[$intCtr]['pro_prix']) . ", 0) WHERE pec_id_original = " . intval($tabProduits2[$intCtr]['pec_id']); $qryUpdate = $objDatabase->fxQuery($sqlUpdate); } else { // Si annulation, effacer de résultats et ajouter le crédit pour futur achat $sqlInsert = "DELETE FROM resultats_produits_new WHERE pro_id = " . intval($tabProduits2[$intCtr]['pro_id']); $qryInsert = $objDatabase->fxQuery($sqlInsert); // trouver le prix original $sqlProduit = "SELECT pro_prix FR OM inscriptions_produits_new WHERE pro_id = " . intval($tabProduits2[$intCtr]['pro_id']); $fltPrix = $objDatabase->fxGetVar($sqlProduit); $sqlUpdate = "UPDATE resultats_epreuves_commandees SET pec_credit_camping = pec_credit_camping + " . floatval($fltPrix) . " WHERE pec_id_original = " . intval($tabProduits2[$intCtr]['pec_id']); $qryUpdate = $objDatabase->fxQuery($sqlUpdate); } } // QUESTIONS for ($intCtr3 = 1; $intCtr3 <= count($tabQuestions); $intCtr3++) { //TODOjs: à vérifier MSIN-2133 $sqlInsert = "INSERT INTO resultats_questions(par_id, pec_id, que_id, que_question_fr, que_question_en, que_choix_fr, pqu_note, que_choix_en, pqu_maj, no_panier, no_commande, pqu_id_original, que_modifiable, que_validation) SELECT par_id, pec_id, que_id, que_question_fr, que_question_en, que_choix_fr, '', que_choix_en, '" . fxGetDateTime() . "', no_panier, '" . $no_commande . "', pqu_id, que_modifiable, que_validation FROM inscriptions_panier_questions WHERE pqu_id = " . intval($tabQuestions[$intCtr3]['pqu_id']); $qryInsert = $objDatabase->fxQuery($sqlInsert); // Désactiver les questions en double $sqlUpdate = "UPDATE resultats_questions SET que_actif = 0 WHERE que_id = " . intval($tabQuestions[$intCtr3]['que_id']) . " AND no_commande <> '" . $no_commande . "'"; //$qryUpdate = $objDatabase->fxQuery($sqlUpdate); } } if ($tabMontantsDus != null) { for ($intCtr = 1; $intCtr <= count($tabMontantsDus); $intCtr++) { // mettre à jour le champ no_commande_paye dans la table montants_dus $sqlUpdate = "UPDATE inscriptions_montants_dus SET no_commande_paye = '" . $no_commande . "' WHERE md_id = " . intval($tabMontantsDus[$intCtr]['md_id']); $qryUpdate = $objDatabase->fxQuery($sqlUpdate); $sqlUpdate2 = "UPDATE resultats_epreuves_commandees SET pec_complete = 1 WHERE pec_id_original = " . intval($tabMontantsDus[$intCtr]['pec_id']); $qryUpdate2 = $objDatabase->fxQuery($sqlUpdate2); } } /* MSIN-2568 - Stéphan * DON + $ach_total_dons * TABLE = inscriptions_panier_dons_auto */ if ($ach_total_don > 0) { $blnDonAuto = true; $arrEvenement2 = fxGetEvenementsId($tabEvenements['eve_id']); $strPrefixe = $arrEvenement2['eve_prefixe']; if ($blnDonAuto && trim($arrEvenement2['eve_prefixe2']) != '') { $strPrefixe = $arrEvenement2['eve_prefixe2']; } elseif (trim($arrEvenement2['eve_prefixe']) != '') { $strPrefixe = $arrEvenement2['eve_prefixe']; } else { $strPrefixe = 'DON-'; } // stephan recherche le dernier numero pour cette evenement don MSIN-2007 $sqldons = "select pd_recu_numero from inscriptions_panier_dons_auto where pd_recu_numero>0 and eve_id = " . intval($tabEvenement['eve_id']) . " order by pd_recu_numero desc limit 1"; $tabdons = $objDatabase->fxGetRow($sqldons); if ($tabdons == null) $mem_no_recu = 1; else $mem_no_recu = $tabdons['pd_recu_numero'] + 1; $sqlInsert = "INSERT INTO inscriptions_panier_dons_auto SET pd_recu_numero=" . $mem_no_recu . ",eve_id = " . intval($tabEvenement['eve_id']) . ", no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pd_montant = " . floatval($ach_total_don) . ", eve_prefixe = '" . $objDatabase->fxEscape($strPrefixe) . "'"; $qryInsert = $objDatabase->fxQuery($sqlInsert); } $return = $no_commande; $blnSend = true; } elseif ($tabAcheteur['no_commande'] != '') { $no_commande = $tabAcheteur['no_commande']; if ($tabDonsAuto != null) { $ach_total_don = $tabDonsAuto[1]['pd_montant']; $blnDonAuto = true; } $return = $no_commande; } else { $no_commande = ''; $return = false; } if (($blnResend || $blnSend) && fxGetVariable('confirm_mail') == '1') { /* MSIN-2568 - Stéphan * DON + $ach_total_dons * TABLE = inscriptions_panier_dons_auto */ if ($ach_total_don > 0) { $tabPanier = fxlistPanier($strNoPanier); $tabDonsAuto = $tabPanier[13]; $intRecu = 1; $arrEvenement2 = fxGetEvenementsId($tabEvenements['eve_id']); if (trim($tabDonsAuto[1]['pd_recu_pdf']) != '') { $strNomFichier = trim($tabDonsAuto[1]['pd_recu_pdf']); } else { if (file_exists($_SERVER['DOCUMENT_ROOT'] . $vRepertoireFichiers . '/pdf/template_dons/recudon' . $tabEvenements['eve_id'] . '.pdf')) { if ($blnDonAuto && trim($arrEvenement2['eve_prefixe2']) != '') { $strPrefixe = $arrEvenement2['eve_prefixe2']; } elseif (trim($arrEvenement2['eve_prefixe']) != '') { $strPrefixe = $arrEvenement2['eve_prefixe']; } else { $strPrefixe = 'DON-'; } $strEvenementURL = fxGetEvenementsUrl($tabDonsAuto[1]['eve_id']); require_once($_SERVER['DOCUMENT_ROOT'] . '/fpdf/fpdf.php'); require_once($_SERVER['DOCUMENT_ROOT'] . '/fpdf/fpdi.php'); require_once($_SERVER['DOCUMENT_ROOT'] . '/fpdf/code128.php'); // initiate FPDI $pdf = new FPDI(); // enregister le pdf $strNomFichier = $strEvenementURL . uniqid('donauto' . $tabEvenements['eve_id'] . '_', true) . '.pdf'; $pdf->AddPage(); // prend le template recudon eve_id $pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . $vRepertoireFichiers . '/pdf/template_dons/recudon' . $tabEvenements['eve_id'] . '.pdf'); // importer la page 1 $tplIdx = $pdf->importPage(1); // utiliser le template original $pdf->useTemplate($tplIdx, null, null, 0, 0, true); for ($multiple = 0; $multiple <= 3; $multiple++) { $ajuste = $multiple * 62; // mettre le # de don $pdf->SetFont('Times', 'B', 19); $mem_date = utf8_decode(fxShowDate($tabAcheteur['ach_maj'], $strLangue, 0, 0)); // info don $pdf->SetFont('Times', '', 8); $pdf->SetXY(108, 35 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode('Numéro de reçu / Receipt number'), 0, 2, 'L'); $pdf->SetXY(108, 38 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode('Montant du don / Donation amount'), 0, 2, 'L'); $pdf->SetFont('Times', '', 6); $pdf->SetXY(108, 41 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode('Montant Admissible du Don / Eligible donation Amount'), 0, 2, 'L'); $pdf->SetFont('Times', '', 8); $pdf->SetXY(108, 44 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode('Date d\'émission / Date of issue'), 0, 2, 'L'); $pdf->SetXY(108, 47 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode('Réception de don / Donation received '), 0, 2, 'L'); $pdf->SetFont('Times', 'B', 8); $pdf->SetXY(158, 35 + $ajuste); $pdf->Cell(50, 5.05, $strPrefixe . $tabDonsAuto[1]['pd_recu_numero'], 0, 2, 'L'); $pdf->SetXY(158, 38 + $ajuste); $pdf->Cell(50, 5.05, $tabDonsAuto[1]['pd_montant'] . ' $', 0, 2, 'L'); $pdf->SetXY(158, 41 + $ajuste); $pdf->Cell(50, 5.05, $tabDonsAuto[1]['pd_montant'] . ' $', 0, 2, 'L'); $pdf->SetXY(158, 44 + $ajuste); $pdf->Cell(50, 5.05, $mem_date, 0, 2, 'L'); $pdf->SetXY(158, 47 + $ajuste); $pdf->Cell(50, 5.05, $mem_date, 0, 2, 'L'); $pdf->SetFont('Times', 'B', 10); // adresse $mem_province = fxGetProvinces($tabAcheteur['pro_id'], $strLangue); $mem_province = fxUnescape($mem_province['pro_nom_' . $strLangue]); $mem_pays = fxGetPays($tabAcheteur['pay_id'], $strLangue); $mem_pays = fxUnescape($mem_pays['pay_nom_' . $strLangue]); $pdf->SetFont('Times', '', 10); $pdf->SetXY(23, 38 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode(fxUnescape($tabAcheteur['com_prenom'])) . ' ' . utf8_decode(fxUnescape($tabAcheteur['com_nom'])), 0, 2, 'L'); $pdf->SetXY(23, 43 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode(fxUnescape($tabAcheteur['com_adresse'])), 0, 2, 'L'); $pdf->SetXY(23, 48 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode(fxUnescape($tabAcheteur['com_ville'])) . ', ' . utf8_decode($mem_province), 0, 2, 'L'); $pdf->SetXY(23, 53 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode($mem_pays) . ', ' . fxUnescape($tabAcheteur['com_codepostal']), 0, 2, 'L'); } // enregister le pdf $pdf->Output($_SERVER['DOCUMENT_ROOT'] . $vRepertoireFichiers . '/pdf/dons/' . $strNomFichier, 'F'); $sqlUpdate = "UPDATE inscriptions_panier_dons_auto set pd_recu_pdf='" . $strNomFichier . "' WHERE pd_id = " . $tabDonsAuto[1]['pd_id']; $qryUpdate = $objDatabase->fxQuery($sqlUpdate); } } } /** #dons2017 MSIN-2007 * Voir les ifos qu'on doit afficher dans $tabDons qui provient de fxListPanier() * Voir aussi table inscriptions_panier_dons * */ if ($tabDons != null) { $intRecu = intval($tabDons[1]['pd_recu']); $strPrefixe = $tabDons[1]['eve_prefixe']; $strEvenementURL = fxGetEvenementsUrl($tabDons[1]['eve_id']); if (/*intval($intRecu)*/ 1 == 1) { // envoi de courriel au récipiendaire du don require_once 'inc_dons.php'; if (!$blnResend) { fxSendConfirmationDon($tabDons, $strLangue); } if (trim($tabDons[1]['pd_recu_pdf']) != '') { $strNomFichier = trim($tabDons[1]['pd_recu_pdf']); } else { if (file_exists($_SERVER['DOCUMENT_ROOT'] . $vRepertoireFichiers . '/pdf/template_dons/recudon' . $tabEvenements['eve_id'] . '.pdf')) { require_once($_SERVER['DOCUMENT_ROOT'] . '/fpdf/fpdf.php'); require_once($_SERVER['DOCUMENT_ROOT'] . '/fpdf/fpdi.php'); require_once($_SERVER['DOCUMENT_ROOT'] . '/fpdf/code128.php'); // initiate FPDI $pdf = new FPDI(); // enregister le pdf //$strNomFichier = $strEvenementURL . '_' . $strPrefixe . $tabDons[1]['pd_recu_numero'] . '.pdf'; $strNomFichier = $strEvenementURL . uniqid('don' . $tabEvenements['eve_id'] . '_', true) . '.pdf'; $pdf->AddPage(); $pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . $vRepertoireFichiers . '/pdf/template_dons/recudon' . $tabEvenements['eve_id'] . '.pdf'); // prend le template recudon eve_id // importer la page 1 $tplIdx = $pdf->importPage(1); // utiliser le template original $pdf->useTemplate($tplIdx, null, null, 0, 0, true); for ($multiple = 0; $multiple <= 3; $multiple++) { $ajuste = $multiple * 62; // mettre le # de don $pdf->SetFont('Times', 'B', 19); $mem_date = utf8_decode(fxShowDate($tabAcheteur['ach_maj'], $strLangue, 0, 0)); // info don $pdf->SetFont('Times', '', 8); $pdf->SetXY(108, 35 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode('Numéro de reçu / Receipt number'), 0, 2, 'L'); $pdf->SetXY(108, 38 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode('Montant du don / Donation amount'), 0, 2, 'L'); $pdf->SetFont('Times', '', 6); $pdf->SetXY(108, 41 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode('Montant Admissible du Don / Eligible donation Amount'), 0, 2, 'L'); $pdf->SetFont('Times', '', 8); $pdf->SetXY(108, 44 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode('Date d\'émission / Date of issue'), 0, 2, 'L'); $pdf->SetXY(108, 47 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode('Réception de don / Donation received '), 0, 2, 'L'); $pdf->SetFont('Times', 'B', 8); $pdf->SetXY(158, 35 + $ajuste); $pdf->Cell(50, 5.05, $strPrefixe . $tabDons[1]['pd_recu_numero'], 0, 2, 'L'); $pdf->SetXY(158, 38 + $ajuste); $pdf->Cell(50, 5.05, $tabDons[1]['pd_montant'] . ' $', 0, 2, 'L'); $pdf->SetXY(158, 41 + $ajuste); $pdf->Cell(50, 5.05, $tabDons[1]['pd_montant'] . ' $', 0, 2, 'L'); $pdf->SetXY(158, 44 + $ajuste); $pdf->Cell(50, 5.05, $mem_date, 0, 2, 'L'); $pdf->SetXY(158, 47 + $ajuste); $pdf->Cell(50, 5.05, $mem_date, 0, 2, 'L'); $pdf->SetFont('Times', 'B', 10); // adresse $mem_province = fxGetProvinces($tabAcheteur['pro_id'], $strLangue); $mem_province = fxUnescape($mem_province['pro_nom_' . $strLangue]); $mem_pays = fxGetPays($tabAcheteur['pay_id'], $strLangue); $mem_pays = fxUnescape($mem_pays['pay_nom_' . $strLangue]); $pdf->SetFont('Times', '', 10); $pdf->SetXY(23, 38 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode(fxUnescape($tabAcheteur['com_prenom'])) . ' ' . utf8_decode(fxUnescape($tabAcheteur['com_nom'])), 0, 2, 'L'); $pdf->SetXY(23, 43 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode(fxUnescape($tabAcheteur['com_adresse'])), 0, 2, 'L'); $pdf->SetXY(23, 48 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode(fxUnescape($tabAcheteur['com_ville'])) . ', ' . utf8_decode($mem_province), 0, 2, 'L'); $pdf->SetXY(23, 53 + $ajuste); $pdf->Cell(50, 5.05, utf8_decode($mem_pays) . ', ' . fxUnescape($tabAcheteur['com_codepostal']), 0, 2, 'L'); } // enregister le pdf $pdf->Output($_SERVER['DOCUMENT_ROOT'] . $vRepertoireFichiers . '/pdf/dons/' . $strNomFichier, 'F'); $sqlUpdate = "UPDATE inscriptions_panier_dons set pd_recu_pdf='" . $strNomFichier . "' WHERE pd_id = " . $tabDons[1]['pd_id']; $qryUpdate = $objDatabase->fxQuery($sqlUpdate); } } } } // envoyer courriel de confirmation au client $to_mail = fxUnescape($tabAcheteur['com_courriel']); $to_name = fxUnescape($tabAcheteur['com_prenom']) . ' ' . fxUnescape($tabAcheteur['com_nom']); $from_mail = $GLOBALS['vEmail']; $from_name = $GLOBALS['vClient']; // Confirmation commande NEW - BEGIN if ($strNomFichier != '' && intval($intRecu) == 1) { $blnReceipt = true; $attachment_url = $vDomaine . $vRepertoireFichiers . '/pdf/dons/' . $strNomFichier; if ($strLangue == 'fr') { $attachment_label = 'Voir le reçu d\'impôts'; } else { $attachment_label = 'See the tax receipt'; } } $body = fxGetMailFormat(true, false, $blnReceipt, false, $strLangue, $tabEvenement['eve_gratuit']); if ($strLangue == 'fr') { $subject = 'Confirmation de la commande No ' . $no_commande; $strMessageEtat = "Félicitations ! Vous êtes maintenant inscrit à une activité présentée dans le cadre du %nom_evenement%."; } else { $subject = 'Confirmation of order #' . $no_commande; $strMessageEtat = "Congratulations ! You are now registered in %nom_evenement%."; } $body = str_replace('%nom%', $to_name, $body); $body = str_replace('%no_commande%', $no_commande, $body); // générer les details $details = ''; $arrLinks = fxGetLinksDonation($strNoPanier, $strLangue); $details .= fxShowLinksDonation('mail', $arrLinks, $strLangue, $strColor); $details .= fxShowAddress($strNoPanier, 'web', $strLangue); $details .= fxShowPanier($strNoPanier, 0, 'web', 1, $strLangue); // remplacer nom, logo et site web de l'événement $sqlEvenement = "SELECT eve_nom_$strLangue, eve_trousses_$strLangue, eve_photo_$strLangue, eve_logo_facture_$strLangue, eve_siteweb, eve_contact, eve_courriel_autres_$strLangue, eve_msg_approbation_$strLangue FROM inscriptions_evenements WHERE eve_id = " . intval($tabEvenement['eve_id']); $recEvenement = $objDatabase->fxGetRow($sqlEvenement); $body = str_replace('%nom_evenement%', fxUnescape($recEvenement['eve_nom_' . $strLangue]), $body); $strMessageEtat = fxShowApprobation($strNoPanier, $strLangue); $body = str_replace('%message_etat%', $strMessageEtat, $body); $body = str_replace('%logo_evenement%', $vDomaine . $vRepertoireFichiers . '/images/evenements/' . $recEvenement['eve_logo_facture_' . $strLangue], $body); $body = str_replace('%web_evenement%', '' . $recEvenement['eve_siteweb'] . '', $body); $body = str_replace('%contact_evenement%', '' . $recEvenement['eve_contact'] . '', $body); $strTrousse = fxShowAdresseMagasin($strNoPanier, $strLangue); $body = str_replace('%trousse%', $strTrousse, $body); $body = str_replace('%to_mail%', $to_mail, $body); $body = str_replace('%subject%', $subject, $body); $body = str_replace('%details%', $details, $body); $body = str_replace('%termes%', fxShowTermesAcceptes($strNoPanier, $strLangue), $body); if ($blnReceipt) { $body = str_replace('%attachment_url%', $attachment_url, $body); $body = str_replace('%attachment_label%', $attachment_label, $body); } if ($strLangue == 'fr') { $web_version_label = 'Voir la facture en ligne'; } else { $web_version_label = 'See the online invoice'; } $web_version_url = $vDomaine . '/facture.php?no_panier=' . $strNoPanier . '&lang=' . $strLangue; $body = str_replace('%web_version_url%', $web_version_url, $body); $body = str_replace('%web_version_label%', $web_version_label, $body); $body = fxUpdateLiensInternes($body); // Confirmation commande NEW - END //TODOjs: enregistrer le message dans la bdd fxSendMail($subject, $body, $to_mail, $to_name, $from_mail, $from_name, true, 1, 0); // envoyer un courriel de confirmation à l'admin $to_mail = $from_mail = $GLOBALS['vEmail']; $to_name = $from_name = $GLOBALS['vClient']; $subject = $tabEvenement['eve_nom_fr'] . ' #' . $no_commande; // j'ai enlevé imprimer le recu ! //$body = '' . fxUnescape($tabAcheteur['com_prenom']) . ' ' . fxUnescape($tabAcheteur['com_nom']) . ' vient de passer une commande. Cliquez ici pour imprimer le reçu.'; // $body = '' . fxUnescape($tabAcheteur['com_prenom']) . ' ' . fxUnescape($tabAcheteur['com_nom']) . ' vient de passer une commande au montant de ' . fxShowPrix($ach_total, 'fr', 1) . '.'; //fxSendMail($subject, $body, $to_mail, $to_name, $from_mail, $from_name, true, 1, 0, $attach); /* MSIN-589: Envoyer un courriel aux autres participants pour leur dire qu'ils sonts inscrits */ $sqlEvenement = "SELECT eve_courriel_participants FROM inscriptions_evenements WHERE eve_id = " . intval($tabEvenement['eve_id']); $intCourrielParticipants = $objDatabase->fxGetVar($sqlEvenement); if ($intCourrielParticipants == 1) { $from_mail = $GLOBALS['vEmail']; $from_name = $GLOBALS['vClient']; for ($intCtr = 1; $intCtr <= count($tabEpreuves); $intCtr++) { if ($tabEpreuves[$intCtr]['pec_equipe'] == 1 && isset($tabParticipants[$tabEpreuves[$intCtr]['pec_id']])) { for ($intCtr2 = 1; $intCtr2 <= count($tabParticipants[$tabEpreuves[$intCtr]['pec_id']]); $intCtr2++) { if (trim($tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_courriel']) != '') { $to_mail = fxUnescape($tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_courriel']); $to_name = fxUnescape($tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_prenom']) . ' ' . fxUnescape($tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_nom']); // Confirmation commande NEW - BEGIN $body = fxGetMailFormat(true, true, false, false, $strLangue, $tabEvenement['eve_gratuit']); if ($strLangue == 'fr') { $subject = 'Info. importante - Votre inscription au ' . fxUnescape($tabEvenement['eve_nom_fr']); } else { $subject = 'Important information - Your ' . fxUnescape($tabEvenement['eve_nom_en']) . ' registration'; } $body = str_replace('%message%', fxUnescape($recEvenement['eve_courriel_autres_' . $strLangue], 1), $body); $body = str_replace('%nom_evenement%', fxUnescape($recEvenement['eve_nom_' . $strLangue]), $body); $body = str_replace('%logo_evenement%', $vDomaine . $vRepertoireFichiers . '/images/evenements/' . $recEvenement['eve_logo_facture_' . $strLangue], $body); $body = str_replace('%web_evenement%', '' . $recEvenement['eve_siteweb'] . '', $body); $body = str_replace('%contact_evenement%', '' . $recEvenement['eve_contact'] . '', $body); $body = str_replace('%to_mail%', $to_mail, $body); $body = str_replace('%subject%', $subject, $body); $body = fxUpdateLiensInternes($body); // Confirmation commande NEW - END fxSendMail($subject, $body, $to_mail, $to_name, $from_mail, $from_name, true, 1, 0); } } } } } } return $return; } // Générer un numéro de commande (JSP) // param : préfixe // créé : 2013-04-20 function fxGetNoCommande($strPrefixe) { global $objDatabase; // créer un numéro de commande dans la nouvelle table $sqlInsert = "INSERT INTO inscriptions_no_commandes(creation) VALUES(NOW())"; $qryInsert = $objDatabase->fxQuery($sqlInsert); $no_commande = $strPrefixe . $objDatabase->fxGetLastId(); return $no_commande; } // Effacer le panier vide (JSP) // param : no panier // créé : 2013-04-22 function fxDelPanierVide($strNoPanier) { global $objDatabase; $sqlDelete = "DELETE FROM inscriptions_panier_acheteurs WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND sta_id = 1 AND receipt_text = ''"; $qryDelete = $objDatabase->fxQuery($sqlDelete); unset($_SESSION['no_panier']); setcookie("no_panier", '', time() - 36000, '/'); return true; } // récupérer les infos du panier par le trx_id (JSP) // param : no de transaction // créé : 2013-04-22 function fxGetPanier($trx_id) { global $objDatabase; $panier_good = false; if ($trx_id != '') { $sqlPanier = "SELECT com_id, no_panier, no_commande FROM inscriptions_panier_acheteurs WHERE TransactionID = '" . $objDatabase->fxEscape($trx_id) . "'"; $recPanier = $objDatabase->fxGetRow($sqlPanier); if ($recPanier != null) { foreach (array_keys($recPanier) as $field) $panier_good[$field] = $recPanier[$field]; } } return $panier_good; } // fonction qui retourne le mode de paiement déjà appliqué (JSP) // param: numéro du panier // créé: 2013-04-20 function fxGetPanierPaiement($strNoPanier) { $tabPanier = fxListPanier($strNoPanier); $tabAcheteur = $tabPanier[0]; return $tabAcheteur['pai_id']; } // fonction qui metà jour le mode de paiement (JSP) // param: numéro du panier, id du paiement // créé: 2013-04-20 function fxSetPanierPaiement($strNoPanier, $pai_id) { global $objDatabase; $sqlUpdate = "UPDATE inscriptions_panier_acheteurs SET pai_id = " . intval($pai_id) . " WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $qryUpdate = $objDatabase->fxQuery($sqlUpdate); } function fxMajCopieParticipantAcheteur($strNoPanier, $strPar_id, $blnAjax = false) { global $objDatabase; $nbValide = null; if (!$blnAjax) { $sqlValide = "select com_prenom from inscriptions_panier_acheteurs WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $nbValide = $objDatabase->fxGetVar($sqlValide); } if ($nbValide == null) { $sqlParticipant = "SELECT par_nom,par_prenom,par_age,par_adresse,par_adresse2,par_ville,pro_id,par_codepostal,pay_id,par_telephone1,par_telephone2,par_courriel,par_id as id_temp FROM inscriptions_panier_participants WHERE par_id =" . intval($strPar_id); $recParticipant = $objDatabase->fxGetRow($sqlParticipant); foreach ($recParticipant as $k => $v) { $newk = str_replace('par_', 'com_', $k); $recParticipant[$newk] = $v; if ($newk != $k) unset($recParticipant[$k]); if ($recParticipant['pro_id'] == 0) $recParticipant['pro_id'] = 1; if ($recParticipant['pay_id'] == 0) $recParticipant['pay_id'] = 1; } $tabFieldsValues = fxListFieldsValues($recParticipant, '', 'inscriptions_comptes', $GLOBALS['arrConDatabaseMain']['db']); $sqlUpdate = "UPDATE inscriptions_panier_acheteurs " . $tabFieldsValues['set'] . ", ach_maj = '" . fxGetDateTime() . "',par_id=" . $recParticipant['id_temp'] . " WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $qryUpdate = $objDatabase->fxQuery($sqlUpdate); } } function fxMajCopieParticipantAcheteurCompte($strNoPanier, $intCompte) { global $objDatabase; $sqlValide = "SELECT com_prenom FROM inscriptions_panier_acheteurs WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $nbValide = $objDatabase->fxGetVar($sqlValide); if (trim($nbValide) == '') { $sqlParticipant = "SELECT com_nom, com_prenom, com_adresse, com_adresse2, com_ville, com_codepostal, com_telephone1, com_telephone2, com_courriel, pro_id, pay_id FROM inscriptions_comptes WHERE com_id = " . intval($intCompte); $recParticipant = $objDatabase->fxGetRow($sqlParticipant); foreach ($recParticipant as $k => $v) { $newk = str_replace('par_', 'com_', $k); $recParticipant[$newk] = $v; if ($newk != $k) unset($recParticipant[$k]); } $tabFieldsValues = fxListFieldsValues($recParticipant, '', 'inscriptions_comptes', $GLOBALS['arrConDatabaseMain']['db']); $sqlUpdate = "UPDATE inscriptions_panier_acheteurs " . $tabFieldsValues['set'] . ", ach_maj = '" . fxGetDateTime() . "', com_id = " . intval($intCompte) . " WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $qryUpdate = $objDatabase->fxQuery($sqlUpdate); } } function fxSetAcheteur($strAction, $tabCompte, $tabData, $strLangue, $strNoPanier) { global $objDatabase; $_SESSION['msg'] = ""; switch ($strAction) { // MODIFICATION case 'mod': $tabFieldsValues = fxListFieldsValues($tabData, '', 'inscriptions_comptes', $GLOBALS['arrConDatabaseMain']['db']); $sqlUpdate = "UPDATE inscriptions_panier_acheteurs " . $tabFieldsValues['set'] . ", ach_maj = '" . fxGetDateTime() . "' WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $qryUpdate = $objDatabase->fxQuery($sqlUpdate); break; // SUPPRESSION case 'del': /* PLUS TARD $sqlDelete = "DELETE FROM ".$bd." WHERE ".$memid." = " . intval($id); $qryDelete = $objDatabase->fxQuery($sqlDelete); */ } } // fonction qui affiche le formulaire de l'acheteur' (SL) // param: tableau contenant les infos du compte client, action (add/mod), langue d'affichage // créé: 2013-04-18 // 2015-01-14 (#CON-54, #CON-55 JS was here) function fxShowFormAcheteur($tabAcheteur, $strLangue, $Evenement) { global $vDomaine; // sortir la liste des provinces et des pays $tabProvinces = fxGetProvinces(0, $strLangue); $tabPays = fxGetPays(0, $strLangue); $type = 'mod'; $mem_btn = "btn_mod_acheteur"; ?>