// source --> http://www.airpark.it/wp-content/plugins/booking-car-park/js/timepicker/jquery.timepicker.min.js
(function(e){typeof define=="function"&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function o(e){e.minTime&&(e.minTime=S(e.minTime)),e.maxTime&&(e.maxTime=S(e.maxTime)),e.durationTime&&typeof e.durationTime!="function"&&(e.durationTime=S(e.durationTime));if(e.disableTimeRanges.length>0){for(var t in e.disableTimeRanges)e.disableTimeRanges[t]=[S(e.disableTimeRanges[t][0]),S(e.disableTimeRanges[t][1])];e.disableTimeRanges=e.disableTimeRanges.sort(function(e,t){return e[0]-t[0]})}return e}function u(t){var r=t.data("timepicker-settings"),i=t.data("timepicker-list");i&&i.length&&(i.remove(),t.data("timepicker-list",!1)),i=e("
",{"class":"ui-timepicker-list"});var o=e("",{"class":"ui-timepicker-wrapper",tabindex:-1});o.css({display:"none",position:"absolute"}).append(i),r.className&&o.addClass(r.className),(r.minTime!==null||r.durationTime!==null)&&r.showDuration&&o.addClass("ui-timepicker-with-duration");var u=r.minTime;typeof r.durationTime=="function"?u=S(r.durationTime()):r.durationTime!==null&&(u=r.durationTime);var a=r.minTime!==null?r.minTime:0,f=r.maxTime!==null?r.maxTime:a+n-1;f<=a&&(f+=n);var l=r.disableTimeRanges,c=0,p=l.length;for(var d=a;d<=f;d+=r.step*60){var v=d%n,m=e("");m.data("time",v),m.text(E(v,r.timeFormat));if((r.minTime!==null||r.durationTime!==null)&&r.showDuration){var g=e("");g.addClass("ui-timepicker-duration"),g.text(" ("+w(d-u)+")"),m.append(g)}c=l[c][0]&&v=l[c][1]&&(c+=1)),i.append(m)}o.data("timepicker-input",t),t.data("timepicker-list",o);var y=r.appendTo;typeof y=="string"?y=e(y):typeof y=="function"&&(y=y(t)),y.append(o),h(t,i),i.on("click","li",function(n){t.off("focus.timepicker"),t.on("focus.timepicker-ie-hack",function(){t.off("focus.timepicker-ie-hack"),t.on("focus.timepicker",s.show)}),t[0].focus(),i.find("li").removeClass("ui-timepicker-selected"),e(this).addClass("ui-timepicker-selected"),b(t)&&o.hide()})}function a(){return new Date(1970,1,1,0,0,0)}function f(t){"ontouchstart"in document?e("body").on("touchstart.ui-timepicker",l):(e("body").on("mousedown.ui-timepicker",l),t.closeOnWindowScroll&&e(window).on("scroll.ui-timepicker",l))}function l(t){var n=e(t.target),r=n.closest(".ui-timepicker-input");r.length===0&&n.closest(".ui-timepicker-wrapper").length===0&&(s.hide(),e("body").unbind(".ui-timepicker"),e(window).unbind(".ui-timepicker"))}function c(t,n,r){if(!r&&r!==0)return!1;var i=t.data("timepicker-settings"),s=!1,o=i.step*30;return n.find("li").each(function(t,n){var i=e(n),u=i.data("time")-r;if(Math.abs(u)t.outerHeight()||i<0)&&t.scrollTop(t.scrollTop()+r.position().top-r.outerHeight()),r.addClass("ui-timepicker-selected")}}function p(){if(this.value==="")return;var t=e(this),n=S(this.value);if(n===null){t.trigger("timeFormatError");return}var r=t.data("timepicker-settings");r.minTime!==null&&nr.maxTime&&t.trigger("timeRangeError"),e.each(r.disableTimeRanges,function(){if(n>=this[0]&&n=r.step*30?n+=r.step*60-i:n-=i}var s=E(n,r.timeFormat);v(t,s)}function d(e){return e.is("input")?e.val():e.data("ui-timepicker-value")}function v(e,t){e.is("input")?e.val(t):e.data("ui-timepicker-value",t)}function m(t){var n=e(this),r=n.data("timepicker-list");if(!r||!r.is(":visible")){if(t.keyCode!=40)return g(t,n);n.focus()}switch(t.keyCode){case 13:return b(n)&&s.hide.apply(this),t.preventDefault(),!1;case 38:var i=r.find(".ui-timepicker-selected");return i.length?i.is(":first-child")||(i.removeClass("ui-timepicker-selected"),i.prev().addClass("ui-timepicker-selected"),i.prev().position().top0)return i=e(n),!1}),i.addClass("ui-timepicker-selected")),!1;case 40:return i=r.find(".ui-timepicker-selected"),i.length===0?(r.find("li").each(function(t,n){if(e(n).position().top>0)return i=e(n),!1}),i.addClass("ui-timepicker-selected")):i.is(":last-child")||(i.removeClass("ui-timepicker-selected"),i.next().addClass("ui-timepicker-selected"),i.next().position().top+2*i.outerHeight()>r.outerHeight()&&r.scrollTop(r.scrollTop()+i.outerHeight())),!1;case 27:r.find("li").removeClass("ui-timepicker-selected"),r.hide();break;case 9:s.hide();break;default:return g(t,n)}}function g(e,t){return!t.data("timepicker-settings").disableTextInput||e.ctrlKey||e.altKey||e.metaKey||e.keyCode!=2&&(e.keyCode<46||e.keyCode>90)}function y(t){var n=e(this),r=n.data("timepicker-list");if(!r||!r.is(":visible"))return!0;switch(t.keyCode){case 96:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 65:case 77:case 80:case 186:case 8:case 46:h(n,r);break;default:return}}function b(e){var t=e.data("timepicker-settings"),n=e.data("timepicker-list"),r=null,i=n.find(".ui-timepicker-selected");if(i.hasClass("ui-timepicker-disabled"))return!1;i.length?r=i.data("time"):d(e)&&(r=S(d(e)),h(e,n));if(r!==null){var s=E(r,t.timeFormat);v(e,s)}return e.trigger("change").trigger("changeTime"),!0}function w(e){var t=Math.round(e/60),n;if(Math.abs(t)<60)n=[t,i.mins];else if(t==60)n=["1",i.hr];else{var r=(t/60).toFixed(1);i.decimal!="."&&(r=r.replace(".",i.decimal)),n=[r,i.hrs]}return n.join(" ")}function E(e,n){if(e===null)return;var r=new Date(t.valueOf()+e*1e3),i="",s,o;for(var u=0;u11?"pm":"am";break;case"A":i+=r.getHours()>11?"PM":"AM";break;case"g":s=r.getHours()%12,i+=s===0?"12":s;break;case"G":i+=r.getHours();break;case"h":s=r.getHours()%12,s!==0&&s<10&&(s="0"+s),i+=s===0?"12":s;break;case"H":s=r.getHours(),i+=s>9?s:"0"+s;break;case"i":var a=r.getMinutes();i+=a>9?a:"0"+a;break;case"s":e=r.getSeconds(),i+=e>9?e:"0"+e;break;default:i+=o}}return i}function S(e){if(e==="")return null;if(!e||e+0==e)return e;typeof e=="object"&&(e=e.getHours()+":"+x(e.getMinutes())+":"+x(e.getSeconds())),e=e.toLowerCase();var t=new Date(0),n;e.indexOf(":")===-1?(n=e.match(/^([0-9]):?([0-5][0-9])?:?([0-5][0-9])?\s*([pa]?)m?$/),n||(n=e.match(/^([0-2][0-9]):?([0-5][0-9])?:?([0-5][0-9])?\s*([pa]?)m?$/))):n=e.match(/^(\d{1,2})(?::([0-5][0-9]))?(?::([0-5][0-9]))?\s*([pa]?)m?$/);if(!n)return null;var r=parseInt(n[1]*1,10),i;n[4]?r==12?i=n[4]=="p"?12:0:i=r+(n[4]=="p"?12:0):i=r;var s=n[2]*1||0,o=n[3]*1||0;return i*3600+s*60+o}function x(e){return("0"+e).slice(-2)}var t=a(),n=86400,r={className:null,minTime:null,maxTime:null,durationTime:null,step:30,showDuration:!1,timeFormat:"g:ia",scrollDefaultNow:!1,scrollDefaultTime:!1,selectOnBlur:!1,disableTouchKeyboard:!0,forceRoundTime:!1,appendTo:"body",disableTimeRanges:[],closeOnWindowScroll:!1,disableTextInput:!1},i={decimal:".",mins:"mins",hr:"hr",hrs:"hrs"},s={init:function(t){return this.each(function(){var n=e(this);if(n[0].tagName=="SELECT"){var u={type:"text",value:n.val()},a=n[0].attributes;for(var f=0;f",u);n.replaceWith(l),n=l}var c=e.extend({},r);t&&(c=e.extend(c,t)),c.lang&&(i=e.extend(i,c.lang)),c=o(c),n.data("timepicker-settings",c),n.prop("autocomplete","off"),n.on("click.timepicker focus.timepicker",s.show),n.on("blur.timepicker",p),n.on("keydown.timepicker",m),n.on("keyup.timepicker",y),n.addClass("ui-timepicker-input"),p.call(n.get(0))})},show:function(t){var n=e(this),r=n.data("timepicker-settings");"ontouchstart"in document&&r.disableTouchKeyboard&&n.blur();var i=n.data("timepicker-list");if(n.prop("readonly"))return;if(!i||i.length===0||typeof r.durationTime=="function")u(n),i=n.data("timepicker-list");if(i.is(":visible"))return;s.hide(),i.show(),n.offset().top+n.outerHeight(!0)+i.outerHeight()>e(window).height()+e(window).scrollTop()?i.offset({left:n.offset().left+parseInt(i.css("marginLeft").replace("px",""),10),top:n.offset().top-i.outerHeight()+parseInt(i.css("marginTop").replace("px",""),10)}):i.offset({left:n.offset().left+parseInt(i.css("marginLeft").replace("px",""),10),top:n.offset().top+n.outerHeight()+parseInt(i.css("marginTop").replace("px",""),10)});var o=i.find(".ui-timepicker-selected");o.length||(d(n)?o=c(n,i,S(d(n))):r.scrollDefaultNow?o=c(n,i,S(new Date)):r.scrollDefaultTime!==!1&&(o=c(n,i,S(r.scrollDefaultTime))));if(o&&o.length){var a=i.scrollTop()+o.position().top-o.outerHeight();i.scrollTop(a)}else i.scrollTop(0);f(r),n.trigger("showTimepicker")},hide:function(t){e(".ui-timepicker-wrapper:visible").each(function(){var t=e(this),n=t.data("timepicker-input"),r=n.data("timepicker-settings");r&&r.selectOnBlur&&b(n),t.hide(),n.trigger("hideTimepicker")})},option:function(t,n){var r=this,i=r.data("timepicker-settings"),s=r.data("timepicker-list");if(typeof t=="object")i=e.extend(i,t);else if(typeof t=="string"&&typeof n!="undefined")i[t]=n;else if(typeof t=="string")return i[t];return i=o(i),r.data("timepicker-settings",i),s&&(s.remove(),r.data("timepicker-list",!1)),r},getSecondsFromMidnight:function(){return S(d(this))},getTime:function(){var e=this,t=new Date;return t.setHours(0,0,0,0),new Date(t.valueOf()+S(d(e))*1e3)},setTime:function(e){var t=this,n=E(S(e),t.data("timepicker-settings").timeFormat);v(t,n)},remove:function(){var e=this;if(!e.hasClass("ui-timepicker-input"))return;e.removeAttr("autocomplete","off"),e.removeClass("ui-timepicker-input"),e.removeData("timepicker-settings"),e.off(".timepicker"),e.data("timepicker-list")&&e.data("timepicker-list").remove(),e.removeData("timepicker-list")}};e.fn.timepicker=function(t){if(s[t])return s[t].apply(this,Array.prototype.slice.call(arguments,1));if(typeof t=="object"||!t)return s.init.apply(this,arguments);e.error("Method "+t+" does not exist on jQuery.timepicker")}});
// source --> http://www.airpark.it/wp-content/plugins/booking-car-park/js/booking-car-park.js
var is_show_cost_in_tooltips = false;
var is_show_availability_in_tooltips = false;
var global_avalaibility_times = [];
var wp_bcp_calendarViewMode = '';
var numbb = 0;
var is_use_visitors_number_for_availability;
var timeoutID_of_thank_you_page = null;
/**
* Show Yes/No dialog
* @param {type} message_question
* @returns {Boolean}
*/
function bcpAreYouSure(message_question)
{
var answer = confirm(message_question);
if (answer) {
return true;
}
else {
return false;
}
}
/**
* Show Yes/No with reason dialog
* @param {type} message_question
* @returns {Boolean}
*/
function bcpAreYouSureReason(message_question)
{
var answer = prompt(message_question, "Inserire il motivo");
if (answer !== null && answer !== '')
{
return answer;
}
else
{
return '';
}
}
/**
* Set Booking listing row as Read
* @param {type} bcp_id
* @returns {undefined}
*/
function bcpSetBookingRowRead(bcp_id)
{
jQuery('#booking_mark_' + bcp_id + '').addClass('hidden_items');
bcpDecreseNewCounter();
}
/**
* Set Booking listing row as UnRead
* @param {type} bcp_id
* @returns {undefined}
*/
function bcpSetBookingRowUnread(bcp_id) {
jQuery('#booking_mark_' + bcp_id + '').removeClass('hidden_items');
bcpIncreaseNewCounter();
}
/**
*
* @returns {undefined}
*/
function bcpIncreaseNewCounter()
{
var my_num = parseInt(jQuery('.bk-update-count').html());
my_num = my_num + 1;
jQuery('.bk-update-count').html(my_num);
}
/**
*
* @returns {undefined}
*/
function bcpDecreseNewCounter()
{
var my_num = parseInt(jQuery('.bk-update-count').html());
if (my_num > 0) {
my_num = my_num - 1;
jQuery('.bk-update-count').html(my_num);
}
}
/**
* Set Booking listing ROW Payement OK
* @param {type} bcp_id
* @param {type} payed_status
* @returns {undefined}
*/
function bcpSetBookingRowPayment(bcp_id, payed_status)
{
for (id = 0; id < 4; id++)
{
if (id === payed_status)
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-payment-status' + id).removeClass('hidden_items');
else
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-payment-status' + id).addClass('hidden_items');
}
}
/**
* Set Booking listing ROW Approved
* @param {type} bcp_id
* @returns {undefined}
*/
function bcpSetBookingRowApproved(bcp_id)
{
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-approved').removeClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-pending').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-notice').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-dates .field-booking-date').addClass('approved');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .approve_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .pending_bcp_link').removeClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking_checkinout .checkin_bcp_link').removeClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking_checkinout .checkout_bcp_link').addClass('hidden_items');
}
/**
* Set Booking listing ROW Pending
* @param {type} bcp_id
* @returns {undefined}
*/
function bcpSetBookingRowPending(bcp_id)
{
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-approved').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-pending').removeClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-notice').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-dates .field-booking-date').removeClass('approved');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .approve_bcp_link').removeClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .pending_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking_checkinout .checkin_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking_checkinout .checkout_bcp_link').addClass('hidden_items');
}
/**
*
* @param {type} bcp_id
* @returns {undefined}
*/
function bcpSetBookingCheckedin(bcp_id,date,time)
{
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-approved').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-notice').removeClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-success').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking_checkinout .checkin_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking_checkinout .checkout_bcp_link').removeClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .approve_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .pending_bcp_link').addClass('hidden_items');
//jQuery('#booking_row_' + bcp_id + ' .booking_dates_small .checkin').html(date + ' ' + time + '');
}
function bcpSetBookingCheckedout(bcp_id,date,time,cost)
{
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-approved').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-notice').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-success').removeClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking_checkinout .checkin_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking_checkinout .checkout_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .approve_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .pending_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .cancel_bcp_link').addClass('hidden_items');
//jQuery('#booking_row_' + bcp_id + ' .booking_dates_small .checkout').html(date + ' ' + time + '');
//jQuery('#booking_row_' + bcp_id + ' .booking-actions .field-currency').html('€ ' + cost);
}
/**
* Remove Booking listing ROW
* @param {type} bcp_id
* @returns {undefined}
*/
function bcpSetBookingRowCanceled(bcp_id)
{
jQuery('#booking_mark_' + bcp_id).addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking_list_item_checkbox').parent().parent().removeClass('row_selected_color');
jQuery('#booking_row_' + bcp_id + ' .booking-listing-collumn .booking_list_item_checkbox').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-listing-collumn .booking_list_item_checkbox').removeClass('booking_list_item_checkbox');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-approved').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-notice').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-pending').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-important').removeClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-payment-status').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-dates .field-booking-date').removeClass('approved');
jQuery('#booking_row_' + bcp_id + ' .booking_checkinout .checkin_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking_checkinout .checkout_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .approve_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .pending_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .cancel_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .edit_bcp_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id + ' .booking-actions .payment_status_bk_link').addClass('hidden_items');
jQuery('#booking_row_' + bcp_id).css({ // this is just for style
"opacity": "0.5"
});
jQuery('#booking_row_' + bcp_id + ' .place_number').html('-');
jQuery('#booking_row_' + bcp_id + ' .place_number').removeClass('label-notice');
jQuery('#booking_row_' + bcp_id + ' .place_number').removeClass('label-success');
}
function bcpSetCarPlaces(bcp_id,places,check)
{
jQuery('#booking_row_' + bcp_id + ' .place_number').removeClass('place_warning');
jQuery('#booking_row_' + bcp_id + ' .place_number').html(places);
jQuery('#booking_row_' + bcp_id + ' .place_number')
.fadeOut(350).fadeIn(400)
.fadeOut(350).fadeIn(400)
.fadeOut(350).fadeIn(400)
.fadeOut(350).fadeIn(400)
.fadeOut(350).fadeIn(400)
;
if (check === 2)
jQuery('#booking_row_' + bcp_id + ' .place_number').addClass('label-notice');
else if (check === 3)
jQuery('#booking_row_' + bcp_id + ' .place_number').addClass('label-success');
}
// Set in Booking listing R O W Resource title
function bcpSetBookingRowResourceName(bcp_id, resourcename)
{
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-resource').html(resourcename);
}
/**
* Set in Booking listing ROW new Remark in hint
* @param {type} bcp_id
* @param {type} new_remark
* @returns {undefined}
*/
function bcpSetBookingRowRemarkInHint(bcp_id, new_remark)
{
jQuery('#booking_row_' + bcp_id + ' .booking-actions .remark_bk_link').attr('data-original-title', new_remark);
var my_img = jQuery('#booking_row_' + bcp_id + ' .booking-actions .remark_bk_link img').attr('src');
var check_my_img = my_img.substr(my_img.length - 7);
if (check_my_img !== '_rd.png') {
my_img = my_img.substr(0, my_img.length - 4);
jQuery('#booking_row_' + bcp_id + ' .booking-actions .remark_bk_link img').attr('src', my_img + '_rd.png');
} else {
my_img = my_img.substr(0, my_img.length - 7);
jQuery('#booking_row_' + bcp_id + ' .booking-actions .remark_bk_link img').attr('src', my_img + '.png');
}
}
/**
* Set in Booking listing R O W new Remark in hint
* @param {type} bcp_id
* @param {type} payment_status
* @param {type} payment_status_show
* @returns {undefined}
*/
function bcpSetBookingRowPaymentStatus(bcp_id, payment_status, payment_status_show)
{
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-payment-status').removeClass('label-important');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-payment-status').removeClass('label-success');
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-payment-status').html(payment_status_show);
if (payment_status === 'OK') {
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-payment-status').addClass('label-success');
} else if (payment_status === '') {
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-payment-status').addClass('label-important');
} else {
jQuery('#booking_row_' + bcp_id + ' .booking-labels .label-payment-status').addClass('label-important');
}
}
/**
*
* @param {type} bcp_id
* @param {type} payment_status
* @param {type} payment_status_show
* @returns {undefined}
*/
function bcpChangeBookingPaymentStatus(bcp_id, payment_status)
{
var ajax_bcp_message = 'Aggiornamento...';
document.getElementById('ajax_working').innerHTML =
'\n\
'+ajax_bcp_message+'
\n\
\n\
\n\
\n\
';
var wp_bcp_ajax_path = wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename;
var ajax_type_action='CHANGE_PAYMENT_STATUS';
jQuery.ajax({ // Start Ajax Sending
url: wp_bcp_ajax_path,
type:'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpChangeBookingPaymentStatus error');
}
},
// beforeSend: someFunction,
data:{
ajax_action : ajax_type_action,
bcp_id : bcp_id,
payment_status : payment_status
}
});
}
/**
* Approve or set Pending booking
* @param {type} bcp_id
* @param {type} is_approve_or_pending
* @param {type} user_id
* @param {type} is_send_emails
* @returns {Boolean}
*/
function bcpApproveUnapproveBooking(bcp_id, is_approve_or_pending, user_id, is_send_emails)
{
if (bcp_id !== '')
{
var wp_bcp_ajax_path = wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename;
var ajax_type_action = 'UPDATE_APPROVE';
var ajax_bcp_message = 'Aggiornamento...';
if (is_send_emails === 1) {
is_send_emails = jQuery('#is_send_email_for_pending').attr('checked');
if (is_send_emails === undefined) {
is_send_emails = 0;
}
else {
is_send_emails = 1;
}
} else {
is_send_emails = 0;
}
document.getElementById('ajax_working').innerHTML =
'\n\
' + ajax_bcp_message + '
\n\
\n\
\n\
\n\
';
jQuery.ajax({// Start Ajax Sending
url: wp_bcp_ajax_path,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpApproveUnapproveBooking error');
}
},
// beforeSend: someFunction,
data: {
ajax_action: ajax_type_action,
bcp_id: bcp_id,
is_approve_or_pending: is_approve_or_pending,
is_send_emails: is_send_emails,
user_id: user_id
}
});
return false;
}
return true;
}
function bcpCheckinoutBooking(bcp_id, is_checkin_or_checkout)
{
if (bcp_id !== '')
{
var wp_bcp_ajax_path = wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename;
var ajax_type_action = 'UPDATE_CHECKINOUT';
var ajax_bcp_message = 'Aggiornamento...';
document.getElementById('ajax_working').innerHTML =
'\n\
' + ajax_bcp_message + '
\n\
\n\
\n\
\n\
';
jQuery.ajax({// Start Ajax Sending
url: wp_bcp_ajax_path,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpCheckinoutBooking error');
}
},
// beforeSend: someFunction,
data: {
ajax_action: ajax_type_action,
bcp_id: bcp_id,
is_checkin_or_checkout: is_checkin_or_checkout
}
});
return false;
}
return true;
}
/**
* Cancel booking
* @param {type} bcp_id
* @param {type} user_id
* @param {type} is_send_emails
* @returns {Boolean}
*/
function bcpCancelBooking(bcp_id, user_id, is_send_emails, answer)
{
if (bcp_id !== '') {
var wp_bcp_ajax_path = wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename;
var ajax_type_action = 'CANCEL_BOOKING';
var ajax_bcp_message = 'Aggiornamento...';
//var is_send_emails = 1;
var denyreason = '';
if (is_send_emails === 1) {
is_send_emails = jQuery('#is_send_email_for_pending').attr('checked');
if (is_send_emails === undefined) {
is_send_emails = 0;
}
else {
is_send_emails = 1;
}
if (answer === '')
denyreason = jQuery('#denyreason').val();
else
denyreason = answer;
} else {
is_send_emails = 0;
}
document.getElementById('ajax_working').innerHTML =
'\n\
' + ajax_bcp_message + '
\n\
\n\
\n\
\n\
';
jQuery.ajax({// Start Ajax Sending
url: wp_bcp_ajax_path,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpDeleteBooking error');
}
},
// beforeSend: someFunction,
data: {
ajax_action: ajax_type_action, // Action
bcp_id: bcp_id, // ID of Booking - separator |
is_send_emails: is_send_emails,
denyreason: denyreason,
user_id: user_id
}
});
return false;
}
return true;
}
/**
* Mark as Read or Unread selected bookings
* @param {type} bcp_id
* @param {type} is_read_or_unread
* @param {type} user_id
* @returns {Boolean}
*/
function bcpMarkReadBooking(bcp_id, is_read_or_unread, user_id)
{
if (bcp_id !== '')
{
var wp_bcp_ajax_path = wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename;
var ajax_type_action = 'UPDATE_READ_UNREAD';
var ajax_bcp_message = 'Aggiornamento...';
document.getElementById('ajax_working').innerHTML =
'\n\
' + ajax_bcp_message + '
\n\
\n\
\n\
\n\
';
jQuery.ajax({// Start Ajax Sending
url: wp_bcp_ajax_path,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpMarkReadBooking error');
}
},
// beforeSend: someFunction,
data: {
ajax_action: ajax_type_action, // Action
bcp_id: bcp_id, // ID of Booking - separator |
is_read_or_unread: is_read_or_unread, // Read: 1, Unread: 0
user_id: user_id
}
});
return false;
}
return true;
}
/**
* Get the list of ID in selected bookings from booking listing
* @returns {unresolved}
*/
function bcpGetSelectedBookingsIdInBookingListing()
{
var checkedd = jQuery(".booking_list_item_checkbox:checked");
var id_for_approve = "";
// get all IDs
checkedd.each(function() {
var id_c = jQuery(this).attr('id');
id_c = id_c.substr(20, id_c.length - 20);
id_for_approve += id_c + "|";
});
if (id_for_approve.length > 1)
id_for_approve = id_for_approve.substr(0, id_for_approve.length - 1); //delete last "|"
return id_for_approve;
}
/**
* Send booking Cacel by visitor
* @param {type} booking_hash
* @returns {Boolean}
*/
function bcpBookingCancelByVisitor(booking_hash)
{
if (booking_hash !== '')
{
document.getElementById('submiting').innerHTML =
'/div>';
var wp_bcp_ajax_path = wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename;
var ajax_type_action = 'DELETE_BY_VISITOR';
jQuery.ajax({// Start Ajax Sending
url: wp_bcp_ajax_path,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond_insert').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpBookingCancelByVisitor error');
}
},
// beforeSend: someFunction,
data: {
ajax_action: ajax_type_action,
booking_hash: booking_hash
}
});
return false;
}
return true;
}
/**
* Scroll to script
* @param {type} object_name
* @returns {undefined}
*/
function bcpMakeScroll(object_name)
{
var targetOffset = jQuery(object_name).offset().top;
targetOffset = targetOffset - 100;
if (targetOffset < 0)
targetOffset = 0;
jQuery('html,body').animate({scrollTop: targetOffset}, 1000);
}
/**
* Admin function s for checking all checkbos in one time
* @param {type} el_stutus
* @param {type} el_class
* @returns {undefined}
*/
function bcpSetCheckBoxInTable(el_stutus, el_class)
{
jQuery('.' + el_class).attr('checked', el_stutus);
if (el_stutus) {
jQuery('.' + el_class).parent().parent().addClass('row_selected_color');
} else {
jQuery('.' + el_class).parent().parent().removeClass('row_selected_color');
}
}
/**
* After reservation action is done
* @param {type} is_full
* @param {type} is_admin
* @returns {undefined}
*/
function bcpSetReservedSelectedDates(is_full, is_admin)
{
if (is_admin)
bcpMakeScroll('#booking_title');
else
bcpMakeScroll('h3.titolo');
if (type_of_thank_you_message === 'page')
{
// Page
// thank_you_page_URL
// location.href= thank_you_page_URL;
timeoutID_of_thank_you_page = setTimeout(function( ) {
location.href = thank_you_page_URL;
}, 1000);
}
else
{
// Message
if (!is_admin)
var full_mess = '
ATTENZIONE: Il nostro parcheggio potrebbe essere completo per le date selezionate.
Stiamo verificando la disponibilità e entro pochi minuti riceverai una mail di
CONFERMA PRENOTAZIONE qualora il posto auto sia disponibile, o in caso contrario una mail di
ANNULLAMENTO PRENOTAZIONE.
Dacci solo qualche minuto...
Grazie per aver scelto AirPark';
else
new_booking_title = 'Inserimento effettuato con successo.';
if (!is_full)
jQuery('#booking_form').html('
' + new_booking_title + '
');
else
jQuery('#booking_form').html('
' + full_mess + '
');
if (!is_admin)
{
timeoutID_of_thank_you_page = setTimeout(function( ) {
jQuery('.submiting_content').fadeOut(new_booking_title_time);
}, 3000);
timeoutID_of_thank_you_page = setTimeout(function( ) {
location.href = wp_bcp_site_url;
}, new_booking_title_time+1000);
}
else
{
timeoutID_of_thank_you_page = setTimeout(function( ) {
jQuery('.submiting_content').fadeOut(1000);
}, 3000);
timeoutID_of_thank_you_page = setTimeout(function( ) {
location.href = wp_bcp_booking_url;
}, 4000);
}
}
}
/**
*
* @param {type} element
* @param {type} element_msg
* @param {type} errorMessage
* @returns {unresolved}
*/
function bcpShowErrorMessage(element, element_msg, errorMessage, position)
{
jQuery("[name='" + element.name + "']")
.fadeOut(350).fadeIn(300)
.fadeOut(350).fadeIn(400)
.animate({opacity: 1}, 4000)
; // mark red border
jQuery("[name='" + element_msg.name + "']")
.after('
' + errorMessage + ''); // Show message
jQuery(".bcp-help-message")
.css({'color': 'red'})
.animate({opacity: 1}, 2000)
.fadeOut(2000); // hide message
element.focus(); // make focus to element
bcpMakeScroll("[name='" + element.name + "']");
return;
}
/**
*
* @param {type} submit_form
* @returns {undefined}
*/
function bcpWpLogin(submit_form)
{
var login = submit_form.elements['login'].value;
var password = submit_form.elements['password'].value;
if (login === '')
{
bcpShowErrorMessage(submit_form.elements['login'], submit_form.elements['login'], message_verif_required, "bottom");
return;
}
if (password === '')
{
bcpShowErrorMessage(submit_form.elements['password'], submit_form.elements['password'], message_verif_required, "bottom");
return;
}
jQuery.ajax({
// Start Ajax Sending
url: wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond_insert').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpWpLogin error');
}
},
// beforeSend: someFunction,
data: {
ajax_action: 'WP_LOGIN',
login: login,
password: password
}
});
}
function bcpFbLogin()
{
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
bcpFbConnected(response);
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'email'});
}
function bcpFbConnected(fb_info)
{
var fb_first_name = fb_info.first_name;
var fb_last_name = fb_info.last_name;
var fb_email = fb_info.email;
jQuery.ajax({
// Start Ajax Sending
url: wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond_insert').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpFbConnected error');
}
},
// beforeSend: someFunction,
data: {
ajax_action: 'FB_CONNECTED',
fb_first_name: fb_first_name,
fb_last_name: fb_last_name,
fb_email: fb_email
}
});
}
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, "");
};
/*
* GCE LONGING VALIDATE COUPON
*/
function checkCoupon(){
var coupon;
var couponCheck = true;
//alert();
if (document.getElementById('coupon').value !== ''){
coupon = document.getElementById('coupon').value;
jQuery.ajax({
// Start Ajax Sending
url: wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename,
type: 'POST',
async: false,
success: function(data, textStatus) {
if (data == '1'){
couponCheck = true;
}
else {
couponCheck = false;
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpSendAjaxSubmit error');
}
},
data: {
ajax_action: 'VALIDATE_COUPON',
coupon: coupon,
email:document.getElementById('email').value
}
});
}
return couponCheck;
/*
* FINE
*/
}
/**
* Check fields at form and then send request
* @param {type} submit_form
* @returns {unresolved}
*/
function bcpAddBookingSubmit(submit_form)
{
/*
* GCE LONGING
*
*/
var checkCouponBool;
//
if(document.getElementById('email').value != ''){
checkCouponBool = checkCoupon();
if(!checkCouponBool){
bcpShowErrorMessage(document.getElementById('coupon'), document.getElementById('coupon'), message_verif_coupon, "bottom");
submit_form.submit.disabled = false;
return;
}
}
/*
* FINE
*/
var count = submit_form.elements.length;
var formdata = '';
var inp_value;
var element;
var el_type;
var bcp_id = 0;
// Serialize form here
for (i = 0; i < count; i++)
{
element = submit_form.elements[i];
if (element.name === ('bcp_id'))
bcp_id = element.value;
// Skip buttons and hidden element - type
if ((element.type !== 'button') && (element.type !== 'hidden') && (element.name !== ('date_booking')))
{
// Get Element Value
if (element.type !== 'checkbox' && element.type !== 'radio')
{
inp_value = element.value;
}
else
{
if (element.value === '')
inp_value = element.checked; // if checkbox so then just check checked
else
{
if (element.checked)
inp_value = element.value;
else
{
if (element.name !== 'invoice')
inp_value = '';
else
continue;
}
}
}
// Validation Check --- Required fields
if (element.className.indexOf('wp-bcp-validates-as-required') !== -1) {
if ((element.type === 'checkbox') && (inp_value === false)) {
bcpShowErrorMessage(element, element, message_verif_required_for_check_box, "bottom");
submit_form.submit.disabled = false;
return;
}
if (inp_value === '') {
bcpShowErrorMessage(element, element, message_verif_required, "bottom");
submit_form.submit.disabled = false;
return;
}
}
// Validation Check --- Email correct filling field
if (element.className.indexOf('wp-bcp-validates-as-email') !== -1) {
var reg = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if (reg.test(inp_value) === false) {
bcpShowErrorMessage(element, element, message_verif_email, "bottom");
//GCE //alert("pippo3");
submit_form.submit.disabled = false;
return;
}
}
if (element.className.indexOf('uppercase') !== -1)
{
inp_value = inp_value.toUpperCase();
}
if (element.className.indexOf('capitalize') !== -1)
{
inp_value = inp_value.toCapitalize(true);
}
if (element.className.indexOf('lowercase') !== -1)
{
inp_value = inp_value.toLowerCase();
}
if (element.className.indexOf('trim') !== -1)
{
inp_value = inp_value.replace(/\s/g,'');
}
// Get Form Data
if (element.name !== ('bcp_type') &&
element.name !== ('place_start') &&
element.name !== ('is_pay_now') &&
element.name !== ('is_bank_iban') &&
element.name !== ('is_cash') &&
element.name !== ('login') &&
element.name !== ('password') &&
element.name !== ('checkindate') &&
element.name !== ('checkoutdate') &&
element.name !== ('checkintime') &&
element.name !== ('checkouttime'))
{
if (formdata !== ''){
/*
* GCE LONGING - BUG FIXED LUGGAGES
*/
if(!(element.name == 'luggages' && inp_value == '')){
formdata += '~'; // next field element
}
/*
* FINE
*/
// formdata += '~'; // ORIGINALE
}
el_type = element.type;
if (element.className.indexOf('wp-bcp-validates-as-email') !== -1)
el_type = 'email';
if (element.className.indexOf('wp-bcp-validates-as-coupon') !== -1)
el_type = 'coupon';
inp_value = inp_value + '';
inp_value = inp_value.replace(new RegExp("\\^", 'g'), '^'); // replace registered characters
inp_value = inp_value.replace(new RegExp("~", 'g'), '~'); // replace registered characters
inp_value = inp_value.replace(/"/g, '"'); // replace double quot
inp_value = inp_value.replace(/'/g, '''); // replace single quot
/*
* GCE LONGING - BUG FIXED LUGGAGES
*/
if(!(element.name == 'luggages' && inp_value == '')){
formdata += el_type + '^' + element.name + '^' + inp_value; // element attr
}
}
}
} // End Fields Loop
submit_form.submit.disabled = 'disabled';
bcpFormSubmitSend(bcp_id, formdata);
return;
}
/**
* Gathering params for sending Ajax request and then send it
* @param {type} bcp_id
* @param {type} formdata
* @returns {undefined}
*/
function bcpFormSubmitSend(bcp_id, formdata)
{
document.getElementById('submiting').innerHTML = '
';
var my_booking_hash = '';
if (bcp_edit_id_hash !== '')
my_booking_hash = bcp_edit_id_hash;
var is_send_emails = jQuery('#is_send_email_for_new_booking');
if (is_send_emails.length === 0)
{
is_send_emails = 1;
}
else
{
is_send_emails = is_send_emails.attr('checked');
if (is_send_emails === undefined)
{
is_send_emails = 0;
}
if (is_send_emails)
is_send_emails = 1;
else
is_send_emails = 0;
}
bcpSendAjaxSubmit(bcp_id, formdata, is_send_emails, my_booking_hash);
}
/**
*
* @param {type} bcp_id
* @param {type} formdata
* @param {type} is_send_emails
* @param {type} my_booking_hash
* @returns {undefined}
*/
function bcpSendAjaxSubmit(bcp_id, formdata, is_send_emails, my_booking_hash)
{
var bcp_type;
var checkindate;
var checkintime;
var checkoutdate;
var checkouttime;
var place_start = -1;
var numbplate;
var coupon;
var car_valet_checkin;
var car_valet_checkout;
var car_wash_auto;
var car_wash_upholstery;
var car_refuel;
var wrap_luggage;
var luggages;
var is_pay_now;
var is_bank_iban;
var is_cash;
var piva; //GCE LONGING
var cf; //GCE LONGING
var ragione_sociale; //GCE LONGING
var emailcoupon; //GCE LONGING
var nota_modifica_prenotazione; //GCE LONGING
var tipologia_sociale; //GCE LONGING
var indirizzo_iva; //GCE LONGING
var localita_iva; //GCE LONGING
var provincia_iva; //GCE LONGING
var cap_iva; //GCE LONGING
var stato_iva; //GCE LONGING
var tel_iva; //GCE LONGING
var rifornitura_carburante;//GCE LONGING
var tipologia_sconto;//GCE LONGING
// Ajax POST here
if (document.getElementById('piva') !== null)//GCE LONGING
piva = document.getElementById('piva').value;//GCE LONGING
if (document.getElementById('cf') !== null)//GCE LONGING
cf = document.getElementById('cf').value;//GCE LONGING
if (document.getElementById('ragione_sociale') !== null)//GCE LONGING
ragione_sociale = document.getElementById('ragione_sociale').value;//GCE LONGING
if (document.getElementById('email') !== null)//GCE LONGING
emailcoupon = document.getElementById('email').value;//GCE LONGING
if (document.getElementById('nota_modifica_prenotazione') !== null)//GCE LONGING
nota_modifica_prenotazione = document.getElementById('nota_modifica_prenotazione').value;//GCE LONGING
if (document.getElementById('rifornitura_carburante') !== null)//GCE LONGING
rifornitura_carburante = document.getElementById('rifornitura_carburante').value;//GCE LONGING
if (document.getElementById('tipologia_sociale') !== null)//GCE LONGING
tipologia_sociale = document.getElementById('tipologia_sociale').value;//GCE LONGING
if (document.getElementById('indirizzo_iva') !== null)//GCE LONGING
indirizzo_iva = document.getElementById('indirizzo_iva').value;//GCE LONGING
if (document.getElementById('localita_iva') !== null)//GCE LONGING
localita_iva = document.getElementById('localita_iva').value;//GCE LONGING
if (document.getElementById('provincia_iva') !== null)//GCE LONGING
provincia_iva = document.getElementById('provincia_iva').value;//GCE LONGING
if (document.getElementById('cap_iva') !== null)//GCE LONGING
cap_iva = document.getElementById('cap_iva').value;//GCE LONGING
if (document.getElementById('stato_iva') !== null)//GCE LONGING
stato_iva = document.getElementById('stato_iva').value;//GCE LONGING
if (document.getElementById('tel_iva') !== null)//GCE LONGING
tel_iva = document.getElementById('tel_iva').value;//GCE LONGING
if (document.getElementById('bcp_type') !== null)
bcp_type = document.getElementById('bcp_type').value;
if (document.getElementById('checkindate') !== null)
checkindate = document.getElementById('checkindate').value;
if (document.getElementById('checkintime') !== null)
checkintime = document.getElementById('checkintime').value;
if (document.getElementById('checkoutdate') !== null)
checkoutdate = document.getElementById('checkoutdate').value;
if (document.getElementById('checkouttime') !== null)
checkouttime = document.getElementById('checkouttime').value;
if (document.getElementById('place_start') !== null)
place_start = document.getElementById('place_start').value;
if (document.getElementById('numbplate') !== null)
numbplate = document.getElementById('numbplate').value;
if (document.getElementById('coupon') !== null)
coupon = document.getElementById('coupon').value;
if (document.getElementById('car_valet_checkin') !== null)
car_valet_checkin = document.getElementById('car_valet_checkin').checked;
if (document.getElementById('car_valet_checkout') !== null)
car_valet_checkout = document.getElementById('car_valet_checkout').checked;
if (document.getElementById('car_wash_auto') !== null)
car_wash_auto = document.getElementById('car_wash_auto').checked;
if (document.getElementById('car_wash_upholstery') !== null)
car_wash_upholstery = document.getElementById('car_wash_upholstery').checked;
if (document.getElementById('car_refuel') !== null)
car_refuel = document.getElementById('car_refuel').checked;
if (document.getElementById('wrap_luggage') !== null)
wrap_luggage = document.getElementById('wrap_luggage').checked;
if (document.getElementById('is_pay_now') !== null)
is_pay_now = document.getElementById('is_pay_now').checked;
if (document.getElementById('is_bank_iban') !== null)
is_bank_iban = document.getElementById('is_bank_iban').checked;
if (document.getElementById('is_cash') !== null)
is_cash = document.getElementById('is_cash').checked;
if ((document.getElementById('luggage-1') !== null) &&
(document.getElementById('luggage-1').checked === true))
luggages = 1;
if ((document.getElementById('luggage-2') !== null) &&
(document.getElementById('luggage-2').checked === true))
luggages = 2;
if ((document.getElementById('luggage-3') !== null) &&
(document.getElementById('luggage-3').checked === true))
luggages = 3;
tipologia_sconto = 0;
if ((document.getElementById('sconto_normal') !== null) &&
(document.getElementById('sconto_normal').checked === true))
tipologia_sconto = 1;
if ((document.getElementById('sconto_none') !== null) &&
(document.getElementById('sconto_none').checked === true))
tipologia_sconto = -1;
if(tipologia_sconto == 0) {
jQuery('input:radio[name="tipologia_sconto"]').filter('[value="1"]').attr('checked', true);
}
jQuery.ajax({
// Start Ajax Sending
url: wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond_insert').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpSendAjaxSubmit error');
}
},
// beforeSend: someFunction,
data: {
ajax_action: 'INSERT_INTO_TABLE',
bcp_id: bcp_id,
bcp_type: bcp_type,
checkindate: checkindate,
checkintime: checkintime,
checkoutdate: checkoutdate,
checkouttime: checkouttime,
place_start: place_start,
numbplate: numbplate,
coupon: coupon,
formdata: formdata,
is_send_emails: is_send_emails,
my_booking_hash: my_booking_hash,
car_valet_checkin: car_valet_checkin,
car_valet_checkout: car_valet_checkout,
car_wash_auto: car_wash_auto,
car_wash_upholstery: car_wash_upholstery,
car_refuel: car_refuel,
wrap_luggage: wrap_luggage,
luggages: luggages,
is_pay_now: is_pay_now,
is_bank_iban: is_bank_iban,
is_cash: is_cash,
piva:piva,//GCE LONGING
cf:cf,//GCE LONGING
emailcoupon:emailcoupon,//GCE LONGING
ragione_sociale:ragione_sociale,//GCE LONGING
nota_modifica_prenotazione:nota_modifica_prenotazione,//GCE LONGING
tipologia_sociale: tipologia_sociale,//GCE LONGING
indirizzo_iva: indirizzo_iva,//GCE LONGING
localita_iva: localita_iva,//GCE LONGING
provincia_iva: provincia_iva,//GCE LONGING
cap_iva: cap_iva,//GCE LONGING
stato_iva: stato_iva,//GCE LONGING
tel_iva: tel_iva,//GCE LONGING
rifornitura_carburante: rifornitura_carburante,//GCE LONGING
tipologia_sconto: tipologia_sconto//GCE LONGING
}
});
}
/**
* Prepare to show tooltips
* @returns {undefined}
*/
function bcpPrepareTooltip()
{
var tooltip_day_class_4_show = " .timespartly";
if (is_show_availability_in_tooltips) {
if (bcpInArray(parent_booking_resources, 1))
tooltip_day_class_4_show = " .datepick-days-cell";//" .datepick-days-cell a"; // each day
}
if (is_show_cost_in_tooltips) {
tooltip_day_class_4_show = " .datepick-days-cell";//" .datepick-days-cell a"; // each day
}
// Show tooltip at each day if time availability filter is set
if (typeof(global_avalaibility_times) !== "undefined") {
if (global_avalaibility_times.length > 0)
tooltip_day_class_4_show = " .datepick-days-cell"; // each day
}
jQuery("#calendar_booking" + tooltip_day_class_4_show).popover({
placement: 'top'
, delay: {show: 500, hide: 1}
, content: ''
, template: '
'
});
}
/**
* Hint labels inside of input boxes
*/
jQuery(document).ready(function()
{
jQuery('div.inside_hint').click(function() {
jQuery(this).css('visibility', 'hidden').siblings('.has-inside-hint').focus();
});
jQuery('input.has-inside-hint').blur(function() {
if (this.value === '')
jQuery(this).siblings('.inside_hint').css('visibility', '');
}).focus(function() {
jQuery(this).siblings('.inside_hint').css('visibility', 'hidden');
});
});
/**
*
* @param {type} content_ID
* @returns {undefined} */
function bcpOpenModalWindow(content_ID)
{
jQuery('.modal_content_text').attr('style', 'display:none;');
document.getElementById(content_ID).style.display = 'block';
var buttons = {};//{ "Ok": bcpDialogClose };
jQuery("#wpdev-bk-dialog").dialog({
autoOpen: false,
width: 700,
height: 330,
buttons: buttons,
draggable: false,
hide: 'slide',
resizable: false,
modal: true,
title: '
Booking Car Park'
});
jQuery("#wpdev-bk-dialog").dialog("open");
}
/**
*
* @returns {undefined}
*/
function bcpDialogClose()
{
jQuery("#wpdev-bk-dialog").dialog("close");
}
/**
*
* @param {type} boxid
* @returns {undefined}
*/
function bcpTogleBox(boxid)
{
if (jQuery('#' + boxid).hasClass('closed'))
jQuery('#' + boxid).removeClass('closed');
else
jQuery('#' + boxid).addClass('closed');
}
/**
*
* @param {type} us_id
* @param {type} window_id
* @returns {undefined}
*/
function bcpVerifyWindowOpening(user_id, window_id)
{
var is_closed = 0;
if (jQuery('#' + window_id).hasClass('closed') === true) {
jQuery('#' + window_id).removeClass('closed');
} else {
jQuery('#' + window_id).addClass('closed');
is_closed = 1;
}
jQuery.ajax({// Start Ajax Sending
url: wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpVerifyWindowOpening error.');
}
},
// beforeSend: someFunction,
data: {
ajax_action: 'USER_SAVE_WINDOW_STATE',
user_id: user_id,
window: window_id,
is_closed: is_closed
}
});
}
/**
*
* @param {type} array_here
* @param {type} p_val
* @returns {Boolean}
*/
function bcpInArray(array_here, p_val)
{
for (var i = 0, l = array_here.length; i < l; i++) {
if (array_here[i] === p_val) {
return true;
}
}
return false;
}
/**
*
* @param {type} date1
* @param {type} date2
* @returns {@exp;Math@call;round}
*/
function bcpDaysBetween(date1, date2)
{
// The number of milliseconds in one day
var ONE_DAY = 1000 * 60 * 60 * 24;
// Convert both dates to milliseconds
var date1_ms = date1.getTime();
var date2_ms = date2.getTime();
// Calculate the difference in milliseconds
var difference_ms = date1_ms - date2_ms;
// Convert back to days and return
return Math.round(difference_ms / ONE_DAY);
}
/**
*
* @returns {undefined}
*/
function bcpShowWideDatesAtAdminSide()
{
jQuery('.short_dates_view').addClass('hide_dates_view');
jQuery('.short_dates_view').removeClass('show_dates_view');
jQuery('.wide_dates_view').addClass('show_dates_view');
jQuery('.wide_dates_view').removeClass('hide_dates_view');
jQuery('#showwidedates').addClass('hide_dates_view');
jQuery('.showwidedates').addClass('hide_dates_view');
jQuery('.showshortdates').addClass('show_dates_view');
jQuery('.showshortdates').removeClass('hide_dates_view');
jQuery('.showwidedates').removeClass('show_dates_view');
}
/**
*
* @returns {undefined}
*/
function bcpShowShortDatesAtAdminSide() {
jQuery('.wide_dates_view').addClass('hide_dates_view');
jQuery('.wide_dates_view').removeClass('show_dates_view');
jQuery('.short_dates_view').addClass('show_dates_view');
jQuery('.short_dates_view').removeClass('hide_dates_view');
jQuery('.showshortdates').addClass('hide_dates_view');
jQuery('.showwidedates').addClass('show_dates_view');
jQuery('.showwidedates').removeClass('hide_dates_view');
jQuery('.showshortdates').removeClass('show_dates_view');
}
/**
*
* @param {type} month
* @param {type} year
* @returns {Number}
*/
function bcpDaysInMonth(month, year)
{
var m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (month !== 2)
return m[month - 1];
if (year % 4 !== 0)
return m[1];
if (year % 100 === 0 && year % 400 !== 0)
return m[1];
return m[1] + 1;
}
/**
*
* @param {type} el_id
* @param {type} el_value
* @returns {undefined}
*/
function bcpSetSelectBoxByValue(el_id, el_value)
{
for (var i = 0; i < document.getElementById(el_id).length; i++) {
if (document.getElementById(el_id)[i].value === el_value) {
document.getElementById(el_id)[i].selected = true;
}
}
}
/**
*
* @param {type} user_id
* @param {type} filter_name
* @param {type} filter_value
* @returns {undefined}
*/
function bcpSaveBookingListingFilter(user_id, filter_name, filter_value)
{
var wp_bcp_ajax_path = wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename;
var ajax_type_action = 'SAVE_BK_LISTING_FILTER';
var ajax_bcp_message = 'Saving...';
document.getElementById('ajax_working').innerHTML =
'
\n\
' + ajax_bcp_message + '
\n\
\n\
\n\
\n\
';
jQuery.ajax({
url: wp_bcp_ajax_path,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpSaveBookingListingFilter error.');
}
},
data: {
ajax_action: ajax_type_action,
user_id: user_id,
filter_name: filter_name,
filter_value: filter_value
}
});
}
/**
*
* @param {type} us_id
* @param {type} window_id
* @returns {undefined}
*/
function bcpVerifyWindowOpening(us_id, window_id) {
var is_closed = 0;
if (jQuery('#' + window_id).hasClass('closed') === true) {
jQuery('#' + window_id).removeClass('closed');
} else {
jQuery('#' + window_id).addClass('closed');
is_closed = 1;
}
jQuery.ajax({// Start Ajax Sending
url: wpdev_bk_plugin_url + '/' + wpdev_bk_plugin_filename,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpVerifyWindowOpening error.');
}
},
// beforeSend: someFunction,
data: {
ajax_action: 'USER_SAVE_WINDOW_STATE',
user_id: us_id,
window: window_id,
is_closed: is_closed
}
});
}
/**
*
* @param {type} submit_form
* @returns {Boolean}
*/
function bcpCheckRequiredSearchForm(submit_form)
{
var count = submit_form.elements.length;
var inp_value;
var element;
var element_in;
var element_out;
var element_msg;
var checkindate;
var checkoutdate;
for (i = 0; i < count; i++)
{
element = submit_form.elements[i];
if (element.name === 'checkintime')
element_in = element;
if (element.name === 'checkouttime')
element_out = element;
}
for (i = 0; i < count; i++)
{
element = submit_form.elements[i];
// Skip buttons and hidden element - type
if ((element.type !== 'button') && (element.type !== 'hidden') && (element.name !== ('date_booking')))
{
// Get Element Value
if (element.type !== 'checkbox')
{
inp_value = element.value;
}
else
{
if (element.value === '')
inp_value = element.checked; // if checkbox so then just check checked
else
{
if (element.checked)
inp_value = element.value;
else
inp_value = '';
}
}
if (element.name === 'checkindate' ||
element.name === 'checkoutdate')
{
if (element.name === 'checkindate')
{
element_msg = element_in;
var date_str = element.value;
date_str = date_str.split("-");
checkindate = new Date(date_str[2],date_str[1]-1,date_str[0]);
}
if (element.name === 'checkoutdate')
{
element_msg = element_out;
var date_str = element.value;
date_str = date_str.split("-");
checkoutdate = new Date(date_str[2],date_str[1]-1,date_str[0]);
if (checkoutdate < checkindate)
{
bcpShowErrorMessage(element, element_msg, message_verif_errordts, "right");
return false;
}
}
}
}
} // End Fields Loop
return true;
}
/**
*
* @param {type} submit_form
* @returns {Boolean}
*/
function bcpCheckRequiredFieldForm1(submit_form)
{
var count = submit_form.elements.length;
var inp_value;
var element;
var element_in;
var element_out;
var element_msg;
var checkindate;
var checkoutdate;
for (i = 0; i < count; i++)
{
element = submit_form.elements[i];
if (element.name === 'checkintime')
element_in = element;
if (element.name === 'checkouttime')
element_out = element;
}
for (i = 0; i < count; i++)
{
element = submit_form.elements[i];
// Skip buttons and hidden element - type
if ((element.type !== 'button') && (element.type !== 'hidden') && (element.name !== ('date_booking')))
{
// Get Element Value
if (element.type !== 'checkbox')
{
inp_value = element.value;
}
else
{
if (element.value === '')
inp_value = element.checked; // if checkbox so then just check checked
else
{
if (element.checked)
inp_value = element.value;
else
inp_value = '';
}
}
if (element.name === 'checkindate' ||
element.name === 'checkintime' ||
element.name === 'checkoutdate'||
element.name === 'checkouttime')
{
if (element.name === 'checkindate')
{
element_msg = element_in;
var date_str = element.value;
date_str = date_str.split("-");
checkindate = new Date(date_str[2],date_str[1]-1,date_str[0]);
}
if (element.name === 'checkoutdate')
{
element_msg = element_out;
var date_str = element.value;
date_str = date_str.split("-");
checkoutdate = new Date(date_str[2],date_str[1]-1,date_str[0]);
if (checkoutdate < checkindate)
{
bcpShowErrorMessage(element, element_msg, message_verif_errordts, "right");
return false;
}
}
// Validation Check --- Required fields
if (element.className.indexOf('wp-bcp-validates-as-required') !== -1)
{
if ((element.type === 'checkbox') && (inp_value === false))
{
bcpShowErrorMessage(element, element_msg, message_verif_required_for_check_box, "right");
return false;
}
if (inp_value === '')
{
bcpShowErrorMessage(element, element_msg, message_verif_required, "right");
return false;
}
}
}
}
} // End Fields Loop
return true;
}
/**
*
* @param {type} submit_form
* @returns {Boolean}
*/
function bcpCheckRequiredFieldForm2(submit_form)
{
var count = submit_form.elements.length;
var inp_value;
var element;
for (i = 0; i < count; i++)
{
element = submit_form.elements[i];
// Skip buttons and hidden element - type
if ((element.type !== 'button') && (element.type !== 'hidden') && (element.name !== ('date_booking')))
{
// Get Element Value
if (element.type !== 'checkbox')
{
inp_value = element.value;
}
else
{
if (element.value === '')
inp_value = element.checked; // if checkbox so then just check checked
else
{
if (element.checked)
inp_value = element.value;
else
inp_value = '';
}
}
if (element.name === 'passengers' ||
element.name === 'numbplate' ||
element.name === 'model' ||
element.name === 'numbfligth' ||
element.name === 'comingfligth' ||
element.name === 'coupon' ||
element.name === 'details')
{
// Validation Check --- Required fields
if (element.className.indexOf('wp-bcp-validates-as-required') !== -1) {
if ((element.type === 'checkbox') && (inp_value === false)) {
bcpShowErrorMessage(element, element, message_verif_required_for_check_box, "right");
return false;
}
if (inp_value === '') {
bcpShowErrorMessage(element, element, message_verif_required, "right");
return false;
}
}
}
}
} // End Fields Loop
return true;
}
/**
*
* @param {type} form
* @returns {undefined}
*/
function bcpCalendarStepClick(form)
{
if (bcpCheckRequiredFieldForm1(form) === true)
{
jQuery('.bcp_calendar_step').fadeIn(1000).css({'display':'block'});
jQuery('.bcp_form_step_1').fadeOut(1000).css({'display':'none'});
bcpMakeScroll('.bcp_calendar_step');
}
}
/**
*
* @param {type} form
* @returns {undefined}
*/
function bcpFormStep1Click(form)
{
if (bcpCheckRequiredFieldForm1(form) === true)
{
jQuery('.bcp_form_step_1').fadeIn(1000).css({'display':'block'});
jQuery('.bcp_calendar_step').fadeOut(1000).css({'display':'none'});
jQuery('.bcp_form_step_2').fadeOut(1000).css({'display':'none'});
bcpMakeScroll('.bcp_form_step_1');
}
}
/**
*
* @param {type} form
* @returns {undefined}
*/
function bcpFormStep2Click(form)
{
if (bcpCheckRequiredFieldForm2(form) === true)
{
jQuery('.bcp_form_step_2').fadeIn(1000).css({'display':'block'});
jQuery('.bcp_form_step_1').fadeOut(1000).css({'display':'none'});
jQuery('.bcp_form_step_3').fadeOut(1000).css({'display':'none'});
bcpMakeScroll('.bcp_form_step_2');
}
}
/**
*
* @param {type} form
* @returns {undefined}
*/
function bcpFormStep3Click()
{
jQuery('.bcp_form_step_3').fadeIn(1000).css({'display':'block'});
jQuery('.bcp_form_step_2').fadeOut(1000).css({'display':'none'});
jQuery('.bcp_form_step_4').fadeOut(1000).css({'display':'none'});
bcpMakeScroll('.bcp_form_step_3');
}
function bcpFormStep4Click()
{
jQuery('#paypalbooking_form').fadeIn(1000).css({'display':'block'});
jQuery('.bcp_form_step_4').fadeIn(1000).css({'display':'block'});
jQuery('.bcp_form_step_3').fadeOut(1000).css({'display':'none'});
bcpMakeScroll('h3.titolo');
}
/**
*
* @param {type} form
* @returns {unresolved}
*/
function bcpCalcBookingCost(form)
{
var element;
var bcp_id;
var bcp_type;
var checkindate;
var checkintime;
var checkoutdate;
var checkouttime;
var coupon;
var car_valet_checkin;
var car_valet_checkout;
var car_wash_auto;
var car_wash_upholstery;
var car_refuel;
var wrap_luggage;
var luggages = 0;
var tipologia_sconto;
var emailcoupon;
var is_pay_now = false;
// Serialize form here
for (i = 0; i < form.elements.length; i++)
{
element = form.elements[i];
if (element.name === 'bcp_id')
bcp_id = element.value;
else if (element.name === 'bcp_type')
bcp_type = element.value;
else if (element.name === 'checkindate')
checkindate = element.value;
else if (element.name === 'checkintime')
checkintime = element.value;
else if (element.name === 'checkoutdate')
checkoutdate = element.value;
else if (element.name === 'checkouttime')
checkouttime = element.value;
else if (element.name === 'coupon')
coupon = element.value;
else if (element.name === 'car_valet_checkin')
car_valet_checkin = element.checked;
else if (element.name === 'car_valet_checkout')
car_valet_checkout = element.checked;
else if (element.name === 'car_wash_auto')
car_wash_auto = element.checked;
else if (element.name === 'car_wash_upholstery')
car_wash_upholstery = element.checked;
else if (element.name === 'car_refuel')
car_refuel = element.checked;
else if (element.name === 'wrap_luggage')
wrap_luggage = element.checked;
else if (element.name === 'luggages' && element.checked)
{
if (element.value === '1')
luggages = 1;
else if (element.value === '2')
luggages = 2;
else if (element.value === '3')
luggages = 3;
}
else if (element.name === 'is_pay_now')
is_pay_now = element.checked;
/*
GCE LONGING COUPON
*/
else if (element.name === 'email')
emailcoupon = element.value;
/*
FINE
*/
else if (element.name === 'tipologia_sconto' && element.checked)
tipologia_sconto = element.value;
}
if (checkindate === '')
return;
if (checkoutdate === '')
checkoutdate = checkindate;
jQuery.ajax({
// Start Ajax Sending
url: wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond_insert').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpCalcBookingCost Error');
}
},
// beforeSend: someFunction,
data: {
ajax_action: 'CALC_BOOKING_COST',
bcp_id: bcp_id,
bcp_type: bcp_type,
checkindate: checkindate,
checkintime: checkintime,
checkoutdate: checkoutdate,
checkouttime: checkouttime,
coupon: coupon,
car_valet_checkin: car_valet_checkin,
car_valet_checkout: car_valet_checkout,
car_wash_auto: car_wash_auto,
car_wash_upholstery: car_wash_upholstery,
car_refuel: car_refuel,
wrap_luggage: wrap_luggage,
luggages: luggages,
is_pay_now: is_pay_now,
tipologia_sconto: tipologia_sconto,
/*
GCE LONGING emailcoupon
*/
email: emailcoupon
/*
FINE
*/
}
});
}
/**
*
* @param {type} form
* @returns {unresolved}
*/
function bcpCalcBookingCostSmart(form)
{
var element;
var bcp_id;
var bcp_type;
var checkindate;
var checkintime;
var checkoutdate;
var checkouttime;
var coupon;
var car_valet_checkin;
var car_valet_checkout;
var car_wash_auto;
var car_wash_upholstery;
var car_refuel;
var wrap_luggage;
var luggages = 0;
var is_pay_now = false;
var n_days;
/*
GCE LONGING COUPON
*/
var emailcoupon;
/*
FINE
*/
// Serialize form here
for (i = 0; i < form.elements.length; i++)
{
element = form.elements[i];
if (element.name === 'bcp_id')
bcp_id = element.value;
else if (element.name === 'bcp_type')
bcp_type = element.value;
else if (element.name === 'checkindate')
checkindate = element.value;
else if (element.name === 'checkintime')
checkintime = element.value;
else if (element.name === 'checkoutdate')
checkoutdate = element.value;
else if (element.name === 'checkouttime')
checkouttime = element.value;
else if (element.name === 'coupon')
coupon = element.value;
else if (element.name === 'car_valet_checkin')
car_valet_checkin = element.checked;
else if (element.name === 'car_valet_checkout')
car_valet_checkout = element.checked;
else if (element.name === 'car_wash_auto')
car_wash_auto = element.checked;
else if (element.name === 'car_wash_upholstery')
car_wash_upholstery = element.checked;
else if (element.name === 'car_refuel')
car_refuel = element.checked;
else if (element.name === 'wrap_luggage')
wrap_luggage = element.checked;
else if (element.name === 'n_days')
n_days = element.value;
else if (element.name === 'luggages' && element.checked)
{
if (element.value === '1')
luggages = 1;
else if (element.value === '2')
luggages = 2;
else if (element.value === '3')
luggages = 3;
}
else if (element.name === 'is_pay_now')
is_pay_now = element.checked;
/*
GCE LONGING COUPON
*/
else if (element.name === 'email')
emailcoupon = element.value;
/*
FINE
*/
}
if (checkindate === '')
return;
if (checkoutdate === '')
checkoutdate = checkindate;
jQuery.ajax({
// Start Ajax Sending
url: wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename,
type: 'POST',
success: function(data) {
jQuery('#ajax_respond_insert').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpCalcBookingCost Error');
}
},
// beforeSend: someFunction,
data: {
ajax_action: 'CALC_BOOKING_COST_SMART',
n_days: n_days,
bcp_id: bcp_id,
bcp_type: bcp_type,
checkindate: checkindate,
checkintime: checkintime,
checkoutdate: checkoutdate,
checkouttime: checkouttime,
coupon: coupon,
car_valet_checkin: car_valet_checkin,
car_valet_checkout: car_valet_checkout,
car_wash_auto: car_wash_auto,
car_wash_upholstery: car_wash_upholstery,
car_refuel: car_refuel,
wrap_luggage: wrap_luggage,
luggages: luggages,
is_pay_now: is_pay_now
}
});
}
function bcpBookingDuplication(form)
{
var element;
var checkindate;
var checkoutdate;
var numbplate;
// Serialize form here
for (i = 0; i < form.elements.length; i++)
{
element = form.elements[i];
if (element.name === 'checkindate')
checkindate = element.value;
else if (element.name === 'checkoutdate')
checkoutdate = element.value;
else if (element.name === 'numbplate')
numbplate = element.value;
}
if (checkindate === '')
return;
if (checkoutdate === '')
checkoutdate = checkindate;
jQuery.ajax({
// Start Ajax Sending
url: wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename,
type: 'POST',
success: function(data, textStatus) {
if (data === 'DUPLICATO')
{
alert ("ATTENZIONE!\nEsiste già una prenotazione con lo stesso numero di targa per i giorni precedentemente selezionati.\nSiete pregati di controllare i dati immessi, di controllare la vostra posta elettronica oppure contattarci telefonicamente per verficare lo stato della vostra prenotazione.");
jQuery("#step2next").prop('disabled', true);
for (i = 0; i < form.elements.length; i++)
{
element = form.elements[i];
if (element.name === 'numbplate')
bcpShowErrorMessage(element, element, "Prenotazione con targa già presente", "bottom");
}
}
else
{
jQuery("#step2next").prop('disabled', false);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpBookingDuplication Error');
}
},
// beforeSend: someFunction,
data: {
ajax_action: 'CHECK_BOOKING_DUPLICATION',
checkindate: checkindate,
checkoutdate: checkoutdate,
numbplate: numbplate
}
});
}
/**
*
* @param {type} bcp_type
* @param {type} checkindate
* @param {type} checkoutdate
* @returns {unresolved}
*/
function bcpCalcBookingCostFromHP(bcp_type,checkindate,checkoutdate)
{
var car_valet_checkin = false;
var car_valet_checkout = false;
var car_wash_auto = false;
var car_wash_upholstery = false;
var car_refuel = false;
var wrap_luggage = false;
if (checkindate === '')
return;
if (checkoutdate === '')
checkoutdate = checkindate;
jQuery.ajax({
// Start Ajax Sending
url: wp_bcp_plugin_url + '/' + wp_bcp_plugin_filename,
type: 'POST',
success: function(data, textStatus) {
if (textStatus === 'success')
jQuery('#ajax_respond_insert').html(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.status = 'Ajax sending Error status:' + textStatus;
alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
if (XMLHttpRequest.status === 500) {
alert('bcpCalcBookingCostFromHP Error');
}
},
// beforeSend: someFunction,
data: {
ajax_action: 'CALC_BOOKING_COST',
bcp_type: bcp_type,
checkindate: checkindate,
checkoutdate: checkoutdate,
car_valet_checkin: car_valet_checkin,
car_valet_checkout: car_valet_checkout,
car_wash_auto: car_wash_auto,
car_wash_upholstery: car_wash_upholstery,
car_refuel: car_refuel,
wrap_luggage: wrap_luggage
}
});
}
/**
*
* @param {type} booking_cost
* @returns {undefined}
*/
function bcpOutputCost(booking_cost, booking_days, discount_pay, discount_coupon, saving)
{
if (discount_coupon !== '0.00' )
{
output = 'Costo convenzione: €
' + booking_cost + ' ' + discount_coupon + ' (' + booking_days + (booking_days === 1?' g)':' gg)');
jQuery('.booking_cost').html(output);
booking_cost = discount_coupon;
}
else if (discount_coupon == '0.00' && saving == 100)//GCE LONGING Bug fixed Coupon 100%
{
output = 'Costo convenzione: €
' + booking_cost + ' ' + discount_coupon + ' (' + booking_days + (booking_days === 1?' g)':' gg)');
jQuery('.booking_cost').html(output);
booking_cost = discount_coupon;
}//GCE LONGING Fine Bug fixed Coupon 100%
else
{
output = 'Costo: €
' + booking_cost + ' (' + booking_days + (booking_days === 1?' g)':' gg)');
jQuery('.booking_cost').html(output);
var scontopaypal = booking_cost - (parseFloat(booking_cost) * 10)/100;
jQuery('.cost_paypal').html(scontopaypal.toFixed(2));
jQuery('.cost_all').html(booking_cost);
}
if (discount_pay !== '0.00' && discount_pay !== booking_cost)
{
output = ', di €
' + discount_pay + ' anziché ' + booking_cost;
jQuery('.booking_discount').html(output);
}
// else
// {
// output = 'del costo totale di €
' + booking_cost + '';
// jQuery('.booking_discount').html(output);
// }
}
//Print
function bcpPrintBookingListing(){
jQuery("#print_loyout_content").html( jQuery("#booking_print_loyout").html() ) ;
jQuery("#printLoyoutModal").modal("show");
}
jQuery.fn.print = function(){
// NOTE: We are trimming the jQuery collection down to the
// first element in the collection.
if (this.size() > 1){
this.eq( 0 ).print();
return;
} else if (!this.size()){
return;
}
// ASSERT: At this point, we know that the current jQuery
// collection (as defined by THIS), contains only one
// printable element.
// Create a random name for the print frame.
var strFrameName = ("printer-" + (new Date()).getTime());
// Create an iFrame with the new name.
var jFrame = jQuery( "