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 .= ''; $strRetour .= ''; if ($cart == 1) $strRetour .= ' '; if (intval($tabEvenements['eve_gratuit']) != 1) { // si événement normal if ($strLangue == 'fr') { $strRetour .= ' '; $strRetour .= ' '; } else { $strRetour .= ' '; $strRetour .= ' '; } } else { if ($strLangue == 'fr') { $strRetour .= ' '; $strRetour .= ' '; } else { $strRetour .= ' '; $strRetour .= ' '; } } $strRetour .= ''; } // En-tête événement if ($tabEvenements['eve_date_debut'] != $tabEvenements['eve_date_fin']) $strDate = fxShowDateInterval($tabEvenements['eve_date_debut'], $tabEvenements['eve_date_fin'], $strLangue); else $strDate = fxShowDate($tabEvenements['eve_date_debut'], $strLangue); if ($output == 'web') { $strRetour .= ''; if ($cart == 1) $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; /* info pour paypal */ $tabPaypal['firstname'] = utf8_encode(fxUnescape($tabAcheteur['com_prenom'])); $tabPaypal['lastname'] = utf8_encode(fxUnescape($tabAcheteur['com_nom'])); $tabPaypal['description'] = utf8_encode(fxUnescape($tabEvenements['eve_nom_' . $strLangue])); $tabPaypal['total'] = $tabTotal['total']; $tabPaypal['details'] = array( 'shipping' => 0, 'tax' => $tabTotal["total_taxes"] + $tabTotal["total_taxes_frais"], 'subtotal' => $tabTotal['stotal'] + $tabTotal["fra_avant_tx"] ); } // boucle des épreuves if ($tabEpreuves != null) { for ($intCtr2 = 1; $intCtr2 <= count($tabEpreuves); $intCtr2++) { // vérifier si l'épreuve est taxable if ($tabEpreuves[$intCtr2]['epr_taxes_incluses'] != 1) $strTaxable = ' (taxable)'; else $strTaxable = ''; if ($output == 'web') { $strRetour .= ''; if ($cart == 1) { if ($strLangue == 'fr') { $strDelete = "Retirer du panier"; $strModifier = "Modifier l'inscription"; $strModifierUrl = "/reserver/"; } else { $strDelete = "Remove from cart"; $strModifier = "Edit registration"; $strModifierUrl = "/book/"; } $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 . '
'; // afficher une note pour compléter l'adhésion if (intval($arrMembership['mt_id']) == 3 || intval($arrMembership['mt_id']) == 4) { $strUrl = $vDomaine . '/' . $strPage . '/mes_adhesions?no=' . $strNumero; $strText = afficheTexte('texte_compléter_adhésion', 0, 1, 1); $strText = str_replace('%url%', $strUrl, $strText); $strEpreuve .= ' '; } } } } // afficher le nom et le prix de l'épreuve if (trim($tabEpreuves[$intCtr2]['epr_categorie_' . $strLangue]) != '') { $strEpreuve .= fxUnescape($tabEpreuves[$intCtr2]['epr_categorie_' . $strLangue]) . ' - '; } if (intval($tabEpreuves[$intCtr2]['tep_id']) == 4) { $strEpreuve .= fxUnescape($tabEpreuves[$intCtr2]['epr_type_' . $strLangue]) . '
' . fxUnescape($tabEpreuves[$intCtr2]['epr_nom_' . $strLangue]); } else { $strEpreuve .= fxUnescape($tabEpreuves[$intCtr2]['epr_type_' . $strLangue]) . '
' . fxUnescape($tabEpreuves[$intCtr2]['epr_nom_' . $strLangue]) . ' - ' . fxShowDate($tabEpreuves[$intCtr2]['epr_date'], $strLangue); } $strRetour .= ' '; /* info pour paypal */ $tabPaypal['items'][] = array( 'name' => utf8_encode(fxUnescape($tabEpreuves[$intCtr2]['epr_type_' . $strLangue]) . ' ' . utf8_encode(fxUnescape($tabEpreuves[$intCtr2]['epr_nom_' . $strLangue]))), 'quantity' => 1, 'price' => $tabEpreuves[$intCtr2]['pec_prix'] - $tabEpreuves[$intCtr2]['rab_montant'], 'description' => utf8_encode(fxUnescape($tabEpreuves[$intCtr2]['epr_type_' . $strLangue]) . ' ' . utf8_encode(fxUnescape($tabEpreuves[$intCtr2]['epr_nom_' . $strLangue])) . ' - ' . utf8_encode(fxShowDate($tabEpreuves[$intCtr2]['epr_date'], $strLangue)) . ' @ ' . fxShowTime($tabEpreuves[$intCtr2]['epr_heure']) . $strTaxable), 'tax' => 0 ); // LEGACY $mem_paypal[$mem_paypal_boucle]['itemDescription'] = fxUnescape($tabEpreuves[$intCtr2]['epr_type_' . $strLangue]) . ' ' . fxUnescape($tabEpreuves[$intCtr2]['epr_nom_' . $strLangue]) . ' - ' . fxShowDate($tabEpreuves[$intCtr2]['epr_date'], $strLangue) . ' @ ' . fxShowTime($tabEpreuves[$intCtr2]['epr_heure']) . $strTaxable; $mem_paypal[$mem_paypal_boucle]['itemName'] = fxUnescape($tabEpreuves[$intCtr2]['epr_type_' . $strLangue]) . ' ' . fxUnescape($tabEpreuves[$intCtr2]['epr_nom_' . $strLangue]); $mem_paypal[$mem_paypal_boucle]['itemAmount'] = $tabEpreuves[$intCtr2]['pec_prix'] - $tabEpreuves[$intCtr2]['rab_montant']; $mem_paypal[$mem_paypal_boucle]['itemQuantity'] = 1; $mem_paypal[$mem_paypal_boucle]['itemSalestaxe'] = 0; $mem_paypal_boucle++; } $intEpreuve = $tabEpreuves[$intCtr2]['pec_id']; // boucle des participants if (isset($tabParticipants[$intEpreuve])) { for ($intCtr3 = 1; $intCtr3 <= count($tabParticipants[$intEpreuve]); $intCtr3++) { $tabEpreuveHeader = $tabQuestionsCart = array(); $strEpreuveHeader = $strCategorie = $strDistance = $strTshirt = ''; if ($output == 'web') { if (isset($tabQuestions[$tabParticipants[$intEpreuve][$intCtr3]['par_id']])) { // récupérer l'info de la catégorie d'âge ou la distance for ($intCtr5 = 1; $intCtr5 <= count($tabQuestions[$tabParticipants[$intEpreuve][$intCtr3]['par_id']]); $intCtr5++) { if ($tabQuestions[$tabParticipants[$intEpreuve][$intCtr3]['par_id']][$intCtr5]['que_validation'] != 'capitaine'/* && $tabQuestions[$tabParticipants[$intEpreuve][$intCtr3]['par_id']][$intCtr5]['que_validation'] != 'equipe'*/) { if ($tabQuestions[$tabParticipants[$intEpreuve][$intCtr3]['par_id']][$intCtr5]['que_cart_show'] == 1) { switch ($tabQuestions[$tabParticipants[$intEpreuve][$intCtr3]['par_id']][$intCtr5]['que_validation']) { case 'categorie': case 'distance': case 'equipe': $tabEpreuveHeader[] = fxUnescape($tabQuestions[$tabParticipants[$intEpreuve][$intCtr3]['par_id']][$intCtr5]['que_cart_label_' . $strLangue]) . ': ' . fxUnescape($tabQuestions[$tabParticipants[$intEpreuve][$intCtr3]['par_id']][$intCtr5]['que_choix_' . $strLangue]); break; default: if (fxUnescape($tabQuestions[$tabParticipants[$intEpreuve][$intCtr3]['par_id']][$intCtr5]['que_choix_' . $strLangue]) != '') $tabQuestionsCart[] = fxUnescape($tabQuestions[$tabParticipants[$intEpreuve][$intCtr3]['par_id']][$intCtr5]['que_cart_label_' . $strLangue]) . ': ' . fxUnescape($tabQuestions[$tabParticipants[$intEpreuve][$intCtr3]['par_id']][$intCtr5]['que_choix_' . $strLangue]); } } } } } if ($intCtr3 == 1) { $strEpreuveHeader .= implode('
', $tabEpreuveHeader); // MSIN-1999 if ($strEpreuveHeader != '') { // récupérer l'info de la catégorie d'âge ou la distance $strRetour .= ''; if ($cart == 1) $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; } } // afficher le nom du participant // if ($tabParticipants[$intEpreuve][$intCtr3]['rol_id'] == 1) { // MSIN-1617 - capitaine seulement if ($tabParticipants[$intEpreuve][$intCtr3]['rol_id'] != 0) { // MSIN-1998 $strRetour .= ''; if ($cart == 1) $strRetour .= ' '; $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 .= ''; } } } } // afficher les produits autres if (isset($tabProduits[$intEpreuve]) && count($tabProduits[$intEpreuve]) > 0) { $strRetour .= ''; if ($cart == 1) $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; for ($intCtr4 = 1; $intCtr4 <= count($tabProduits[$intEpreuve]); $intCtr4++) { if ($output == 'web') { $strRetour .= ''; if ($cart == 1) { if ($tabProduits[$intEpreuve][$intCtr4]['pro_effacable'] == 1) { if ($strLangue == 'fr') $strDelete = "Retirer produit"; else $strDelete = "Remove product"; $strRetour .= ' '; } else $strRetour .= ' '; } $strRetour .= ' '; } /* info pour paypal */ $tabPaypal['items'][] = array( 'name' => utf8_encode(fxUnescape($tabProduits[$intEpreuve][$intCtr4]['pro_nom_' . $strLangue])), 'quantity' => 1, 'price' => $tabProduits[$intEpreuve][$intCtr4]['pro_prix'] - $tabProduits[$intEpreuve][$intCtr4]['rab_montant'], 'description' => (fxUnescape($tabProduits[$intEpreuve][$intCtr4]['pro_nom_' . $strLangue]) . ' ' . fxUnescape($tabProduits[$intEpreuve][$intCtr4]['pro_taille_' . $strLangue])), 'tax' => 0 ); // LEGACY $mem_paypal[$mem_paypal_boucle]['itemDescription'] = fxUnescape($tabProduits[$intEpreuve][$intCtr4]['pro_nom_' . $strLangue]) . ' ' . fxUnescape($tabProduits[$intEpreuve][$intCtr4]['pro_taille_' . $strLangue]); $mem_paypal[$mem_paypal_boucle]['itemName'] = fxUnescape($tabProduits[$intEpreuve][$intCtr4]['pro_nom_' . $strLangue]); $mem_paypal[$mem_paypal_boucle]['itemAmount'] = $tabProduits[$intEpreuve][$intCtr4]['pro_prix']; $mem_paypal[$mem_paypal_boucle]['itemQuantity'] = 1; $mem_paypal[$mem_paypal_boucle]['itemSalestaxe'] = 0; $mem_paypal_boucle++; } } $strRetour .= ''; if ($cart == 1) $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; } } // afficher les produits non rattachés à une épreuve if ($tabProduits2 != null) { for ($intCtr = 1; $intCtr <= count($tabProduits2); $intCtr++) { if ($output == 'web') { $strRetour .= ''; if ($cart == 1) { if ($tabProduits2[$intCtr]['pro_effacable'] == 1) { if ($strLangue == 'fr') $strDelete = "Retirer produit"; else $strDelete = "Remove product"; $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 = '
pour épreuve: ' . fxUnescape($tabProduits2[$intCtr]['epr_type_' . $strLangue]) . ' réservé par ' . $strReservee; else $strEpreuveProduit = '
for race: ' . fxUnescape($tabProduits2[$intCtr]['epr_type_' . $strLangue]) . ' booked by ' . $strReservee; } else $strEpreuveProduit = ''; $strRetour .= ' '; if ($tabEvenements['eve_gratuit'] != 1) { // si événement normal $strRetour .= ' '; } $strRetour .= ''; } /* info pour paypal */ $tabPaypal['items'][] = array( 'name' => utf8_encode(strip_tags($strAnnulation) . fxUnescape($tabProduits2[$intCtr]['pt_nom_' . $strLangue]) . ': ' . fxUnescape($tabProduits2[$intCtr]['pro_nom_' . $strLangue])), 'quantity' => 1, 'price' => $tabProduits2[$intCtr]['pro_prix'], 'description' => utf8_encode(strip_tags($strAnnulation) . fxUnescape($tabProduits2[$intCtr]['pt_nom_' . $strLangue]) . ': ' . fxUnescape($tabProduits2[$intCtr]['pro_nom_' . $strLangue]) . ' ' . fxUnescape($tabProduits2[$intCtr]['pro_taille_' . $strLangue]) . strip_tags($strEpreuveProduit)), 'tax' => 0 ); // LEGACY $mem_paypal[$mem_paypal_boucle]['itemDescription'] = strip_tags($strAnnulation) . fxUnescape($tabProduits2[$intCtr]['pt_nom_' . $strLangue]) . ': ' . fxUnescape($tabProduits2[$intCtr]['pro_nom_' . $strLangue]) . ' ' . fxUnescape($tabProduits2[$intCtr]['pro_taille_' . $strLangue]) . strip_tags($strEpreuveProduit); $mem_paypal[$mem_paypal_boucle]['itemName'] = strip_tags($strAnnulation) . fxUnescape($tabProduits2[$intCtr]['pt_nom_' . $strLangue]) . ': ' . fxUnescape($tabProduits2[$intCtr]['pro_nom_' . $strLangue]); $mem_paypal[$mem_paypal_boucle]['itemAmount'] = $tabProduits2[$intCtr]['pro_prix']; $mem_paypal[$mem_paypal_boucle]['itemQuantity'] = 1; $mem_paypal[$mem_paypal_boucle]['itemSalestaxe'] = 0; $mem_paypal_boucle++; } } // afficher les dons #dons2017 #MSIN-1987 if ($tabDons != null) { for ($intCtr = 1; $intCtr <= count($tabDons); $intCtr++) { if ($tabDons[$intCtr]['participant'] != '') $strReservee = fxUnescape($tabDons[$intCtr]['participant']); else $strReservee = fxUnescape($tabDons[$intCtr]['pec_nom_equipe']); if ($strLangue == 'fr') $strEpreuveMontant = '
Don pour: ' . $strReservee; else $strEpreuveMontant = '
Donation for: ' . $strReservee; if ($output == 'web') { $strRetour .= ' '; } /* info pour paypal */ $tabPaypal['items'][] = array( 'name' => utf8_encode(strip_tags($strEpreuveMontant)), 'quantity' => 1, 'price' => $tabDons[$intCtr]['pd_montant'], 'description' => utf8_encode(strip_tags($strEpreuveMontant)), 'tax' => 0 ); // LEGACY $mem_paypal[$mem_paypal_boucle]['itemDescription'] = $mem_paypal[$mem_paypal_boucle]['itemName'] = strip_tags($strEpreuveMontant); $mem_paypal[$mem_paypal_boucle]['itemAmount'] = $tabDons[$intCtr]['pd_montant']; $mem_paypal[$mem_paypal_boucle]['itemQuantity'] = 1; $mem_paypal[$mem_paypal_boucle]['itemSalestaxe'] = 0; $mem_paypal_boucle++; } } // affiche le sous-total, les taxes, rabais et le total complet if ($output == 'web') { if ($cart == 1) $colspan = 'colspan="2"'; else $colspan = ''; if ($tabEvenements['eve_gratuit'] != 1) { // si événement normal // lister les codes rabais if (isset($tabRabais[1])) { for ($intCtr = 1; $intCtr <= count($tabRabais); $intCtr++) { if ($output == 'web') { $strRetour .= ''; if ($cart == 1) { if ($resume != 1 && $tabRabais[$intCtr]['rab_effacable'] == 1) { if ($strLangue == 'fr') $strDelete = "Retirer rabais"; else $strDelete = "Remove discount"; $strRetour .= ' '; } 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 .= ' '; $strRetour .= ' '; $strRetour .= ''; $strRetour .= ''; if ($cart == 1) $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; } } } if ($tabTotal['rabais_total'] > 0) { $strRetour .= ''; if ($strLangue == 'fr') $strRetour .= ' '; else $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; /* info pour paypal */ if ($strLangue == 'fr') $strDescription = 'Rabais total'; else $strDescription = 'Discount total'; $tabPaypal['items'][] = array( 'name' => utf8_encode($strDescription), 'quantity' => 1, 'price' => -$tabTotal['rabais_total'], 'description' => utf8_encode($strDescription), 'tax' => 0 ); // LEGACY if ($strLangue == 'fr') $mem_paypal[$mem_paypal_boucle]['itemDescription'] = $mem_paypal[$mem_paypal_boucle]['itemName'] = 'Rabais total'; else $mem_paypal[$mem_paypal_boucle]['itemDescription'] = $mem_paypal[$mem_paypal_boucle]['itemName'] = 'Discount total'; $mem_paypal[$mem_paypal_boucle]['itemAmount'] = -$tabTotal['rabais_total']; $mem_paypal[$mem_paypal_boucle]['itemQuantity'] = 1; $mem_paypal[$mem_paypal_boucle]['itemSalestaxe'] = 0; $mem_paypal_boucle++; } if ($tabTotal["stotal"] != $tabTotal["total"]) { $strRetour .= ''; if ($tabTotal["stotal2"] == $tabTotal["stotal2"]) { if ($strLangue == 'fr') $strRetour .= ' '; else $strRetour .= ' '; } else { if ($strLangue == 'fr') $strRetour .= ' '; else $strRetour .= ' '; } $strRetour .= ' '; $strRetour .= ''; $strRetour .= ''; if ($cart == 1) $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; } if ($tabTotal['total_taxes'] > 0) { for ($intCtr = 1; $intCtr <= 3; $intCtr++) { if ($tabTotal['taxes'][$intCtr]['montant'] > 0) { $strRetour .= ''; $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; } } $strRetour .= ''; if ($cart == 1) $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; } if ($tabTotal["stotal2"] != $tabTotal["stotal"]) { $strRetour .= ''; if ($strLangue == 'fr') $strRetour .= ' '; else $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; $strRetour .= ''; if ($cart == 1) $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; } if ($tabTotal['fra_total'] > 0) { if ($tabTotal['fra_pourcent'] != 0) $strFraisPourcent = ''; //$strFraisPourcent = ' (' . $tabTotal['fra_pourcent'] . ' %)'; else $strFraisPourcent = ''; if ($tabAcheteur['fa_montant'] > 0) { $strFraisAutres = '
('; if ($strLangue == 'fr') $strFraisAutres .= 'inclut '; else $strFraisAutres .= 'includes '; $strFraisAutres .= fxUnescape($tabAcheteur['fa_nom_' . $strLangue]) . ' ' . fxShowPrix($tabAcheteur['fa_montant'], $strLangue, 1) . ')'; } else { $strFraisAutres = ''; } $strRetour .= ''; if ($strLangue == 'fr') $strRetour .= ' '; else $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; for ($intCtr = 1; $intCtr <= 3; $intCtr++) { if ($tabTotal['taxes_frais'][$intCtr]['montant'] > 0) { $strRetour .= ''; $strRetour .= ' '; $strRetour .= ' '; $strRetour .= ''; } } $strRetour .= ''; if ($cart == 1) $strRetour .= ' '; $strRetour .= ' '; /* info pour paypal */ if ($strLangue == 'fr') $strDescription = 'Frais de service MS-1' . $strFraisPourcent; else $strDescription = 'MS-1 Processing Fees' . $strFraisPourcent; $tabPaypal['items'][] = array( 'name' => utf8_encode($strDescription), 'quantity' => 1, 'price' => $tabTotal["fra_avant_tx"], 'description' => utf8_encode($strDescription), 'tax' => $tabTotal['total_taxes_frais'] ); // LEGACY if ($strLangue == 'fr') $mem_paypal[$mem_paypal_boucle]['itemDescription'] = $mem_paypal[$mem_paypal_boucle]['itemName'] = 'Frais de services MS-1' . $strFraisPourcent; else $mem_paypal[$mem_paypal_boucle]['itemDescription'] = $mem_paypal[$mem_paypal_boucle]['itemName'] = 'MS-1 Processing Fees' . $strFraisPourcent; $mem_paypal[$mem_paypal_boucle]['itemAmount'] = $tabTotal["fra_avant_tx"]; $mem_paypal[$mem_paypal_boucle]['itemQuantity'] = 1; $mem_paypal[$mem_paypal_boucle]['itemSalestaxe'] = 0; $mem_paypal_boucle++; } if (!($tabTotal["total_taxes"]) > 0) { if ($strLangue == 'fr') $strTaxes = '(taxes incluses) '; else $strTaxes = '(taxes included) '; } else $strTaxes = ''; if ($tabAcheteur['sta_id'] == 3) { if ($strLangue == 'fr') $strPaid = 'payé '; else $strPaid = 'paid '; } else $strPaid = ''; $strRetour .= ' '; // génération de don MSIN-2566 if ($tabTotal["total_don"] > 0) { if ($strLangue == 'fr') $strLabel = "Total don = "; else $strLabel = "Total donation = "; $strRetour .= ' '; } } $strRetour .= '
 ProduitPrixProductPriceInscriptionRegistration
 ' . fxUnescape($tabEvenements['eve_nom_' . $strLangue]) . '
' . $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 .= '
 ' . $strEpreuveHeader . '
 '; 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 .= '
'.''.'
 
 ' . 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 .= '
 
 ' . $strAnnulation . fxUnescape($tabProduits2[$intCtr]['pt_nom_' . $strLangue]) . ': ' . fxUnescape($tabProduits2[$intCtr]['pro_nom_' . $strLangue]) . ' ' . fxUnescape($tabProduits2[$intCtr]['pro_taille_' . $strLangue]) . $strEpreuveProduit . '' . fxShowPrix($tabProduits2[$intCtr]['pro_prix'], $strLangue, 1) . '
' . $strEpreuveMontant . ' ' . fxShowPrix($tabDons[$intCtr]['pd_montant'], $strLangue, 1) . '
 ' . $strCodeRabais . fxUnescape($tabRabais[$intCtr]['rab_description_' . $strLangue]) ; //MSIN-4316 if($tabRabais[$intCtr]['rab_note_' . $strLangue]!=''){ $strRetour .= '
'.$tabRabais[$intCtr]['rab_note_' . $strLangue].''; } $strRetour .= '
(' . $strRabaisValeur . ')
 
Rabais total :Discount total :(' . fxShowPrix($tabTotal["rabais_total"], $strLangue, 1) . ')
Sous-total 1 (avant frais de services) :Subtotal (before services fees) :Sous-total :Subtotal :' . fxShowPrix($tabTotal["stotal"], $strLangue, 1) . '
 
' . $tabTotal['taxes'][$intCtr]['label_' . $strLangue] . ' ' . $tabTotal['taxes'][$intCtr]['numero'] . ' :' . fxShowPrix($tabTotal['taxes'][$intCtr]['montant'], $strLangue, 1) . '
 
Sous-total 2 (avant frais de services) :Subtotal (before services fees) :' . fxShowPrix($tabTotal["stotal2"], $strLangue, 1) . '
 
Frais de service MS-1' . $strFraisPourcent . ' :' . $strFraisAutres . 'MS-1 Processing Fees' . $strFraisPourcent . ' :' . $strFraisAutres . '' . fxShowPrix($tabTotal["fra_avant_tx"], $strLangue, 1) . '
' . $tabTotal['taxes_frais'][$intCtr]['label_' . $strLangue] . ' ' . $tabTotal['taxes_frais'][$intCtr]['numero'] . ' :' . fxShowPrix($tabTotal['taxes_frais'][$intCtr]['montant'], $strLangue, 1) . '
 
Total ' . $strPaid . $strTaxes . ': ' . fxShowPrix($tabTotal["total"], $strLangue, 1) . '
' . $strLabel . fxShowPrix($tabTotal["total_don"], $strLangue, 1) . '
'; $strRetour .= '
'; } if ($retour_output == 'paypal') { if ($vblnEnvironementDev) return $tabPaypal; else return $mem_paypal; } else return $strRetour; } // mets les totaux dans un tableau (JSP) // param : no panier, langue // créé : 2013-04-19 function fxTotalPanier($strNoPanier, $strLangue) { global $objDatabase; $fltTotalTaxes = $fltTotalTaxesFrais = $fltMontantTaxable = $fltSousTotal = $fltSousTotal2 = $fltTotal = 0; $strMotifDepotFr = $strMotifDepotEn = ''; // infos événement $tabPanier = fxListPanier($strNoPanier); $tabAcheteur = $tabPanier[0]; $tabEvenements = $tabPanier[1]; $mem_eve_id = $tabEvenements['eve_id']; /* $sqlEvenements = "SELECT c.eve_id, e.tt_id, e.eve_frais FROM inscriptions_panier_evenements e, inscriptions_panier_epreuves_commandees c WHERE e.eve_id = c.eve_id AND c.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' GROUP BY c.eve_id"; $tabEvenements = $objDatabase->fxGetRow($sqlEvenements); */ // info épreuves $sqlEpreuves = "SELECT pec_id FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' ORDER BY pec_id"; $tabEpreuves = $objDatabase->fxGetResults($sqlEpreuves); // get rabais $sqlRabais = "SELECT r.rab_produits_inclus, r.rab_epreuves, r.rab_epr_diff, r.rab_pourcent FROM inscriptions_rabais r, inscriptions_panier_rabais p, inscriptions_panier_rabais_acheteurs a WHERE r.rab_id = p.rab_id AND r.rab_epr_diff = 1 AND p.pra_id = a.pra_id AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $tabRabaisInfos = $objDatabase->fxGetRow($sqlRabais); //MSIN-4342 $sqlTotalavant = " SELECT (SELECT SUM(pec_prix) FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_epreuves, (SELECT SUM(pec_prix) FROM inscriptions_panier_epreuves_commandees WHERE eve_id !='" . $mem_eve_id . "' and no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_epreuves_autre_eve, (SELECT SUM(e.rab_montant) FROM inscriptions_panier_epreuves_commandees e, inscriptions_panier_rabais r WHERE r.pra_id = e.pra_id AND r.pra_depot = 0 AND e.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS rabais_epreuves, (SELECT SUM(e.rab_montant) FROM inscriptions_panier_epreuves_commandees e, inscriptions_panier_rabais r WHERE r.pra_id = e.pra_id AND r.pra_depot = 1 AND e.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS depot_epreuves, (SELECT SUM(c.pec_prix - c.rab_montant) FROM inscriptions_panier_epreuves_commandees c, inscriptions_panier_epreuves e WHERE c.epr_id = e.epr_id AND e.epr_taxes_incluses = 0 AND c.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_epreuves_taxable, (SELECT SUM(c.pec_prix - c.rab_montant) FROM inscriptions_panier_epreuves_commandees c, inscriptions_panier_epreuves e WHERE eve_id !='" . $mem_eve_id . "' and c.epr_id = e.epr_id AND e.epr_taxes_incluses = 0 AND c.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_epreuves_taxable_autre_eve, (SELECT SUM(pro_prix) FROM inscriptions_panier_produits_new WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_produits, (SELECT SUM(pro_prix) FROM inscriptions_panier_produits_new WHERE eve_id !='" . $mem_eve_id . "' and no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_produits_autre_eve, (SELECT SUM(p.rab_montant) FROM inscriptions_panier_produits_new p, inscriptions_panier_rabais r WHERE r.pra_id = p.pra_id AND r.pra_depot = 0 AND p.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS rabais_produits, (SELECT SUM(p.rab_montant) FROM inscriptions_panier_produits_new p, inscriptions_panier_rabais r WHERE r.pra_id = p.pra_id AND r.pra_depot = 1 AND p.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS depot_produits, (SELECT SUM(pro_prix - rab_montant) FROM inscriptions_panier_produits_new WHERE pro_taxable = 1 AND no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_produits_taxable, (SELECT SUM(pp.pro_prix - IFNULL(pp.rab_montant, 0)) FROM inscriptions_panier_produits_new pp JOIN inscriptions_produits_new p ON p.pro_id = pp.pro_id WHERE pp.pro_taxable = 1 AND (p.pt_id = 7 || p.pt_id = 6) AND pp.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' ) AS prix_produits_taxable_pasderabais, (SELECT SUM(pro_prix - rab_montant) FROM inscriptions_panier_produits_new WHERE eve_id !='" . $mem_eve_id . "' and pro_taxable = 1 AND no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_produits_taxable_autre_eve, (SELECT SUM(md_montant) FROM inscriptions_panier_montants_dus WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_montants_dus, (SELECT SUM(pd_montant) FROM inscriptions_panier_dons WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS dons, (SELECT SUM(r.rab_montant) FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE r.pra_id = a.pra_id AND r.rab_taxes=1 AND r.pra_depot = 0 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND r.rab_pourcent = 0 AND r.rab_epreuves = '' AND r.rab_produits = '') AS rabais_panier_montant_taxable, (SELECT SUM(r.rab_montant) FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE r.pra_id = a.pra_id AND r.rab_taxes=0 AND r.pra_depot = 0 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND r.rab_pourcent = 0 AND r.rab_epreuves = '' AND r.rab_produits = '') AS rabais_panier_montant, (SELECT SUM(r.rab_montant) FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE r.pra_id = a.pra_id AND r.pra_depot = 1 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND r.rab_pourcent = 0 AND r.rab_epreuves = '' AND r.rab_produits = '') AS depot_panier_montant, (SELECT SUM(r.rab_pourcent) FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE r.pra_id = a.pra_id AND r.pra_depot = 0 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND r.rab_montant = 0 AND r.rab_epreuves = '' AND r.rab_produits = '') AS rabais_panier_pourcent, (SELECT SUM(r.rab_pourcent) FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE r.pra_id = a.pra_id AND r.pra_depot = 1 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND r.rab_montant = 0 AND r.rab_epreuves = '' AND r.rab_produits = '') AS depot_panier_pourcent, (SELECT SUM(opt_prix) FROM inscriptions_panier_options WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_options, (SELECT SUM(opt_prix) FROM inscriptions_panier_options WHERE opt_taxable = 1 AND no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_options_taxable, (SELECT opt_date_limite_paiement FROM inscriptions_panier_options WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS date_limite_paiement, (SELECT SUM(par_frais_montant) FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS fra_avant_tx, (SELECT SUM(par_frais_tps) FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS fra_tps, (SELECT SUM(par_frais_tvq) FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS fra_tvq, (SELECT SUM(pec_montant_don - rab_montant) FROM inscriptions_panier_epreuves_commandees WHERE pec_don_actif = 1 AND no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS total_don FROM DUAL "; // MSIN-4217 // Calculer le sous-total $sqlTotal = " SELECT (SELECT SUM(pec_prix) FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_epreuves, (SELECT SUM(pec_prix) FROM inscriptions_panier_epreuves_commandees WHERE eve_id !='" . $mem_eve_id . "' and no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_epreuves_autre_eve, (SELECT SUM(e.rab_montant) FROM inscriptions_panier_epreuves_commandees e, inscriptions_panier_rabais r WHERE r.pra_id = e.pra_id AND r.pra_depot = 0 AND e.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS rabais_epreuves, (SELECT SUM(e.rab_montant) FROM inscriptions_panier_epreuves_commandees e, inscriptions_panier_rabais r WHERE r.pra_id = e.pra_id AND r.pra_depot = 1 AND e.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS depot_epreuves, (SELECT SUM(c.pec_prix - c.rab_montant) FROM inscriptions_panier_epreuves_commandees c, inscriptions_panier_epreuves e WHERE c.epr_id = e.epr_id AND e.epr_taxes_incluses = 0 AND c.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_epreuves_taxable, (SELECT SUM(c.pec_prix - c.rab_montant) FROM inscriptions_panier_epreuves_commandees c, inscriptions_panier_epreuves e WHERE eve_id !='" . $mem_eve_id . "' and c.epr_id = e.epr_id AND e.epr_taxes_incluses = 0 AND c.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_epreuves_taxable_autre_eve, (SELECT SUM(pp.pro_prix) FROM inscriptions_panier_produits_new pp JOIN inscriptions_produits_new p ON p.pro_id = pp.pro_id WHERE p.pt_id NOT IN (6,7) AND pp.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_produits, (SELECT SUM(pro_prix) FROM inscriptions_panier_produits_new WHERE eve_id !='" . $mem_eve_id . "' and no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_produits_autre_eve, (SELECT SUM(p.rab_montant) FROM inscriptions_panier_produits_new p, inscriptions_panier_rabais r WHERE r.pra_id = p.pra_id AND r.pra_depot = 0 AND p.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS rabais_produits, (SELECT SUM(p.rab_montant) FROM inscriptions_panier_produits_new p, inscriptions_panier_rabais r WHERE r.pra_id = p.pra_id AND r.pra_depot = 1 AND p.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS depot_produits, (SELECT SUM(pp.pro_prix - IFNULL(pp.rab_montant, 0)) FROM inscriptions_panier_produits_new pp JOIN inscriptions_produits_new p ON p.pro_id = pp.pro_id WHERE pp.pro_taxable = 1 AND p.pt_id NOT IN (6,7) AND pp.no_panier ='" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_produits_taxable, (SELECT SUM(pp.pro_prix - IFNULL(pp.rab_montant, 0)) FROM inscriptions_panier_produits_new pp JOIN inscriptions_produits_new p ON p.pro_id = pp.pro_id WHERE pp.pro_taxable = 1 AND p.pt_id IN (6,7) AND pp.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' ) AS prix_produits_taxable_pasderabais, (SELECT SUM(pro_prix - rab_montant) FROM inscriptions_panier_produits_new WHERE eve_id !='" . $mem_eve_id . "' and pro_taxable = 1 AND no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_produits_taxable_autre_eve, (SELECT SUM(md_montant) FROM inscriptions_panier_montants_dus WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_montants_dus, (SELECT SUM(pd_montant) FROM inscriptions_panier_dons WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS dons, (SELECT SUM(r.rab_montant) FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE r.pra_id = a.pra_id AND r.rab_taxes!=0 AND r.pra_depot = 0 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND r.rab_pourcent = 0 AND r.rab_epreuves = '' AND r.rab_produits = '') AS rabais_panier_montant_taxable, (SELECT SUM(r.rab_montant) FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE r.pra_id = a.pra_id AND r.rab_taxes=0 AND r.pra_depot = 0 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND r.rab_pourcent = 0 AND r.rab_epreuves = '' AND r.rab_produits = '') AS rabais_panier_montant, (SELECT SUM(r.rab_montant) FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE r.pra_id = a.pra_id AND r.pra_depot = 1 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND r.rab_pourcent = 0 AND r.rab_epreuves = '' AND r.rab_produits = '') AS depot_panier_montant, (SELECT SUM(r.rab_pourcent) FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE r.pra_id = a.pra_id AND r.pra_depot = 0 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND r.rab_montant = 0 AND r.rab_epreuves = '' AND r.rab_produits = '') AS rabais_panier_pourcent, (SELECT SUM(r.rab_pourcent) FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE r.pra_id = a.pra_id AND r.pra_depot = 1 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND r.rab_montant = 0 AND r.rab_epreuves = '' AND r.rab_produits = '') AS depot_panier_pourcent, (SELECT SUM(opt_prix) FROM inscriptions_panier_options WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_options, (SELECT SUM(opt_prix) FROM inscriptions_panier_options WHERE opt_taxable = 1 AND no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS prix_options_taxable, (SELECT opt_date_limite_paiement FROM inscriptions_panier_options WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS date_limite_paiement, (SELECT SUM(par_frais_montant) FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS fra_avant_tx, (SELECT SUM(par_frais_tps) FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS fra_tps, (SELECT SUM(par_frais_tvq) FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS fra_tvq, (SELECT SUM(pec_montant_don - rab_montant) FROM inscriptions_panier_epreuves_commandees WHERE pec_don_actif = 1 AND no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "') AS total_don FROM DUAL "; $tabTotal = $objDatabase->fxGetRow($sqlTotal); //$tabTotal["prix_produits_taxable"]=0; // $tabTotal["prix_produits_taxable_pasderabais"]=10; if ($tabTotal["prix_produits_taxable_pasderabais"]>0){ //MSIN-4342 // $tabTotal["prix_produits"]=$tabTotal["prix_produits"]-$tabTotal["prix_produits_taxable_pasderabais"]; $tabTotal["prix_produits_taxable"]=$tabTotal["prix_produits_taxable"]+$tabTotal["prix_produits_taxable_pasderabais"]; }; $tabTotal['prix_epreuves_autre_eve_pastx'] = $tabTotal["prix_epreuves_autre_eve"] - $tabTotal["prix_epreuves_taxable_autre_eve"]; $tabTotal['prix_produits_autre_eve_pastx'] = $tabTotal["prix_produits_autre_eve"] - $tabTotal["prix_produits_taxable_autre_eve"]; $fltRegistrationTotal = $tabTotal['prix_epreuves'] + $tabTotal['prix_produits'] + $tabTotal['prix_montants_dus'] + $tabTotal['dons']; // #dons2017 #MSIN-1987 $fltRegistrationTotalpastx = $fltRegistrationTotal - ($tabTotal['prix_epreuves_taxable'] + $tabTotal['prix_produits_taxable']); // #dons2017 #MSIN-1987 $fltRegistrationTotaltx = $fltRegistrationTotal - $fltRegistrationTotalpastx; //echo("
v2 fltRegistrationTotal:");echo($fltRegistrationTotal); // echo("
v2 fltRegistrationTotalpastx:");echo($fltRegistrationTotalpastx); // echo("
v2 fltRegistrationTotaltx:");echo($fltRegistrationTotaltx); $fltOptionsTotal = $tabTotal['prix_options']; //MSIN-4301 prix_produits_taxable_pasderabais // calculer les rabais $fltRabaisMontant = $tabTotal['rabais_panier_montant_taxable'] + $tabTotal['rabais_panier_montant'] + $tabTotal['rabais_epreuves'] + $tabTotal['rabais_produits'] ; $intRabaisPourcent = $tabTotal['rabais_panier_pourcent']; if ($intRabaisPourcent > 100) $intRabaisPourcent = 100; // calculer le rabais % //$fltRabaisPourcent = ($fltRegistrationTotal - $fltRabaisMontant) * ($intRabaisPourcent / 100); //$fltRabaisPourcent = (($fltRegistrationTotal-$fltRegistrationTotalpastx) - $fltRabaisMontant-$tabTotal['prix_epreuves_autre_eve']-$tabTotal['prix_produits_autre_eve']) * ($intRabaisPourcent / 100); $fltRabaisPourcenttx = (($fltRegistrationTotaltx) - $fltRabaisMontant - $tabTotal['prix_epreuves_taxable_autre_eve'] - $tabTotal['prix_produits_taxable_autre_eve']) * ($intRabaisPourcent / 100); $fltRabaisPourcentpastx = ($fltRegistrationTotalpastx - $fltRabaisMontant - $tabTotal['prix_epreuves_autre_eve_pastx'] - $tabTotal['prix_produits_autre_eve_pastx']) * ($intRabaisPourcent / 100); $fltRabaisPourcent = $fltRabaisPourcentpastx + $fltRabaisPourcenttx; // calculer les dépôts $fltDepotMontant = $tabTotal['depot_panier_montant'] + $tabTotal['depot_epreuves'] + $tabTotal['depot_produits']; $intDepotPourcent = $tabTotal['depot_panier_pourcent']; if ($fltDepotMontant > 0 || $intDepotPourcent > 0) { $sqlDepot = "SELECT MIN(r.rab_code) AS rab_code, MIN(r.rab_description_fr) AS motif_fr, MIN(r.rab_description_en) AS motif_en FROM inscriptions_panier_rabais r, inscriptions_panier_rabais_acheteurs a WHERE r.pra_id = a.pra_id AND r.pra_depot = 1 AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $tabDepot = $objDatabase->fxGetRow($sqlDepot); $strMotifDepotFr = fxUnescape($tabDepot['rab_code']) . ' - ' . fxUnescape($tabDepot['motif_fr']); $strMotifDepotEn = fxUnescape($tabDepot['rab_code']) . ' - ' . fxUnescape($tabDepot['motif_en']); } // calculer le dépôt % $fltDepotPourcent = $fltRegistrationTotal * ($intDepotPourcent / 100); // calculer le total après rabais pourcent $fltRabaisTotal = $fltRabaisMontant + $fltRabaisPourcent; $fltDepotTotal = $fltDepotPourcent + $fltDepotMontant; // echo("
v2 fltRegistrationTotal:");echo($fltRegistrationTotal); // echo("
v2 fltRegistrationTotaltx:");echo($fltRegistrationTotaltx); // a voir $fltRegistrationTotal -= ($fltRabaisTotal + $fltDepotTotal); if ($fltRegistrationTotal < 0){ $fltRegistrationTotal = 0; } $fltRegistrationTotal =$fltRegistrationTotal +$tabTotal['prix_produits_taxable_pasderabais']; //MSIN-4257 retour en arriere $fltMontantTaxable = ($tabTotal['prix_epreuves_taxable'] + $tabTotal['prix_produits_taxable'] + $tabTotal['prix_options_taxable'] + $tabTotal['prix_montants_dus']) - ($fltRabaisPourcent + $tabTotal['rabais_panier_montant_taxable']) - ($fltDepotPourcent + $fltDepotMontant) ; //$fltMontantTaxable = ($tabTotal['prix_epreuves_taxable'] + $tabTotal['prix_produits_taxable'] + $tabTotal['prix_options_taxable'] + $tabTotal['prix_montants_dus']) - ($fltRabaisPourcent ) - ($fltDepotPourcent + $fltDepotMontant); // echo("
v1 fltMontantTaxable:");echo($fltMontantTaxable); // v2 tax // echo("
v2 fltRegistrationTotaltx:");echo($fltRegistrationTotaltx); // echo("
v2 fltRabaisPourcenttx:");echo($fltRabaisPourcenttx); // echo("
v2 fltDepotPourcent:");echo($fltDepotPourcent); // echo("
v2 fltDepotMontant:");echo($fltDepotMontant); // echo("
v2 fltRabaisPourcentpastx:");echo($fltRabaisPourcentpastx); // echo("
v2 fltMontantTaxable:");echo($fltMontantTaxable); // $fltMontantTaxable = $fltRegistrationTotaltx - $fltRabaisPourcenttx - ($fltDepotPourcent + $fltDepotMontant); // echo("
v2 fltMontantTaxable:");echo($fltMontantTaxable); if ($fltMontantTaxable < 0) $fltMontantTaxable = 0; //MSIN-4301 prix_produits_taxable_pasderabais // calculer le sous total (registration + option) $fltSousTotal = $fltRegistrationTotal + $fltOptionsTotal ; // calculer les taxes $tabTaxes[1] = $tabTaxes[2] = $tabTaxes[3] = $tabTaxesFrais[1] = $tabTaxesFrais[2] = $tabTaxesFrais[3] = array('label_fr' => '', 'label_en' => '', 'montant' => 0, 'taux' => 0, 'numero' => ''); // récupérer les infos des taxes if ($tabEvenements['tt_id'] > 1) { $sqlTaux = "SELECT t.tau_nom_fr, t.tau_nom_en, t.tau_taux, t.tau_numero_client, t.tau_numero_ms1 FROM inscriptions_taux t, inscriptions_taux_types_taux ttt WHERE t.tau_id = ttt.tau_id AND ttt.tt_id = " . intval($tabEvenements['tt_id']) . " ORDER BY ttt.ttt_tri"; $tabTaux = $objDatabase->fxGetResults($sqlTaux); if ($tabTaux != null) { for ($intCtr = 1; $intCtr <= count($tabTaux); $intCtr++) { $fltMontantTaxes = round($fltMontantTaxable * ($tabTaux[$intCtr]['tau_taux'] / 100), 2); $tabTaxes[$intCtr] = array('label_fr' => $tabTaux[$intCtr]['tau_nom_fr'] . ' (' . $tabTaux[$intCtr]['tau_taux'] . '%)', 'label_en' => $tabTaux[$intCtr]['tau_nom_en'] . ' (' . $tabTaux[$intCtr]['tau_taux'] . '%)', 'montant' => $fltMontantTaxes, 'taux' => $tabTaux[$intCtr]['tau_taux'], 'numero' => $tabTaux[$intCtr]['tau_numero_client']); $fltTotalTaxes += $fltMontantTaxes; } } else { fxcreer_log("Il y a eu une erreur lors de la récupération des taxes:\n" . $sqlTaux); } } // calculer le total après taxes $fltSousTotal2 = $fltSousTotal + $fltTotalTaxes; // caculer les frais d'administration if ($tabEvenements['eve_frais'] > 0) { if ($tabAcheteur['pai_id'] == 6) { // MSIN-2136 $tabFrais = array('fra_avant_tx' => 0, 'fra_total' => 0, 'fra_pourcent' => 0); } else { $sqlFrais = "SELECT fra_avant_tx, fra_avant_tx AS fra_total, fra_pourcent FROM inscriptions_frais WHERE fra_actif = 1 AND fra_montant_max >= " . floatval($fltSousTotal2) . " AND fra_montant_min <= " . floatval($fltSousTotal2) . " AND eve_frais = " . intval($tabEvenements['eve_frais']); $tabFrais2 = $objDatabase->fxGetRow($sqlFrais); if ($tabFrais2 != null) { if ($tabFrais2['fra_pourcent'] > 0) { $fltFraisAvantTaxes = round($fltSousTotal2 * ($tabFrais2['fra_pourcent'] / 100), 2); $fltPourcent = $tabFrais2['fra_pourcent']; } else { $fltFraisAvantTaxes = $tabFrais2['fra_avant_tx']; $fltPourcent = 0; } $fltFraisAvantTaxes += $tabAcheteur['fa_montant']; if ($tabEvenements['tt_id'] > 1) { $sqlTaux = "SELECT t.tau_nom_fr, t.tau_nom_en, t.tau_taux, t.tau_numero_client, t.tau_numero_ms1 FROM inscriptions_taux t, inscriptions_taux_types_taux ttt WHERE t.tau_id = ttt.tau_id AND ttt.tt_id = " . intval($tabEvenements['tt_id']) . " ORDER BY ttt.ttt_tri"; $tabTaux = $objDatabase->fxGetResults($sqlTaux); if ($tabTaux != null) { for ($intCtr = 1; $intCtr <= count($tabTaux); $intCtr++) { $fltMontantTaxesFrais = round($fltFraisAvantTaxes * ($tabTaux[$intCtr]['tau_taux'] / 100), 2); $tabTaxesFrais[$intCtr] = array('label_fr' => $tabTaux[$intCtr]['tau_nom_fr'] . ' (' . $tabTaux[$intCtr]['tau_taux'] . '%)', 'label_en' => $tabTaux[$intCtr]['tau_nom_en'] . ' (' . $tabTaux[$intCtr]['tau_taux'] . '%)', 'montant' => $fltMontantTaxesFrais, 'taux' => $tabTaux[$intCtr]['tau_taux'], 'numero' => $tabTaux[$intCtr]['tau_numero_ms1']); $fltTotalTaxesFrais += $fltMontantTaxesFrais; } } else { fxcreer_log("Il y a eu une erreur lors de la récupération des taxes:\n" . $sqlTaux); } } $tabFrais = array('fra_avant_tx' => $fltFraisAvantTaxes, 'fra_total' => $fltFraisAvantTaxes + $fltTotalTaxesFrais, 'fra_pourcent' => $fltPourcent); } else { fxcreer_log("Il y a eu une erreur lors de la récupération des frais de l'événement:\n" . $sqlFrais); $tabFrais = array('fra_avant_tx' => 0, 'fra_total' => 0, 'fra_pourcent' => 0); } } } else $tabFrais = array('fra_avant_tx' => 0, 'fra_total' => 0, 'fra_pourcent' => 0); // calculer le total avec frais d'administration $fltTotal = $fltSousTotal2 + $tabFrais['fra_total']; // affiche le sous-total, les taxes, rabais et le total complet $tabRetour['taxes'] = $tabTaxes; $tabRetour['taxes_frais'] = $tabTaxesFrais; $tabRetour['total_taxes'] = $fltTotalTaxes; $tabRetour['total_taxes_frais'] = $fltTotalTaxesFrais; $tabRetour['total'] = abs($fltTotal); $tabRetour['stotal'] = $fltSousTotal; $tabRetour['stotal2'] = $fltSousTotal2; $tabRetour['rabais_total'] = $fltRabaisTotal; $tabRetour['depot_total'] = $fltDepotTotal; $tabRetour['depot_motif_fr'] = $strMotifDepotFr; $tabRetour['depot_motif_en'] = $strMotifDepotEn; $tabRetour['total_don'] = $tabTotal['total_don']; if ($tabEpreuves != null) $tabRetour['pec_id'] = implode(',', array_map(function ($tab) { return $tab['pec_id']; }, $tabEpreuves)); else $tabRetour['pec_id'] = 0; $tabRetour['eve_id'] = $tabEvenements['eve_id']; $tabRetour['date_limite_paiement'] = $tabTotal['date_limite_paiement']; $tabRetour['fra_total'] = $tabFrais['fra_total']; $tabRetour['fra_avant_tx'] = $tabFrais['fra_avant_tx']; $tabRetour['fra_pourcent'] = $tabFrais['fra_pourcent']; if (abs($fltTotal) > 0) { $tabRetour['fra_total2'] = $tabTotal['fra_avant_tx'] + $tabTotal['fra_tps'] + $tabTotal['fra_tvq']; $tabRetour['taxes_frais2'] = array(1 => array('label_fr' => 'TPS (5%)', 'label_en' => 'GST (5%)', 'montant' => $tabTotal['fra_tps'], 'taux' => 5, 'numero' => ''), 2 => array('label_fr' => 'TVQ (9,975%)', 'label_en' => 'PST (9,975%)', 'montant' => $tabTotal['fra_tvq'], 'taux' => 9.975, 'numero' => ''), 3 => array('label_fr' => '', 'label_en' => '', 'montant' => 0, 'taux' => 0, 'numero' => '')); $tabRetour['fra_avant_tx2'] = $tabTotal['fra_avant_tx']; } else { $tabRetour['fra_total2'] = 0; $tabRetour['taxes_frais2'] = array(1 => array('label_fr' => '', 'label_en' => '', 'montant' => 0, 'taux' => 0, 'numero' => ''), 2 => array('label_fr' => '', 'label_en' => '', 'montant' => 0, 'taux' => 0, 'numero' => ''), 3 => array('label_fr' => '', 'label_en' => '', 'montant' => 0, 'taux' => 0, 'numero' => '')); $tabRetour['fra_avant_tx2'] = 0; } return $tabRetour; } // Afficher l'adresse du client (JSP) // $type = mail ou web function fxShowAddress($strNoPanier, $type, $strLangue = 'fr') { global $vDomaine; $tabPanier = fxlistPanier($strNoPanier); $tabAcheteur = $tabPanier[0]; $strColor = $tabPanier[14]; $adresse = ''; if ($type == 'web') { $adresse .= ''; $adresse .= ''; if ($strLangue == 'fr') $adresse .= ' '; else $adresse .= ' '; $adresse .= ''; $adresse .= ''; $adresse .= ' '; $adresse .= ''; $adresse .= '
AdresseAddress
'; } $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 .= '
'; } return $adresse; } // fonction pour afficher l'adresse du magasin (JSP) // param : no panier function fxShowAdresseMagasin($strNoPanier, $strLangue) { global $objDatabase; $strAdresse = $strContact = ''; if ($strNoPanier != '') { $sqlContact = "SELECT e.eve_trousses_$strLangue AS info FROM inscriptions_evenements e WHERE e.eve_id IN(SELECT eve_id FROM inscriptions_panier_acheteurs WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "')"; $arrContact = $objDatabase->fxGetResults($sqlContact); foreach ($arrContact as $arr) { $strContact .= $arr['info']; } $strContact = str_replace('%recu_pdf%', '', $strContact); $strAdresse = '
' . fxUnescape($strContact, 1) . '
'; } else { $strAdresse = '

' . $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 .= '
'; } if (trim($arr['msg']) != '') { $strOutput .= ($arr['msg']); } else { $strOutput .= str_replace('%nom_evenement%', fxUnescape($arr['nom']), $strMessageEtat); } } } return $strOutput; } // fonction pour marquer la commande comme "acceptée" et envoyer le courriel de confirmation (JSP) function fxMajCommande($strNoPanier, $strLangue = 'fr', $blnResend = false) { global $objDatabase, $vDomaine, $vRepertoireFichiers; $strNomFichier = $attachment_url = $attachment_label = ""; $ach_total_don = $intRecu = 0; $blnSend = $blnReceipt = false; $tabPanier = fxlistPanier($strNoPanier); $tabAcheteur = $tabPanier[0]; $tabEvenement = $tabEvenements = $tabPanier[1]; $tabProduits = $tabPanier[2]; $tabEpreuves = $tabPanier[3]; $tabParticipants = $tabPanier[4]; $tabQuestions = $tabPanier[5]; $tabProduits2 = $tabPanier[7]; $tabMontantsDus = $tabPanier[10]; $tabQuestionsEpreuve = $tabPanier[11]; $tabDons = $tabPanier[12]; $blnDonAuto = false; $tabDonsAuto = $tabPanier[13]; $strColor = $tabPanier[14]; $pec_complete = 1; if (($tabAcheteur['receipt_text'] == 'APPROUVEE - MERCI' || $tabAcheteur['receipt_text'] == 'APPROVED - THANK YOU') && $tabAcheteur['no_commande'] == '') { $tabTotal = fxTotalPanier($strNoPanier, $strLangue); $ach_total = $tabTotal['total']; $ach_total_don = $tabTotal['total_don']; // générer un numéro de commande $no_commande = fxGetNoCommande('ms1_'); $_SESSION['no_commande'] = $no_commande; $sqlUpdate = "UPDATE inscriptions_panier_acheteurs SET eve_id = " . intval($tabTotal['eve_id']) . ", sta_id = 3, ach_maj = '" . fxGetDateTime() . "', no_commande = '" . $no_commande . "', ach_total = " . floatval($ach_total) . ", ach_total_dons = " . floatval($ach_total_don) . ", fra_avant_tx = " . floatval($tabTotal['fra_avant_tx']) . ", fra_total = " . floatval($tabTotal['fra_total']) . ", fra_pourcent = " . floatval($tabTotal['fra_pourcent']) . ", fra_taxe1 = " . floatval($tabTotal['taxes_frais'][1]['montant']) . ", fra_taxe2 = " . floatval($tabTotal['taxes_frais'][2]['montant']) . ", fra_taxe3 = " . floatval($tabTotal['taxes_frais'][3]['montant']) . ", fra_taxe1_label_fr = '" . $objDatabase->fxEscape($tabTotal['taxes_frais'][1]['label_fr'] . " " . $tabTotal['taxes_frais'][1]['numero']) . "', fra_taxe1_label_en = '" . $objDatabase->fxEscape($tabTotal['taxes_frais'][1]['label_en'] . " " . $tabTotal['taxes_frais'][1]['numero']) . "', fra_taxe2_label_fr = '" . $objDatabase->fxEscape($tabTotal['taxes_frais'][2]['label_fr'] . " " . $tabTotal['taxes_frais'][2]['numero']) . "', fra_taxe2_label_en = '" . $objDatabase->fxEscape($tabTotal['taxes_frais'][2]['label_en'] . " " . $tabTotal['taxes_frais'][2]['numero']) . "', fra_taxe3_label_fr = '" . $objDatabase->fxEscape($tabTotal['taxes_frais'][3]['label_fr'] . " " . $tabTotal['taxes_frais'][3]['numero']) . "', fra_taxe3_label_en = '" . $objDatabase->fxEscape($tabTotal['taxes_frais'][3]['label_en'] . " " . $tabTotal['taxes_frais'][3]['numero']) . "', fra_taxe1_taux = " . floatval($tabTotal['taxes_frais'][1]['taux']) . ", fra_taxe2_taux = " . floatval($tabTotal['taxes_frais'][2]['taux']) . ", fra_taxe3_taux = " . floatval($tabTotal['taxes_frais'][3]['taux']) . ", ach_taxe1 = " . floatval($tabTotal['taxes'][1]['montant']) . ", ach_taxe2 = " . floatval($tabTotal['taxes'][2]['montant']) . ", ach_taxe3 = " . floatval($tabTotal['taxes'][3]['montant']) . ", ach_taxe1_label_fr = '" . $objDatabase->fxEscape($tabTotal['taxes'][1]['label_fr'] . " " . $tabTotal['taxes'][1]['numero']) . "', ach_taxe1_label_en = '" . $objDatabase->fxEscape($tabTotal['taxes'][1]['label_en'] . " " . $tabTotal['taxes'][1]['numero']) . "', ach_taxe2_label_fr = '" . $objDatabase->fxEscape($tabTotal['taxes'][2]['label_fr'] . " " . $tabTotal['taxes'][2]['numero']) . "', ach_taxe2_label_en = '" . $objDatabase->fxEscape($tabTotal['taxes'][2]['label_en'] . " " . $tabTotal['taxes'][2]['numero']) . "', ach_taxe3_label_fr = '" . $objDatabase->fxEscape($tabTotal['taxes'][3]['label_fr'] . " " . $tabTotal['taxes'][3]['numero']) . "', ach_taxe3_label_en = '" . $objDatabase->fxEscape($tabTotal['taxes'][3]['label_en'] . " " . $tabTotal['taxes'][3]['numero']) . "', ach_taxe1_taux = " . floatval($tabTotal['taxes'][1]['taux']) . ", ach_taxe2_taux = " . floatval($tabTotal['taxes'][2]['taux']) . ", ach_taxe3_taux = " . floatval($tabTotal['taxes'][3]['taux']) . ", depot_total = " . floatval($tabTotal['depot_total']) . ", rabais_total = " . floatval($tabTotal['rabais_total']) . " WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $qryUpdate = $objDatabase->fxQuery($sqlUpdate); if (!($tabTotal['fra_total'] > 0) && $tabTotal['fra_total2'] > 0) { $sqlUpdate = "UPDATE inscriptions_panier_acheteurs SET fra_avant_tx = " . floatval($tabTotal['fra_avant_tx2']) . ", fra_total = " . floatval($tabTotal['fra_total2']) . ", fra_taxe1 = " . floatval($tabTotal['taxes_frais2'][1]['montant']) . ", fra_taxe2 = " . floatval($tabTotal['taxes_frais2'][2]['montant']) . ", fra_taxe3 = " . floatval($tabTotal['taxes_frais2'][3]['montant']) . ", fra_taxe1_label_fr = '" . $objDatabase->fxEscape($tabTotal['taxes_frais2'][1]['label_fr'] . " " . $tabTotal['taxes_frais2'][1]['numero']) . "', fra_taxe1_label_en = '" . $objDatabase->fxEscape($tabTotal['taxes_frais2'][1]['label_en'] . " " . $tabTotal['taxes_frais2'][1]['numero']) . "', fra_taxe2_label_fr = '" . $objDatabase->fxEscape($tabTotal['taxes_frais2'][2]['label_fr'] . " " . $tabTotal['taxes_frais2'][2]['numero']) . "', fra_taxe2_label_en = '" . $objDatabase->fxEscape($tabTotal['taxes_frais2'][2]['label_en'] . " " . $tabTotal['taxes_frais2'][2]['numero']) . "', fra_taxe3_label_fr = '" . $objDatabase->fxEscape($tabTotal['taxes_frais2'][3]['label_fr'] . " " . $tabTotal['taxes_frais2'][3]['numero']) . "', fra_taxe3_label_en = '" . $objDatabase->fxEscape($tabTotal['taxes_frais2'][3]['label_en'] . " " . $tabTotal['taxes_frais2'][3]['numero']) . "', fra_taxe1_taux = " . floatval($tabTotal['taxes_frais2'][1]['taux']) . ", fra_taxe2_taux = " . floatval($tabTotal['taxes_frais2'][2]['taux']) . ", fra_taxe3_taux = " . floatval($tabTotal['taxes_frais2'][3]['taux']) . " WHERE no_panier = '" . $objDatabase->fxEscape($_SESSION['no_panier']) . "'"; $qryUpdate = $objDatabase->fxQuery($sqlUpdate); } fxMajStockEpreuves('-', $strNoPanier); fxMajStockRabais('-', $strNoPanier); if ($tabTotal['depot_total'] > 0) { // Ajouter le montant du $pec_complete = 0; $sqlInsert = "INSERT INTO inscriptions_montants_dus SET com_id = " . intval($_SESSION['com_id']) . ", pec_id = '" . $objDatabase->fxEscape($tabTotal['pec_id']) . "', md_montant = " . floatval($tabTotal['depot_total']) . ", eve_id = " . intval($tabTotal['eve_id']) . ", no_commande = '" . $no_commande . "', no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', md_date_limite_paiement = '" . $objDatabase->fxEscape($tabTotal['date_limite_paiement']) . "', md_motif_fr = '" . $objDatabase->fxEscape($tabTotal['depot_motif_fr']) . "', md_motif_en = '" . $objDatabase->fxEscape($tabTotal['depot_motif_en']) . "'"; $qryInsert = $objDatabase->fxQuery($sqlInsert); } /********************** * Associer le com_id * **********************/ $intCompte = 0; // boucle pour les épreuves si plus que un abonnement (sl) for ($intCtr = 1; $intCtr <= count($tabEpreuves); $intCtr++) { if (intval($tabEpreuves[$intCtr]['tep_id']) == 4) {// si le type est abonnement // valide si membre dun club // MSIN-3922 $club = ""; foreach ($tabQuestions as $quest) { foreach ($quest as $det) { if ($det['pec_id'] == intval($tabEpreuves[$intCtr]['pec_id']) && $det['que_validation'] == 'clubtq') $nom_club = $det['que_choix_fr']; } } $intCompte = $tabEpreuves[$intCtr]['mem_com_id']; $intType = $tabEpreuves[$intCtr]['mt_id']; $intepr_id = $tabEpreuves[$intCtr]['epr_id']; $intSousType = (intval(fxIfRenouvellementMembership($intType, $intCompte)) > 0) ? 2 : 1; $strDateDebut = $tabEpreuves[$intCtr]['pec_membership_start']; $strDateFin = $tabEpreuves[$intCtr]['pec_membership_end']; $intpec_id = $tabEpreuves[$intCtr]['pec_id']; $numero_manuele = $tabEpreuves[$intCtr]['tq_temp']; // enregistrer l'abonnement $arrMembership = fxSetMembership($intCompte, $intType, $intSousType, $strDateDebut, $strDateFin, $strNoPanier, $no_commande, $intepr_id, $intpec_id, $numero_manuele, $nom_club); } } // valider par js pourquois le else //if (intval($tabEpreuves[1]['tep_id']) == 4) {// si le type est abonnement // $intCompte = $tabEpreuves[1]['com_id']; // $intType = $tabEpreuves[1]['mt_id']; // $intSousType = $tabEpreuves[1]['mst_id']; // $strDateDebut = $tabEpreuves[1]['pec_membership_start']; // $strDateFin = $tabEpreuves[1]['pec_membership_end']; // // enregistrer l'abonnement // $arrMembership = fxSetMembership($intCompte, $intType, $intSousType, $strDateDebut, $strDateFin,$strNoPanier,$no_commande); // } elseif (isset($_SESSION['com_info']['com_id']) && !isset($_SESSION['usa_id'])) { // $intCompte = $_SESSION['com_info']['com_id']; // } if (intval($intCompte) != 0) { // mettre à jour le com_id $sqlUpdate1 = "UPDATE inscriptions_panier_acheteurs SET com_id = " . intval($intCompte) . " WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $qryUpdate1 = $objDatabase->fxQuery($sqlUpdate1); $sqlUpdate2 = "UPDATE inscriptions_panier_epreuves_commandees SET com_id = " . intval($intCompte) . " WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $qryUpdate2 = $objDatabase->fxQuery($sqlUpdate2); $sqlUpdate3 = "UPDATE inscriptions_panier_participants SET com_id = " . intval($intCompte) . " WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $qryUpdate3 = $objDatabase->fxQuery($sqlUpdate3); } /* ^^^^^^^^^^^^^^^^^^^^^ */ for ($intCtr = 1; $intCtr <= count($tabEpreuves); $intCtr++) { // insérer les épreuves // NOTE: nouvraux champs épreuve #NCEPR $sqlInsert = "INSERT INTO resultats_epreuves_commandees(eve_id, epr_id, no_panier, pec_label, pec_nom_equipe, pec_equipe, com_id, pec_maj, pec_id_original, no_commande, ep_prix_participant, epr_objectif_dons, epr_objectif_dons_original, epr_objectif_distance, epr_objectif_distance_original, epr_objectif_temps, epr_objectif_temps_original, pec_complete, tep_id, mt_id, mst_id, pec_membership_start, pec_membership_end) SELECT eve_id, epr_id, no_panier, pec_label, pec_nom_equipe, pec_equipe, com_id, '" . fxGetDateTime() . "', pec_id, '" . $no_commande . "', ep_prix_participant, epr_objectif_dons, epr_objectif_dons, epr_objectif_distance, epr_objectif_distance, epr_objectif_temps, epr_objectif_temps, '" . $pec_complete . "', tep_id, mt_id, mst_id, pec_membership_start, pec_membership_end FROM inscriptions_panier_epreuves_commandees WHERE pec_id = " . intval($tabEpreuves[$intCtr]['pec_id']); $qryInsert = $objDatabase->fxQuery($sqlInsert); if ($qryInsert !== false) { // pixel PURCHASE if (trim($tabEpreuves[$intCtr]['epr_categorie_' . $strLangue]) != '') { $strEpreuve = $tabEpreuves[$intCtr]['epr_categorie_' . $strLangue] . ' - '; } else { $strEpreuve = ''; } $strEpreuve .= fxUnescape($tabEpreuves[$intCtr]['epr_type_' . $strLangue]); if (trim($tabEpreuves[$intCtr]['epr_nom_' . $strLangue]) != '') $strEpreuve .= ' - ' . fxUnescape($tabEpreuves[$intCtr]['epr_nom_' . $strLangue]); $mem_pixcel = array("param1" => "track", "param2" => "Purchase", "currency" => "CAD", "content_name" => $strEpreuve, "content_ids" => $tabEpreuves[$intCtr]['epr_id'], "value" => $tabEpreuves[$intCtr]['pec_prix'], "content_type" => "product"); fxsessionpixelfacebook($mem_pixcel); } // insérer les questions épreuve/participants if (isset($tabQuestionsEpreuve[$tabEpreuves[$intCtr]['pec_id']])) { for ($intCtr2 = 1; $intCtr2 <= count($tabQuestionsEpreuve[$tabEpreuves[$intCtr]['pec_id']]); $intCtr2++) { $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($tabQuestionsEpreuve[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['pqu_id']); $qryInsert = $objDatabase->fxQuery($sqlInsert); } } // insérer les produits if (isset($tabProduits[$tabEpreuves[$intCtr]['pec_id']])) { for ($intCtr2 = 1; $intCtr2 <= count($tabProduits[$tabEpreuves[$intCtr]['pec_id']]); $intCtr2++) { $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($tabProduits[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['ppn_id']); $qryInsert = $objDatabase->fxQuery($sqlInsert); if ($qryInsert !== false) { // pixel PURCHASE $mem_pixcel = array("param1" => "track", "param2" => "Purchase", "currency" => "CAD", "content_name" => $tabProduits[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['pro_nom_' . $strLangue], "content_ids" => $tabProduits[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['pro_id'], "value" => $tabProduits[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['pro_prix'], "content_type" => "product"); fxsessionpixelfacebook($mem_pixcel); } } } if (isset($tabParticipants[$tabEpreuves[$intCtr]['pec_id']])) { for ($intCtr2 = 1; $intCtr2 <= count($tabParticipants[$tabEpreuves[$intCtr]['pec_id']]); $intCtr2++) { // insérer les participants $sqlInsert = "INSERT INTO resultats_participants(eve_id, epr_id, par_prenom, par_nom, par_naissance, par_age, par_sexe, par_adresse, par_adresse2, par_ville, pro_id, par_codepostal, pay_id, par_telephone1, par_telephone1_ext, par_telephone2, par_courriel, par_capitaine, com_id, par_nom_equipe, no_panier, par_note, par_maj, no_commande, par_id_original, par_no_equipe, par_equipe, pec_id, rol_id, no_invitation, epr_objectif_dons, epr_objectif_dons_original, par_categorie_1_long_fr, par_categorie_1_long_en,par_categorie_1_court_fr, par_categorie_1_court_en, par_categorie_2_long_fr, par_categorie_2_long_en, par_categorie_2_court_fr, par_categorie_2_court_en, par_categorie_3_long_fr, par_categorie_3_long_en, par_categorie_3_court_fr, par_categorie_3_court_en, epr_objectif_distance, epr_objectif_distance_original, epr_objectif_temps, epr_objectif_temps_original, par_contact_urgence_nom, par_contact_urgence_telephone) SELECT eve_id, epr_id, par_prenom, par_nom, par_naissance, par_age, par_sexe, par_adresse, par_adresse2, par_ville, pro_id, par_codepostal, pay_id, par_telephone1, par_telephone1_ext, par_telephone2, par_courriel, par_capitaine, com_id, par_nom_equipe, no_panier, par_note, '" . fxGetDateTime() . "', '" . $no_commande . "', par_id, par_no_equipe, par_equipe, pec_id, rol_id, no_invitation, epr_objectif_dons, epr_objectif_dons, par_categorie_1_long_fr, par_categorie_1_long_en,par_categorie_1_court_fr, par_categorie_1_court_en, par_categorie_2_long_fr, par_categorie_2_long_en, par_categorie_2_court_fr, par_categorie_2_court_en, par_categorie_3_long_fr, par_categorie_3_long_en, par_categorie_3_court_fr, par_categorie_3_court_en, epr_objectif_distance, epr_objectif_distance, epr_objectif_temps, epr_objectif_temps, par_contact_urgence_nom, par_contact_urgence_telephone FROM inscriptions_panier_participants WHERE par_id = " . intval($tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_id']); $qryInsert = $objDatabase->fxQuery($sqlInsert); // MSIN-4379 — Étape 7 : assignation auto du dossard après création du participant (achat). if ($qryInsert !== false) { $intNewParId = (int)$objDatabase->fxGetLastId(); $intEprIdAutoBib = (int)$tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['epr_id']; if ($intNewParId > 0 && $intEprIdAutoBib > 0) { fxAssignAutoBibForParticipant($intEprIdAutoBib, $intNewParId); } } // insérer les questions if (isset($tabQuestions[$tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_id']])) { $list_file = []; for ($intCtr3 = 1; $intCtr3 <= count($tabQuestions[$tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_id']]); $intCtr3++) { // if fichier if ($tabQuestions[$tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_id']][$intCtr3]['que_validation'] == "image" || $tabQuestions[$tabParticipants[$tabEpreuves[$intCtr]['pec_id']][$intCtr2]['par_id']][$intCtr3]['que_validation'] == "pdf") { //print("
".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"; ?>
maxlength="50" required autofocus>
maxlength="50" required>
maxlength="100" required>
maxlength="100">
maxlength="50" required>
maxlength="7" required>
maxlength="12" required>
maxlength="12">
maxlength="100" required>
1. SommaireSummary
2. PaiementPaymentInscriptionRegistration
3. ConfirmationConfirmation
fxEscape($strNoPanier) . "' GROUP BY nom ORDER BY rol_id, nom"; $tabParticipants = $objDatabase->fxGetResults($sqlParticipants); if ($tabParticipants != null) { // mettre les infos dans une variable session $sqlParticipantsInfo = "SELECT * FROM inscriptions_panier_participants WHERE par_id IN(" . implode(',', array_map(function ($tab) { return $tab['par_id']; }, $tabParticipants)) . ") ORDER BY rol_id, par_nom, par_prenom"; $tabParticipantsInfo = $objDatabase->fxGetResults($sqlParticipantsInfo); $_SESSION['panier_info'] = $tabParticipantsInfo; } else $_SESSION['panier_info'] = ''; return $tabParticipants; } // met à jour les stocks des épreuves dun panier (JSP) // param: action (+ ou -), no panier function fxMajStockEpreuves($strAction, $strNoPanier) { global $objDatabase; $strWhere = ''; if (isset($_SESSION['no_transfert']) && trim($_SESSION['no_transfert']) != '') { $strWhere = ' AND pec_id <> ' . intval($_SESSION['pec_id_new']); } $sqlEpreuves = "SELECT epr_id FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'" . $strWhere; $tabEpreuves = $objDatabase->fxGetResults($sqlEpreuves); if ($tabEpreuves != null) { for ($intCtr = 1; $intCtr <= count($tabEpreuves); $intCtr++) { $sqlUpdate = "UPDATE inscriptions_epreuves SET epr_qte = (epr_qte " . $strAction . " 1) WHERE epr_id = " . intval($tabEpreuves[$intCtr]['epr_id']) . " AND epr_qte_limitee = 1"; fxcreer_log($sqlUpdate . '-' . $intCtr); $qryUpdate = $objDatabase->fxQuery($sqlUpdate); if (isset($_SESSION['com_id'])) { $sqlUpdate = "UPDATE inscriptions_liste_attente_participants SET lispar_statut=3 WHERE lispar_statut=2 and epr_id = " . intval($tabEpreuves[$intCtr]['epr_id']) . " AND com_id = " . $_SESSION['com_id']; fxcreer_log($sqlUpdate . ' attente ' . $intCtr); $qryUpdate = $objDatabase->fxQuery($sqlUpdate); } } } } // valide les stocks des épreuves d'un panier (SL) MSIN-811 // param: no panier // retour : tableau des épreuves refusées function fxValideStockEpreuves($strNoPanier) { global $objDatabase; $strWhere = ''; if (isset($_SESSION['no_transfert']) && trim($_SESSION['no_transfert']) != '') { $strWhere = ' AND pec_id <> ' . intval($_SESSION['pec_id_new']); } $sqlEpreuves = "SELECT COUNT(*) AS qte, epr_id FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'" . $strWhere . " GROUP BY epr_id ORDER BY epr_id"; $tabEpreuves = $objDatabase->fxGetResults($sqlEpreuves); $tabResultat = array(); $intCtr2 = 1; if ($tabEpreuves != null) { for ($intCtr = 1; $intCtr <= count($tabEpreuves); $intCtr++) { $sqlQte = "SELECT * FROM inscriptions_epreuves WHERE epr_id = " . intval($tabEpreuves[$intCtr]['epr_id']) . " AND epr_qte_limitee = 1"; $qryQte = $objDatabase->fxGetRow($sqlQte); if ($qryQte != null) { if ($tabEpreuves[$intCtr]['qte'] > $qryQte['epr_qte']) { $tabResultat[$intCtr2] = $qryQte; $intCtr2++; } } } } if ($intCtr2 > 1) return $tabResultat; else return null; } // valide les stocks camping des épreuves d'un panier (SL-alex) MSIN-1107 // param: no panier // retour : tableau des épreuves refusées function fxValideStockCampingEpreuves($strNoPanier) { global $objDatabase; $sqlEpreuves = "SELECT *, COUNT(*) AS qte FROM inscriptions_panier_produits_new WHERE pro_annulation <> 1 AND no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $tabEpreuves = $objDatabase->fxGetResults($sqlEpreuves); if ($tabEpreuves != null) return $tabEpreuves; else return null; } // valide les stocks des produits d'un panier (JSP) MSIN-747 // param: no panier // retour : tableau des produits refusés function fxValideStockProduits($strNoPanier) { global $objDatabase; $sqlProduits = "SELECT COUNT(*) AS qte, pro_id FROM inscriptions_panier_produits_new WHERE pro_annulation <> 1 AND no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' GROUP BY pro_id ORDER BY pro_id"; $tabProduits = $objDatabase->fxGetResults($sqlProduits); $tabResultat = array(); $intCtr2 = 1; if ($tabProduits != null) { for ($intCtr = 1; $intCtr <= count($tabProduits); $intCtr++) { // $sqlQte = "SELECT pro_qte FROM inscriptions_produits_new WHERE pro_id = " . intval($tabProduits[$intCtr]['pro_id']) . " - SELECT (SELECT COUNT(ppn_id) FROM resultats_produits_new WHERE pro_id = " . intval($intSiteId) . ") + (SELECT COUNT(p.ppn_id) FROM inscriptions_panier_produits_new p, inscriptions_panier_acheteurs a WHERE a.no_panier = p.no_panier AND a.sta_id = 1 AND p.pro_id = " . intval($intSiteId) . ") AS total FROM DUAL"; $sqlRestant = "SELECT (SELECT pro_qte FROM inscriptions_produits_new WHERE pro_id = " . intval($tabProduits[$intCtr]['pro_id']) . ") - (SELECT COUNT(ppn_id) FROM resultats_produits_new WHERE pro_id = " . intval($tabProduits[$intCtr]['pro_id']) . ") AS restant FROM DUAL"; $intRestant = $objDatabase->fxGetVar($sqlRestant); if ($intRestant != null) { if ($tabProduits[$intCtr]['qte'] > $intRestant) { // récupérer le détail du produit $sqlProduit = "SELECT * FROM inscriptions_produits_new WHERE pro_id = " . intval($tabProduits[$intCtr]['pro_id']); $tabProduit = $objDatabase->fxGetRow($sqlProduit); $tabResultat[$intCtr2] = $tabProduit; $tabResultat[$intCtr2]['qte_restant'] = $intRestant; $intCtr2++; } } } } if ($intCtr2 > 1) return $tabResultat; else return null; } function fxMajEpreuvesCommandees($str_ancien_no_panier, $pec_id_old, $pec_id_new, $strNoTransfert) { global $objDatabase; $sqlEpreuveOld = "SELECT * FROM resultats_epreuves_commandees WHERE pec_actif = 1 AND pec_id_original = " . intval($pec_id_old); $tabEpreuveOld = $objDatabase->fxGetRow($sqlEpreuveOld); $sqlEpreuveNew = "SELECT * FROM resultats_epreuves_commandees WHERE pec_actif = 1 AND pec_id_original = " . intval($pec_id_new); $tabEpreuveNew = $objDatabase->fxGetRow($sqlEpreuveNew); if ($tabEpreuveOld != null && $tabEpreuveNew != null) { if (trim($strNoTransfert) != '') { $sqlUpdateTransfert = "UPDATE inscriptions_transferts SET ts_id = 2, pec_id_new = " . intval($pec_id_new) . ", com_id_new = " . intval($_SESSION['com_info']['com_id']) . " WHERE no_transfert = '" . $objDatabase->fxEscape($strNoTransfert) . "'"; $qryUpdateTransfert = $objDatabase->fxQuery($sqlUpdateTransfert); if (!$qryUpdateTransfert) { fxcreer_log("Erreur lors de mise a jour du statut du transfert:\n" . $sqlUpdateTransfert); } // inscrire les autres transfert "ANNULÉ" $sqlUpdateTransfert = "UPDATE inscriptions_transferts SET ts_id = 4 WHERE pec_id = " . intval($pec_id_old) . " AND no_transfert <> '" . $objDatabase->fxEscape($strNoTransfert) . "'"; $qryUpdateTransfert = $objDatabase->fxQuery($sqlUpdateTransfert); if (!$qryUpdateTransfert) { fxcreer_log("Erreur lors de mise a jour du statut du transfert:\n" . $sqlUpdateTransfert); } $strField = 'transfert'; } else { //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($tabEpreuveOld['epr_id']) . " AND epr_qte_limitee = 1"; $qryUpdateStocks = $objDatabase->fxQuery($sqlUpdate); if (!$qryUpdateStocks) { fxcreer_log("Erreur lors de mise a jour des stocks: epreuve id " . $tabEpreuveOld['epr_id']); } // FLAG TABLES $sqlJonction = "INSERT INTO inscriptions_panier_epreuves_commandees_upgrade SET pec_id_new = " . intval($pec_id_new) . ", pec_id_old = " . intval($pec_id_old); $qryJonction = $objDatabase->fxQuery($sqlJonction); if (!$qryJonction) { fxcreer_log("Erreur lors de l'ajout a la table upgrade:\n" . $sqlJonction); } $strField = 'upgraded'; } // _panier_epreuves_commandees $sqlUpdateTrx = "UPDATE inscriptions_panier_epreuves_commandees SET pec_" . $strField . " = 1 WHERE pec_id = " . intval($pec_id_old); $qryUpdateTrx = $objDatabase->fxQuery($sqlUpdateTrx); if (!$qryUpdateTrx) { fxcreer_log("Erreur lors de mise à jour de l'épreuve au panier:\n" . $sqlUpdateTrx); } // _panier_acheteurs $sqlUpdateTrx = "UPDATE inscriptions_panier_acheteurs SET ach_" . $strField . " = 1 WHERE no_panier = '" . $objDatabase->fxEscape($str_ancien_no_panier) . "'"; $qryUpdateTrx = $objDatabase->fxQuery($sqlUpdateTrx); if (!$qryUpdateTrx) { fxcreer_log("Erreur lors de mise à jour de l'acheteur au panier:\n" . $sqlUpdateTrx); } // desactivation de l'ancienne epreuve et participants $sqlUpdate = "UPDATE resultats_epreuves_commandees SET pec_actif = 0, is_cancelled = 1, pec_maj = '" . fxGetDateTime() . "' WHERE pec_id_original = " . intval($pec_id_old); $qryUpdateEpreuve = $objDatabase->fxQuery($sqlUpdate); $sqlUpdate = "UPDATE resultats_participants SET is_cancelled = 1, par_modification_promoteur = 1, par_maj = '" . fxGetDateTime() . "' WHERE pec_id = " . intval($pec_id_old); $qryUpdateParticipants = $objDatabase->fxQuery($sqlUpdate); if (!$qryUpdateEpreuve || !$qryUpdateParticipants) fxcreer_log("Erreur de désactivation de l'ancienne épreuve lors d'un upgrade ou transfert."); } unset($_SESSION['ancien_no_panier']); unset($_SESSION['pec_id_old']); unset($_SESSION['pec_id_new']); unset($_SESSION['no_transfert']); } function fxSetProduitsAuto($strAction, $intEvenement, $intEvenementMembership, $intEpreuve, $strNoPanier, $intEpreuveCommandee,$mem_type_transaction="") { global $objDatabase; switch ($strAction) { case 'add': // insérer les produits automatiques $sqlProduitsAuto = "SELECT * FROM inscriptions_produits_new WHERE pro_actif = 1 AND pro_automatique = 1 AND (pro_date_limite = '0000-00-00' OR pro_date_limite = '' OR pro_date_limite IS NULL OR pro_date_limite >= '" . fxGetDate() . "') AND eve_id IN(" . intval($intEvenement) . ", " . intval($intEvenementMembership) . ") AND (FIND_IN_SET(" . intval($intEpreuve) . ", pro_epreuves) OR pro_epreuves = '') " . " ORDER BY pro_id"; $tabProduitsAuto = $objDatabase->fxGetResults($sqlProduitsAuto); if ($tabProduitsAuto != null) { for ($intCtr = 1; $intCtr <= count($tabProduitsAuto); $intCtr++) { // insérer le produit dans le panier $sqlInsert = "INSERT INTO inscriptions_panier_produits_new SET eve_id = " . intval($tabProduitsAuto[$intCtr]['eve_id']) . ", pec_id = " . intval($intEpreuveCommandee) . ", par_id = 0, pro_id = " . intval($tabProduitsAuto[$intCtr]['pro_id']) . ", pt_id = " . intval($tabProduitsAuto[$intCtr]['pt_id']) . ", pro_nom_fr = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_nom_fr']) . "', pro_nom_en = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_nom_en']) . "', pro_description_fr = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_description_fr']) . "', pro_description_en = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_description_en']) . "', pro_taille_fr = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_taille_fr']) . "', pro_taille_en = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_taille_en']) . "', pro_section_fr = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_section_fr']) . "', pro_section_en = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_section_en']) . "', pro_prix = " . floatval($tabProduitsAuto[$intCtr]['pro_prix']) . ", pro_taxable = " . intval($tabProduitsAuto[$intCtr]['pro_taxable']) . ", pro_effacable = " . intval($tabProduitsAuto[$intCtr]['pro_effacable']) . ", pro_maj = '" . fxGetDateTime() . "', no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $qryInsert = $objDatabase->fxQuery($sqlInsert); if ($qryInsert == null) { fxcreer_log("Il y a eu une erreur lors de l'ajout du produit auto:\n" . $sqlInsert); } } } break; //MSIN-4276 case 'addtransfert': // insérer les produits automatiques if ($mem_type_transaction !=""){ if ($mem_type_transaction =="transfert") $sqlProduitsAuto = "SELECT * FROM inscriptions_produits_new WHERE pro_actif = 1 AND pt_id = 6 AND (pro_date_limite = '0000-00-00' OR pro_date_limite = '' OR pro_date_limite IS NULL OR pro_date_limite >= '" . fxGetDate() . "') AND (pro_date_debut = '0000-00-00' OR pro_date_debut = '' OR pro_date_debut IS NULL OR pro_date_debut <= '" . fxGetDate() . "') AND eve_id IN(" . intval($intEvenement) . ", " . intval($intEvenementMembership) . ") AND (FIND_IN_SET(" . intval($intEpreuve) . ", pro_epreuves) OR pro_epreuves = '') " . " ORDER BY pro_id"; else $sqlProduitsAuto = "SELECT * FROM inscriptions_produits_new WHERE pro_actif = 1 AND pt_id = 7 AND (pro_date_limite = '0000-00-00' OR pro_date_limite = '' OR pro_date_limite IS NULL OR pro_date_limite >= '" . fxGetDate() . "') AND (pro_date_debut = '0000-00-00' OR pro_date_debut = '' OR pro_date_debut IS NULL OR pro_date_debut <= '" . fxGetDate() . "') AND eve_id IN(" . intval($intEvenement) . ", " . intval($intEvenementMembership) . ") AND (FIND_IN_SET(" . intval($intEpreuve) . ", pro_epreuves) OR pro_epreuves = '') " . " ORDER BY pro_id"; $tabProduitsAuto = $objDatabase->fxGetResults($sqlProduitsAuto); if ($tabProduitsAuto != null) { for ($intCtr = 1; $intCtr <= count($tabProduitsAuto); $intCtr++) { // insérer le produit dans le panier $sqlInsert = "INSERT INTO inscriptions_panier_produits_new SET eve_id = " . intval($tabProduitsAuto[$intCtr]['eve_id']) . ", pec_id = " . intval($intEpreuveCommandee) . ", par_id = 0, pro_id = " . intval($tabProduitsAuto[$intCtr]['pro_id']) . ", pt_id = " . intval($tabProduitsAuto[$intCtr]['pt_id']) . ", pro_nom_fr = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_nom_fr']) . "', pro_nom_en = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_nom_en']) . "', pro_description_fr = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_description_fr']) . "', pro_description_en = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_description_en']) . "', pro_taille_fr = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_taille_fr']) . "', pro_taille_en = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_taille_en']) . "', pro_section_fr = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_section_fr']) . "', pro_section_en = '" . $objDatabase->fxEscape($tabProduitsAuto[$intCtr]['pro_section_en']) . "', pro_prix = " . floatval($tabProduitsAuto[$intCtr]['pro_prix']) . ", pro_taxable = " . intval($tabProduitsAuto[$intCtr]['pro_taxable']) . ", pro_effacable = " . intval($tabProduitsAuto[$intCtr]['pro_effacable']) . ", pro_maj = '" . fxGetDateTime() . "', no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $qryInsert = $objDatabase->fxQuery($sqlInsert); if ($qryInsert == null) { fxcreer_log("Il y a eu une erreur lors de l'ajout du produit auto:\n" . $sqlInsert); } } } } break; case 'del': // effacer les produits automatiques $sqlEpreuveCommandee = "SELECT eve_id, no_panier, epr_id FROM inscriptions_panier_epreuves_commandees WHERE pec_id = " . intval($intEpreuveCommandee); $tabEpreuveCommandee = $objDatabase->fxGetRow($sqlEpreuveCommandee); if ($tabEpreuveCommandee != null) { $sqlProduitsAuto = "SELECT * FROM inscriptions_produits_new WHERE pro_actif = 1 AND pro_automatique = 1 AND (pro_date_limite = '0000-00-00' OR pro_date_limite = '' OR pro_date_limite IS NULL OR pro_date_limite >= '" . fxGetDate() . "') AND eve_id = " . intval($tabEpreuveCommandee['eve_id']) . " AND (FIND_IN_SET(" . intval($tabEpreuveCommandee['epr_id']) . ", pro_epreuves) OR pro_epreuves = '') " . " ORDER BY pro_id"; $tabProduitsAuto = $objDatabase->fxGetResults($sqlProduitsAuto); if ($tabProduitsAuto != null) { for ($intCtr = 1; $intCtr <= count($tabProduitsAuto); $intCtr++) { // effacer le produit dans le panier $sqlDelete = "DELETE FROM inscriptions_panier_produits_new WHERE eve_id = " . intval($tabProduitsAuto[$intCtr]['eve_id']) . " AND pec_id = " . intval($intEpreuveCommandee) . " AND pro_id = " . intval($tabProduitsAuto[$intCtr]['pro_id']) . " AND no_panier = '" . $objDatabase->fxEscape($tabEpreuveCommandee['no_panier']) . "'"; $qryDelete = $objDatabase->fxQuery($sqlDelete); if (!$qryDelete) { fxcreer_log("Il y a eu une erreur lors de l'ajout du produit auto:\n" . $sqlDelete); } } } } else { fxcreer_log("ERREUR delete produit auto:\n" . $sqlEpreuveCommandee); } break; } } function fxSetQuestions($strAction, $tabQuestions, $tabData, $tabFiles, $strNoPanier, $intEpreuveCommandee, $intParticipant, $intCtr, $strLangue, $strTableSqlQuestions = '', $strTableSqlEpreuveCommandees = '', $strTableSqlPart = '', $strTableSqlProduits = '', $strKeyEpreuveCommandee = '') { global $objDatabase, $arrConFTP; $arrRetour = array( 'categorie_fr' => '', 'categorie_en' => '' ); (intval($intCtr) > 0) ? $strSufixe = '_' . $intCtr : $strSufixe = ''; // mettre sufixe si c'est une question participant //echosl("tabQuestions"); //print_rsl($tabQuestions); //echosl("tabData"); //print_rsl($tabData); switch ($strAction) { case 'add': for ($intCtr2 = 1; $intCtr2 <= count($tabQuestions); $intCtr2++) { $intProduit = $intIndex = 0; if (array_key_exists('que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe, $tabData) || array_key_exists('que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe, $tabFiles)) { if (intval($tabQuestions[$intCtr2]['que_liste']) == 1) { $tabChoixFr = explode(',', $tabQuestions[$intCtr2]['que_choix_fr']); $tabChoixEn = explode(',', $tabQuestions[$intCtr2]['que_choix_en']); if (intval($tabQuestions[$intCtr2]['que_choix_multiple']) == 1) { // interpréter les réponses si choix multipes $arrValuesFr = $arrValuesEn = array(); $arrSelection = $tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]; foreach ($arrSelection as $intIndex) { $arrValuesFr[] = $tabChoixFr[$intIndex - 1]; $arrValuesEn[] = $tabChoixEn[$intIndex - 1]; // questions payantes $$$ if ($tabQuestions[$intCtr2]['que_choix_produit'] != '') { $tabProduits = explode(',', $tabQuestions[$intCtr2]['que_choix_produit']); $intProduit = $tabProduits[$tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] - 1]; } } $intIndex = implode(',', $arrSelection); $strChoixFr = implode(',', $arrValuesFr); $strChoixEn = implode(',', $arrValuesEn); } else { $intIndex = $tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]; $strChoixFr = $tabChoixFr[$tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] - 1]; $strChoixEn = $tabChoixEn[$tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] - 1]; // mettre à jour la catégorie si nécessaire if ($tabQuestions[$intCtr2]['que_validation'] == 'categorie' && $intCtr == 1) { $arrRetour['categorie_fr'] = $tabChoixFr[$tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] - 1]; $arrRetour['categorie_en'] = $tabChoixEn[$tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] - 1]; } // questions payantes $$$ if ($tabQuestions[$intCtr2]['que_choix_produit'] != '') { $tabProduits = explode(',', $tabQuestions[$intCtr2]['que_choix_produit']); $intProduit = $tabProduits[$tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] - 1]; } } } else { $strChoixFr = $strChoixEn = $tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]; if ($tabFiles['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]['name'] != '') { require_once('inc_files.php'); $strFileName = $tabFiles['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]['name']; $strFileTmp = $tabFiles['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]['tmp_name']; $strPath = $arrConFTP['path_prod'] . '/upload/temp/' . $objDatabase->fxEscape($strNoPanier); if (!file_exists($strPath)) { mkdir($strPath, 0777, true); } $strPath = $strPath . '/'; $strChoixFr = $strChoixEn = fxUploadFilesl($strFileName, $strFileTmp, $strPath); // UPLOAD } if (trim($tabQuestions[$intCtr2]['que_validation']) == 'image') { // SI IMAGE, REDIMENSIONER AU BESOIN } } $sqlInsert = "INSERT INTO inscriptions_panier_questions SET no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pec_id = " . intval($intEpreuveCommandee) . ", par_id = " . intval($intParticipant) . ", que_id = " . intval($tabQuestions[$intCtr2]['que_id']) . ", que_question_fr = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_question_fr']) . "', que_question_en = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_question_en']) . "', que_choix_fr = '" . $objDatabase->fxEscape($strChoixFr) . "', que_choix_en = '" . $objDatabase->fxEscape($strChoixEn) . "', que_index = " . intval($intIndex) . ", pro_id = " . intval($intProduit) . ", que_validation = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_validation']) . "', que_cart_show = " . intval($tabQuestions[$intCtr2]['que_cart_show']) . ", que_cart_label_fr = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_cart_label_fr']) . "', que_cart_label_en = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_cart_label_en']) . "', que_modifiable = " . intval($tabQuestions[$intCtr2]['que_modifiable']); $qryInsert = $objDatabase->fxQuery($sqlInsert); // mettre à jour le nom de l'équipe si nécessaire // if ($tabQuestions[$intCtr2]['que_validation'] == 'equipe' && $intCtr == 1) { // MSIN-4170 if ($tabQuestions[$intCtr2]['que_validation'] == 'equipe' && $intCtr <= 1) { $strNomEquipe = $tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]; $sqlUpdate = "UPDATE inscriptions_panier_epreuves_commandees SET pec_nom_equipe = '" . $objDatabase->fxEscape($strNomEquipe) . "' WHERE no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "' AND pec_id = " . intval($intEpreuveCommandee); $qryUpdate = $objDatabase->fxQuery($sqlUpdate); } // insérer le produit si nécessaire TODOjs: gérer produits choix Multiple if ($intProduit != 0) { // récupérer les infos du produit $tabProduit = fxGetProduits($intProduit); $blnProduit = fxCheckStockProduits($intProduit, 0, 0); if ($blnProduit) { $fltPrixProduit = $tabProduit['pro_prix']; } else { $fltPrixProduit = 0; } if ($tabProduit != null) { // insérer le produit dans le panier $sqlInsert = "INSERT INTO inscriptions_panier_produits_new SET eve_id = " . intval($tabProduit['eve_id']) . ", pec_id = " . intval($intEpreuveCommandee) . ", par_id = " . intval($intParticipant) . ", pro_id = " . intval($intProduit) . ", 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($fltPrixProduit) . ", pro_taxable = " . intval($tabProduit['pro_taxable']) . ", pro_effacable = " . intval($tabProduit['pro_effacable']) . ", pro_maj = '" . fxGetDateTime() . "', no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $qryInsert = $objDatabase->fxQuery($sqlInsert); $mem_pixcel = array("param1" => "track", "param2" => "AddToCart", "currency" => "CAD", "content_name" => $tabProduit['pro_nom_' . $strLangue], "content_ids" => $intProduit, "value" => $tabProduit['pro_prix'], "content_type" => "product"); fxsessionpixelfacebook($mem_pixcel); if (!$qryInsert) fxcreer_log("Il y a eu une erreur lors de l'ajout du produit:\n" . $sqlInsert); } } } } break; case 'mod': $arrProduitsDeleteMemoire = $arrProduitsInsertMemoire = $arrQuestionsMemoire = array(); for ($intCtr2 = 1; $intCtr2 <= count($tabQuestions); $intCtr2++) { $intProduit = $intIndex = 0; if (array_key_exists('que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe, $tabData) || array_key_exists('que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe, $tabFiles)) { // if (array_key_exists('q ue_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe, $tabData)) { $blnDifferent = false; if ($tabQuestions[$intCtr2]['que_liste'] == 1) { $tabChoixFr = explode(',', $tabQuestions[$intCtr2]['que_choix_fr']); $tabChoixEn = explode(',', $tabQuestions[$intCtr2]['que_choix_en']); if (intval($tabQuestions[$intCtr2]['que_choix_multiple']) == 1) { // interpréter les réponses si choix multipes $arrValuesFr = $arrValuesEn = array(); $arrSelection = $tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]; if ($arrSelection != $tabData['old_que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]) { // si le choix a changé $blnDifferent = true; } foreach ($arrSelection as $intIndex) { $arrValuesFr[] = $tabChoixFr[$intIndex - 1]; $arrValuesEn[] = $tabChoixEn[$intIndex - 1]; // questions payantes $$$ if ($tabQuestions[$intCtr2]['que_choix_produit'] != '') { $tabProduits = explode(',', $tabQuestions[$intCtr2]['que_choix_produit']); $intProduit = $tabProduits[$tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] - 1]; } } $intIndex = implode(',', $arrSelection); $strChoixFr = implode(',', $arrValuesFr); $strChoixEn = implode(',', $arrValuesEn); } else { $intIndex = $tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]; if ($intIndex != $tabData['old_que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]) { // si le choix a changé $blnDifferent = true; } $strChoixFr = $tabChoixFr[$tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] - 1]; $strChoixEn = $tabChoixEn[$tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] - 1]; // mettre à jour la catégorie si nécessaire if ($tabQuestions[$intCtr2]['que_validation'] == 'categorie') { $arrRetour['categorie_fr'] = $tabChoixFr[$tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] - 1]; $arrRetour['categorie_en'] = $tabChoixEn[$tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] - 1]; } // questions payantes $$$ if ($tabQuestions[$intCtr2]['que_choix_produit'] != '') { $tabProduits = explode(',', $tabQuestions[$intCtr2]['que_choix_produit']); $intProduit = $tabProduits[$tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] - 1]; } } } else { $strChoixFr = $strChoixEn = $tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]; // upload fichier ici if ($tabFiles['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]['name'] != '') { require_once('inc_files.php'); $strFileName = $tabFiles['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]['name']; $strFileTmp = $tabFiles['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]['tmp_name']; if (isset($_SESSION['no_panier']) && $tabData['promoteur'] == 0) { $strPath = $arrConFTP['path_prod'] . '/upload/temp/' . $objDatabase->fxEscape($strNoPanier); } else { $strPath = $arrConFTP['path_prod'] . '/upload/' . $tabQuestions[$intCtr2]['eve_id']; } if (!file_exists($strPath)) { mkdir($strPath, 0777, true); } $strPath = $strPath . '/'; $strChoixFr = $strChoixEn = fxUploadFilesl($strFileName, $strFileTmp, $strPath); // UPLOAD $blnDifferent = true; } else { if ($tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe] != $tabData['old_que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]) { // si la réponse a changée $blnDifferent = true; } } } // 1) Vérifier si la question existe dans la bdd $sqlSelect = "SELECT * FROM " . $strTableSqlQuestions . " WHERE pec_id = " . intval($intEpreuveCommandee) . " AND que_id = " . intval($tabQuestions[$intCtr2]['que_id']) . " AND par_id = " . intval($intParticipant); $tabSelect = $objDatabase->fxGetRow($sqlSelect); if ($tabSelect != null) { // si la question existe if ($blnDifferent) { // si la réponse changée if ($tabQuestions[$intCtr2]['que_choix_produit'] != '') { // effacer le produit original if (isset($_SESSION['no_panier']) || $tabData['promoteur'] == 1) { $sqlDelete = "DELETE FROM " . $strTableSqlProduits . " WHERE pro_id IN(" . $tabQuestions[$intCtr2]['que_choix_produit'] . ") AND pec_id = " . intval($intEpreuveCommandee) . " AND par_id = " . intval($intParticipant); $qryDelete = $objDatabase->fxQuery($sqlDelete); } else { // garder en mémoire les produits à effacer //TODOjs: à revoir - $arrProduitsDeleteMemoire[] = array('produits' => $tabQuestions[$intCtr2]['que_choix_produit'], 'pec_id' => $intEpreuveCommandee,, par_id => $intParticipant); } } if ($tabQuestions[$intCtr2]['que_validation'] == 'equipe' && $intCtr == 1) { // mettre à jour le nom de l'équipe si nécessaire $strNomEquipe = $tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]; // mettre à jour le nom d'équipe $sqlUpdate = "UPDATE " . $strTableSqlEpreuveCommandees . " SET pec_nom_equipe = '" . $objDatabase->fxEscape($strNomEquipe) . "' WHERE " . $strKeyEpreuveCommandee . " = " . intval($intEpreuveCommandee); $qryUpdate = $objDatabase->fxQuery($sqlUpdate); $sqlUpdate = "UPDATE " . $strTableSqlPart . " SET par_nom_equipe = '" . $objDatabase->fxEscape($strNomEquipe) . "' WHERE pec_id = " . intval($intEpreuveCommandee); $qryUpdateNomEq = $objDatabase->fxQuery($sqlUpdate); } if ($intProduit != 0) { // si la question génere un produit $tabProduit = fxGetProduits($intProduit); // récupérer les infos du produit if (isset($_SESSION['no_panier']) || $tabData['promoteur'] == 1) { // mettre à jour la question $sqlUpdate = "UPDATE " . $strTableSqlQuestions . " SET que_choix_fr = '" . $objDatabase->fxEscape($strChoixFr) . "', que_choix_en = '" . $objDatabase->fxEscape($strChoixEn) . "' WHERE pec_id = " . intval($intEpreuveCommandee) . " AND que_id = " . intval($tabQuestions[$intCtr2]['que_id']) . " AND par_id = " . intval($intParticipant); $qryUpdate = $objDatabase->fxQuery($sqlUpdate); if ($tabProduit != null) { // insérer le produit $sqlInsert = "INSERT INTO " . $strTableSqlProduits . " SET eve_id = " . intval($tabProduit['eve_id']) . ", pec_id = " . intval($intEpreuveCommandee) . ", pro_id = " . intval($intProduit) . ", 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_maj = '" . fxGetDateTime() . "', par_id = " . intval($intParticipant) . ", pro_effacable = " . intval($tabProduit['pro_effacable']) . ", pro_taxable = " . intval($tabProduit['pro_taxable']) . ", pro_prix = " . floatval($tabProduit['pro_prix']) . ", no_panier = '" . $strNoPanier . "'"; $qryInsert = $objDatabase->fxQuery($sqlInsert); if (!$qryInsert) fxcreer_log("Modif panier/promoteur: erreur lors de l'ajout du produit:\n" . $sqlInsert); } } else { // garder en mémoire les questions et produits à insérer $arrQuestionsMemoire[] = array('que_id' => $tabQuestions[$intCtr2]['que_id'], 'index' => $intIndex, 'pro_id' => $intProduit, 'choix_fr' => $strChoixFr, 'choix_en' => $strChoixEn, 'question' => $tabQuestions[$intCtr2], 'pec_id' => $intEpreuveCommandee, 'par_id' => $intParticipant); if ($tabProduit != null) { $arrProduitsInsertMemoire[] = array('produit' => $tabProduit, 'pec_id' => $intEpreuveCommandee, 'par_id' => $intParticipant); } } } else { // si la question NE génere PAS un produit // mettre à jour la question $sqlUpdate = "UPDATE " . $strTableSqlQuestions . " SET que_choix_fr = '" . $objDatabase->fxEscape($strChoixFr) . "', que_choix_en = '" . $objDatabase->fxEscape($strChoixEn) . "' WHERE pec_id = " . intval($intEpreuveCommandee) . " AND que_id = " . intval($tabQuestions[$intCtr2]['que_id']) . " AND par_id = " . intval($intParticipant); $qryUpdate = $objDatabase->fxQuery($sqlUpdate); } } } else { // si la question N'existe PAS if ($tabQuestions[$intCtr2]['que_validation'] == 'equipe' && $intCtr == 1) { // mettre à jour le nom de l'équipe si nécessaire $strNomEquipe = $tabData['que_' . $tabQuestions[$intCtr2]['que_id'] . $strSufixe]; // mettre à jour le nom d'équipe $sqlUpdate = "UPDATE " . $strTableSqlEpreuveCommandees . " SET pec_nom_equipe = '" . $objDatabase->fxEscape($strNomEquipe) . "' WHERE " . $strKeyEpreuveCommandee . " = " . intval($intEpreuveCommandee); $qryUpdate = $objDatabase->fxQuery($sqlUpdate); $sqlUpdate = "UPDATE " . $strTableSqlPart . " SET par_nom_equipe = '" . $objDatabase->fxEscape($strNomEquipe) . "' WHERE pec_id = " . intval($intEpreuveCommandee); $qryUpdateNomEq = $objDatabase->fxQuery($sqlUpdate); } if ($intProduit != 0) { // si la question génere un produit $tabProduit = fxGetProduits($intProduit); // récupérer les infos du produit if (isset($_SESSION['no_panier']) || $tabData['promoteur'] == 1) { if (isset($_SESSION['no_panier'])) { $strChampsExtra = ", no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', que_index = " . intval($intIndex) . ", pro_id = " . intval($intProduit) . ", que_validation = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_validation']) . "', que_cart_show = " . intval($tabQuestions[$intCtr2]['que_cart_show']) . ", que_cart_label_fr = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_cart_label_fr']) . "', que_cart_label_en = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_cart_label_en']) . "'"; } else { $strChampsExtra = ", pqu_maj = '" . fxGetDateTime() . "'"; } // insérer la question $sqlInsert = "INSERT INTO " . $strTableSqlQuestions . " SET pec_id = " . intval($intEpreuveCommandee) . ", par_id = " . intval($intParticipant) . ", que_id = " . intval($tabQuestions[$intCtr2]['que_id']) . ", que_question_fr = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_question_fr']) . "', que_question_en = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_question_en']) . "', que_choix_fr = '" . $objDatabase->fxEscape($strChoixFr) . "', que_choix_en = '" . $objDatabase->fxEscape($strChoixEn) . "', que_modifiable = " . intval($tabQuestions[$intCtr2]['que_modifiable']) . $strChampsExtra; $qryInsert = $objDatabase->fxQuery($sqlInsert); if ($tabProduit != null) { if (isset($_SESSION['no_panier'])) { $strChampsExtra = ", no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pro_prix = " . floatval($tabProduit['pro_prix']) . ", pro_taxable = " . intval($tabProduit['pro_taxable']) . ", pro_effacable = " . intval($tabProduit['pro_effacable']); } else { $strChampsExtra = ''; } // insérer le produit $sqlInsert = "INSERT INTO " . $strTableSqlProduits . " SET eve_id = " . intval($tabProduit['eve_id']) . ", pec_id = " . intval($intEpreuveCommandee) . ", par_id = " . intval($intParticipant) . ", pro_id = " . intval($intProduit) . ", 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_maj = '" . fxGetDateTime() . "'" . $strChampsExtra; $qryInsert = $objDatabase->fxQuery($sqlInsert); if (!$qryInsert) fxcreer_log("Modif panier/promoteur: erreur lors de l'ajout du produit:\n" . $sqlInsert); } } else { // garder en mémoire les questions et produits à insérer $arrQuestionsMemoire[] = array('que_id' => $tabQuestions[$intCtr2]['que_id'], 'index' => $intIndex, 'pro_id' => $intProduit, 'choix_fr' => $strChoixFr, 'choix_en' => $strChoixEn, 'question' => $tabQuestions[$intCtr2], 'pec_id' => $intEpreuveCommandee, 'par_id' => $intParticipant); if ($tabProduit != null) { $arrProduitsInsertMemoire[] = array('produit' => $tabProduit, 'pec_id' => $intEpreuveCommandee, 'par_id' => $intParticipant); } } } else { // si la question NE génere PAS un produit if (isset($_SESSION['no_panier'])) { $strChampsExtra = ", no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', que_index = " . intval($intIndex) . ", pro_id = " . intval($intProduit) . ", que_validation = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_validation']) . "', que_cart_show = " . intval($tabQuestions[$intCtr2]['que_cart_show']) . ", que_cart_label_fr = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_cart_label_fr']) . "', que_cart_label_en = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_cart_label_en']) . "'"; } else { $strChampsExtra = ", pqu_maj = '" . fxGetDateTime() . "'"; } // insérer la question $sqlInsert = "INSERT INTO " . $strTableSqlQuestions . " SET pec_id = " . intval($intEpreuveCommandee) . ", par_id = " . intval($intParticipant) . ", que_id = " . intval($tabQuestions[$intCtr2]['que_id']) . ", que_question_fr = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_question_fr']) . "', que_question_en = '" . $objDatabase->fxEscape($tabQuestions[$intCtr2]['que_question_en']) . "', que_choix_fr = '" . $objDatabase->fxEscape($strChoixFr) . "', que_choix_en = '" . $objDatabase->fxEscape($strChoixEn) . "', que_modifiable = " . intval($tabQuestions[$intCtr2]['que_modifiable']) . $strChampsExtra; $qryInsert = $objDatabase->fxQuery($sqlInsert); } } } } if (count($arrQuestionsMemoire) > 0) { // MSIN-1841 - produits facturables $strNoPanier = fxNumPanier($arrQuestionsMemoire[0]['question']['eve_id'], $strLangue); //créer un panier foreach ($arrQuestionsMemoire as $question) { // insérer les questions $sqlInsert = "INSERT INTO inscriptions_panier_questions SET no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "', pec_id = " . intval($question['pec_id']) . ", par_id = " . intval($question['par_id']) . ", que_id = " . intval($question['question']['que_id']) . ", que_question_fr = '" . $objDatabase->fxEscape($question['question']['que_question_fr']) . "', que_question_en = '" . $objDatabase->fxEscape($question['question']['que_question_en']) . "', que_choix_fr = '" . $objDatabase->fxEscape($question['choix_fr']) . "', que_choix_en = '" . $objDatabase->fxEscape($question['choix_en']) . "', que_index = " . intval($question['index']) . ", pro_id = " . intval($question['pro_id']) . ", que_validation = '" . $objDatabase->fxEscape($question['question']['que_validation']) . "', que_cart_show = " . intval($question['question']['que_cart_show']) . ", que_cart_label_fr = '" . $objDatabase->fxEscape($question['question']['que_cart_label_fr']) . "', que_cart_label_en = '" . $objDatabase->fxEscape($question['question']['que_cart_label_en']) . "', que_modifiable = " . intval($question['question']['que_modifiable']); $qryInsert = $objDatabase->fxQuery($sqlInsert); } foreach ($arrProduitsInsertMemoire as $produit) { // insérer les produits $sqlInsert = "INSERT INTO inscriptions_panier_produits_new SET eve_id = " . intval($produit['produit']['eve_id']) . ", pec_id = " . intval($produit['pec_id']) . ", par_id = " . intval($produit['par_id']) . ", pro_id = " . intval($produit['produit']['pro_id']) . ", pt_id = " . intval($produit['produit']['pt_id']) . ", pro_nom_fr = '" . $objDatabase->fxEscape($produit['produit']['pro_nom_fr']) . "', pro_nom_en = '" . $objDatabase->fxEscape($produit['produit']['pro_nom_en']) . "', pro_description_fr = '" . $objDatabase->fxEscape($produit['produit']['pro_description_fr']) . "', pro_description_en = '" . $objDatabase->fxEscape($produit['produit']['pro_description_en']) . "', pro_taille_fr = '" . $objDatabase->fxEscape($produit['produit']['pro_taille_fr']) . "', pro_taille_en = '" . $objDatabase->fxEscape($produit['produit']['pro_taille_en']) . "', pro_section_fr = '" . $objDatabase->fxEscape($produit['produit']['pro_section_fr']) . "', pro_section_en = '" . $objDatabase->fxEscape($produit['produit']['pro_section_en']) . "', pro_prix = " . floatval($produit['produit']['pro_prix']) . ", pro_taxable = " . intval($produit['produit']['pro_taxable']) . ", pro_effacable = " . intval($produit['produit']['pro_effacable']) . ", pro_maj = '" . fxGetDateTime() . "', no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; $qryInsert = $objDatabase->fxQuery($sqlInsert); // $mem_pixcel = array("param1"=>"track","param2"=>"AddToCart","content_name"=>$produit['produit']['pro_nom'.$strLangue],"content_ids"=>$produit['par_id'],"value"=>$produit['produit']['pro_prix'],"content_type"=>"produit"); // fxsessionpixelfacebook($mem_pixcel); } } break; } return $arrRetour; } // transfert des fichier uploader dans le rep pemenant (sl) function fxtransfertfiles($tabFiles, $no_panier, $eve_id) { if (!file_exists('upload/' . $eve_id)) { mkdir('upload/' . $eve_id, 0777, true); } foreach ($tabFiles as $value) { // error_log($_SERVER['DOCUMENT_ROOT'].'/upload/temp/'.$no_panier.'/'.$value); // error_log($_SERVER['DOCUMENT_ROOT'].'/upload/'.$eve_id.'/'.$value); if (copy($_SERVER['DOCUMENT_ROOT'] . '/upload/temp/' . $no_panier . '/' . $value, $_SERVER['DOCUMENT_ROOT'] . '/upload/' . $eve_id . '/' . $value)) { } else { $error = error_get_last(); error_log("Détails de l'erreur : " . $error['message']); error_log("La copie du fichier a échoué. " . $value . " eve_id=" . $eve_id); } } } function fxdeletefiles($dirname) { $dir_handle = false; if (is_dir($dirname)) $dir_handle = opendir($dirname); if (!$dir_handle) return false; while ($file = readdir($dir_handle)) { if ($file != "." && $file != "..") { if (!is_dir($dirname . "/" . $file)) unlink($dirname . "/" . $file); else delete_directory($dirname . '/' . $file); } } closedir($dir_handle); rmdir($dirname); return true; } function fxGetGender($strValeur, $strLangue) { $strGender = ''; switch ($strValeur) { case 'h': ($strLangue == 'fr') ? $strGender = 'homme' : $strGender = 'male'; break; case 'f': ($strLangue == 'fr') ? $strGender = 'femme' : $strGender = 'female'; break; case 'n': ($strLangue == 'fr') ? $strGender = 'non-binaire' : $strGender = 'genderfluid'; break; case 'a': ($strLangue == 'fr') ? $strGender = 'autre' : $strGender = 'other'; break; } return $strGender; } require_once 'inc_dons.php';