Changeset 2408218
- Timestamp:
- 10/28/2020 10:33:56 AM (5 years ago)
- Location:
- easyreservations/trunk
- Files:
-
- 16 edited
-
assets/js/frontend/date-selection.js (modified) (4 diffs)
-
assets/js/frontend/date-selection.min.js (modified) (1 diff)
-
easyReservations.php (modified) (1 diff)
-
includes/admin/views/html-admin-resource-filter-add.php (modified) (5 diffs)
-
includes/admin/views/html-timeline.php (modified) (1 diff)
-
includes/class-easyreservations.php (modified) (1 diff)
-
includes/class-er-ajax.php (modified) (3 diffs)
-
includes/class-er-checkout.php (modified) (1 diff)
-
includes/class-er-form-handler.php (modified) (1 diff)
-
includes/class-er-resource-availability.php (modified) (4 diffs)
-
includes/class-er-resources.php (modified) (1 diff)
-
includes/class-er-template-loader.php (modified) (1 diff)
-
includes/emails/class-er-email.php (modified) (1 diff)
-
includes/er-order-functions.php (modified) (1 diff)
-
includes/updates/easyreservations-update-4.0.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
easyreservations/trunk/assets/js/frontend/date-selection.js
r2290893 r2408218 28 28 }, options ); 29 29 30 let data = false, 30 let pageLoad = true, 31 data = false, 31 32 lastRequest = false, 32 33 done = false, … … 315 316 } 316 317 317 calendarContainer.datepicker( 318 $.extend( { 319 minDate: arrival ? arrival : settings.minDate, 320 maxDate: maxDate ? maxDate : null, 321 dateFormat: dateFormat, 322 numberOfMonths: settings.numberOfMonths, 323 beforeShowDay: checkData, 324 onChangeMonthYear: function( year, month, inst ) { 325 if ( ! slots || ( ! arrivalTime && settings.time ) || ( arrival && ! settings.time ) ) { 326 loadData( dateFormat.replace( 'dd', '01' ).replace( 'mm', month ).replace( 'yy', year ) ); 327 } 328 329 e.find( 'div.time' ).slideUp( 300 ); 330 331 if ( arrival && ( arrivalTime || ! settings.time ) ) { 332 resetDeparture(); 333 e.find( '.departure .text .date' ).addClass( 'important' ).html( er_date_picker_params.wait ); 334 } else { 335 resetArrival(); 336 e.find( '.arrival .text .date' ).addClass( 'important' ).html( er_date_picker_params.wait ); 337 } 338 }, 339 onSelect: select, 340 }, defaultArgs ) 341 ).datepicker( 'setDate', null ).slideDown( '300' ); 318 calendarContainer 319 .datepicker( 320 $.extend( { 321 minDate: arrival ? arrival : settings.minDate, 322 maxDate: maxDate ? maxDate : null, 323 dateFormat: dateFormat, 324 numberOfMonths: settings.numberOfMonths, 325 beforeShowDay: checkData, 326 onChangeMonthYear: function( year, month, inst ) { 327 if ( ! slots || ( ! arrivalTime && settings.time ) || ( arrival && ! settings.time ) ) { 328 loadData( dateFormat.replace( 'dd', '01' ).replace( 'mm', month ).replace( 'yy', year ) ); 329 } 330 331 e.find( 'div.time' ).slideUp( 300 ); 332 333 if ( arrival && ( arrivalTime || ! settings.time ) ) { 334 resetDeparture(); 335 e.find( '.departure .text .date' ).addClass( 'important' ).html( er_date_picker_params.wait ); 336 } else { 337 resetArrival(); 338 e.find( '.arrival .text .date' ).addClass( 'important' ).html( er_date_picker_params.wait ); 339 } 340 }, 341 onSelect: select, 342 }, defaultArgs ) 343 ) 344 .datepicker( 'setDate', null ).slideDown( '300' ); 342 345 343 346 const element = calendarContainer.parent().parent(); 344 347 345 if ( resourceQuantity&& ! element.isInViewport() ) {348 if ( ! pageLoad && resourceQuantity && calendarContainer.hasClass( 'hasDatepicker' ) && ! element.isInViewport() ) { 346 349 $( [ document.documentElement, document.body ] ).animate( { 347 350 scrollTop: element.offset().top - 30, … … 349 352 } 350 353 354 pageLoad = false; 355 351 356 calendarContainer.find( '.ui-datepicker' ).removeClass( 'ui-datepicker' ).addClass( 'easy-datepicker' ); 352 357 calendarContainer.find( '.ui-state-active' ).removeClass( 'ui-state-highlight' ).removeClass( 'ui-state-hover' ).removeClass( 'ui-state-active' ); 358 353 359 $.each( er_date_picker_params.datepicker, function( k, v ) { 354 360 calendarContainer.datepicker( 'option', k, $.parseJSON( v ) ); … … 645 651 slots = data.hasOwnProperty( 'slots' ) && data.slots; 646 652 653 const firstPossibleDate = data.first_possible.split( ' ' ); 654 if ( arrival ) { 655 calendarContainer.datepicker( 'option', 'minDate', firstPossibleDate[ 0 ] ); 656 } 657 647 658 if ( data.hasOwnProperty( 'max' ) && data.max ) { 648 659 //TODO: reintroduce feature WEIRD BUG still present as of 02 2020 -
easyreservations/trunk/assets/js/frontend/date-selection.min.js
r2290893 r2408218 1 (function(a){a.fn.isInViewport=function(){const c=a(this).offset().top;const e=c+a(this).outerHeight();const b=a(window).scrollTop();const d=b+a(window).height();return e>b&&c<d};a.fn.dateSelection=function(f){const u=a(this),i=u.find(".datepicker"),g=erDatepickerArgs(),n=[],v=a.extend({resource:0,arrivalHour:false,arrivalMinute:false,departureHour:false,departureMinute:false,minDate:g.minDate,init:true,departure:true,numberOfMonths:1,time:false,price:false},f);let data=false,lastRequest=false,done=false,slots=false,resourceQuantity=false,arrival=false,arrivalTime=false,frequency=false,departure=false,departureTime=false;if(v.resource===0){v.resource=a("*[name=resource]").val()}if(v.resource&&v.resource>0){frequency=er_both_params.resources[v.resource].frequency;resourceQuantity=er_both_params.resources[v.resource].quantity}u.find("div.arrival").bind("click",function(){q()});u.find("div.departure").bind("click",function(){if(arrival&&(arrivalTime||!v.time)){b();if(!i.hasClass("hasDatepicker")){u.find(".departure .text .date").addClass("important").html(er_date_picker_params.wait);c(arrival);t()}else{u.find(".time-picker > td > div").slideUp(50,function(){i.find(".ui-state-active").removeClass("ui-state-highlight").removeClass("ui-state-active");a(this).closest(".time-picker").remove()})}}});a("*[name=resource]").bind("change",function(){s();b();v.resource=a(this).val();frequency=er_both_params.resources[v.resource].frequency;resourceQuantity=er_both_params.resources[v.resource].quantity;q()});if(v.init&&u.find("input[name=arrival]").val()===""&&v.resource&&v.resource>0){q()}function q(){u.find(".calendar").css("display","block");if(i.hasClass("hasDatepicker")){l(q)}else{u.find(".text .time").html("");data=false;slots=false;s();b();u.find(".arrival .text .date").addClass("important").html(er_date_picker_params.wait);u.find("input[name=slot]").val(-1);c(arrival?arrival:0);t()}}function d(){if(!done){if(departure){if(departureTime||!v.time){l(o);done=true}else{h()}}else{if(arrival){if(arrivalTime!==false||!v.time){if(v.departure){u.find(".departure .text .date").addClass("important").html(er_date_picker_params.wait);t()}else{if(i.hasClass("hasDatepicker")){l(d)}else{if(slots){const x=data[arrival][arrivalTime][0].departure.split(" ");const e=x[1].split(":");k(x[0]);w(e[0],e[1])}o()}done=true}}else{h()}}}}}function h(){const x=a.datepicker.formatDate("DD, d M yy",i.datepicker("getDate"));u.find("a.ui-state-active").parent().parent().after('<tr class="time-picker"><td colspan="7"><div>'+x+'<div class="insert"></div></div></td></tr>');let timeOptions="";if(slots){if(arrivalTime!==false){a.each(data[arrival][arrivalTime],function(A,z){const C=z.departure.split(" ");if(C[0]!==departure){return}const B=C[1].split(":"),D=z.availability<1?"unavailable":(z.availability<resourceQuantity?"partially":"available");let label=easyFormatTime(B[0],B[1],er_both_params.time_format);if(z.price){label+='<span class="price">('+z.price+")</span>"}timeOptions+='<li class="easy-button" data-hour="'+B[0]+'" data-minute="'+B[1]+'" data-id="'+z.key+'" class="'+D+'">'+label+"</li>"})}else{a.each(data[arrival],function(A,z){const B=A.split(":");a.each(z,function(D,C){const G=C.availability<1?"unavailable":(C.availability<resourceQuantity?"partially":"available");let label=easyFormatTime(B[0],B[1],er_both_params.time_format),attributes="";if(!v.departure){const F=C.departure.split(" ");const E=F[1].split(":");label+=" -";if(arrival!==F[0]){label+=" "+F[0]}label+=" "+easyFormatTime(E[0],E[1],er_both_params.time_format);if(C.price){label+='<span class="price">('+C.price+")</span>"}attributes+=' data-departure=" '+F[0]+'"';attributes+=' data-departure-hour=" '+E[0]+'"';attributes+=' data-departure-minute=" '+E[1]+'"'}timeOptions+='<li class="easy-button" data-hour="'+B[0]+'" data-minute="'+B[1]+'" data-id="'+C.key+'" class="'+G+'" '+attributes+">"+label+"</li>";if(v.departure){return false}})})}if(timeOptions!==""){u.find(".time-picker .insert").html('<ul class="option-buttons">'+timeOptions+"</ul>");u.find(".time-picker > td > div").slideDown(350);u.find("ul.option-buttons li").bind("click",function(){if(arrivalTime!==false){u.find("input[name=slot]").val(a(this).attr("data-id"));w(a(this).attr("data-hour"),a(this).attr("data-minute"))}else{if(!v.departure){u.find("input[name=slot]").val(a(this).attr("data-id"));k(a(this).attr("data-departure"));w(a(this).attr("data-departure-hour"),a(this).attr("data-departure-minute"))}p(a(this).attr("data-hour"),a(this).attr("data-minute"))}l(d)})}}else{if(data[departure?departure:arrival].availability&&data[departure?departure:arrival].availability===parseInt(data[departure?departure:arrival].availability,10)){u.find("div.time-prototype").contents().clone(true).appendTo(u.find(".time-picker .insert")).attr("disabled");let minMax;if(departure){minMax=data[departure].time}else{minMax=data[arrival].time}const y=data.first_possible.split(" ");if(y[0]===(departure?departure:arrival)){const e=y[1].split(":");minMax[0]=parseInt(minMax[0],10)<e[0]?parseInt(e[0],10):minMax[0]}u.find(".time-picker select[name=time_hour] option").each(function(){const z=parseInt(a(this).val());if(z<minMax[0]||z>minMax[1]){a(this).attr("disabled",true).prop("selected",false).css("display","none")}else{a(this).attr("disabled",false).css("display","block")}});u.find(".time-picker .apply-time").bind("click",function(){const z=u.find(".time-picker select[name=time_hour]");if(z.length>0){const A=parseInt(u.find(".time-picker select[name=time_minute]").val());if(arrivalTime!==false){w(z.val(),A)}else{p(z.val(),A);if(v.departure){c(arrival)}}l(d)}})}else{a.each(data[departure?departure:arrival].availability,function(A,z){const B=A.split(" ");const C=B[0].split(":");const D=z<1?"unavailable":(z<resourceQuantity?"partially":"available");timeOptions+='<div class="time-option '+D+'" data-hour="'+C[0]+'" data-minute="'+C[1]+'">'+easyFormatTime(C[0],C[1])+"</div>"});u.find(".time-picker .insert").html('<div class="option-buttons">'+timeOptions+"</div>");u.find(".time-picker .time-option.available, .time-picker .time-option.partially").bind("click",function(){if(arrivalTime!==false){w(a(this).attr("data-hour"),a(this).attr("data-minute"))}else{p(a(this).attr("data-hour"),a(this).attr("data-minute"));if(v.departure){c(arrival)}}l(d)})}u.find(".time-picker > td > div").slideDown(350)}}function t(x){let dateFormat="dd.mm.yy";if(er_both_params.date_format==="Y/m/d"){dateFormat="yy/mm/dd"}else{if(er_both_params.date_format==="m/d/Y"){dateFormat="mm/dd/yy"}else{if(er_both_params.date_format==="Y-m-d"){dateFormat="yy-mm-dd"}else{if(er_both_params.date_format==="d-m-Y"){dateFormat="dd-mm-yy"}}}}i.datepicker(a.extend({minDate:arrival?arrival:v.minDate,maxDate:x?x:null,dateFormat:dateFormat,numberOfMonths:v.numberOfMonths,beforeShowDay:j,onChangeMonthYear:function(y,A,z){if(!slots||(!arrivalTime&&v.time)||(arrival&&!v.time)){c(dateFormat.replace("dd","01").replace("mm",A).replace("yy",y))}u.find("div.time").slideUp(300);if(arrival&&(arrivalTime||!v.time)){b();u.find(".departure .text .date").addClass("important").html(er_date_picker_params.wait)}else{s();u.find(".arrival .text .date").addClass("important").html(er_date_picker_params.wait)}},onSelect:m},g)).datepicker("setDate",null).slideDown("300");const e=i.parent().parent();if(resourceQuantity&&!e.isInViewport()){a([document.documentElement,document.body]).animate({scrollTop:e.offset().top-30},500)}i.find(".ui-datepicker").removeClass("ui-datepicker").addClass("easy-datepicker");i.find(".ui-state-active").removeClass("ui-state-highlight").removeClass("ui-state-hover").removeClass("ui-state-active");a.each(er_date_picker_params.datepicker,function(z,y){i.datepicker("option",z,a.parseJSON(y))})}function s(){arrival=false;arrivalTime=false;u.find(".arrival .text .date").addClass("important").html(er_date_picker_params.select);u.find(".arrival .text .time").html("");u.find("input[name=arrival]").val("");u.find("input[name=departure_hour]").val("");u.find("input[name=departure_minute]").val("")}function b(){departure=false;departureTime=false;done=false;if(arrival){u.find(".departure .text .date").addClass("important").html(er_date_picker_params.select)}else{u.find(".departure .text .date").removeClass("important").html("—")}u.find(".departure .text .time").html("");u.find("input[name=departure]").val("");u.find("input[name=departure_hour]").val("");u.find("input[name=departure_minute]").val("");u.find(".departure").removeClass("active")}function r(e){arrival=e;u.find(".arrival .text .date").removeClass("important").html(e);u.find("input[name=arrival]").val(e);u.find("input[name=arrival_hour]").val("");u.find("input[name=arrival_minute]").val("")}function k(e){departure=e;u.find("input[name=departure]").val(e);u.find(".departure").addClass("active");u.find(".departure .text .date").removeClass("important").html(e)}function p(e,y,x){e=easyAddZero(e);y=easyAddZero(y);if(!x){x=easyFormatTime(e,y)}arrivalTime=e+":"+y;u.find("input[name=arrival_hour]").val(e);u.find("input[name=arrival_minute]").val(y);u.find(".arrival .text .time").html(x)}function w(e,y,x){e=easyAddZero(e);y=easyAddZero(y);if(!x){x=easyFormatTime(e,y)}departureTime=e+":"+y;u.find("input[name=departure_hour]").val(e);u.find("input[name=departure_minute]").val(y);u.find(".departure .text .time").html(x)}function m(z,e){if(arrival&&(arrivalTime!==false||!v.time)){if(departure===z){b();u.find(".time-picker > td > div").slideUp(50,function(){i.find(".ui-state-active").removeClass("ui-state-highlight").removeClass("ui-state-active")});return false}k(z);if(v.time){setTimeout(h,1)}else{if(slots){const x=false;a.each(data[arrival][arrivalTime],function(B,A){const D=A.departure.split(" ");if(departure===D[0]){const C=D.split(":");w(C[0],C[1]);return false}})}else{w(v.departureHour?v.departureHour:data[departure].time[0],v.departureMinute?v.departureMinute:0)}l(d)}}else{if(arrival===z){s();u.find(".time-picker > td > div").slideUp(50,function(){i.find(".ui-state-active").removeClass("ui-state-highlight").removeClass("ui-state-active")});return false}r(z);if(v.time){setTimeout(h,1)}else{let hour=12,minute=v.arrivalHour?v.arrivalMinute:0;if(slots){const y=Object.keys(data[arrival])[0].split(":");hour=y[0];minute=y[1]}else{hour=v.arrivalHour?v.arrivalHour:data[arrival].time[1]}p(hour,minute);if(v.departure){u.find(".departure .text .date").addClass("important").html(er_date_picker_params.wait);c(arrival)}l(d)}}}function l(e){i.slideUp(350,function(){a(this).datepicker("destroy").removeClass("hasDatepicker").removeAttr("id");if(e){e()}})}function j(x){let className="";if(data){const e=easyFormatDate(x,false);if(slots&&arrival&&arrivalTime!==false){if(easyStringToDate(arrival)>x){return[false,"past",""]}let toReturn=[false,"unavailable",""],iterate;if(arrivalTime!==false&&v.time){iterate=data[arrival][arrivalTime]}else{iterate=data[arrival][Object.keys(data[arrival])[0]]}a.each(iterate,function(z,y){const A=y.departure.split(" ");if(A[0]===e){toReturn=[true,"available",""];return true}});return toReturn}if(data.hasOwnProperty(e)){if(data[e].price){className="datepicker-content-"+data[e].price.hashCode();if(a.inArray(className,n)===-1){a("head").append("<style>.easy-date-selection td."+className+" a:after {content: '"+data[e].price+"'}</style>");n.push(className)}}else{if(v.price&&!slots&&frequency===86400){className="price-placeholder"}}if(data[e].availability&&data[e].availability===parseInt(data[e].availability,10)){if(data[e].availability<0){return[false,"unavailable rule "+className,""]}if(data[e].availability<1){return[false,"unavailable "+className,""]}if(data[e].availability<resourceQuantity){return[true,"partially "+className,""]}}else{let amountAvailable=0,hasAvailableSlot=false,total;if(slots){total=data[e][Object.keys(data[e])[0]];a.each(total,function(z,y){if(y.availability>0){hasAvailableSlot=true;amountAvailable++}})}else{total=data[e].availability;a.each(total,function(z,y){if(y>0){hasAvailableSlot=true;amountAvailable++}})}if(!hasAvailableSlot){return[false,"unavailable "+className,""]}if(Object.keys(total).length>amountAvailable){return[true,"partially "+className,""]}}return[true,"available "+className,""]}}if(v.price&&!slots&&frequency===86400){className="price-placeholder"}return[false,"past "+className,""]}function c(x){const e=Date.now(),y={action:"easyreservations_calendar",date:x===0?0:x,arrival:arrival&&(arrivalTime!==false||!v.time)?arrival:0,arrivalTime:arrivalTime,months:v.numberOfMonths,adults:a("*[name=adults]").val(),children:a("*[name=children]").val(),resource:v.resource,price:v.price,minDate:v.minDate,security:u.find('input[name="easy-date-selection-nonce"]').val()};lastRequest=e;data=false;if(!y.resource){alert("no resource field in form, please fix");return}a.post(er_both_params.ajaxurl,y,function(z){if(lastRequest===e){if(arrival&&(arrivalTime||!v.time)){u.find(".departure .text .date").addClass("important").html(er_date_picker_params.select)}else{u.find(".arrival .text .date").html(er_date_picker_params.select)}data=z;slots=data.hasOwnProperty("slots")&&data.slots;if(data.hasOwnProperty("max")&&data.max){i.datepicker("refresh")}else{i.datepicker("refresh")}i.find(".ui-datepicker-today a, .ui-datepicker-current-day a").removeClass("ui-state-highlight").removeClass("ui-state-hover").removeClass("ui-state-active")}})}function o(){u.find("input[name=arrival]").trigger("change")}}}(jQuery));Object.defineProperty(String.prototype,"hashCode",{value:function(){var c=0,a,b;for(a=0;a<this.length;a++){b=this.charCodeAt(a);c=((c<<5)-c)+b;c|=0}return c}});1 (function(a){a.fn.isInViewport=function(){const c=a(this).offset().top;const e=c+a(this).outerHeight();const b=a(window).scrollTop();const d=b+a(window).height();return e>b&&c<d};a.fn.dateSelection=function(f){const u=a(this),i=u.find(".datepicker"),g=erDatepickerArgs(),n=[],v=a.extend({resource:0,arrivalHour:false,arrivalMinute:false,departureHour:false,departureMinute:false,minDate:g.minDate,init:true,departure:true,numberOfMonths:1,time:false,price:false},f);let pageLoad=true,data=false,lastRequest=false,done=false,slots=false,resourceQuantity=false,arrival=false,arrivalTime=false,frequency=false,departure=false,departureTime=false;if(v.resource===0){v.resource=a("*[name=resource]").val()}if(v.resource&&v.resource>0){frequency=er_both_params.resources[v.resource].frequency;resourceQuantity=er_both_params.resources[v.resource].quantity}u.find("div.arrival").bind("click",function(){q()});u.find("div.departure").bind("click",function(){if(arrival&&(arrivalTime||!v.time)){b();if(!i.hasClass("hasDatepicker")){u.find(".departure .text .date").addClass("important").html(er_date_picker_params.wait);c(arrival);t()}else{u.find(".time-picker > td > div").slideUp(50,function(){i.find(".ui-state-active").removeClass("ui-state-highlight").removeClass("ui-state-active");a(this).closest(".time-picker").remove()})}}});a("*[name=resource]").bind("change",function(){s();b();v.resource=a(this).val();frequency=er_both_params.resources[v.resource].frequency;resourceQuantity=er_both_params.resources[v.resource].quantity;q()});if(v.init&&u.find("input[name=arrival]").val()===""&&v.resource&&v.resource>0){q()}function q(){u.find(".calendar").css("display","block");if(i.hasClass("hasDatepicker")){l(q)}else{u.find(".text .time").html("");data=false;slots=false;s();b();u.find(".arrival .text .date").addClass("important").html(er_date_picker_params.wait);u.find("input[name=slot]").val(-1);c(arrival?arrival:0);t()}}function d(){if(!done){if(departure){if(departureTime||!v.time){l(o);done=true}else{h()}}else{if(arrival){if(arrivalTime!==false||!v.time){if(v.departure){u.find(".departure .text .date").addClass("important").html(er_date_picker_params.wait);t()}else{if(i.hasClass("hasDatepicker")){l(d)}else{if(slots){const x=data[arrival][arrivalTime][0].departure.split(" ");const e=x[1].split(":");k(x[0]);w(e[0],e[1])}o()}done=true}}else{h()}}}}}function h(){const x=a.datepicker.formatDate("DD, d M yy",i.datepicker("getDate"));u.find("a.ui-state-active").parent().parent().after('<tr class="time-picker"><td colspan="7"><div>'+x+'<div class="insert"></div></div></td></tr>');let timeOptions="";if(slots){if(arrivalTime!==false){a.each(data[arrival][arrivalTime],function(A,z){const C=z.departure.split(" ");if(C[0]!==departure){return}const B=C[1].split(":"),D=z.availability<1?"unavailable":(z.availability<resourceQuantity?"partially":"available");let label=easyFormatTime(B[0],B[1],er_both_params.time_format);if(z.price){label+='<span class="price">('+z.price+")</span>"}timeOptions+='<li class="easy-button" data-hour="'+B[0]+'" data-minute="'+B[1]+'" data-id="'+z.key+'" class="'+D+'">'+label+"</li>"})}else{a.each(data[arrival],function(A,z){const B=A.split(":");a.each(z,function(D,C){const G=C.availability<1?"unavailable":(C.availability<resourceQuantity?"partially":"available");let label=easyFormatTime(B[0],B[1],er_both_params.time_format),attributes="";if(!v.departure){const F=C.departure.split(" ");const E=F[1].split(":");label+=" -";if(arrival!==F[0]){label+=" "+F[0]}label+=" "+easyFormatTime(E[0],E[1],er_both_params.time_format);if(C.price){label+='<span class="price">('+C.price+")</span>"}attributes+=' data-departure=" '+F[0]+'"';attributes+=' data-departure-hour=" '+E[0]+'"';attributes+=' data-departure-minute=" '+E[1]+'"'}timeOptions+='<li class="easy-button" data-hour="'+B[0]+'" data-minute="'+B[1]+'" data-id="'+C.key+'" class="'+G+'" '+attributes+">"+label+"</li>";if(v.departure){return false}})})}if(timeOptions!==""){u.find(".time-picker .insert").html('<ul class="option-buttons">'+timeOptions+"</ul>");u.find(".time-picker > td > div").slideDown(350);u.find("ul.option-buttons li").bind("click",function(){if(arrivalTime!==false){u.find("input[name=slot]").val(a(this).attr("data-id"));w(a(this).attr("data-hour"),a(this).attr("data-minute"))}else{if(!v.departure){u.find("input[name=slot]").val(a(this).attr("data-id"));k(a(this).attr("data-departure"));w(a(this).attr("data-departure-hour"),a(this).attr("data-departure-minute"))}p(a(this).attr("data-hour"),a(this).attr("data-minute"))}l(d)})}}else{if(data[departure?departure:arrival].availability&&data[departure?departure:arrival].availability===parseInt(data[departure?departure:arrival].availability,10)){u.find("div.time-prototype").contents().clone(true).appendTo(u.find(".time-picker .insert")).attr("disabled");let minMax;if(departure){minMax=data[departure].time}else{minMax=data[arrival].time}const y=data.first_possible.split(" ");if(y[0]===(departure?departure:arrival)){const e=y[1].split(":");minMax[0]=parseInt(minMax[0],10)<e[0]?parseInt(e[0],10):minMax[0]}u.find(".time-picker select[name=time_hour] option").each(function(){const z=parseInt(a(this).val());if(z<minMax[0]||z>minMax[1]){a(this).attr("disabled",true).prop("selected",false).css("display","none")}else{a(this).attr("disabled",false).css("display","block")}});u.find(".time-picker .apply-time").bind("click",function(){const z=u.find(".time-picker select[name=time_hour]");if(z.length>0){const A=parseInt(u.find(".time-picker select[name=time_minute]").val());if(arrivalTime!==false){w(z.val(),A)}else{p(z.val(),A);if(v.departure){c(arrival)}}l(d)}})}else{a.each(data[departure?departure:arrival].availability,function(A,z){const B=A.split(" ");const C=B[0].split(":");const D=z<1?"unavailable":(z<resourceQuantity?"partially":"available");timeOptions+='<div class="time-option '+D+'" data-hour="'+C[0]+'" data-minute="'+C[1]+'">'+easyFormatTime(C[0],C[1])+"</div>"});u.find(".time-picker .insert").html('<div class="option-buttons">'+timeOptions+"</div>");u.find(".time-picker .time-option.available, .time-picker .time-option.partially").bind("click",function(){if(arrivalTime!==false){w(a(this).attr("data-hour"),a(this).attr("data-minute"))}else{p(a(this).attr("data-hour"),a(this).attr("data-minute"));if(v.departure){c(arrival)}}l(d)})}u.find(".time-picker > td > div").slideDown(350)}}function t(x){let dateFormat="dd.mm.yy";if(er_both_params.date_format==="Y/m/d"){dateFormat="yy/mm/dd"}else{if(er_both_params.date_format==="m/d/Y"){dateFormat="mm/dd/yy"}else{if(er_both_params.date_format==="Y-m-d"){dateFormat="yy-mm-dd"}else{if(er_both_params.date_format==="d-m-Y"){dateFormat="dd-mm-yy"}}}}i.datepicker(a.extend({minDate:arrival?arrival:v.minDate,maxDate:x?x:null,dateFormat:dateFormat,numberOfMonths:v.numberOfMonths,beforeShowDay:j,onChangeMonthYear:function(y,A,z){if(!slots||(!arrivalTime&&v.time)||(arrival&&!v.time)){c(dateFormat.replace("dd","01").replace("mm",A).replace("yy",y))}u.find("div.time").slideUp(300);if(arrival&&(arrivalTime||!v.time)){b();u.find(".departure .text .date").addClass("important").html(er_date_picker_params.wait)}else{s();u.find(".arrival .text .date").addClass("important").html(er_date_picker_params.wait)}},onSelect:m},g)).datepicker("setDate",null).slideDown("300");const e=i.parent().parent();if(!pageLoad&&resourceQuantity&&i.hasClass("hasDatepicker")&&!e.isInViewport()){a([document.documentElement,document.body]).animate({scrollTop:e.offset().top-30},500)}pageLoad=false;i.find(".ui-datepicker").removeClass("ui-datepicker").addClass("easy-datepicker");i.find(".ui-state-active").removeClass("ui-state-highlight").removeClass("ui-state-hover").removeClass("ui-state-active");a.each(er_date_picker_params.datepicker,function(z,y){i.datepicker("option",z,a.parseJSON(y))})}function s(){arrival=false;arrivalTime=false;u.find(".arrival .text .date").addClass("important").html(er_date_picker_params.select);u.find(".arrival .text .time").html("");u.find("input[name=arrival]").val("");u.find("input[name=departure_hour]").val("");u.find("input[name=departure_minute]").val("")}function b(){departure=false;departureTime=false;done=false;if(arrival){u.find(".departure .text .date").addClass("important").html(er_date_picker_params.select)}else{u.find(".departure .text .date").removeClass("important").html("—")}u.find(".departure .text .time").html("");u.find("input[name=departure]").val("");u.find("input[name=departure_hour]").val("");u.find("input[name=departure_minute]").val("");u.find(".departure").removeClass("active")}function r(e){arrival=e;u.find(".arrival .text .date").removeClass("important").html(e);u.find("input[name=arrival]").val(e);u.find("input[name=arrival_hour]").val("");u.find("input[name=arrival_minute]").val("")}function k(e){departure=e;u.find("input[name=departure]").val(e);u.find(".departure").addClass("active");u.find(".departure .text .date").removeClass("important").html(e)}function p(e,y,x){e=easyAddZero(e);y=easyAddZero(y);if(!x){x=easyFormatTime(e,y)}arrivalTime=e+":"+y;u.find("input[name=arrival_hour]").val(e);u.find("input[name=arrival_minute]").val(y);u.find(".arrival .text .time").html(x)}function w(e,y,x){e=easyAddZero(e);y=easyAddZero(y);if(!x){x=easyFormatTime(e,y)}departureTime=e+":"+y;u.find("input[name=departure_hour]").val(e);u.find("input[name=departure_minute]").val(y);u.find(".departure .text .time").html(x)}function m(z,e){if(arrival&&(arrivalTime!==false||!v.time)){if(departure===z){b();u.find(".time-picker > td > div").slideUp(50,function(){i.find(".ui-state-active").removeClass("ui-state-highlight").removeClass("ui-state-active")});return false}k(z);if(v.time){setTimeout(h,1)}else{if(slots){const x=false;a.each(data[arrival][arrivalTime],function(B,A){const D=A.departure.split(" ");if(departure===D[0]){const C=D.split(":");w(C[0],C[1]);return false}})}else{w(v.departureHour?v.departureHour:data[departure].time[0],v.departureMinute?v.departureMinute:0)}l(d)}}else{if(arrival===z){s();u.find(".time-picker > td > div").slideUp(50,function(){i.find(".ui-state-active").removeClass("ui-state-highlight").removeClass("ui-state-active")});return false}r(z);if(v.time){setTimeout(h,1)}else{let hour=12,minute=v.arrivalHour?v.arrivalMinute:0;if(slots){const y=Object.keys(data[arrival])[0].split(":");hour=y[0];minute=y[1]}else{hour=v.arrivalHour?v.arrivalHour:data[arrival].time[1]}p(hour,minute);if(v.departure){u.find(".departure .text .date").addClass("important").html(er_date_picker_params.wait);c(arrival)}l(d)}}}function l(e){i.slideUp(350,function(){a(this).datepicker("destroy").removeClass("hasDatepicker").removeAttr("id");if(e){e()}})}function j(x){let className="";if(data){const e=easyFormatDate(x,false);if(slots&&arrival&&arrivalTime!==false){if(easyStringToDate(arrival)>x){return[false,"past",""]}let toReturn=[false,"unavailable",""],iterate;if(arrivalTime!==false&&v.time){iterate=data[arrival][arrivalTime]}else{iterate=data[arrival][Object.keys(data[arrival])[0]]}a.each(iterate,function(z,y){const A=y.departure.split(" ");if(A[0]===e){toReturn=[true,"available",""];return true}});return toReturn}if(data.hasOwnProperty(e)){if(data[e].price){className="datepicker-content-"+data[e].price.hashCode();if(a.inArray(className,n)===-1){a("head").append("<style>.easy-date-selection td."+className+" a:after {content: '"+data[e].price+"'}</style>");n.push(className)}}else{if(v.price&&!slots&&frequency===86400){className="price-placeholder"}}if(data[e].availability&&data[e].availability===parseInt(data[e].availability,10)){if(data[e].availability<0){return[false,"unavailable rule "+className,""]}if(data[e].availability<1){return[false,"unavailable "+className,""]}if(data[e].availability<resourceQuantity){return[true,"partially "+className,""]}}else{let amountAvailable=0,hasAvailableSlot=false,total;if(slots){total=data[e][Object.keys(data[e])[0]];a.each(total,function(z,y){if(y.availability>0){hasAvailableSlot=true;amountAvailable++}})}else{total=data[e].availability;a.each(total,function(z,y){if(y>0){hasAvailableSlot=true;amountAvailable++}})}if(!hasAvailableSlot){return[false,"unavailable "+className,""]}if(Object.keys(total).length>amountAvailable){return[true,"partially "+className,""]}}return[true,"available "+className,""]}}if(v.price&&!slots&&frequency===86400){className="price-placeholder"}return[false,"past "+className,""]}function c(x){const e=Date.now(),y={action:"easyreservations_calendar",date:x===0?0:x,arrival:arrival&&(arrivalTime!==false||!v.time)?arrival:0,arrivalTime:arrivalTime,months:v.numberOfMonths,adults:a("*[name=adults]").val(),children:a("*[name=children]").val(),resource:v.resource,price:v.price,minDate:v.minDate,security:u.find('input[name="easy-date-selection-nonce"]').val()};lastRequest=e;data=false;if(!y.resource){alert("no resource field in form, please fix");return}a.post(er_both_params.ajaxurl,y,function(z){if(lastRequest===e){if(arrival&&(arrivalTime||!v.time)){u.find(".departure .text .date").addClass("important").html(er_date_picker_params.select)}else{u.find(".arrival .text .date").html(er_date_picker_params.select)}data=z;slots=data.hasOwnProperty("slots")&&data.slots;const A=data.first_possible.split(" ");if(arrival){i.datepicker("option","minDate",A[0])}if(data.hasOwnProperty("max")&&data.max){i.datepicker("refresh")}else{i.datepicker("refresh")}i.find(".ui-datepicker-today a, .ui-datepicker-current-day a").removeClass("ui-state-highlight").removeClass("ui-state-hover").removeClass("ui-state-active")}})}function o(){u.find("input[name=arrival]").trigger("change")}}}(jQuery));Object.defineProperty(String.prototype,"hashCode",{value:function(){var c=0,a,b;for(a=0;a<this.length;a++){b=this.charCodeAt(a);c=((c<<5)-c)+b;c|=0}return c}}); -
easyreservations/trunk/easyReservations.php
r2290893 r2408218 4 4 Plugin URI: http://www.easyreservations.org 5 5 Description: This powerful property and reservation management plugin allows you to receive, schedule and handle your bookings easily! 6 Version: 6.0-alpha.1 36 Version: 6.0-alpha.14 7 7 Author: Feryaz Beer 8 8 Author URI: http://www.feryaz.de -
easyreservations/trunk/includes/admin/views/html-admin-resource-filter-add.php
r2267583 r2408218 206 206 </label> 207 207 </th> 208 <td style="line-height: 20px">208 <td onclick="jQuery('#price_filter_cond_unit').attr('checked', true);" style="line-height: 20px"> 209 209 <span> 210 210 <i> … … 233 233 </label> 234 234 </th> 235 <td style="line-height: 20px">235 <td onclick="jQuery('#price_filter_cond_unit').attr('checked', true);" style="line-height: 20px"> 236 236 <span style=""> 237 237 <i> … … 314 314 </label> 315 315 </th> 316 <td style="line-height: 20px">316 <td onclick="jQuery('#price_filter_cond_unit').attr('checked', true);" style="line-height: 20px"> 317 317 <span> 318 318 <i> … … 370 370 </label> 371 371 </th> 372 <td style="line-height: 20px">372 <td onclick="jQuery('#price_filter_cond_unit').attr('checked', true);" style="line-height: 20px"> 373 373 <span> 374 374 <i> … … 390 390 </label> 391 391 </th> 392 <td style="line-height: 20px">392 <td onclick="jQuery('#price_filter_cond_unit').attr('checked', true);" style="line-height: 20px"> 393 393 <div> 394 394 <label style="width:75px"><input type="checkbox" name="price_filter_unit_year[]" value="2023">2023</label> -
easyreservations/trunk/includes/admin/views/html-timeline.php
r2262833 r2408218 5 5 6 6 $resources = ER()->resources()->get_accessible(); 7 7 8 ?> 8 9 <div class="er-timeline-tooltip"></div> -
easyreservations/trunk/includes/class-easyreservations.php
r2290893 r2408218 19 19 * @var string 20 20 */ 21 public $version = '6.0-alpha.1 3';21 public $version = '6.0-alpha.14'; 22 22 23 23 /** -
easyreservations/trunk/includes/class-er-ajax.php
r2290893 r2408218 216 216 217 217 $days = array(); 218 $occupied_spaces = array(); 218 219 $was_unavailable = false; 219 220 $earliest_possible_arrival = new DateTimeImmutable( wp_date( 'd.m.Y H:i' ) ); … … 439 440 440 441 if ( ! $was_unavailable && $req['nights-min'] <= $billing_units ) { 441 $avail = $availability->check_arrivals_and_departures( $resource->availability_by( 'unit' ) ? $arrival : $last_departure, $departure, 'departure' ); 442 442 $avail = $availability->check_spaces( $resource->availability_by( 'unit' ) ? $arrival : $last_departure, $departure, 'departure' ); 443 443 444 444 if ( $display_price ) { … … 462 462 $avail = is_numeric( $avail ) ? $quantity : $quantity + 1; 463 463 } else { 464 if ( $avail->count_all >= $quantity ) { 465 $avail->count_all = $avail->count_all + $avail->arrival - $avail->departure; 466 464 if ( count($avail->count_all) >= $quantity ) { 467 465 //[0] Minimum departure time 468 466 //[1] Maximum departure time -
easyreservations/trunk/includes/class-er-checkout.php
r2290893 r2408218 520 520 ER()->session->set( 'order_awaiting_payment', false ); 521 521 } 522 522 523 er_empty_cart(); 523 524 -
easyreservations/trunk/includes/class-er-form-handler.php
r2290893 r2408218 342 342 return; 343 343 } 344 var_dump( 354 );345 344 346 345 // Update payment method. -
easyreservations/trunk/includes/class-er-resource-availability.php
r2262833 r2408218 306 306 } 307 307 308 $day = $arrival->format( "Y-m-d" ); 309 310 if ( $this->per_person ) { 311 $sql = $wpdb->prepare( 312 "SELECT SUM(CASE WHEN arrival >= %s AND arrival <= %s THEN {$this->per_person} END) AS arrival, " . 313 "SUM(CASE WHEN departure >= %s AND departure <= %s THEN {$this->per_person} END) AS departure, " . 314 "SUM({$this->per_person}) AS count_all, " . 315 "MAX(CASE WHEN arrival >= %s AND arrival <= %s THEN arrival END) AS max_arrival, " . 316 "MIN(CASE WHEN departure >= %s AND departure <= %s THEN departure END) as min_departure " . 317 "FROM {$wpdb->prefix}reservations WHERE {$this->status} AND {$this->resource_query} %s <= {$this->departure} AND %s >= {$this->arrival}", 318 $day . ' 00:00:00', 319 $day . ' 23:59:59', 320 $day . ' 00:00:00', 321 $day . ' 23:59:59', 322 $day . ' 00:00:00', 323 $day . ' 23:59:59', 324 $day . ' 00:00:00', 325 $day . ' 23:59:59', 326 $arrival->format( "Y-m-d" ) . ' 00:00:00', 327 $departure->format( "Y-m-d" ) . ' 23:59:59' 328 ); 329 330 $result = $wpdb->get_row( $sql ); 331 } else { 332 $sql = $wpdb->prepare( 333 "SELECT COUNT((CASE WHEN arrival >= %s AND arrival <= %s THEN space END)) AS arrival, " . 334 "COUNT((CASE WHEN departure >= %s AND departure <= %s THEN space END)) AS departure, " . 335 "COUNT(DISTINCT space) AS count_all, " . 336 "MAX(CASE WHEN arrival >= %s AND arrival <= %s THEN arrival END) AS max_arrival, " . 337 "MIN(CASE WHEN departure >= %s AND departure <= %s THEN departure END) as min_departure " . 338 "FROM {$wpdb->prefix}reservations WHERE {$this->status} AND {$this->resource_query} %s <= {$this->departure} AND %s >= {$this->arrival}", 339 $day . ' 00:00:00', 340 $day . ' 23:59:59', 341 $day . ' 00:00:00', 342 $day . ' 23:59:59', 343 $day . ' 00:00:00', 344 $day . ' 23:59:59', 345 $day . ' 00:00:00', 346 $day . ' 23:59:59', 347 $arrival->format( "Y-m-d H:i:s" ), 348 $departure->format( "Y-m-d H:i:s" ) 349 ); 350 351 $result = $wpdb->get_row( $sql ); 352 } 353 354 return $result; 355 } 356 357 /** 358 * Check spaces 359 * 360 * @param ER_DateTime $arrival 361 * @param ER_DateTime $departure 362 * @param bool|string $check_arrivals_and_departures 363 * 364 * @return object|int|string 365 */ 366 public function check_spaces( $arrival, $departure, $check_arrivals_and_departures = true ) { 367 global $wpdb; 368 369 $filter = $this->check_filter( $arrival, $departure, false, $check_arrivals_and_departures ); 370 if ( $filter !== 0 ) { 371 return $filter; 372 } 373 308 374 $check_from = $arrival->format( "Y-m-d H:i:s" ); 309 375 $check_until = $departure->format( "Y-m-d H:i:s" ); … … 330 396 "SELECT COUNT(DISTINCT(CASE WHEN DATE(arrival) = DATE(%s) THEN space END)) AS arrival, " . 331 397 "COUNT(DISTINCT(CASE WHEN DATE(departure) = DATE(%s) THEN space END)) AS departure, " . 332 "COUNT(DISTINCT space) AS count_all, " .398 "COUNT(DISTINCT(CASE WHEN DATE(arrival) != DATE(%s) THEN space END)) AS count_all, " . 333 399 "MAX(CASE WHEN DATE(arrival) = DATE(%s) THEN arrival END) AS max_arrival, " . 334 400 "MIN(CASE WHEN DATE(departure) = DATE(%s) THEN departure END) as min_departure " . 335 401 "FROM {$wpdb->prefix}reservations WHERE {$this->status} AND {$this->resource_query} %s <= {$this->departure} AND %s >= {$this->arrival}", 336 $check_from, 337 $check_from, 338 $check_from, 339 $check_from, 402 $check_until, 403 $check_until, 404 $check_until, 405 $check_until, 406 $check_until, 340 407 $check_from, 341 408 $check_until … … 363 430 $billing_units = $this->resource->get_frequency_units( $arrival, $departure, $this->interval ); 364 431 365 for ( $i = 0; $i < =$billing_units; $i ++ ) {432 for ( $i = 0; $i < $billing_units; $i ++ ) { 366 433 if ( isset( $error[ $i ] ) ) { 367 434 continue; … … 398 465 $count = $wpdb->get_col( 399 466 $wpdb->prepare( 400 "SELECT DISTINCT(space) as spaces , SUM(adults+children) as personsFROM {$wpdb->prefix}reservations " .467 "SELECT DISTINCT(space) as spaces FROM {$wpdb->prefix}reservations " . 401 468 "WHERE {$this->status} AND {$this->resource_query} {$this->space} (%s < {$this->departure} AND %s > {$this->arrival}) GROUP BY spaces", 402 469 array( $date_to_check, $date_to_check ) -
easyreservations/trunk/includes/class-er-resources.php
r2290893 r2408218 111 111 FROM {$wpdb->prefix}posts 112 112 WHERE post_type = 'easy-rooms' AND post_status != 'auto-draft' 113 ORDER BY menu_order ASC"113 ORDER BY menu_order, ID ASC" 114 114 ); 115 115 -
easyreservations/trunk/includes/class-er-template-loader.php
r2262833 r2408218 197 197 * @return string 198 198 */ 199 public static function unsupported_theme_title_filter( $title, $id ) {199 public static function unsupported_theme_title_filter( $title, $id = null ) { 200 200 if ( self::$theme_support || ! $id !== self::$shop_page_id ) { 201 201 return $title; -
easyreservations/trunk/includes/emails/class-er-email.php
r2262833 r2408218 918 918 $local_file = $this->get_theme_template_file( $template ); 919 919 $core_file = $this->template_base . $template; 920 $template_file = apply_filters( 'easyreservations_locate_core_template', $ core_file, $template, $this->template_base, $this->id );920 $template_file = apply_filters( 'easyreservations_locate_core_template', $this->template_base, $template, $this->id ); 921 921 $template_dir = apply_filters( 'easyreservations_template_directory', 'easyReservations', $template ); 922 922 ?> 923 923 <div class="template <?php echo esc_attr( $template_type ); ?>"> 924 924 <h4><?php echo wp_kses_post( $title ); ?></h4> 925 926 925 <?php if ( file_exists( $local_file ) ) : ?> 927 926 <p> -
easyreservations/trunk/includes/er-order-functions.php
r2262833 r2408218 591 591 592 592 /** 593 * Search orders. 594 * 595 * @param string $term Term to search. 596 * 597 * @return array List of orders ID. 598 */ 599 function esr_order_search( $term ) { 600 $data_store = ER_Data_Store::load( 'order' ); 601 602 return $data_store->search_orders( str_replace( 'Order #', '', er_clean( $term ) ) ); 603 } 604 605 /** 593 606 * Create a new order refund programmatically. 594 607 * -
easyreservations/trunk/includes/updates/easyreservations-update-4.0.php
r2262833 r2408218 18 18 } 19 19 20 $dummy = new easyReservations_form_widget();21 $settings = $dummy->get_settings();22 $changed = false;23 foreach ( $settings as $k => $setting ) {24 if ( isset( $setting['form_editor'] ) ) {25 $changed = true;26 add_option( 'reservations_form_old-widget-' . $k, html_entity_decode( str_replace( '<br>', "\n", $setting['form_editor'] ) ), false, false );27 $settings[ $k ]['form_template'] = 'old-widget-' . $k;28 unset( $settings[ $k ]['form_editor'] );29 }30 }31 if ( $changed ) {32 $dummy->save_settings( $settings );33 }34 35 20 $the_search_bar = get_option( 'reservations_search_bar' ); 36 21 if ( $the_search_bar && ! empty( $the_search_bar ) ) { -
easyreservations/trunk/readme.txt
r2290893 r2408218 54 54 55 55 == Changelog == 56 57 = 6.0-alpha.14 - 2020-10-28 = 58 * Enhancement - Display of possible departure dates in calendar 59 * Enhancement - Order of resources if no menu order is defined 60 * Fix - Email settings overridden templates 61 * Fix - Center view on calendar in form 62 * Fix - Wrong month after selecting arrival 56 63 57 64 = 6.0-alpha.13 - 2020-04-24 =
Note: See TracChangeset
for help on using the changeset viewer.