////////////////////////////////////////////////////////////////////////////// // Gestion des comptes ////////////////////////////////////////////////////////////////////////////// //Fonction appelée par le flash pour actualiser le site suite à une authentif function Compte_authentif() { if (document.getElementById("caddieopened")) ajax_load("POST","dynamic/caddie_show.php","",null,"sub_corps"); } //fonction qui charge le formulaire de validation pour un compte non validé function Compte_formvalidation() { var sParam=""; var sElement="sub_corps"; panelH_close(); //ferme le panneau d'en haut (si ouvert) msgbox("Chargement en cours",600); //document.getElementById(sElement).innerHTML="Chargement en cours..."; ajax_load("POST","dynamic/cpte_formvalidation.php",sParam,null,sElement); } //appelé lors de la validation du compte (click sur ok du formulaire) //code est le code de 4 chiffres tapé par l'internaute (recu par mail) function Compte_validation(code) { var sParam="code="+code; var sElement=null; ajax_load("POST","dynamic/cpte_validation.php",sParam,"Compte_valide",sElement); } //fonction callback de la fonction Compte_validation function Compte_valide(JReponse) { var Reponse = eval('(' + JReponse + ')'); retour=trim(Reponse["reponse"]); if (retour=="ok") { var sElement="sub_corps"; var header = getFlashMovieObject("header"); header.comptevalide(); if (document.getElementById("caddieopened")) caddie_show(); else { //affichage du profil var sParam=""; var sElement="sub_corps"; panelH_close(); //ferme le panneau d'en haut (si ouvert) msgbox("Chargement en cours",600); ajax_load("POST","dynamic/cpte_form_inscription.php",sParam,null,sElement); } } else { document.getElementById("cptevalidation_msg").innerHTML="<< le code ne correspond pas"; } } //fonction qui authentifie un compte function Compte_authentification() { var sParam=""; var sElement="sub_corps"; //Initialisation var pseudo=trim(document.cpteauthentification.pseudo.value); var pass=trim(document.cpteauthentification.pass.value); document.getElementById("cpteauthentif_pseudo").style.color="#000000"; document.getElementById("cpteauthentif_pass").style.color="#000000"; //Verification saisie var erreurs=0; //test pseudo if (pseudo=="") { document.getElementById("cpteauthentif_pseudo").style.color="#FF0000"; erreurs++; } if (pass=="") { document.getElementById("cpteauthentif_pass").style.color="#FF0000"; erreurs++; } if (erreurs==0) { document.cpteauthentification.cpteenvoi.disabled=true; sParam="l="+pseudo+"&p="+pass; sElement=null; sFonction="Compte_authentification_retour"; msgbox("Veuillez patienter"); ajax_load("POST","dynamic/cpte_authentification.php",sParam,sFonction,sElement); } else { //le perso parle //header_talk(""); } } function Compte_authentification_retour(JReponse) { var Reponse = eval('(' + JReponse + ')'); code=trim(Reponse["reponse"]); document.cpteinscription.cpteenvoi.disabled=false; switch(code) { case "1"://Erreur msgbox_end(); document.getElementById("cpteauthentif_pseudo").style.color="#FF0000"; document.cpteauthentification.cpteenvoi.disabled=false; break; case "2"://le compte n'est pas encore validé case "3"://Ok sParam=""; sElement="sub_corps"; sFonction=null; if (document.getElementById("caddieopened"))caddie_show(); else { //affichage du profil var sParam=""; var sElement="sub_corps"; panelH_close(); //ferme le panneau d'en haut (si ouvert) msgbox("Chargement en cours",600); ajax_load("POST","dynamic/cpte_form_inscription.php",sParam,null,sElement); } break; default: msgbox_end(); alert("autre:"+code); break; } } //fonction qui charge le formulaire de validation pour un compte non validé function Compte_forminscription() { var sParam=""; var sElement="sub_corps"; panelH_close(); //ferme le panneau d'en haut (si ouvert) //document.getElementById(sElement).innerHTML="Chargement en cours..."; msgbox("Chargement en cours",600); ajax_load("POST","dynamic/cpte_form_inscription.php",sParam,null,sElement); } //fonction qui envoi les données du formulaire d'inscription function Compte_forminscription_envoyer() { var sParam=""; var sElement="sub_corps"; //Initialisation var pseudo=trim(document.cpteinscription.pseudo.value); var pass=trim(document.cpteinscription.pass.value); var cp=trim(document.cpteinscription.cp.value); var adrmail=trim(document.cpteinscription.mail.value); var adrmailconfirm=trim(document.cpteinscription.mail_conf.value); var code=trim(document.cpteinscription.code.value); document.getElementById("cpteinscription_pseudo").style.color="#000000"; document.getElementById("cpteinscription_pass").style.color="#000000"; document.getElementById("cpteinscription_cp").style.color="#000000"; document.getElementById("cpteinscription_mail").style.color="#000000"; document.getElementById("cpteinscription_mail_conf").style.color="#000000"; //Verification saisie var erreurs=0; //test pseudo if (pseudo=="") { document.getElementById("cpteinscription_pseudo").style.color="#FF0000"; erreurs++; } if (pass=="") { document.getElementById("cpteinscription_pass").style.color="#FF0000"; erreurs++; } if (code=="" || code.length!=7) { document.getElementById("cpteinscription_code").innerHTML="<< le code ne correspond pas"; erreurs++; }else { document.getElementById("cpteinscription_code").innerHTML=""; } if (parseInt(cp)<1 || isNaN(parseInt(cp)) || cp.length<5) { document.getElementById("cpteinscription_cp").style.color="#FF0000"; erreurs++; } //test adresse mail if (emailCheck(adrmail)==false) { //Adresse mail invalide document.getElementById("cpteinscription_mail").style.color="#FF0000"; erreurs++; } if (adrmail!=adrmailconfirm) { document.getElementById("cpteinscription_mail_conf").style.color="#FF0000"; erreurs++; } if (erreurs==0) { document.cpteinscription.cpteenvoi.disabled=true; sParam="l="+pseudo+"&p="+pass+"&cp="+cp+"&m="+adrmail+"&c="+code; sElement=null; sFonction="Compte_forminscription_envoyer_retour"; ajax_load("POST","dynamic/cpte_inscription.php",sParam,sFonction,sElement); } else { //le perso parle header_talk(""); } } function Compte_forminscription_envoyer_retour(JReponse) { alert(JReponse); var Reponse = eval('(' + JReponse + ')'); code=trim(Reponse["reponse"]); document.cpteinscription.cpteenvoi.disabled=false; msgbox_end(); alert(code); switch(code) { case "0"://le code flood ne correspond pas document.getElementById("cpteinscription_code").innerHTML="<< le code ne correspond pas"; break; case "1"://le compte existe déjà document.getElementById("cpteinscription_pseudo_msg").innerHTML="<< Ce compte existe déjà"; document.getElementById("cpteinscription_pseudo").style.color="#FF0000"; break; case "2"://le compte n'est pas inséré dans la base alert("Un problème est survenu : erreur code 760"); break; case "3"://Ok msgbox("Veuillez patienter",10); sParam=""; sElement="sub_corps"; sFonction=null; //Si on est dans le caddie if (document.getElementById("caddieopened"))ajax_load("POST","dynamic/cpte_formvalidation.php",sParam,sFonction,"caddiemoncompte"); else ajax_load("POST","dynamic/cpte_formvalidation.php",sParam,sFonction,sElement); break; default: alert("autre:"+code); break; } } //fonction qui envoi les données du formulaire d'inscription function Compte_commande_envoyer() { var sParam=""; var sElement="sub_corps"; var frm=document.cptecommande; //Initialisation var l_nom=trim(frm.l_nom.value); var l_prenom=trim(frm.l_prenom.value); var l_societe=trim(frm.l_societe.value); var l_adresse=trim(frm.l_adresse.value); var l_cp=trim(frm.l_cp.value); var l_ville=trim(frm.l_ville.value); var l_tel=trim(frm.l_tel.value); var f_nom=trim(frm.f_nom.value); var f_prenom=trim(frm.f_prenom.value); var f_societe=trim(frm.f_societe.value); var f_adresse=trim(frm.f_adresse.value); var f_cp=trim(frm.f_cp.value); var f_ville=trim(frm.f_ville.value); var f_tel=trim(frm.f_tel.value); document.getElementById("tdcptecom_l_nom").style.color="#000000"; document.getElementById("tdcptecom_l_prenom").style.color="#000000"; document.getElementById("tdcptecom_l_adresse").style.color="#000000"; document.getElementById("tdcptecom_l_cp").style.color="#000000"; document.getElementById("tdcptecom_l_ville").style.color="#000000"; document.getElementById("tdcptecom_l_tel").style.color="#000000"; document.getElementById("tdcptecom_f_nom").style.color="#000000"; document.getElementById("tdcptecom_f_prenom").style.color="#000000"; document.getElementById("tdcptecom_f_adresse").style.color="#000000"; document.getElementById("tdcptecom_f_cp").style.color="#000000"; document.getElementById("tdcptecom_f_ville").style.color="#000000"; document.getElementById("tdcptecom_f_tel").style.color="#000000"; //Verification saisie var erreurs=0; //test livraison if (l_nom=="") { document.getElementById("tdcptecom_l_nom").style.color="#FF0000"; erreurs++; } if (l_prenom=="") { document.getElementById("tdcptecom_l_prenom").style.color="#FF0000"; erreurs++; } if (l_adresse=="") { document.getElementById("tdcptecom_l_adresse").style.color="#FF0000"; erreurs++; } if (l_cp=="") { document.getElementById("tdcptecom_l_cp").style.color="#FF0000"; erreurs++; } if (l_ville=="") { document.getElementById("tdcptecom_l_ville").style.color="#FF0000"; erreurs++; } if (l_tel=="") { document.getElementById("tdcptecom_l_tel").style.color="#FF0000"; erreurs++; } //test facturation (A FAIRE) if (erreurs==0) { frm.commande_envoi.disabled=true; var sParams=formserialize(frm); sElement=null; sFonction="Compte_commande_envoyer_retour"; //msgbox("Veuillez patienter"); ajax_load("POST","dynamic/caddie_preco.php",sParams,sFonction,sElement); } } function formserialize(frm) { var sResult=""; for(var i=0;i