var ServiceDay=[], Spaces=[]; var min_date2=new Date(2024, 3, 29); var min_spaces_open_date=60; $(document).ready(function(){ $('#waiting-spin').show(); $.ajax({ url: '/reservation/get_spaces.php', cache: false, dataType: 'json', timeout: 10000, async: false, success: function (data){ $.each(data, function(index, value){ ServiceDay.push(value.a+":"+value.b); Spaces.push(value.c); }); } }); $('#waiting-spin').fadeOut(20); $('.radio_durationtrek').checkboxradio({ icon: false }) .on('change', function(event, ui){ var duration = $(this).val(); var qty=$('#spinner-qty').val(); event.preventDefault(); if(duration==4) { $('#div-category').slideDown('fast'); $('#datepicker').datepicker('option', {minDate: new Date(2024, 3, 29)}); } else { $('#div-category').slideUp('fast'); $('#datepicker').datepicker('option', {minDate: new Date(2024, 3, 29)}); } $('#div-date0').show(); $('#div-date1').hide(); $('#datepicker').datepicker({ setDate: null, }); $('#datetrek').val(''); $('.spacesleft .max').html((duration==2) ? 250 : 200); $('.spaces-container .bar') .html('') .width(0); if(duration==2) { $('#available2').show(); $('#available4').hide(); } else { $('#available4').show(); $('#available2').hide(); } $('.error-date').hide(); $('#datepicker').val("Elegir una fecha"); }); $('.radio_typetrek').checkboxradio({ icon: false }); $('#popup-opendate').magnificPopup({ type: 'inline', tClose: "Cerrar (Esc)", tLoading: "Cargando..." }); $('.check-opendate').change(function(event) { var checked = ($(this).prop('checked')) ? 1 : 0; $(this).closest('div').find('.opendatevalue').val(checked); if(checked==1) $('#popup-opendate').magnificPopup('open'); }); $('#handle-qty').handleCounter({ minimum: 1, maximize: 10, onChange: qtyChanged }) .click(function(e){ event.preventDefault(); }); var def_date = new Date(2024, 3, 28, 0, 0); var duration = $('.radio_durationtrek').val(); //var min_date; //if(duration==4) ? min_date=new Date(2024, 3, 29) : new Date(2024, 3, 29); if(duration==4) min_date=new Date(2024, 3, 29); else min_date=new Date(2024, 3, 29); $('#datepicker').datepicker({ dateFormat: 'DD dd MM yy', altField: '#datetrek', altFormat: 'yymmdd', minDate: new Date(2024, 3, 29), //maxDate: new Date(2024, 11, 31), maxDate: new Date(2024, 11, 31), defaultDate: def_date, autoSize: true, beforeShowDay: checkDay }) .on("change", function(event, param) { var newDate = $(this).datepicker('getDate'); var selM = newDate.getMonth(); var selD = newDate.getDate(); var trek = $("#check-duration input[type='radio']:checked").val(); var check = trek+":"+newDate.getFullYear()+'.'+(newDate.getMonth()+1)+'.'+newDate.getDate(); var idx = $.inArray(check, ServiceDay); var factor=(trek==2) ? 250/100 : 200/100; if(idx!=-1) { var spaces=Math.round(Spaces[idx]); var swidth=(trek==2) ? Math.round(spaces/250*200) : Math.round(spaces/200*200); $('.spaces-container .bar') .html(spaces) .animate({ width: swidth }, 2000); if(spaces