odoo.define('booking.main', function (require) {
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
$('#datetimepickerstart_day').datetimepicker({
|
|
format: 'DD/MM/YYYY',
|
|
enableOnReadonly: true
|
|
});
|
|
$('#datetimepickerend_day').datetimepicker({
|
|
format: 'DD/MM/YYYY',
|
|
enableOnReadonly: true
|
|
});
|
|
|
|
$('#medical_info').hide()
|
|
|
|
$('#booking_total_price').text(
|
|
$('#booking_price_product').val()+' €'
|
|
);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
$( "#start_day").on("input", function(e) {
|
|
//alert(parseDate($("#start_day").val()))
|
|
if (parseDate($("#start_day").val())==-1 && parseDate($("#end_day").val())==-1)
|
|
{
|
|
console.log('end_day_change')
|
|
console.log('start_day='+$("#start_day").val())
|
|
console.log('end_day='+$("#end_day").val())
|
|
console.log(parseDate($("#start_day").val()))
|
|
console.log(parseDate($("#end_day").val()))
|
|
|
|
fct_days()
|
|
}
|
|
else
|
|
{
|
|
$("#days").html()
|
|
}
|
|
|
|
});
|
|
$( "#end_day").on("input", function(e) {
|
|
|
|
if (parseDate($("#end_day").val())==-1 && parseDate($("#start_day").val())==-1)
|
|
{
|
|
console.log('end_day_change')
|
|
console.log('start_day='+$("#start_day").val())
|
|
console.log('end_day='+$("#end_day").val())
|
|
console.log(parseDate($("#start_day").val()))
|
|
console.log(parseDate($("#end_day").val()))
|
|
|
|
|
|
fct_days()
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
$("#days").html()
|
|
}
|
|
|
|
});
|
|
|
|
function fct_days()
|
|
{
|
|
var s = $("#start_day").val().split('/');
|
|
var e = $("#end_day").val().split('/');
|
|
var end_day=e[2]+'-'+e[1]+'-'+e[0]
|
|
var start_day=s[2]+'-'+s[1]+'-'+s[0]
|
|
|
|
var diff = Math.floor((Date.parse(end_day) - Date.parse(start_day)) / 86400000)+1;
|
|
if (diff<0 || diff>100)
|
|
{
|
|
|
|
return 'les dates saisies ne sont pas correctes'
|
|
|
|
}
|
|
html_days_message='Soit '+diff.toString()+' jours'
|
|
console.log(html_days_message)
|
|
$("#days").html(html_days_message)
|
|
compute_individual_booking_prices_without_option(diff)
|
|
compute_total_price_from_status_without_options()
|
|
compute_total_price_with_options()
|
|
|
|
$("#days_duration").val(diff)
|
|
|
|
|
|
|
|
return true
|
|
}
|
|
function parseDate(str) {
|
|
var d = str.split('/');
|
|
var date1=d[0]+'-'+d[1]+'-'+d[2]
|
|
var m = date1.match(/^(\d{1,2})-(\d{1,2})-(\d{4})$/);
|
|
return (m) ? -1 : null;
|
|
}
|
|
|
|
function compute_individual_booking_prices_without_option(days)
|
|
{
|
|
mod_days=days%7
|
|
if (days<7)
|
|
{
|
|
|
|
$("#booking_price").val(days*$("#individual_day_price").val())
|
|
$("#booking_member_price").val(days*$("#individual_member_day_price").val())
|
|
$("#booking_super_member_price").val(days*$("#individual_super_member_day_price").val())
|
|
|
|
|
|
|
|
}
|
|
if (days<14 && days>6)
|
|
{
|
|
mod_days=days%7
|
|
// console.log('booking_price'+mod_days*$("#individual_day_price").val())
|
|
$("#booking_price").val(parseInt($("#individual_week_price").val(),10)+mod_days*$("#individual_day_price").val())
|
|
$("#booking_member_price").val(parseInt($("#individual_member_week_price").val(),10)+mod_days*$("#individual_member_day_price").val())
|
|
$("#booking_super_member_price").val(parseInt($("#individual_super_member_week_price").val(),10)+mod_days*$("#individual_super_member_day_price").val())
|
|
|
|
}
|
|
if (days<22 && days>13)
|
|
{
|
|
mod_days=days%14
|
|
// console.log('booking_price'+mod_days*$("#individual_day_price").val())
|
|
$("#booking_price").val(parseInt($("#individual_2weeks_price").val(),10)+mod_days*$("#individual_day_price").val())
|
|
$("#booking_member_price").val(parseInt($("#individual_member_2weeks_price").val(),10)+mod_days*$("#individual_member_day_price").val())
|
|
$("#booking_super_member_price").val(parseInt($("#individual_super_member_2weeks_price").val(),10)+mod_days*$("#individual_super_member_day_price").val())
|
|
|
|
}
|
|
if (days>21)
|
|
{
|
|
mod_days=days%21
|
|
// console.log('booking_price'+mod_days*$("#individual_day_price").val())
|
|
$("#booking_price").val(parseInt($("#individual_3weeks_price").val(),10)+mod_days*$("#individual_day_price").val())
|
|
$("#booking_member_price").val(parseInt($("#individual_member_3weeks_price").val(),10)+mod_days*$("#individual_member_day_price").val())
|
|
$("#booking_super_member_price").val(parseInt($("#individual_super_member_3weeks_price").val(),10)+mod_days*$("#individual_super_member_day_price").val())
|
|
|
|
}
|
|
|
|
|
|
}
|
|
function compute_total_price_from_status_without_options()
|
|
{
|
|
//recalcul du prix total selon le status
|
|
if ($("#status2").val()=='not member')
|
|
{
|
|
|
|
$("#total_price").val($("#booking_price").val())
|
|
$("#price_individual_booking").val($("#booking_price").val())
|
|
}
|
|
if ($("#status2").val()=='member')
|
|
{
|
|
|
|
$("#total_price").val($("#booking_member_price").val())
|
|
$("#price_individual_booking").val($("#booking_member_price").val())
|
|
}
|
|
if ($("#status2").val()=='super member')
|
|
{
|
|
|
|
$("#total_price").val($("#booking_super_member_price").val())
|
|
$("#price_individual_booking").val($("#booking_super_member_price").val())
|
|
}
|
|
|
|
}
|
|
|
|
function compute_total_price_with_options()
|
|
{
|
|
$( ":checkbox" ).each(function( index ) {
|
|
var l=this.name.length
|
|
var i=this.name.substring(2,l-1)
|
|
|
|
if (this.value==$("#membership_product").val())
|
|
{
|
|
var option_price_str='#o_standard'+i
|
|
}
|
|
else
|
|
{
|
|
if ($("#status2").val()=='not member')
|
|
{
|
|
var option_price_str='#o_standard'+i
|
|
}
|
|
else
|
|
{
|
|
var option_price_str='#o_'+$("#status2").val()+i
|
|
}
|
|
|
|
}
|
|
|
|
|
|
option_price=$(option_price_str).val()
|
|
if (!option_price) option_price=0
|
|
console.log(option_price_str+'='+option_price)
|
|
total_price=$("#total_price").val()
|
|
|
|
if(this.checked) {
|
|
|
|
$("#total_price").val(parseInt(total_price)+parseInt(option_price))
|
|
console.log($("#total_price").val())
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$("#booking_total_price").text($("#total_price").val()+' €');
|
|
console.log( 'total price final='+$("#booking_total_price").text())
|
|
console.log('end debug price')
|
|
|
|
}
|
|
$( "#medical_concern" ).change(function() {
|
|
|
|
if (this.value=='have medical concern')
|
|
{
|
|
|
|
$('#medical_info').show()
|
|
$("medical_info_div").addClass("s_website_form_required");
|
|
$("medical_information").prop('required',true);
|
|
}
|
|
else
|
|
{
|
|
$('#medical_info').hide()
|
|
$("medical_info_div").removeClass("s_website_form_required");
|
|
$("medical_information").prop('required',false);
|
|
}
|
|
|
|
|
|
});
|
|
|
|
$( "#continue_button" ).click(function() {
|
|
if ($('#email').val()=='' && $('#mobile').val()=='' && $('#phone').val()=='')
|
|
{
|
|
$('#validation_message').text('merci de saisir un email ou un mobile ou un téléphone')
|
|
$('#validation_message').show()
|
|
}
|
|
else
|
|
{
|
|
if ($('#name').val()=='')
|
|
{
|
|
$('#validation_message').text('merci de saisir un nom')
|
|
$('#validation_message').show()
|
|
|
|
|
|
}
|
|
else if ($('#firstname').val()=='')
|
|
{
|
|
$('#validation_message').text('merci de saisir un prénom')
|
|
$('#validation_message').show()
|
|
|
|
|
|
}
|
|
else if ($('#age').val()=='')
|
|
{
|
|
$('#validation_message').text('merci de saisir l\'age du participant')
|
|
$('#validation_message').show()
|
|
|
|
|
|
}
|
|
else if ($('#city').val()=='')
|
|
{
|
|
$('#validation_message').text('merci de saisir la ville du participant')
|
|
$('#validation_message').show()
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
$('#form1').submit()
|
|
}
|
|
|
|
|
|
|
|
}
|
|
});
|
|
|
|
$( "#continue_button2" ).click(function() {
|
|
if ($('#image_permission').val()=='')
|
|
{
|
|
|
|
$('#validation_message').text('merci de répondre à la demande d\'autorisation de l\'utilisation de votre image')
|
|
$('#validation_message').show()
|
|
}
|
|
else
|
|
{
|
|
if ($('#medical_contact_name').val()=='')
|
|
{
|
|
$('#validation_message').text('merci de saisir le nom du contact')
|
|
$('#validation_message').show()
|
|
|
|
|
|
}
|
|
else if ($('#medical_contact_phone').val()=='')
|
|
{
|
|
$('#validation_message').text('merci de saisir le téléphone du contact')
|
|
$('#validation_message').show()
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
$('#form2').submit()
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$( "#back_button2" ).click(function() {
|
|
history.back()
|
|
});
|
|
|
|
$( "#back_button1" ).click(function() {
|
|
history.back()
|
|
});
|
|
|
|
$(":checkbox").change(function() {
|
|
//console.log('start debug price')
|
|
//console.log('status:'+$("#status").val())
|
|
//si coche adhésion alors le statut devient membre
|
|
if(this.value==$("#membership_product").val() && this.checked)
|
|
{
|
|
|
|
if ($("#status").val()=='not member') {$("#status2").val('member')}
|
|
|
|
|
|
}
|
|
//si décoche adhésion alors le statut devient non membre
|
|
if(this.value==$("#membership_product").val() && this.checked==false)
|
|
{
|
|
if ($("#status").val()=='not member'){$("#status2").val('not member')}
|
|
|
|
}
|
|
|
|
console.log('status2:'+$("#status2").val())
|
|
|
|
compute_total_price_from_status_without_options()
|
|
compute_total_price_with_options()
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|