';
console.log('service complet');
return;
}
$.each(shift.shift_slots, function (k, slot) {
window.slots[slot.slot_name] = slot;
var full = fullSlot(slot);
var closed = closedSlot(slot);
if(slot.capacity.total_per_slot != 0) {
if(full || closed) {
html += '';
html += slot.name + '';
} else {
html += '';
html += slot.name + '';
}
}
});
console.log(shift);
});
$("#step22_schedule").html('');
$("#step22_schedule").html(html);
// Replace links with select if too many of them
if ($("#step22_schedule a.btn-schedule").length > 15) {
$('#step22_schedule .service_schedule').hide();
$("#step22_schedule .btn-schedule").hide();
var selectHtml = '
' + $("#timelabel").val() + '
' +
'
' +
'' +
'
';
$("#step22_schedule").append(selectHtml);
$("#step22_schedule select.select_schedule").on('change', function () {
ga('send', 'pageview', {'page': '/tunnel/3/choose_time', 'title': 'Choose time'});
$("#step22_schedule").find("a.btn-schedule[data-time='" + $(this).val() + "']").click();
});
}
clickbtnschedule();
if (main_time_selected == true) {
// we display automatically the pax button selected based on time selected
$("#step22_schedule select.select_schedule").trigger('change');
}
},
error: function () {
}
});
if ($('#lang').val() == "fr") {
var strdate = mydate.getDate() + ' ' + month + ' ' + mydate.getFullYear();
} else {
var strdate = month + ' ' + mydate.getDate() + ', ' + mydate.getFullYear();
}
$('.summary-date').text(strdate);
//$('#summary-time').text($('#time').val());
//$('#summary-nbguests').text($('#nbguests').val());
$('.change-date').removeClass('hidden').show();
$('.step1').hide();
$('.step22').removeClass('hidden').show();
try {
window.parent.postMessage('booking-step2', '*');
}
catch (e) {
}
return false;
}
checktimeandpax();
function checktimeandpax() {
$("#check-time-pax").click(function () {
if ($('#resatype').val() == 'concierge') {
//TEST CONDITION FOR CONCIERGERIE
$.when(checkingCreditConciergerie()).done(function (conciergerie) {
if (conciergerie.success == 'true') {
// Conciergerie activated
__actionchecktimeandpax();
} else {
// block widget
alert(conciergerie.error);
}
});
} else {
__actionchecktimeandpax();
}
});
}
function __actionchecktimeandpax() {
ga('send', 'pageview', {'page': '/tunnel/5/check_time_pax', 'title': 'Check time and pax'});
//TEST CONDITION FOR CONCIERGERIE
$('.progress-indicator').css('display', 'block');
var sch_sel = "";
var display_sch_sel = "";
var pax_sel = "";
$(".btn-schedule").each(function (index, el) {
if ($(this).attr('class').search(/active-schedule/i) != -1) {
sch_sel = $(this).data("time");
display_sch_sel = $(this).text();
}
});
$(".btn-pax").each(function (index, el) {
if ($(this).attr('class').search(/active-schedule/i) != -1) {
pax_sel = $(this).data("pax");
}
});
if (pax_sel == "") {
if ($("#pax_people").length > 0) {
if ($("#pax_people option:selected").val() != "-") {
pax_sel = $("#pax_people option:selected").val();
}
}
}
if (pax_sel == "" || sch_sel == "") {
alert($("#problem-reservation-time-pax").val());
} else {
$("#pax_hidden").val(pax_sel);
$("#time_hidden").val(sch_sel);
$(".summary-nbguests").text(pax_sel);
$(".summary-time").text(display_sch_sel.replace(':', 'h'));
$('.step22').hide();
$('.step3').removeClass('hidden').show();
ga('send', 'pageview', {'page': '/tunnel/6/fill_form', 'title': 'Fill form'});
try {
window.parent.postMessage('booking-step3', '*');
}
catch (e) {
}
}
$('.progress-indicator').css('display', 'none');
}
/*checkcustomer();
function checkcustomer() {
$("#check-customer").click(function () {
__actioncheckcustomer();
});
}
function __actioncheckcustomer() {
ga('send', 'pageview', {'page': '/tunnel/6/check_customer', 'title': 'Check customer'});
$('.step3').hide();
$('.step4').removeClass('hidden').show();
}*/
function clickbtnschedule() {
__actionclickbtnschedule();
}
function __actionclickbtnschedule() {
$("a.btn-schedule").bind('click', function () {
//TEST CONDITION FOR CONCIERGERIE
classarray = $(this).attr("class").split(" ");
$(".btn-schedule").each(function (index) {
$(this).attr("class", "btn-schedule");
});
if ($.inArray("active-schedule", classarray) == true) {
$(this).attr("class", "btn-schedule active-schedule");
} else {
$(this).attr("class", "btn-schedule active-schedule");
}
$("#date").val($(this).data('date'));
var months = $('#months').val().split(',');
var datebtn = $(this).data('date').split("-");
var timebtn = $(this).data('time');
var html = "";
var html2 = "";
$('.progress-indicator').css('display', 'block');
var slot = window.slots[timebtn];
var btn_written = false;
html += '
' + $("#msg_pax").val() + '
';
var max = 10;
var nb = 0;
$.each(slot.possible_guests, function (k, v) {
if (nb < max) {
html += '' + v + '';
nb++;
} else {
if (nb == max) {
html2 += '
';
html2 += '
';
}
if (nb == 0) {
html += $("#msg_no_availability").val();
}
if ($('#lang').val() == "fr") {
var strdate = datebtn[2] + ' ' + months[datebtn[1] - 1] + ' ' + datebtn[0];
} else {
var strdate = months[datebtn[1] - 1] + ' ' + datebtn[2] + ', ' + datebtn[0];
}
$('.summary-date').text(strdate);
$("#step22_pax").html("")
$("#step22_pax").html(html + html2);
clickbtnpax();
selectclickbtnpax();
$('.progress-indicator').css('display', 'none');
return false;
});
}
function clickbtnpax() {
$(".btn-pax").bind('click', function () {
ga('send', 'pageview', {'page': '/tunnel/4/choose_guests', 'title': 'Choose guests'});
classarray = $(this).attr("class").split(" ");
$(".btn-pax").each(function (index) {
$(this).attr("class", "btn-pax");
});
$("#pax_people option:selected").removeAttr('selected');
$("#pax_people option[value=-]").attr('selected');
if ($.inArray("active-schedule", classarray) == true) {
$(this).attr("class", "btn-pax active-schedule");
} else {
$(this).attr("class", "btn-pax active-schedule");
}
toggleWarningBookingCharges($(this).data().pax);
return false;
});
}
function selectclickbtnpax() {
$("#pax_people").bind('change', function () {
var classarray = $(this).attr("class").split(" ");
$(".btn-pax").each(function (index, element) {
$(this).attr("class", "btn-pax");
});
toggleWarningBookingCharges($(this).val());
return false;
});
}
function toggleWarningBookingCharges(pax) {
var min_pax_booking_charges = parseInt($('#min_pax_booking_charges').val());
if (parseInt(pax) >= min_pax_booking_charges) {
$('#eb-notice').show();
} else {
$('#eb-notice').hide();
}
}
function pad(str, max) {
var string = new String(str);
return string.length < max ? pad("0" + string, max) : str;
}
function checkingCreditConciergerie() {
var result = false;
$.ajax({
url: "http://app.zenchef.com/public/conciergerie/rid/" + $("#restoid_base64").val() + "/checking",
type: 'GET',
dataType: 'json',
async: false,
success: function (data) {
$('.progress-indicator').css('display', 'block');
result = data;
},
error: function () {
}
});
return result;
}
function closedSlot(slot) {
return slot.closed;
};
function fullSlot(slot, guests) {
if (guests) {
return !$.inArray(guests, slot.possible_guests);
} else {
return slot.possible_guests.length == 0;
}
};
function closedShift(shift) {
var closedCount = 0;
$.each(shift.shift_slots, function (k, s) {
if (closedSlot(s)) {
closedCount++;
}
});
return closedCount == shift.shift_slots.length;
};
function fullShift(shift, guests) {
var fullCount = 0;
$.each(shift.shift_slots, function (k, s) {
if (fullSlot(s, guests)) {
fullCount++;
}
});
return fullCount == shift.shift_slots.length;
};
})(jQuery);