let contactName = $('#contact_name'); let contactFirstName = $('#contact_firstname'); let company = $('#institution'); let emailAddress = $('#customer_email_address'); let object = $('#name'); let phoneContact = $('#phone_contact'); let description = $('#description'); let contactSubmit = $('#customer-form-submit'); let contactWrapper = $('#area-preloader'); /** * Send email to jobs */ contactSubmit.on('click', function (e) { e.preventDefault(); sendEmailContact(); }); /** * Send opportunity to Odoo */ function sendEmailContact() { contactSubmit.hide(); contactWrapper.show(); //Get fields value var firstname = contactFirstName.val(); var lastname = contactName.val(); var companyContact = company.val(); var email = emailAddress.val(); var name = object.val(); var phone = phoneContact.val(); var informations = description.val(); $.ajax({ url: 'controller/contact-mailing.php', type: 'POST', data: {email: email, phone: phone, lastName: lastname, firstName: firstname, company: companyContact, object: name, description: informations}, /** * @return integer */ success: function (result) { if (result == -1) { let translation = "Veuillez renseigner les champs obligatoires"; if (locale === "en") { translation = "Please fill in the required fields"; } if (locale === 'ar') { translation = "يرجى ملء الحقول المطلوبة"; } M.toast({html: translation}, 4000); } else if (result == -2) { let translation = "Format de l'adresse email non valide"; if (locale === "en") { translation = "Invalid email address format"; } if (locale === 'ar') { translation = "تنسيق عنوان البريد الإلكتروني غير صالح"; } M.toast({html: translation}, 4000); } else if (result == -4) { let translation = "Le numéro de téléphone n'est pas valide"; if (locale === "en") { translation = "Invalid phone number format"; } if (locale === 'ar') { translation = "تنسيق رقم الهاتف غير صالح"; } M.toast({html: translation}, 4000); } else if (result == -7) { let translation = "Une erreur est survenue lors de l'envoi du mail"; if (locale === "en") { translation = "An error occurred while sending the email"; } if (locale === 'ar') { translation = "حدث خطأ أثناء إرسال البريد الإلكتروني"; } M.toast({html: translation}, 4000); } else if (result == 1) { let translation = "Votre demande d'informations a bien été prise en compte. Nous vous recontacterons très rapidement."; if (locale === "en") { translation = "Your information request has been taken into account. We will contact you very soon."; } if (locale === 'ar') { translation = "تم اتخاذ طلب المعلومات الخاص بك بعين الاعتبار. سنتصل بك قريبا جدا."; } erasesFormFields(); M.toast({html: translation}, 4000); } }, error: function () { }, complete: function () { contactSubmit.show(); contactWrapper.hide(); } }); } function erasesFormFields() { emailAddress.val(''); contactFirstName.val(''); contactName.val(''); company.val(''); object.val(''); phoneContact.val(''); description.val(''); }