196 lines
10 KiB
PHP
196 lines
10 KiB
PHP
<h2 class="contacts-page-subtitle subtitle_paint"><?= the_title(); ?></h2>
|
|
<div class="contacts-category-page wrapper">
|
|
<div class="back-button-wrapper">
|
|
<a href="/nous-contacter/" class="back-button" title="Retour au choix de contact"><?php _e('Return to choice of contact', 'LDC Custom string'); ?></a>
|
|
</div>
|
|
<div class="contacts-form__wrapper">
|
|
<form class="form">
|
|
<div class="form__container">
|
|
<div class="form__row">
|
|
<div class="form__field">
|
|
<div class="form__field-title"><?php _e('Surname', 'LDC Custom string'); ?> *</div>
|
|
<input type="text" name="lastname" size="40" class="form__input" placeholder="<?php _e('Your surname', 'LDC Custom string'); ?>"
|
|
required>
|
|
</div>
|
|
<div class="form__field">
|
|
<div class="form__field-title"><?php _e('First name', 'LDC Custom string'); ?> *</div>
|
|
<input type="text" name="firstname" size="40" class="form__input" placeholder="<?php _e('Your first name', 'LDC Custom string'); ?>"
|
|
required>
|
|
</div>
|
|
</div>
|
|
<div class="form__field">
|
|
<div class="form__field-title"><?php _e('Address', 'LDC Custom string'); ?> *</div>
|
|
<input type="text" name="address" size="40" class="form__input" placeholder="<?php _e('Your address', 'LDC Custom string'); ?>"
|
|
required>
|
|
</div>
|
|
<div class="form__row">
|
|
<div class="form__field">
|
|
<div class="form__field-title"><?php _e('Postcode', 'LDC Custom string'); ?> *</div>
|
|
<input type="text" name="postalcode" size="40" class="form__input"
|
|
placeholder="<?php _e('Your postcode', 'LDC Custom string'); ?>" required>
|
|
</div>
|
|
<div class="form__field">
|
|
<div class="form__field-title"><?php _e('Town', 'LDC Custom string'); ?> *</div>
|
|
<input type="text" name="town" size="40" class="form__input" placeholder="<?php _e('Your town', 'LDC Custom string'); ?>" required>
|
|
</div>
|
|
</div>
|
|
<div class="form__field">
|
|
<div class="form__field-title"><?php _e('Country', 'LDC Custom string'); ?> *</div>
|
|
<input type="text" name="country" size="40" class="form__input" placeholder="<?php _e('Your country', 'LDC Custom string'); ?>" required>
|
|
</div>
|
|
<div class="form__row">
|
|
<div class="form__field">
|
|
<div class="form__field-title"><?php _e('Email address', 'LDC Custom string'); ?> *</div>
|
|
<input type="email" name="email" size="40" class="form__input" aria-required="true"
|
|
aria-invalid="false" placeholder="<?php _e('Firstname.surname@mail.fr', 'LDC Custom string'); ?>" required>
|
|
</div>
|
|
<div class="form__field">
|
|
<div class="form__field-title"><?php _e('Telephone', 'LDC Custom string'); ?></div>
|
|
<input type="tel" name="phone" size="20" class="form__input"
|
|
placeholder="<?php _e('For example, 02 43 62 70 00', 'LDC Custom string'); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="form__field">
|
|
<div class="form__field-title"><?php _e('Establishment', 'LDC Custom string'); ?> *</div>
|
|
<input type="text" name="establishment" size="40" class="form__input"
|
|
placeholder="Votre établissement" required>
|
|
</div>
|
|
<div class="form__field">
|
|
<div class="form__field-title"><?php _e('Type of catering / business', 'LDC Custom string'); ?> *</div>
|
|
<input type="text" name="type" size="40" class="form__input"
|
|
placeholder="<?php _e('Type of catering / business', 'LDC Custom string'); ?>" required>
|
|
</div>
|
|
<div class="form__container">
|
|
<div class="form__field-title"><?php _e('Message', 'LDC Custom string'); ?> *</div>
|
|
|
|
<div class="form__field">
|
|
<textarea name="message" cols="40" rows="10" class="form__input"
|
|
placeholder="<?php _e('Explain your project or request', 'LDC Custom string'); ?>" required></textarea>
|
|
</div>
|
|
|
|
<div class="form__row">
|
|
<div class="form__field">
|
|
<label class="form__field-pseudolabel">
|
|
<input type="checkbox" name="agree">
|
|
<span class="form__field-pseudosquare"><?php _e('I accept the conditions of use', 'LDC Custom string'); ?> *</span>
|
|
</label>
|
|
<!-- <label class="form__field-pseudolabel">
|
|
<input type="checkbox" name="newsletter">
|
|
<span class="form__field-pseudosquare"><?php /*_e('I would like to subscribe to the newsletter', 'LDC Custom string'); */?></span>
|
|
</label>-->
|
|
</div>
|
|
|
|
<div class="form__field">
|
|
<div class="form__tip">* <?php _e('Compulsory fields', 'LDC Custom string'); ?></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form__response" style="display: none;"><?php _e('One or more fields contain an error. Please check and try again.', 'LDC Custom string'); ?>
|
|
</div>
|
|
|
|
<div class="form__row">
|
|
<div class="form-submit">
|
|
<input type="submit" value="<?php _e('Send', 'LDC Custom string'); ?>" class="form-submit__btn btn">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
let processing = false;
|
|
let lastname = $("input[name=lastname]");
|
|
let firstname = $("input[name=firstname]");
|
|
let address = $('input[name=address]');
|
|
let postalcode = $("input[name=postalcode]");
|
|
let country = $("input[name=country]");
|
|
let town = $("input[name=town]");
|
|
let email = $("input[name=email]");
|
|
let phone = $("input[name=phone]");
|
|
let establishment = $('input[name=establishment]');
|
|
let type = $('input[name=type]');
|
|
let message = $("textarea[name=message]");
|
|
let agree = $("input[name=agree]");
|
|
// TODO : Gestion newsletter
|
|
/* let newsletter = $("input[name=newsletter]");*/
|
|
|
|
function reset() {
|
|
lastname.val('');
|
|
firstname.val('');
|
|
address.val('');
|
|
postalcode.val('');
|
|
country.val('');
|
|
town.val('');
|
|
email.val('');
|
|
phone.val('');
|
|
establishment.val('');
|
|
type.val('');
|
|
message.val('');
|
|
|
|
agree.prop("checked", false);
|
|
/* newsletter.prop("checked", false);*/
|
|
}
|
|
|
|
$("input[type=submit]").on('click', function (e) {
|
|
e.preventDefault();
|
|
|
|
if (processing === true)
|
|
return;
|
|
|
|
if (lastname.val().length > 0 && firstname.val().length > 0 && address.val().length > 0 && postalcode.val().length > 0 && country.val().length > 0 && town.val().length > 0 && email.val().length > 0 && establishment.val().length > 0 && type.val().length > 0 && message.val().length > 0) {
|
|
|
|
if (/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(email.val())) {
|
|
|
|
$(".form__response").hide();
|
|
|
|
if (agree.is(':checked') === false) {
|
|
alert("Vous devez accepter les conditions d'utilisation.");
|
|
} else {
|
|
processing = true;
|
|
grecaptcha.ready(function () {
|
|
grecaptcha.execute('6LePZvAUAAAAABs8uGHxhSkJVPVs4yCJ3amJ1HpX', {action: 'contact'}).then(function (token) {
|
|
$.ajax({
|
|
type: "POST",
|
|
url: window.location.origin + '/wp-admin/admin-ajax.php',
|
|
data: {
|
|
'token': token,
|
|
'action': 'ContactAjx',
|
|
'id': <?= $post->ID; ?>,
|
|
'firstname': firstname.val(),
|
|
'lastname': lastname.val(),
|
|
'address': address.val(),
|
|
'postalcode': postalcode.val(),
|
|
'country': country.val(),
|
|
'town': town.val(),
|
|
'email': email.val(),
|
|
'phone': phone.val(),
|
|
'establishment': establishment.val(),
|
|
'type': type.val(),
|
|
'message': message.val(),
|
|
},
|
|
success: function (response, textStatus, jqXHR) {
|
|
reset();
|
|
alert('Bonjour. Nous vous remercions de nous avoir contactés. Notre équipe commerciale vous répondra dans les meilleurs délais.');
|
|
processing = false;
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
alert('Une erreur est survenue, veuillez recharger la page.');
|
|
processing = false;
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
} else {
|
|
alert('Le format de l\'adresse email est invalide.');
|
|
}
|
|
|
|
} else {
|
|
$(".form__response").show();
|
|
}
|
|
|
|
});
|
|
</script>
|