//var currentAction; //var FormToSerialize; var stopTime = 3000; //connexion company function connectCompany(){ currentAction = "connectCompany"; FormToSerialize = $("#Connect-Form"); //Set up the JQuery validator Plugin validator = FormToSerialize.validate({ submitHandler: function() { manageConnexionForm(); }, rules: { login: { required: true }, pass: { required: true } }, messages: { login: { required: "Champ obligatoire" }, pass: { required: "Champ obligatoire" } } }); } //Post the Add action or the Modify action with form's datas function manageConnexionForm(){ $(".error_message").hide(); $(".ok_message").hide(); $(".error_messages_block").hide(); $(".ok_messages_block").hide(); $.ajax({ type: "POST", url: "home.action.php", data: FormToSerialize.serialize()+'&action='+currentAction, success: function(data){ switch(data){ case 'errorName': $("#errorName").fadeIn("fast").delay(stopTime).fadeOut("fast"); $("#page_error").fadeIn("fast").delay(stopTime).fadeOut("fast"); break; case 'errorLogin': $("#errorLogin").fadeIn("fast").delay(stopTime).fadeOut("fast"); $("#page_error").fadeIn("fast").delay(stopTime).fadeOut("fast"); break; case 'errorStatus': $("#errorStatus").fadeIn("fast").delay(stopTime).fadeOut("fast"); $("#page_error").fadeIn("fast").delay(stopTime).fadeOut("fast"); break; case 'errorPassword': $("#errorPassword").fadeIn("fast").delay(stopTime).fadeOut("fast"); $("#page_error").fadeIn("fast").delay(stopTime).fadeOut("fast"); break; case 'loginAlreadyUsed': $("#loginAlreadyUsed").fadeIn("fast").delay(stopTime).fadeOut("fast"); $("#page_error").fadeIn("fast").delay(stopTime).fadeOut("fast"); break; case 'addAccountOk': $("#addAccountOk").fadeIn("fast").delay(stopTime).fadeOut("fast"); $("#page_ok").fadeIn("fast").delay(stopTime).fadeOut("fast"); validator.resetForm(); break; case 'emptyLogin': $("#emptyLogin").fadeIn("fast").delay(stopTime).fadeOut("fast"); $("#page_error").fadeIn("fast").delay(stopTime).fadeOut("fast"); break; case 'endProAccount': setModalEndProAccount(); break; case 'endRetailerAccountForProAccount': $("#endRetailerAccountForProAccount").fadeIn("fast").delay(stopTime).fadeOut("fast"); $("#page_error").fadeIn("fast").delay(stopTime).fadeOut("fast"); break; case 'endRetailerAccount': setModalEndRetailerAccount(); break; case 'offerError': $("#offerError").fadeIn("fast").delay(stopTime).fadeOut("fast"); $("#page_error").fadeIn("fast").delay(stopTime).fadeOut("fast"); break; case 'wrongPassword': $("#wrongPassword").fadeIn("fast").delay(stopTime).fadeOut("fast"); $("#page_error").fadeIn("fast").delay(stopTime).fadeOut("fast"); break; case 'userConnectionOk': document.location.href="index.php?p=dashboard"; break; case 'userMobileConnectionOk': document.location.href="../mobile/"; break; case 'retailerConnectionOk': document.location.href="index.php?p=dashboard"; break; default: $("#failError").fadeIn("fast").delay(stopTime).fadeOut("fast"); $("#page_error").fadeIn("fast").delay(stopTime).fadeOut("fast"); } } }); } /** * Display an alert when a pro account ends and switch to free * @name setModalEndProAccount */ function setModalEndProAccount(){ $("#modalEndProAccount").dialog({ width:400, modal: true, draggable: false, closeOnEscape: false, resizable: false, buttons: { Renouveler: function() { document.location.href="index.php?p=offers"; }, Continuer: function() { document.location.href="index.php?p=dashboard"; } }, close: function() { document.location.href="index.php?p=dashboard"; } }); } /** * Display an alert when a retailer account ends * @name setModalEndRetailerAccount */ function setModalEndRetailerAccount(){ $("#modalEndRetailerAccount").dialog({ width:400, modal: true, draggable: false, closeOnEscape: false, resizable: false, buttons: { Renouveler: function() { document.location.href="index.php?p=offers"; }, Continuer: function() { document.location.href="index.php?p=dashboard"; } }, close: function() { document.location.href="index.php?p=dashboard"; } }); } function forgetPassword(){ $("#new_password_block").slideDown(); }