odoo.define('booking.main', function (require) { $(document).ready(function() { $('#datetimepickerstart_day').datetimepicker({format: 'DD/MM/YYYY'}); $('#datetimepickerend_day').datetimepicker({format: 'DD/MM/YYYY'}); $('#medical_info').hide() $('#booking_total_price').text( $('#booking_price_product').val()+' €' ); //$( "#continue_button2").unbind( "click" ); }); $( "#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()) //recalcul du prix total selon le status if ($("#status2").val()=='not member') { $("#your_status").text('non adhérent') $("#price_of_the_stay").text($("#booking_price").val()+' €') $("#total_price").val($("#booking_price").val()) } if ($("#status2").val()=='member') { $("#your_status").text('adhérent') $("#price_of_the_stay").text($("#booking_member_price").val()+' €') $("#total_price").val($("#booking_member_price").val()) } if ($("#status2").val()=='super member') { $("#your_status").text('Adhérent de soutien') $("#price_of_the_stay").text($("#booking_super_member_price").val()+' €') $("#total_price").val($("#booking_super_member_price").val()) } $( ":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') }); });