1988 lines
69 KiB
JavaScript
1988 lines
69 KiB
JavaScript
|
|
// Used to provide inheritance for the recurrence pseudo-classes at the bottom of this file.
|
|
var __extends = this.__extends || function (derived, base) {
|
|
function __() { this.constructor = derived; }
|
|
__.prototype = base.prototype;
|
|
derived.prototype = new __();
|
|
};
|
|
|
|
var AvailabilityStatus = {
|
|
Unknown: 0,
|
|
Available: 1,
|
|
Booked: 2,
|
|
TimeBetweenReservationsConflict: 3,
|
|
AdvanceNoticeConflict: 4,
|
|
StartTimeInThePastConflict: 5,
|
|
AdminOverride: 6,
|
|
RecurrenceLimitExceeded: 7,
|
|
DurationLimitExceeded: 8,
|
|
OutsideOfBusinessHours : 9
|
|
};
|
|
|
|
function formatTime(objDateTime) {
|
|
var hour = objDateTime.getHours();
|
|
var min = objDateTime.getMinutes();
|
|
var ampm = '';
|
|
if (hour < 12) {
|
|
ampm = 'AM';
|
|
} else if (hour == 12) {
|
|
ampm = 'PM';
|
|
} else {
|
|
hour = hour - 12;
|
|
ampm = 'PM';
|
|
}
|
|
|
|
var minStr = '';
|
|
if (min < 10) {
|
|
minStr = '0' + min;
|
|
} else {
|
|
minStr = min;
|
|
}
|
|
|
|
return hour + ':' + minStr + ' ' + ampm;
|
|
|
|
}
|
|
|
|
var FacilityNewReservationModal = (function ($) {
|
|
|
|
var self = this;
|
|
var modalLoaded = false;
|
|
var gcalledFromCalendarModule = false;
|
|
var gPublishButtonName;
|
|
var gStartDateID;
|
|
var gStartTimeID;
|
|
var gEndDateID;
|
|
var gEndTimeID;
|
|
var gTitle;
|
|
var gIsFE = true;
|
|
var gCalledFromReservationForm = false;
|
|
var gCalledFromEpayment = false;
|
|
var gSubmit = false;
|
|
var gPrint = false;
|
|
var gCheckout = false;
|
|
var gOpenFormInNewWindow = false;
|
|
var gHideViewCalendarLink = false;
|
|
var gModifyReservationDate = false;
|
|
var gReservationID = null;
|
|
var gAvailability = AvailabilityStatus.Unknown;
|
|
var gIsProceedWithoutPayment = false;
|
|
var gIsOnNewReservationFormFE = false;
|
|
var recurringReservationJS = null;
|
|
var gIsModifyingSeries = false;
|
|
var gRecurrenceID = 0;
|
|
var gIsRecurrenceDateModified = false;
|
|
var gIsEdit = false;
|
|
var gContinueAsGuest = false;
|
|
var gRecurrenceJSON;
|
|
|
|
$(document).ready(function () {
|
|
|
|
self.recurringReservationJS = new RecurringReservationJS();
|
|
|
|
$('#newReservation').click(function (e) {
|
|
e.preventDefault();
|
|
self.openReservationModal();
|
|
});
|
|
|
|
$('#fullCalendarReserveButton').keypress(function () {
|
|
$(this).click();
|
|
});
|
|
|
|
$('#fullCalendarReserveButton').click(function (e) {
|
|
e.preventDefault();
|
|
self.openReservationModal();
|
|
});
|
|
|
|
// Click handler for the reservation form "Modify Recurring" link
|
|
$(document).delegate('li[data-external-submission-name="e_513"]', 'click', function (e) {
|
|
e.preventDefault();
|
|
gIsOnNewReservationFormFE = true;
|
|
var json = $('#e_512').val();
|
|
self.openReservationModal($('#hdnFacilityID').val(), true);
|
|
var loadExisting = new LoadFromExistingReservation();
|
|
loadExisting.execute(json);
|
|
});
|
|
|
|
$(document).delegate('#lnkCheckAvailability', 'click', function (e) {
|
|
e.preventDefault();
|
|
var contCheck = true;
|
|
if (gIsModifyingSeries) {
|
|
var response = DefaultView.recurrenceHasExceptions(gRecurrenceID, gIsRecurrenceDateModified, true);
|
|
if (response.Confirm) {
|
|
contCheck = confirm(response.Confirm);
|
|
}
|
|
}
|
|
if (contCheck) {
|
|
self.checkAvailability();
|
|
}
|
|
});
|
|
|
|
$(document).delegate('#lnkProceedAsGuest', 'click', function (e) {
|
|
e.preventDefault();
|
|
var contCheck = true;
|
|
gContinueAsGuest = true;
|
|
if (gIsModifyingSeries) {
|
|
var response = DefaultView.recurrenceHasExceptions(gRecurrenceID, gIsRecurrenceDateModified, true);
|
|
if (response.Confirm) {
|
|
contCheck = confirm(response.Confirm);
|
|
}
|
|
}
|
|
if (contCheck) {
|
|
self.checkAvailability();
|
|
}
|
|
});
|
|
|
|
|
|
// Click handler for the "Proceed with Reservation" link
|
|
$(document).delegate('#lnkProceed', 'click', function (e) {
|
|
e.preventDefault();
|
|
var startDate = new Date(self.getStartDate() + ' ' + self.getStartTime());
|
|
var endDate = new Date(self.getEndDate() + ' ' + self.getEndTime());
|
|
$('#hdnisAdminOverride').val(true);
|
|
self.checkAvailabilitySuccess({ "Availability": 6, "BeginDate": startDate, "EndDate": endDate, "UnavilableDates": "" });
|
|
});
|
|
|
|
// Click handler for the "Cancel" link
|
|
$(document).delegate('#lnkCancel', 'click', function (e) {
|
|
e.preventDefault();
|
|
self.closeReservationModal();
|
|
});
|
|
|
|
// Click handler for the "View Calendar" link
|
|
$(document).delegate('#lnkViewCalendar', 'click', function (e) {
|
|
e.preventDefault();
|
|
var url = '/Facilities/Facility/Details/' + $('#hdnReservationFacilityID').val() + '#CalendarAnchor';
|
|
self.openLinkNewWindow(url);
|
|
});
|
|
|
|
$(document).delegate('#lnkFindAnotherFacility', 'click', function (e) {
|
|
e.preventDefault();
|
|
self.searchForAnotherFacility();
|
|
});
|
|
|
|
$(document).delegate('#allDayEvent', 'change', function (e) {
|
|
self.allDayEventChange();
|
|
});
|
|
if (modalLoaded) {
|
|
self.allDayEventChange();
|
|
}
|
|
});
|
|
|
|
self.searchForAnotherFacility = function () {
|
|
var startDate = self.getStartDate();
|
|
var startTime = self.getStartTime();
|
|
var endDate = self.getEndDate();
|
|
var endTime = self.getEndTime();
|
|
|
|
var data = {
|
|
dateRangeStart: startDate,
|
|
dateRangeEnd: endDate,
|
|
startTime: startTime,
|
|
endTime: endTime
|
|
};
|
|
|
|
var url = '/Facilities/Facility/PrepopulatedSearch?' + $.param(data);
|
|
|
|
self.openLinkNewWindow(url);
|
|
};
|
|
|
|
self.closeReservationModal = function () {
|
|
self.clearReservationModalFields();
|
|
$('.modalContainer.modalNewReservation').css('top', '50%');
|
|
$('.modalContainer.modalNewReservation').css('left', '50%');
|
|
hideModal('modalNewReservation');
|
|
};
|
|
|
|
self.clearReservationModalFields = function () {
|
|
$('#startDate').val('');
|
|
$('#endDate').val('');
|
|
$('#startTime').val('');
|
|
$('#endTime').val('');
|
|
$('.modalNewReservation p.booked').addClass('hidden');
|
|
gReservationID = null;
|
|
gModifyReservationDate = false;
|
|
gTitle = $("#hdnDefaultModalTitle").val();
|
|
if (!self.IsAllDayForced())
|
|
{
|
|
attrOrProps($('#allDayEvent'), "checked", false);
|
|
$('#startTime').attr('disabled', '');
|
|
$('#endTime').attr('disabled', '');
|
|
}
|
|
attrOrProps($('#notRecurringRadio'), "checked", "checked");
|
|
$('#divAllDay').removeClass('hidden');
|
|
gRecurrenceID = 0;
|
|
gIsModifyingSeries = false;
|
|
gIsRecurrenceDateModified = false;
|
|
$('#lnkProceed').hide();
|
|
|
|
RecurCommon.showNotRecurring();
|
|
RecurCommon.resetRecurring();
|
|
|
|
if (needPlaceHoldersShim()) {
|
|
unregisterPlaceHolderShim($('#startDate'));
|
|
unregisterPlaceHolderShim($('#endDate'));
|
|
unregisterPlaceHolderShim($('#startTime'));
|
|
unregisterPlaceHolderShim($('#endTime'));
|
|
registerPlaceHoldersShim($('#startTime'));
|
|
registerPlaceHoldersShim($('#endTime'));
|
|
registerPlaceHoldersShim($('#endDate'));
|
|
registerPlaceHoldersShim($('#startDate'));
|
|
}
|
|
};
|
|
|
|
self.setCalledFromReservationForm = function (value) {
|
|
gCalledFromReservationForm = value;
|
|
};
|
|
|
|
self.openReservationModal = function (facilityID, isFE, disableRecurring, isEdit) {
|
|
var self = this;
|
|
disableRecurring = typeof (disableRecurring) !== 'undefined' ? disableRecurring : false;
|
|
if (isFE || $('#hdnIsFrontEnd').val() == 'False' || $('#hdn_IsReservable').val() == 'True' || gIsOnNewReservationFormFE) {
|
|
|
|
//Set globals
|
|
if (isFE != null)
|
|
gIsFE = isFE;
|
|
|
|
if (isEdit == null) {
|
|
gIsEdit = false;
|
|
} else {
|
|
gIsEdit = isEdit;
|
|
}
|
|
|
|
if (facilityID == null)
|
|
facilityID = $('#FacilityID').val();
|
|
|
|
if (modalLoaded) {
|
|
self.clearReservationModalFields();
|
|
self.resetModalTitle();
|
|
$('.modalNewReservation').show();
|
|
|
|
self.calledFromCalendarSetup();
|
|
self.calledFromReservationFormSetup();
|
|
self.calledFromEpaymentSetup();
|
|
if (!disableRecurring) {
|
|
self.enableRucurringOptions();
|
|
} else {
|
|
$('#recurringRadio').attr('disabled', 'disabled');
|
|
}
|
|
self.setReservationFacilityID(facilityID);
|
|
self.setFacilityNameOrCombo();
|
|
self.enableTimeButtons();
|
|
return;
|
|
}
|
|
|
|
openCpModal({
|
|
title: gTitle,
|
|
className: 'modalNewReservation',
|
|
isFrontEnd: gIsFE,
|
|
autoAdjust: false,
|
|
data: { facilityID: facilityID, isEdit: gIsEdit },
|
|
onClose: function () {
|
|
modalLoaded = false;
|
|
self.closeReservationModal();
|
|
return false;
|
|
},
|
|
onLoadComplete: function () {
|
|
$('.modalContainer.modalNewReservation').css('top', '50%');
|
|
setTimeout(function () {
|
|
if ($('#notRecurringRadio')[0].type == 'hidden')
|
|
$('#startDate').focus();
|
|
else
|
|
$('#notRecurringRadio').focus();
|
|
}, 100);
|
|
},
|
|
url: '/Facilities/Facility/NewReservationModal?isFrontEnd=' + gIsFE,
|
|
elementID: 'divNewReservationModal',
|
|
draggable:true
|
|
});
|
|
|
|
modalLoaded = true;
|
|
if (!disableRecurring)
|
|
self.enableRucurringOptions();
|
|
else
|
|
$('#recurringRadio').attr('disabled', 'disabled');
|
|
|
|
$('#hdnReservationFacilityID').val(facilityID);
|
|
$('#divNewReservationModal .modalContentRight > .modalContent').addClass('slimNewReservationModal');
|
|
self.setReservationFacilityID(facilityID);
|
|
self.calledFromCalendarSetup();
|
|
self.calledFromReservationFormSetup();
|
|
self.calledFromEpaymentSetup();
|
|
self.setFacilityNameOrCombo();
|
|
self.disableTimeButtons();
|
|
if (gHideViewCalendarLink) {
|
|
hideViewCalendarLink();
|
|
}
|
|
|
|
if (gTitle == null) {
|
|
self.resetModalTitle();
|
|
}
|
|
}
|
|
};
|
|
|
|
self.checkAvailabilitySuccess = function (response) {
|
|
var availability = response.Availability;
|
|
var isRecurring = RecurCommon.isRecurringSelected();
|
|
var unAvailableDates = response.UnavilableDates;
|
|
|
|
$.jStorage.deleteKey("removedUnavailableDates");
|
|
|
|
if (availability == AvailabilityStatus.Available && isRecurring && unAvailableDates != "") {
|
|
var question = $('#hdnRecurringBookedQuestion').val();
|
|
|
|
if (response.CanOverride) {
|
|
question = $('#hdnRecurringBookedQuestionAdminOverride').val();
|
|
}
|
|
|
|
if (!confirm($('#hdnRecurringBookedHeader').val() + " \n" + unAvailableDates +
|
|
question)) {
|
|
|
|
availability = AvailabilityStatus.Booked;
|
|
}
|
|
else {
|
|
$.jStorage.set("removedUnavailableDates", true);
|
|
}
|
|
}
|
|
|
|
//If allday event is checked set the times to brought back to be used when needed
|
|
//If allday is forced, do not update the calendar event times.
|
|
if (self.IsAllDayEventChecked()) {
|
|
if (!response.BeginDate.toString().indexOf("Date") > 0) {
|
|
var startDateAD = response.BeginDate;
|
|
var endDateAD = response.EndDate;
|
|
$('#startTime').val(formatTime(startDateAD));
|
|
$('#endTime').val(formatTime(endDateAD));
|
|
}
|
|
if (needPlaceHoldersShim()) {
|
|
unregisterPlaceHolderShim($('#startTime'));
|
|
unregisterPlaceHolderShim($('#endTime'));
|
|
}
|
|
}
|
|
|
|
if (availability != AvailabilityStatus.Available && availability != AvailabilityStatus.AdminOverride) {
|
|
self.handleUnavailable(availability);
|
|
$('.modalNewReservation .booked').removeClass('hidden');
|
|
|
|
} else if (gcalledFromCalendarModule) {
|
|
self.publishSetDates();
|
|
}
|
|
else if (gCalledFromReservationForm) {
|
|
calledFromReservationFormComplete(response);
|
|
}
|
|
else if (gCalledFromEpayment) {
|
|
calledFromEpaymentComplete(response, isRecurring);
|
|
}
|
|
else if (gModifyReservationDate) {
|
|
self.modifyEventDate(response);
|
|
}
|
|
else if (gIsOnNewReservationFormFE) {
|
|
var queryParams = {};
|
|
var getParams = new GetRecurringRequestParameters();
|
|
getParams.setParameters(queryParams);
|
|
var url = '/Facilities/ReservationForm/GetUpdatesForModifiedRecurrence/3';
|
|
FacilitiesCommon.AJAX(
|
|
url,
|
|
'POST',
|
|
queryParams,
|
|
function (response) {
|
|
// update the paragragraph tag for the "Recurrence Description" field.
|
|
$('li[data-external-submission-name="e_511"] p.tip').html(response.RecurrenceText);
|
|
$('#e_511').text(response.RecurrenceText);
|
|
$('#e_512').val(response.RecurrenceObject);
|
|
self.closeReservationModal();
|
|
},
|
|
true);
|
|
}
|
|
else {
|
|
var startDateTime = self.getStartDate() + ' ' + self.getStartTime();
|
|
var endDateTime = self.getEndDate() + ' ' + self.getEndTime();
|
|
var url = '/Facilities/ReservationForm/NewReservation/' + $('#hdnReservationFacilityID').val();
|
|
var queryParams = {};
|
|
if (isRecurring) {
|
|
var getParams = new GetRecurringRequestParameters();
|
|
getParams.setParameters(queryParams);
|
|
queryParams.isRecurringReservation = isRecurring;
|
|
queryParams.isProceedWithoutPayment = gIsProceedWithoutPayment;
|
|
} else {
|
|
queryParams = {
|
|
startDate: startDateTime.trim(),
|
|
endDate: endDateTime.trim(),
|
|
isProceedWithoutPayment: gIsProceedWithoutPayment,
|
|
isAllDay: $('#allDayEvent').is(':checked'),
|
|
isRecurringReservation: isRecurring
|
|
};
|
|
}
|
|
|
|
if (availability == AvailabilityStatus.AdminOverride) {
|
|
queryParams.isAdminOverride = true;
|
|
}
|
|
|
|
var queryString = $.param(queryParams);
|
|
var fullURL = url + '?' + queryString;
|
|
|
|
var allowGuest = $('#allowGuestRegistration').val();
|
|
if (allowGuest && gContinueAsGuest) {
|
|
window.location.href = fullURL;
|
|
} else if (allowGuest) {
|
|
var find = '&';
|
|
var re = new RegExp(find, 'g');
|
|
window.location.href = "/MyAccount?from=url&url=" + fullURL.replace(re, '%26');
|
|
} else {
|
|
if (gOpenFormInNewWindow) {
|
|
window.open(fullURL, '_blank');
|
|
self.closeReservationModal();
|
|
} else {
|
|
popupSignIn(fullURL, '');
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
self.hideAllMessages = function () {
|
|
$('#AdvanceNoticeConflictSpan').hide();
|
|
$('#TimeBetweeReservationConflictSpan').hide();
|
|
$('#TimeUnavailableSpan').hide();
|
|
$('#StartTimeInThePastConflictSpan').hide();
|
|
$('#TimeUnavailableSpanAdmin').hide();
|
|
$('#RecurrenceLimitExceededSpan').hide();
|
|
$('#DurationLimitExceededSpan').hide();
|
|
$('#lnkProceed').hide();
|
|
};
|
|
|
|
self.handleUnavailable = function (availability) {
|
|
self.hideAllMessages();
|
|
self.showMessage(availability);
|
|
gAvailability = availability;
|
|
};
|
|
|
|
self.showMessage = function (availability) {
|
|
if (availability == AvailabilityStatus.AdvanceNoticeConflict) {
|
|
$('#AdvanceNoticeConflictSpan').show();
|
|
self.showAdminMessageCheck();
|
|
} else if (availability == AvailabilityStatus.TimeBetweenReservationsConflict) {
|
|
$('#TimeBetweeReservationConflictSpan').show();
|
|
} else if (availability == AvailabilityStatus.StartTimeInThePastConflict) {
|
|
$('#StartTimeInThePastConflictSpan').show();
|
|
} else if (availability == AvailabilityStatus.RecurrenceLimitExceeded) {
|
|
$('#RecurrenceLimitExceededSpan').show();
|
|
} else if (availability == AvailabilityStatus.DurationLimitExceeded) {
|
|
$('#DurationLimitExceededSpan').show();
|
|
} else if (availability == AvailabilityStatus.OutsideOfBusinessHours) {
|
|
self.showAdminMessageCheck();
|
|
} else {
|
|
self.showAdminMessageCheck();
|
|
|
|
if (RecurCommon.isRecurringSelected()) {
|
|
$('#TimeUnavailableSpan').show();
|
|
}
|
|
}
|
|
};
|
|
|
|
self.showAdminMessageCheck = function () {
|
|
|
|
//If there we know it is a author or above
|
|
if ($('#lnkProceed').length) {
|
|
//if editing making sure the new facility they selected they have access to
|
|
if (gIsEdit && self.getNewFacilityID() != $('#hdnReservationFacilityID').val()) {
|
|
var url = '/Facilities/Facility/IsUserFacilityAuthor?facilityID=' + self.getNewFacilityID();
|
|
FacilitiesCommon.AJAX(
|
|
url,
|
|
'GET',
|
|
null,
|
|
function (response) {
|
|
if (response.Rights) {
|
|
self.showAdminMessage();
|
|
} else {
|
|
self.showNonAdminMessage();
|
|
}
|
|
},
|
|
false);
|
|
} else {
|
|
self.showAdminMessage();
|
|
}
|
|
} else {
|
|
self.showNonAdminMessage();
|
|
}
|
|
|
|
};
|
|
|
|
self.showNonAdminMessage = function () {
|
|
$('#TimeUnavailableSpan').show();
|
|
};
|
|
|
|
self.showAdminMessage = function () {
|
|
$('#TimeUnavailableSpanAdmin').show();
|
|
$('#lnkProceed').show();
|
|
};
|
|
|
|
self.isRecurring = function () {
|
|
return $('#recurringRadio').is(':checked');
|
|
};
|
|
|
|
self.getStartDate = function (keepDayBeforeMonth) {
|
|
if (keepDayBeforeMonth == null) {
|
|
keepDayBeforeMonth = false;
|
|
}
|
|
var startDate;
|
|
if (self.isRecurring()) {
|
|
startDate = getDateFromInput('#recurringStartDate', keepDayBeforeMonth);
|
|
} else {
|
|
startDate = getDateFromInput('#startDate', keepDayBeforeMonth);
|
|
}
|
|
return startDate;
|
|
};
|
|
|
|
self.getStartTime = function () {
|
|
if (self.isRecurring()) {
|
|
return $('#recurringStartTime').val();
|
|
} else {
|
|
return $('#startTime').val();
|
|
}
|
|
};
|
|
|
|
self.getEndDate = function (keepDayBeforeMonth) {
|
|
if (keepDayBeforeMonth == null) {
|
|
keepDayBeforeMonth = false;
|
|
}
|
|
var endDate;
|
|
if (self.isRecurring()) {
|
|
if ($('#endOptionsNumber').is(':checked')) {
|
|
var calc = new EndDateCalculator();
|
|
endDate = calc.calculateEndDate(keepDayBeforeMonth);
|
|
} else {
|
|
endDate = getDateFromInput('#recurringEndDate', keepDayBeforeMonth);
|
|
}
|
|
} else {
|
|
endDate = getDateFromInput('#endDate', keepDayBeforeMonth);
|
|
}
|
|
return endDate;
|
|
};
|
|
|
|
self.getEndTime = function () {
|
|
if (self.isRecurring()) {
|
|
return $('#recurringEndTime').val();
|
|
} else {
|
|
return $('#endTime').val();
|
|
}
|
|
};
|
|
|
|
self.IsAllDayEventChecked = function () {
|
|
if ($('#allDayEvent')[0] === undefined)
|
|
return $('#e_509_0').is(':checked');
|
|
return $('#allDayEvent').is(':checked') || self.IsAllDayForced();
|
|
};
|
|
|
|
self.IsAllDayForced = function () {
|
|
return $('#hdnForceAllDay').val() === 'True';
|
|
}
|
|
self.checkAvailability = function () {
|
|
self.hideAllMessages();
|
|
$('.modalNewReservation .booked').addClass('hidden');
|
|
|
|
var isRecurring = RecurCommon.isRecurringSelected();
|
|
|
|
// Validate the recurrence pattern before checking the dates and times, because the recurrence
|
|
// pattern generates the end date. Errors messages for the recurrence pattern will be more meaningful
|
|
// to the user than a generic invalid date message at this point.
|
|
if (isRecurring) {
|
|
var validator = new RecurringReservationValidator();
|
|
if (!validator.isInputValid()) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (!validateDatesAndTimes()) {
|
|
return;
|
|
}
|
|
|
|
var startDate = self.getStartDate();
|
|
var startTime = self.getStartTime();
|
|
var endDate = self.getEndDate();
|
|
var endTime = self.getEndTime();
|
|
|
|
var id = $('#hdnReservationFacilityID').val();
|
|
|
|
if (gIsEdit) {
|
|
id = self.getNewFacilityID();
|
|
}
|
|
|
|
var data = {};
|
|
|
|
if (isRecurring) {
|
|
var getRecurringParams = new GetRecurringRequestParameters();
|
|
data.facilityID = id;
|
|
data.reservationID = gReservationID;
|
|
data.isAllDay = false;
|
|
data.isRecurring = isRecurring;
|
|
data.startDate = startDate + ' ' + startTime;
|
|
data.endDate = endDate + ' ' + endTime;
|
|
data.recurrenceID = gRecurrenceID;
|
|
getRecurringParams.setParameters(data);
|
|
} else {
|
|
data = {
|
|
facilityID: id,
|
|
startDate: startDate + ' ' + startTime,
|
|
endDate: endDate + ' ' + endTime,
|
|
reservationID: gReservationID,
|
|
isAllDay: $('#allDayEvent').is(':checked'),
|
|
isRecurring: isRecurring
|
|
};
|
|
}
|
|
|
|
var urlWithQuerystring = '/Facilities/Facility/CheckAvailability?' + $.param(data);
|
|
$.ajax({
|
|
url: urlWithQuerystring,
|
|
type: 'GET',
|
|
success: self.checkAvailabilitySuccess,
|
|
async: false
|
|
});
|
|
};
|
|
|
|
self.isAdminOverrideSet = function () {
|
|
var isOverride = false;
|
|
if ($('#hdnisAdminOverride').val()) {
|
|
isOverride = $('#hdnisAdminOverride').val().toLowerCase() === 'true';
|
|
}
|
|
return isOverride;
|
|
}
|
|
|
|
self.modifyEventDate = function (response) {
|
|
var startDate = self.getStartDate();
|
|
var startTime = self.getStartTime();
|
|
var endDate = self.getEndDate();
|
|
var endTime = self.getEndTime();
|
|
var isAllDay = self.IsAllDayEventChecked();
|
|
var facilityID = $('#hdnReservationFacilityID').val();
|
|
var isRecurring = RecurCommon.isRecurringSelected();
|
|
|
|
if (isAllDay) {
|
|
var startDateAD = FacilitiesCommon.getDateFromJSONDate(response.BeginDate);
|
|
var endDateAD = FacilitiesCommon.getDateFromJSONDate(response.EndDate);
|
|
startDate = startDateAD.format(getDateFormat());
|
|
startTime = startDateAD.format("h:mm tt");
|
|
endDate = endDateAD.format(getDateFormat());
|
|
endTime = endDateAD.format("h:mm tt");
|
|
}
|
|
|
|
var queryParams = {};
|
|
|
|
if (gRecurrenceID > 0 && !gIsRecurrenceDateModified) {
|
|
var getParams = new GetRecurringRequestParameters();
|
|
getParams.setParameters(queryParams);
|
|
queryParams.isRecurringReservation = isRecurring;
|
|
queryParams.id = self.getNewFacilityID();
|
|
queryParams.ReservationID = gReservationID;
|
|
queryParams.start = startDate + ' ' + startTime;
|
|
queryParams.end = endDate + ' ' + endTime;
|
|
queryParams.categoryID = $('#hiddenCategoryID').val() == undefined ? null : $('#hiddenCategoryID').val();
|
|
queryParams.recurrenceID = gRecurrenceID;
|
|
queryParams.isRecurrenceDateModified = gIsRecurrenceDateModified;
|
|
queryParams.oldFacilityID = facilityID;
|
|
} else {
|
|
queryParams = {
|
|
id: self.getNewFacilityID(),
|
|
ReservationID: gReservationID,
|
|
start: startDate + ' ' + startTime,
|
|
end: endDate + ' ' + endTime,
|
|
categoryID: $('#hiddenCategoryID').val() == undefined ? null : $('#hiddenCategoryID').val(),
|
|
recurrenceID: gRecurrenceID,
|
|
isRecurrenceDateModified: gIsRecurrenceDateModified,
|
|
oldFacilityID: facilityID
|
|
};
|
|
};
|
|
|
|
queryParams.isAdminOverride = self.isAdminOverrideSet();
|
|
|
|
var urlWithQuerystring = '/Admin/Facilities/UpdateReservation?';
|
|
FacilitiesCommon.AJAX(
|
|
urlWithQuerystring,
|
|
'POST',
|
|
queryParams,
|
|
self.modifyEventDateSuccess,
|
|
true);
|
|
};
|
|
|
|
self.modifyEventDateSuccess = function (response) {
|
|
if (response.Success) {
|
|
self.closeReservationModal();
|
|
$("#calendar").fullCalendar('refetchEvents');
|
|
DefaultView.reloadDetailsModal();
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
self.getStartDateID = function () {
|
|
if (self.isRecurring()) {
|
|
return '#recurringStartDate';
|
|
} else {
|
|
return '#startDate';
|
|
}
|
|
};
|
|
|
|
self.getEndDateID = function () {
|
|
if (self.isRecurring()) {
|
|
if ($('#endOptionsDate').is(':checked')) {
|
|
return '#recurringEndDate';
|
|
} else {
|
|
// User has specified a number of occurrences for the end date, so use the calculated
|
|
// value.
|
|
var $calculatedEndDate = $('#calculatedEndDate');
|
|
var calc = new EndDateCalculator();
|
|
$calculatedEndDate.val(calc.calculateEndDate(true));
|
|
return '#calculatedEndDate';
|
|
}
|
|
return '#recurringEndDate';
|
|
} else {
|
|
return '#endDate';
|
|
}
|
|
};
|
|
|
|
self.getStartTimeID = function () {
|
|
if (self.isRecurring()) {
|
|
return '#recurringStartTime';
|
|
} else {
|
|
return '#startTime';
|
|
}
|
|
};
|
|
|
|
self.getEndTimeID = function () {
|
|
if (self.isRecurring()) {
|
|
return '#recurringEndTime';
|
|
} else {
|
|
return '#endTime';
|
|
}
|
|
};
|
|
|
|
self.validateDatesAndTimes = function () {
|
|
|
|
var isAllDay = self.IsAllDayEventChecked();
|
|
var timesRequired = !isAllDay;
|
|
var mIsRecurring = self.isRecurring();
|
|
|
|
//Set options for validation
|
|
var endDateRequired = true;
|
|
if (mIsRecurring && $('#endOptionsNumber').is(':checked')) {
|
|
endDateRequired = false;
|
|
}
|
|
|
|
var allowDatesInThePast = true;
|
|
|
|
if (mIsRecurring) {
|
|
allowWrongTimeOrder = false;
|
|
} else {
|
|
allowWrongTimeOrder = true;
|
|
}
|
|
|
|
var ok = FacilitiesCommon.validateDateTime(
|
|
self.getStartDateID(), /* startDateID */
|
|
self.getEndDateID(), /* endDateID */
|
|
self.getStartTimeID(), /* startTimeID */
|
|
self.getEndTimeID(), /* endTimeID */
|
|
true, /* allowEqualDates */
|
|
false, /* allowEqualTimes */
|
|
true, /* startDateRequired */
|
|
endDateRequired, /* endDateRequired */
|
|
true, /* startRequiredIfEndSpecified */
|
|
allowDatesInThePast, /* allowDatesInThePast */
|
|
timesRequired, /* startTimeRequired */
|
|
timesRequired, /* endTimeRequired */
|
|
allowWrongTimeOrder, /* allowWrongTimeOrderIfDatesNotSame */
|
|
FacilityNewReservationModal_l10n.StartDateName, /* startDateName */
|
|
FacilityNewReservationModal_l10n.EndDateName, /* endDateName */
|
|
FacilityNewReservationModal_l10n.StartTimeName, /* startTimeName */
|
|
FacilityNewReservationModal_l10n.EndTimeName, /* endTimeName */
|
|
FacilityNewReservationModal_l10n.WrongTimeFormatMessage, /* wrongTimeFormatMessage */
|
|
'', /* unknownErrorMessage */
|
|
FacilityNewReservationModal_l10n.DateInPastErrorMessage, /* dateInPastErrorMessage */
|
|
FacilityNewReservationModal_l10n.WrongTimeOrderErrorMessage /* wrongTimeOrderErrorMessage */
|
|
);
|
|
|
|
return ok;
|
|
};
|
|
|
|
self.setupGlobals = function (title, publishButtonName, startDateID, startTimeID, endDateID,
|
|
endTimeID, calledFromCalendarModule, calledFromReservationForm, calledFromEpayment) {
|
|
|
|
gTitle = title;
|
|
gPublishButtonName = publishButtonName;
|
|
self.setReservationStartEndIDs(startDateID, startTimeID, endDateID, endTimeID);
|
|
|
|
if (calledFromCalendarModule != null)
|
|
gcalledFromCalendarModule = calledFromCalendarModule;
|
|
if (calledFromReservationForm != null)
|
|
gCalledFromReservationForm = calledFromReservationForm;
|
|
if (calledFromEpayment != null)
|
|
gCalledFromEpayment = calledFromEpayment;
|
|
|
|
};
|
|
|
|
self.publishSetDates = function () {
|
|
$(gStartDateID).val(getStartDate(true));
|
|
$(gEndDateID).val(getEndDate(true));
|
|
if (!self.IsAllDayForced()) {
|
|
$(gStartTimeID).val(getStartTime());
|
|
$(gEndTimeID).val(getEndTime());
|
|
$('[id$="hdnIsAllDay"]').val($('#allDayEvent').is(':checked'));
|
|
}
|
|
closeReservationModal();
|
|
if (gcalledFromCalendarModule) {
|
|
var hasList = false;
|
|
if ($('[id$="hdnHasList"]').val() == true) {
|
|
hasList = true;
|
|
}
|
|
if (!hasList) {
|
|
__doPostBack('ctl00$ctl00$adminContent$pageContent$calendarAdmin$ctl01$btnPublish', '')
|
|
return;
|
|
}
|
|
}
|
|
OpenNotificationPopUp();
|
|
};
|
|
|
|
function OpenNotificationPopUp()
|
|
{
|
|
var behaviorID = $find('editItemBehavior');
|
|
var ifrID = document.getElementById('NotifyMeDialog');
|
|
var eventBeginsDate = "";
|
|
var eventEndsDate = "";
|
|
if (window.FeatureToggles.isActive("CMS.JqueryUpgrade.UpgradeTo224") && $('#hdnModuleEligibleForJquery224Upgrade').val() == "true") {
|
|
eventBeginsDate = document.getElementById('ctl00_ctl00_adminContent_pageContent_calendarAdmin_ctl01_dtiEventBeginsFromAmsul').value;
|
|
eventEndsDate = document.getElementById('ctl00_ctl00_adminContent_pageContent_calendarAdmin_ctl01_dtiEventEndsFromAmsul').value;
|
|
}
|
|
else {
|
|
eventBeginsDate = document.getElementById('ctl00_ctl00_adminContent_pageContent_calendarAdmin_ctl01_dtiEventBegins').value;
|
|
eventEndsDate = document.getElementById('ctl00_ctl00_adminContent_pageContent_calendarAdmin_ctl01_dtiEventEnds').value;
|
|
}
|
|
saveAndSendBE(calendarID, document.aspnetForm.name, behaviorID, ifrID, '', document.getElementById('ctl00_ctl00_adminContent_pageContent_calendarAdmin_ctl01_txtEventTitle').value, 'fullEdit', eventBeginsDate, document.getElementById('ctl00_ctl00_adminContent_pageContent_calendarAdmin_ctl01_txtEventStartTime').value, eventEndsDate, document.getElementById('ctl00_ctl00_adminContent_pageContent_calendarAdmin_ctl01_txtEventEndTime').value);
|
|
document.body.style.cursor = "default";
|
|
return false;
|
|
}
|
|
|
|
self.calledFromCalendarSetup = function () {
|
|
if (gcalledFromCalendarModule)
|
|
$('.modalNewReservation .booked').removeClass('hidden');
|
|
};
|
|
|
|
self.calledFromReservationFormSetup = function () {
|
|
if (gCalledFromReservationForm) {
|
|
var isRecurring = $('#e_510_0').is(':checked');
|
|
$('.modalNewReservation .booked').removeClass('hidden');
|
|
|
|
if (isRecurring) {
|
|
var recurJson = $('#e_512').val();
|
|
|
|
var loadExisting = new LoadFromExistingReservation();
|
|
loadExisting.execute(recurJson);
|
|
} else {
|
|
|
|
setDateTimesInModal($(gStartDateID).val(), $(gStartTimeID).val(), $(gEndDateID).val(), $(gEndTimeID).val(), self.IsAllDayEventChecked());
|
|
}
|
|
}
|
|
};
|
|
|
|
self.calledFromEpaymentSetup = function () {
|
|
if (gCalledFromEpayment) {
|
|
$('.modalNewReservation .booked').removeClass('hidden');
|
|
}
|
|
};
|
|
|
|
self.setRecurranceJSON = function (json, copyTimes) {
|
|
if (json != null) {
|
|
gRecurrenceJSON = json;
|
|
|
|
var loadExisting = new LoadFromExistingReservation();
|
|
loadExisting.execute(json, copyTimes);
|
|
}
|
|
};
|
|
|
|
self.calledFromReservationFormComplete = function (response) {
|
|
var dateFormat = getDateFormat();
|
|
$(gStartDateID).val(new Date(getStartDate()).format(dateFormat));
|
|
$(gStartTimeID).val(getStartTime());
|
|
$(gEndDateID).val(new Date(getStartDate()).format(dateFormat));
|
|
$(gEndTimeID).val(getEndTime());
|
|
document.getElementById('e_509_0').checked = document.getElementById('allDayEvent').checked;
|
|
|
|
closeReservationModal();
|
|
|
|
if (gCheckout) {
|
|
proceedToCheckOut2(response);
|
|
}
|
|
else if (gSubmit && !gPrint) {
|
|
submitForm(response);
|
|
}
|
|
else if (gSubmit && gPrint) {
|
|
gSaveData = true;
|
|
|
|
printForm(response);
|
|
}
|
|
else if (!gSubmit && gPrint) {
|
|
gSaveData = false;
|
|
|
|
printForm(response);
|
|
}
|
|
};
|
|
|
|
self.setReservationCallBack = function (submit, print, checkout) {
|
|
gCheckout = checkout;
|
|
gSubmit = submit;
|
|
gPrint = print;
|
|
};
|
|
|
|
self.calledFromEpaymentComplete = function (response, isRecurring) {
|
|
if (isRecurring) {
|
|
var queryParams = {};
|
|
var getParams = new GetRecurringRequestParameters();
|
|
getParams.setParameters(queryParams);
|
|
var url = '/Facilities/ReservationForm/UpdateEpaymentTransaction/' + $('#hdnItemID').val() + '?isRecurring=true';
|
|
FacilitiesCommon.AJAX(
|
|
url,
|
|
'POST',
|
|
queryParams,
|
|
self.reloadEpay,
|
|
true);
|
|
}
|
|
else {
|
|
var newDates = [getStartDate(), getEndDate(), getStartTime(), getEndTime()];
|
|
|
|
FacilitiesCommon.AJAX(
|
|
'/Facilities/ReservationForm/UpdateEpaymentTransaction/' + $('#hdnItemID').val(),
|
|
'POST',
|
|
{ newDates: newDates.toString(), isAllDay: self.IsAllDayEventChecked() },
|
|
self.reloadEpay,
|
|
false);
|
|
}
|
|
closeReservationModal();
|
|
};
|
|
|
|
self.reloadEpay = function () {
|
|
window.location = window.location;
|
|
};
|
|
|
|
self.openLinkNewWindow = function (url) {
|
|
window.open(url, '_blank');
|
|
window.focus();
|
|
};
|
|
|
|
self.setDateTimesInModal = function (startDate, startTime, endDate, endTime, isAllDay) {
|
|
if (startDate != null) {
|
|
$('#startDate').val(startDate);
|
|
}
|
|
|
|
if (startTime != null) {
|
|
$('#startTime').val(startTime);
|
|
}
|
|
|
|
if (endDate != null) {
|
|
$('#endDate').val(endDate);
|
|
}
|
|
|
|
if (endTime != null) {
|
|
$('#endTime').val(endTime);
|
|
}
|
|
|
|
if (isAllDay != null) {
|
|
attrOrProps($('#allDayEvent'), 'checked', isAllDay || self.IsAllDayForced());
|
|
allDayEventChange();
|
|
}
|
|
};
|
|
|
|
self.setIsFrontEndGlobal = function (isFrontEnd) {
|
|
gIsFE = isFrontEnd;
|
|
};
|
|
|
|
self.setOpenReservationNewWindow = function (isNewWindow) {
|
|
gOpenFormInNewWindow = isNewWindow;
|
|
};
|
|
|
|
self.setReservationStartEndIDs = function (startDateID, startTimeID, endDateID, endTimeID) {
|
|
gStartDateID = "#" + startDateID;
|
|
gStartTimeID = "#" + startTimeID;
|
|
gEndDateID = "#" + endDateID;
|
|
gEndTimeID = "#" + endTimeID;
|
|
};
|
|
|
|
self.hideViewCalendarLink = function () {
|
|
$("#spnViewInCalendar").addClass("hidden");
|
|
$("#spnViewInCalendarPeriod").removeClass("hidden");
|
|
};
|
|
|
|
self.setHideViewCalendarLink = function (hideViewCalendarLink) {
|
|
gHideViewCalendarLink = hideViewCalendarLink;
|
|
};
|
|
|
|
self.setModifyEventVariables = function (reservationid, modifyReservationDate, recurrenceID, isRecurrenceDateModified, isModifyingSeries) {
|
|
gReservationID = reservationid;
|
|
gModifyReservationDate = modifyReservationDate;
|
|
gRecurrenceID = recurrenceID;
|
|
gIsRecurrenceDateModified = isRecurrenceDateModified;
|
|
gIsModifyingSeries = isModifyingSeries;
|
|
self.setTitle($("#hdnModifyModalTitle").val());
|
|
|
|
if (recurrenceID > 0) {
|
|
self.modifyRecurrenceRecord();
|
|
} else {
|
|
self.enableRucurringOptions();
|
|
$("#recurringRadio").attr("disabled", true); //Don't let them turn a single to a recurring this may come later
|
|
}
|
|
};
|
|
|
|
self.enableRucurringOptions = function () {
|
|
$("#recurringRadio").attr("disabled", false);
|
|
$("#notRecurringRadio").attr("disabled", false);
|
|
};
|
|
|
|
self.setTitle = function (title) {
|
|
gTitle = title;
|
|
self.resetModalTitle();
|
|
};
|
|
|
|
self.setProceedWithoutPayment = function (isProceedWithoutPayment) {
|
|
gIsProceedWithoutPayment = isProceedWithoutPayment;
|
|
};
|
|
|
|
self.isAvailable = function () {
|
|
return gAvailability;
|
|
};
|
|
|
|
self.isAvailableReset = function () {
|
|
gAvailability = AvailabilityStatus.Unknown;
|
|
};
|
|
|
|
self.resetModalTitle = function () {
|
|
if (gTitle == null) {
|
|
gTitle = $("#hdnDefaultModalTitle").val();
|
|
}
|
|
|
|
$(".modalNewReservation .modalTitle").html(gTitle);
|
|
};
|
|
|
|
self.allDayEventChange = function () {
|
|
if (self.IsAllDayEventChecked()) {
|
|
self.disableTimeButtons();
|
|
self.setAllDayTimes();
|
|
} else {
|
|
self.enableTimeButtons();
|
|
}
|
|
};
|
|
self.disableTimeButtons = function () {
|
|
if (self.IsAllDayEventChecked()) {
|
|
$('#startTime').attr('disabled', 'disabled');
|
|
$('#endTime').attr('disabled', 'disabled');
|
|
//TODO: Handle recurring
|
|
//$('#olNonRecurringEvents').find('.t-icon.t-icon-clock').hide();
|
|
}
|
|
/*if (self.IsAllDayForced()) {
|
|
timePicker = $('#recurringStartTime').data('tTimePicker');
|
|
if (timePicker) {
|
|
$('#recurringStartTime').data("tTimePicker").disable();
|
|
$('#recurringEndTime').data("tTimePicker").disable();
|
|
} else {
|
|
$('#recurringStartTime').attr('disabled', 'disabled');
|
|
$('#recurringEndTime').attr('disabled', 'disabled');
|
|
//$('#olRecurringEvents').find('.t-icon.t-icon-clock').hide();
|
|
}
|
|
}*/
|
|
};
|
|
|
|
self.enableTimeButtons = function () {
|
|
//TODO: Handle recurring
|
|
/*$('#olNonRecurringEvents').find('.t-icon.t-icon-clock').show();
|
|
$('#olNonRecurringEvents').find('.t-icon.t-icon-clock').removeAttr('style');*/
|
|
if (!self.IsAllDayEventChecked()) {
|
|
$('#startTime').removeAttr('disabled');
|
|
$('#endTime').removeAttr('disabled');
|
|
}
|
|
};
|
|
|
|
self.disableATimePicker = function (id) {
|
|
$(id).attr('disabled', true)
|
|
.next('span.t-select')
|
|
.children('span.t-icon-clock')
|
|
.css('visibility', 'hidden');
|
|
};
|
|
|
|
self.enableATimePicker = function (id) {
|
|
$(id).removeAttr('disabled')
|
|
.next('span.t-select')
|
|
.children('span.t-icon-clock')
|
|
.css('visibility', 'visible');
|
|
};
|
|
|
|
self.modifyRecurrenceRecord = function () {
|
|
if (gIsModifyingSeries) {
|
|
$("#recurringRadio").attr("disabled", false);
|
|
$("#notRecurringRadio").attr("disabled", true);
|
|
$("#recurringRadio").attr("checked", 'checked');
|
|
self.getRecurrenceRecord();
|
|
RecurCommon.copyDatesAndTimesToRecurring(true);
|
|
} else {
|
|
$("#recurringRadio").attr("disabled", true);
|
|
$("#notRecurringRadio").attr("disabled", false);
|
|
$("#notRecurringRadio").attr("checked", 'checked');
|
|
RecurCommon.nonRecurringClick();
|
|
}
|
|
};
|
|
|
|
self.getRecurrenceRecord = function () {
|
|
FacilitiesCommon.AJAX(
|
|
'/Admin/Facilities/ReservationRecurrenceGet/GetReservationRecurrence/' + gRecurrenceID,
|
|
'GET',
|
|
null,
|
|
function (response) {
|
|
if (response.RecurrenceObject == null) {
|
|
self.closeReservationModal();
|
|
} else {
|
|
|
|
var loadExisting = new LoadFromExistingReservation();
|
|
loadExisting.execute(response.RecurrenceObject, true);
|
|
}
|
|
},
|
|
true);
|
|
};
|
|
|
|
self.setFacilityNameOrCombo = function () {
|
|
if (gIsEdit) {
|
|
$("#FacilityList").show();
|
|
$("#FacilityTitle").hide();
|
|
$("#Facility_FacilityID").attr("disabled", false);
|
|
$("#Facility_FacilityID").val($('#hdnReservationFacilityID').val());
|
|
} else {
|
|
$("#FacilityList").hide();
|
|
$("#FacilityTitle").show();
|
|
$("#Facility_FacilityID").attr("disabled", true);
|
|
}
|
|
};
|
|
|
|
self.getNewFacilityID = function () {
|
|
return $("#Facility_FacilityID").val();
|
|
};
|
|
|
|
self.setReservationFacilityID = function (facilityID) {
|
|
$('#hdnReservationFacilityID').val(facilityID);
|
|
};
|
|
|
|
self.setAllDayTimes = function () {
|
|
if (IsAllDayEventChecked()) {
|
|
var keepDayBeforeMonth = getDateFormat().toLowerCase() == 'dd/mm/yyyy';
|
|
var startDate = getDateFromInput(!RecurCommon.isRecurringSelected() ? '#startDate' : '#recurringStartDate', keepDayBeforeMonth);
|
|
var endDate = !RecurCommon.isRecurringSelected() ? getDateFromInput('#endDate', keepDayBeforeMonth) : startDate;
|
|
var validator = new dateValidator();
|
|
var valid = validator.dateValidateNew(startDate, true) && validator.dateValidateNew(endDate, true);
|
|
|
|
if (valid) {
|
|
var id = $('#FacilityID').val();
|
|
if (id === undefined)
|
|
id = $('#hdnReservationFacilityID').val();
|
|
var data = {
|
|
facilityID: id,
|
|
startDate: startDate,
|
|
endDate: endDate
|
|
};
|
|
|
|
var url = '/Facilities/Facility/AllDayHours?' + $.param(data);
|
|
|
|
FacilitiesCommon.AJAX(
|
|
url,
|
|
'POST',
|
|
'',
|
|
function (response) {
|
|
$('.startTime').val(response.StartTime);
|
|
$('.endTime').val(response.EndTime);
|
|
},
|
|
false);
|
|
}
|
|
}
|
|
};
|
|
}(jQuery));
|
|
|
|
var RecurrenceType = {
|
|
None: 0,
|
|
Daily: 1,
|
|
Weekly: 2,
|
|
Monthly: 3,
|
|
Yearly: 4
|
|
};
|
|
|
|
var RecurrenceTypeWeekly = {
|
|
First: 1,
|
|
Second: 2,
|
|
Third: 3,
|
|
Fourth: 4,
|
|
Last: 5
|
|
};
|
|
|
|
var RecurringReservationJS = (function () {
|
|
|
|
function RecurringReservationJS() {
|
|
this.initEventHandlers();
|
|
}
|
|
|
|
// Gets a javascript object describing the type of recurrence the user specified
|
|
// in the new reservation modal.
|
|
RecurringReservationJS.prototype.getRecurrenceDefinition = function () {
|
|
var self = this;
|
|
return self.getTestRecurrenceDefinition();
|
|
};
|
|
|
|
// _initEventHandlers binds functions to various HTML controls on the Recurring Reservations
|
|
// modal.
|
|
RecurringReservationJS.prototype.initEventHandlers = function () {
|
|
|
|
$(document).delegate('#recurringRadio', 'click', function (e) {
|
|
RecurCommon.showRecurring(true);
|
|
});
|
|
|
|
$(document).delegate('#notRecurringRadio', 'click', function (e) {
|
|
RecurCommon.nonRecurringClick();
|
|
RecurCommon.copyDatesAndTimesToNonRecurring();
|
|
});
|
|
|
|
function ensureMaxLength(maxLength) {
|
|
|
|
}
|
|
|
|
$(document).delegate('#endCount', 'focus', function (e) {
|
|
attrOrProps($('#endOptionsNumber'), 'checked','checked');
|
|
});
|
|
|
|
$(document).delegate('#dailyIntervalSize', 'focus', function (e) {
|
|
attrOrProps($('#dailyOptionsNum'), "checked", "checked");
|
|
});
|
|
|
|
$(document).delegate('#recurringEndDate', 'focus', function (e) {
|
|
attrOrProps($('#endOptionsDate'), "checked", "checked");
|
|
});
|
|
|
|
$(document).delegate('#monthlyDayOfMonth', 'focus', function (e) {
|
|
attrOrProps($('#monthlyOptionsNum'), "checked", "checked");
|
|
});
|
|
|
|
$(document).delegate('#monthlyIntervalSize', 'focus', function (e) {
|
|
attrOrProps($('#monthlyOptionsNum'), "checked", "checked");
|
|
});
|
|
|
|
$(document).delegate('#monthlyIntervalSize2', 'focus', function (e) {
|
|
attrOrProps($('#monthlyOptionsDay'), "checked", "checked");
|
|
});
|
|
|
|
$(document).delegate('#monthlyWeekType', 'focus', function (e) {
|
|
attrOrProps($('#monthlyOptionsDay'), "checked", "checked");
|
|
});
|
|
|
|
$(document).delegate('#monthlyDayOfWeek', 'focus', function (e) {
|
|
attrOrProps($('#monthlyOptionsDay'), "checked", "checked");
|
|
});
|
|
|
|
$(document).delegate('#recurrenceTypeDaily', 'click', function (e) {
|
|
RecurCommon.showDaily();
|
|
});
|
|
|
|
$(document).delegate('#recurrenceTypeWeekly', 'click', function (e) {
|
|
RecurCommon.showWeekly();
|
|
});
|
|
|
|
$(document).delegate('#recurrenceTypeMonthly', 'click', function (e) {
|
|
RecurCommon.showMonthly();
|
|
});
|
|
};
|
|
|
|
|
|
// This is just a temporary test method -- delete it after implementation.
|
|
RecurringReservationJS.prototype.getTestRecurrenceDefinition = function () {
|
|
return {
|
|
RecurrenceTypeID: RecurrenceType.Daily,
|
|
StartDate: '1/1/2013',
|
|
EndDate: '1/10/2013',
|
|
StartTime: '8:00 am',
|
|
EndTime: '10:00 am',
|
|
EndAfterNumOccurrences: 0,
|
|
DailyRecurCount: 0,
|
|
DailyIsEveryDay: false,
|
|
WeeklyRecurCount: 0,
|
|
IsSunday: true,
|
|
IsMonday: false,
|
|
IsTuesday: false,
|
|
IsWednesday: false,
|
|
IsThursday: false,
|
|
IsFriday: false,
|
|
IsSaturday: false,
|
|
MonthlyDay: 0,
|
|
MonthlyEveryNumMonths: 0,
|
|
RecurrenceWeeklyTypeID: 0,
|
|
YearlyMonth: 0
|
|
};
|
|
};
|
|
|
|
|
|
return RecurringReservationJS;
|
|
}());
|
|
|
|
// Common javascript functions used by the recurrence code
|
|
var RecurCommon = {
|
|
getRecurrenceType: function () {
|
|
if ($('#recurrenceTypeDaily').is(':checked')) {
|
|
return RecurrenceType.Daily;
|
|
} else if ($('#recurrenceTypeWeekly').is(':checked')) {
|
|
return RecurrenceType.Weekly;
|
|
} else if ($('#recurrenceTypeMonthly').is(':checked')) {
|
|
return RecurrenceType.Monthly;
|
|
} else {
|
|
return RecurrenceType.None;
|
|
}
|
|
},
|
|
|
|
nonRecurringClick: function () {
|
|
$('#olNonRecurringEvents').removeClass('hidden');
|
|
$('#olRecurringEvents').addClass('hidden');
|
|
$('#divAllDay').removeClass('hidden');
|
|
},
|
|
|
|
showDaily: function () {
|
|
$('#liDailyOptions').removeClass('hidden');
|
|
$('#liWeeklyOptions').addClass('hidden');
|
|
$('#liMonthlyOptions').addClass('hidden');
|
|
},
|
|
|
|
showWeekly: function () {
|
|
$('#liDailyOptions').addClass('hidden');
|
|
$('#liWeeklyOptions').removeClass('hidden');
|
|
$('#liMonthlyOptions').addClass('hidden');
|
|
},
|
|
|
|
showMonthly: function () {
|
|
$('#liDailyOptions').addClass('hidden');
|
|
$('#liWeeklyOptions').addClass('hidden');
|
|
$('#liMonthlyOptions').removeClass('hidden');
|
|
},
|
|
|
|
daysCheckedFlag: function () {
|
|
var daysChecked = 0;
|
|
if ($('#recurringSunday').is(':checked')) {
|
|
daysChecked = daysChecked | 1;
|
|
}
|
|
if ($('#recurringMonday').is(':checked')) {
|
|
daysChecked = daysChecked | 2;
|
|
}
|
|
if ($('#recurringTuesday').is(':checked')) {
|
|
daysChecked = daysChecked | 4;
|
|
}
|
|
if ($('#recurringWednesday').is(':checked')) {
|
|
daysChecked = daysChecked | 8;
|
|
}
|
|
if ($('#recurringThursday').is(':checked')) {
|
|
daysChecked = daysChecked | 16;
|
|
}
|
|
if ($('#recurringFriday').is(':checked')) {
|
|
daysChecked = daysChecked | 32
|
|
}
|
|
if ($('#recurringSaturday').is(':checked')) {
|
|
daysChecked = daysChecked | 64;
|
|
}
|
|
return daysChecked;
|
|
},
|
|
|
|
isRecurringSelected: function () {
|
|
// $('#recurringRadio') is used when the reservation modal is visible. We also need this function
|
|
// on the reservation form, to determine how to show it when the user clicks the "Modify" link. In that
|
|
// case we need to use the "IsRecurring" checkbox value to determine if the reservation is recurring.
|
|
return $('#recurringRadio').is(':checked') || $('#e_510_0').is(':checked');
|
|
},
|
|
|
|
copyDatesAndTimesToRecurring: function (timeOnly) {
|
|
var startTime = $('#startTime').val();
|
|
$('#recurringStartTime').val(startTime);
|
|
|
|
var endTime = $('#endTime').val();
|
|
$('#recurringEndTime').val(endTime);
|
|
|
|
if (!timeOnly) {
|
|
var startDate = $('#startDate').val();
|
|
$('#recurringStartDate').val(startDate);
|
|
}
|
|
},
|
|
|
|
copyDatesAndTimesToNonRecurring: function () {
|
|
var startTime = $('#recurringStartTime').val();
|
|
$('#startTime').val(startTime);
|
|
|
|
var endTime = $('#recurringEndTime').val();
|
|
$('#endTime').val(endTime);
|
|
|
|
var startDate = RecurCommon.getRecurStartDate(false);
|
|
if(startDate !== undefined)
|
|
$('#startDate').val(startDate);
|
|
},
|
|
|
|
showNotRecurring: function () {
|
|
$('#olNonRecurringEvents').removeClass('hidden');
|
|
$('#olRecurringEvents').addClass('hidden');
|
|
},
|
|
|
|
showRecurring: function (shouldCopyDatesAndTimes) {
|
|
$('#olNonRecurringEvents').addClass('hidden');
|
|
$('#olRecurringEvents').removeClass('hidden');
|
|
$('#divAllDay').addClass('hidden');
|
|
|
|
var isFirstLoad = function () {
|
|
return $('#liDailyOptions').hasClass('hidden')
|
|
&& $('#liWeeklyOptions').hasClass('hidden')
|
|
&& $('#liMonthlyOptions').hasClass('hidden');
|
|
};
|
|
|
|
if (isFirstLoad()) {
|
|
$('#liDailyOptions').removeClass('hidden');
|
|
attrOrProps($('#dailyOptionsNum'), "checked", "checked");
|
|
attrOrProps($('#endOptionsDate'), "checked", "checked");
|
|
}
|
|
|
|
if (self.IsAllDayEventChecked()) {
|
|
$('#recurringStartTime').attr('disabled', 'disabled');
|
|
$('#recurringEndTime').attr('disabled', 'disabled');
|
|
}
|
|
|
|
if (shouldCopyDatesAndTimes) {
|
|
RecurCommon.copyDatesAndTimesToRecurring();
|
|
}
|
|
},
|
|
|
|
resetRecurring: function () {
|
|
// Daily
|
|
$('#dailyIntervalSize').val('1');
|
|
attrOrProps($('#dailyOptionsNum'), "checked", "checked");
|
|
|
|
// Weekly
|
|
$('#weeklyIntervalSize').val(1);
|
|
$('#recurringMonday').removeAttr('checked');
|
|
$('#recurringTuesday').removeAttr('checked');
|
|
$('#recurringWednesday').removeAttr('checked');
|
|
$('#recurringThursday').removeAttr('checked');
|
|
$('#recurringFriday').removeAttr('checked');
|
|
$('#recurringSaturday').removeAttr('checked');
|
|
$('#recurringSunday').removeAttr('checked');
|
|
|
|
// Monthly
|
|
$('#monthlyDayOfMonth').val('1');
|
|
$('#monthlyIntervalSize').val('1');
|
|
$('#monthlyWeekType').val('1');
|
|
$('#monthlyDayOfWeek').val('2'); // 2 = Monday
|
|
$('#monthlyIntervalSize2').val('1');
|
|
$('#monthlyOptionsNum')
|
|
attrOrProps($('#monthlyOptionsNum'), "checked", "checked");
|
|
|
|
$('#endCount').val('')
|
|
attrOrProps($('#endOptionsDate'), "checked", "checked");
|
|
|
|
$('#liDailyOptions').addClass('hidden');
|
|
$('#liWeeklyOptions').addClass('hidden');
|
|
$('#liMonthlyOptions').addClass('hidden');
|
|
attrOrProps($('#recurrenceTypeDaily'), "checked", "checked");
|
|
},
|
|
|
|
getRecurStartDate: function (keepDayBeforeMonth) {
|
|
if (keepDayBeforeMonth == null) {
|
|
keepDayBeforeMonth = false;
|
|
}
|
|
return getDateFromInput('#recurringStartDate', keepDayBeforeMonth);
|
|
},
|
|
|
|
getRecurEndDate: function (keepDayBeforeMonth) {
|
|
if (keepDayBeforeMonth == null) {
|
|
keepDayBeforeMonth = false;
|
|
}
|
|
return getDateFromInput('#recurringEndDate', keepDayBeforeMonth);
|
|
}
|
|
|
|
};
|
|
|
|
// This class is used to generate a set of parameters for recurring events, which can then be passed
|
|
// to the controller used to create the reservation form.
|
|
var GetRecurringRequestParameters = (function () {
|
|
|
|
function GetRecurringRequestParameters() {
|
|
}
|
|
|
|
// Generates an object that contains all the parameters necessary to create a recurring
|
|
// event. This is the public entry point for this class.
|
|
GetRecurringRequestParameters.prototype.setParameters = function (params) {
|
|
var recurrenceType = this._getRecurrenceType();
|
|
params.recurrenceTypeID = recurrenceType;
|
|
|
|
this._setCommonParameters(params);
|
|
switch (recurrenceType) {
|
|
case RecurrenceType.Daily:
|
|
this._setDailyParameters(params);
|
|
break;
|
|
case RecurrenceType.Weekly:
|
|
this._setWeeklyParameters(params);
|
|
break;
|
|
case RecurrenceType.Monthly:
|
|
this._setMonthlyParameters(params);
|
|
break;
|
|
}
|
|
};
|
|
|
|
// Returns the type of recurrence selected by the user.
|
|
GetRecurringRequestParameters.prototype._getRecurrenceType = function () {
|
|
return RecurCommon.getRecurrenceType();
|
|
};
|
|
|
|
// Populates the `params` argument with parameters common to all recurrence
|
|
// pattern types (e.g. Daily, Weekly, and Monthly)
|
|
GetRecurringRequestParameters.prototype._setCommonParameters = function (params) {
|
|
params.startTm = $('#recurringStartTime').val();
|
|
params.endTm = $('#recurringEndTime').val();
|
|
|
|
if ($('#endOptionsNumber').is(':checked')) {
|
|
var endDateCalculator = new EndDateCalculator();
|
|
params.endDt = endDateCalculator.calculateEndDate();
|
|
params.endAfterNumOccurrences = $('#endCount').val();
|
|
} else {
|
|
params.endAfterNumOccurrences = 0;
|
|
params.endDt = RecurCommon.getRecurEndDate(false);
|
|
}
|
|
|
|
params.startDt = RecurCommon.getRecurStartDate(false);
|
|
};
|
|
|
|
// Populates `params` with the parameters specific to a daily recurrence
|
|
// pattern.
|
|
GetRecurringRequestParameters.prototype._setDailyParameters = function (params) {
|
|
if ($('#dailyOptionsNum').is(':checked')) {
|
|
params.dailyRecurCount = $('#dailyIntervalSize').val();
|
|
params.dailyIsEveryDay = false;
|
|
} else {
|
|
params.dailyRecurCount = 0;
|
|
params.dailyIsEveryDay = true;
|
|
}
|
|
|
|
};
|
|
|
|
// Populates `params` with the parameters specific to a weekly recurrence
|
|
// pattern.
|
|
GetRecurringRequestParameters.prototype._setWeeklyParameters = function (params) {
|
|
this._setDaysChecked(params);
|
|
params.weeklyRecurCount = $('#weeklyIntervalSize').val();
|
|
};
|
|
|
|
// Populates `params` with the parameters specific to a monthly recurrence
|
|
// pattern.
|
|
GetRecurringRequestParameters.prototype._setMonthlyParameters = function (params) {
|
|
if ($('#monthlyOptionsNum').is(':checked')) {
|
|
params.monthlyDay = $('#monthlyDayOfMonth').val();
|
|
params.monthlyEveryNumMonths = $('#monthlyIntervalSize').val();
|
|
} else {
|
|
params.recurrenceWeeklyTypeID = $('#monthlyWeekType').val();
|
|
params.daysChecked = $('#monthlyDayOfWeek').val();
|
|
params.monthlyEveryNumMonths = $('#monthlyIntervalSize2').val();
|
|
}
|
|
};
|
|
|
|
// Populates `params` with all the days the user has checked. This function
|
|
// is only used for Monthly and Weekly recurrence patterns.
|
|
GetRecurringRequestParameters.prototype._setDaysChecked = function (params) {
|
|
params.daysChecked = RecurCommon.daysCheckedFlag();
|
|
};
|
|
|
|
return GetRecurringRequestParameters;
|
|
}());
|
|
|
|
// Determins the end date for recurring events, based on the user's input.
|
|
var EndDateCalculator = (function (keepDateFormat) {
|
|
function EndDateCalculator() {
|
|
};
|
|
|
|
EndDateCalculator.prototype.calculateEndDate = function (keepDayBeforeMonth) {
|
|
if ($('#endOptionsDate').is(':checked')) {
|
|
return RecurCommon.getRecurEndDate(false);
|
|
}
|
|
|
|
var objEndDate = null;
|
|
var strStartDate = RecurCommon.getRecurStartDate(false);
|
|
|
|
if ($('#recurrenceTypeDaily').is(':checked')) {
|
|
objEndDate = this._getDailyEndDate(strStartDate);
|
|
} else if ($('#recurrenceTypeWeekly').is(':checked')) {
|
|
objEndDate = this._getWeeklyEndDate(strStartDate);
|
|
} else {
|
|
objEndDate = this._getMonthlyEndDate(strStartDate);
|
|
}
|
|
|
|
var endDate;
|
|
|
|
if (!keepDayBeforeMonth || getDateFormat().toLowerCase() == 'mm/dd/yyyy') {
|
|
endDate = (objEndDate.getMonth() + 1) + '/' + objEndDate.getDate() + '/' + objEndDate.getFullYear();
|
|
} else {
|
|
endDate = objEndDate.getDate() + '/' + (objEndDate.getMonth() + 1) + '/' + objEndDate.getFullYear();
|
|
}
|
|
return endDate;
|
|
}
|
|
|
|
EndDateCalculator.prototype._getDailyEndDate = function (strStartDate) {
|
|
var objStartDate = new Date(strStartDate);
|
|
var objEndDate = new Date(strStartDate);
|
|
|
|
// Get the number of days between each event.
|
|
var daysBetweenEvent = 1;
|
|
if ($('#dailyOptionsNum').is(':checked')) {
|
|
daysBetweenEvent = $('#dailyIntervalSize').val();
|
|
}
|
|
objEndDate.setDate(objStartDate.getDate() + (daysBetweenEvent * this._getNumOfOccurrences()));
|
|
return objEndDate;
|
|
};
|
|
|
|
EndDateCalculator.prototype._getWeeklyEndDate = function (strStartDate) {
|
|
var objStartDate = new Date(strStartDate);
|
|
var objEndDate = new Date(strStartDate);
|
|
|
|
// Get the number of days between each event.
|
|
var weeksBetween = $('#weeklyIntervalSize').val();
|
|
var daysBetween = weeksBetween * 7;
|
|
|
|
objEndDate.setDate(objStartDate.getDate() + (daysBetween * this._getNumOfOccurrences()));
|
|
return objEndDate;
|
|
};
|
|
|
|
EndDateCalculator.prototype._getMonthlyEndDate = function (strStartDate) {
|
|
var objStartDate = new Date(strStartDate);
|
|
var objEndDate = new Date(strStartDate);
|
|
|
|
// Get the number of months between each event.
|
|
var monthsBetween = $('#monthlyIntervalSize').val();
|
|
|
|
objEndDate.setMonth(objStartDate.getMonth() + (monthsBetween * this._getNumOfOccurrences()));
|
|
return objEndDate;
|
|
};
|
|
|
|
EndDateCalculator.prototype._getNumOfOccurrences = function () {
|
|
return $('#endCount').val();
|
|
};
|
|
|
|
|
|
return EndDateCalculator;
|
|
}());
|
|
|
|
var RecurringReservationValidator = (function () {
|
|
|
|
function RecurringReservationValidator() {
|
|
};
|
|
|
|
RecurringReservationValidator.prototype.isInputValid = function () {
|
|
var recurrenceType = RecurCommon.getRecurrenceType();
|
|
|
|
// The number of occurrences must be valid for all recurrence pattern types.
|
|
if (!this._validateNumberOfOccurrences()) {
|
|
return false;
|
|
}
|
|
|
|
if (recurrenceType == RecurrenceType.Daily) {
|
|
return this._validateDaily();
|
|
} else if (recurrenceType == RecurrenceType.Weekly) {
|
|
return this._validateWeekly();
|
|
} else if (recurrenceType == RecurrenceType.Monthly) {
|
|
return this._validateMonthly();
|
|
} else {
|
|
return true;
|
|
}
|
|
};
|
|
|
|
RecurringReservationValidator.prototype._validateNumericRange = function (value, min, max) {
|
|
var intRegex = /^\d+$/;
|
|
if (!intRegex.test(value)) {
|
|
return false;
|
|
}
|
|
var valueAsNum = parseInt(value);
|
|
if (isNaN(valueAsNum)) {
|
|
return false;
|
|
}
|
|
if (min) {
|
|
if (valueAsNum < min) { return false; }
|
|
}
|
|
|
|
if (max) {
|
|
if (valueAsNum > max) { return false; }
|
|
}
|
|
return true;
|
|
};
|
|
|
|
RecurringReservationValidator.prototype._validateDaily = function () {
|
|
if ($('#dailyOptionsNum').is(':checked')) {
|
|
var val = $('#dailyIntervalSize').val();
|
|
if (!this._validateNumericRange(val, 1, null)) {
|
|
alert(FacilityNewReservationModal_l10n.NumberOfDaysMustBeAtLeast1);
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
|
|
RecurringReservationValidator.prototype._validateWeekly = function () {
|
|
if (!this._isDayChecked()) {
|
|
alert(FacilityNewReservationModal_l10n.YouMustSelectAtLeastOneDay);
|
|
return false;
|
|
}
|
|
|
|
var val = $('#weeklyIntervalSize').val();
|
|
if (!this._validateNumericRange(val, 1, null)) {
|
|
alert(FacilityNewReservationModal_l10n.NumberOfWeeksMustBeAtLeast1);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
RecurringReservationValidator.prototype._validateMonthly = function () {
|
|
|
|
if ($('#monthlyOptionsNum').is(':checked')) {
|
|
|
|
// Validate #monthlyDayOfMonth is between 1 and 31 if #monthlyOptionsNum is checked
|
|
var dayOfMonth = $('#monthlyDayOfMonth').val();
|
|
if (!this._validateNumericRange(dayOfMonth, 1, 31)) {
|
|
alert(FacilityNewReservationModal_l10n.DayOfMonthBetween1And31);
|
|
return false;
|
|
}
|
|
|
|
// Validate #monthlyIntervalSize is >= 1 if #monthlyOptionsNum is checked
|
|
var val = $('#monthlyIntervalSize').val();
|
|
if (!this._validateNumericRange(val, 1, null)) {
|
|
alert(FacilityNewReservationModal_l10n.NumberOfMonthsBetweenMustBeGreaterThan1);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Validate #monthlyIntervalSize2 is >= 1 if #monthlyOptionsDay is checked
|
|
if ($('#monthlyOptionsDay').is(':checked')) {
|
|
var val = $('#monthlyIntervalSize2').val();
|
|
if (!this._validateNumericRange(val, 1, null)) {
|
|
alert(FacilityNewReservationModal_l10n.NumberOfMonthsBetweenMustBeGreaterThan1);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
RecurringReservationValidator.prototype._validateNumberOfOccurrences = function () {
|
|
// Validate #endCount >= 1 if #endOptionsNumber is checked
|
|
if ($('#endOptionsNumber').is(':checked')) {
|
|
var val = $('#endCount').val();
|
|
if (!this._validateNumericRange(val, 1, null)) {
|
|
alert(FacilityNewReservationModal_l10n.NumberOfOccurrencesAtLeast1);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
RecurringReservationValidator.prototype._isDayChecked = function () {
|
|
return (
|
|
$('#recurringSunday').is(':checked')
|
|
|| $('#recurringMonday').is(':checked')
|
|
|| $('#recurringTuesday').is(':checked')
|
|
|| $('#recurringWednesday').is(':checked')
|
|
|| $('#recurringThursday').is(':checked')
|
|
|| $('#recurringFriday').is(':checked')
|
|
|| $('#recurringSaturday').is(':checked'));
|
|
};
|
|
|
|
|
|
|
|
return RecurringReservationValidator;
|
|
}());
|
|
|
|
var LoadFromExistingReservation = (function () {
|
|
|
|
// Initialized so we have intellisense
|
|
this.reservation = {
|
|
RecurrenceID: 0,
|
|
StartDate: '',
|
|
EndDate: '',
|
|
StartTime: '',
|
|
EndTime: '',
|
|
DailyRecurCount: 0,
|
|
DailyIsEveryDay: false,
|
|
WeeklyRecurCount: 0,
|
|
IsSunday: false,
|
|
IsMonday: false,
|
|
IsTuesday: false,
|
|
IsWednesday: false,
|
|
IsThursday: false,
|
|
IsFriday: false,
|
|
IsSaturday: false,
|
|
MonthlyDay: false,
|
|
MonthlyEveryNumMonth: false,
|
|
RecurrenceWeeklyTypeID: 0,
|
|
EndAfterNumOccurrences: 0
|
|
};
|
|
|
|
var gCopyTimes = false;
|
|
|
|
function LoadFromExistingReservation() {
|
|
};
|
|
|
|
LoadFromExistingReservation.prototype.execute = function (json, copyTimes) {
|
|
this.reservation = JSON.parse(json);
|
|
gCopyTimes = copyTimes == null ? false : copyTimes;
|
|
switch (this.reservation.RecurrenceTypeID) {
|
|
case RecurrenceType.Daily:
|
|
this._loadCommon();
|
|
this._loadDaily();
|
|
RecurCommon.showDaily();
|
|
$('#recurringTypeDaily').click();
|
|
break;
|
|
case RecurrenceType.Weekly:
|
|
this._loadCommon();
|
|
this._loadWeekly();
|
|
RecurCommon.showWeekly();
|
|
$('#recurringTypeWeekly').click();
|
|
break;
|
|
case RecurrenceType.Monthly:
|
|
this._loadCommon();
|
|
this._loadMonthly();
|
|
RecurCommon.showMonthly();
|
|
$('#recurringTypeMonthly').click();
|
|
break;
|
|
}
|
|
|
|
$('#notRecurringRadio').attr('disabled', 'disabled');
|
|
attrOrProps($('#recurringRadio', 'checked', 'checked'));
|
|
RecurCommon.showRecurring(false);
|
|
};
|
|
|
|
LoadFromExistingReservation.prototype._loadDaily = function () {
|
|
attrOrProps($('#recurrenceTypeDaily'), 'checked', 'checked');
|
|
if (this.reservation.DailyIsEveryDay) {
|
|
attrOrProps($('#dailyOptionsErrday'), 'checked', 'checked');
|
|
} else {
|
|
attrOrProps($('#dailyOptionsNum'), 'checked', 'checked');
|
|
$('#dailyIntervalSize').val(this.reservation.DailyRecurCount);
|
|
}
|
|
};
|
|
|
|
function formatTime(objDateTime) {
|
|
var hour = objDateTime.getHours();
|
|
var min = objDateTime.getMinutes();
|
|
var ampm = '';
|
|
if (hour < 12) {
|
|
ampm = 'AM';
|
|
} else if (hour == 12) {
|
|
ampm = 'PM';
|
|
} else {
|
|
hour = hour - 12;
|
|
ampm = 'PM';
|
|
}
|
|
|
|
var minStr = '';
|
|
if (min < 10) {
|
|
minStr = '0' + min;
|
|
} else {
|
|
minStr = min;
|
|
}
|
|
|
|
return hour + ':' + minStr + ' ' + ampm;
|
|
|
|
}
|
|
|
|
function formatDate(objDateTime) {
|
|
if (objDateTime.valueOf() < 0) {
|
|
return '';
|
|
}
|
|
return objDateTime.format(getDateFormat());
|
|
}
|
|
|
|
LoadFromExistingReservation.prototype._loadCommon = function () {
|
|
var objStartDate = this._evalDate(this.reservation.StartDate);
|
|
var objEndDate = this._evalDate(this.reservation.EndDate);
|
|
|
|
if (gCopyTimes) {
|
|
RecurCommon.copyDatesAndTimesToRecurring(true);
|
|
} else {
|
|
var objStartTime = this._evalDate(this.reservation.StartTime);
|
|
var objEndTime = this._evalDate(this.reservation.EndTime);
|
|
$('#recurringStartTime').val(formatTime(objStartTime));
|
|
$('#recurringEndTime').val(formatTime(objEndTime));
|
|
}
|
|
|
|
$('#recurringStartDate').val(formatDate(objStartDate));
|
|
|
|
if (this.reservation.EndAfterNumOccurrences == 0) {
|
|
attrOrProps($('#endOptionsDate', 'checked', 'checked'));
|
|
$('#recurringEndDate').val(formatDate(objEndDate));
|
|
// $('#recurringEndDate').data('tDatePicker').value(objEndDate);
|
|
$('#endCount').val('');
|
|
} else {
|
|
// $('#recurringEndDate').data('tDatePicker').value('');
|
|
$('#recurringEndDate').val(formatDate(objEndDate));
|
|
attrOrProps($('#endOptionsNumber', 'checked', 'checked'));
|
|
$('#endCount').val(this.reservation.EndAfterNumOccurrences);
|
|
}
|
|
};
|
|
|
|
LoadFromExistingReservation.prototype._loadWeekly = function () {
|
|
attrOrProps($('#recurrenceTypeWeekly', 'checked', 'checked'));
|
|
this._setDaysChecked();
|
|
};
|
|
|
|
LoadFromExistingReservation.prototype._loadMonthly = function () {
|
|
attrOrProps($('#recurrenceTypeMonthly', 'checked', 'checked'));
|
|
$('#monthlyWeekType').val(this.reservation.RecurrenceWeeklyTypeID);
|
|
|
|
if (this.reservation.MonthlyDay == 0) {
|
|
attrOrProps($('#monthlyOptionsDay', 'checked', 'checked'));
|
|
$('#monthlyIntervalSize2').val(this.reservation.MonthlyEveryNumMonths);
|
|
} else {
|
|
attrOrProps($('#monthlyOptionsNum', 'checked', 'checked'));
|
|
$('#monthlyDayOfMonth').val(this.reservation.MonthlyDay);
|
|
$('#monthlyIntervalSize').val(this.reservation.MonthlyEveryNumMonths);
|
|
}
|
|
|
|
var $monthlyDayOfWeek = $('#monthlyDayOfWeek');
|
|
if (this.reservation.isSunday) {
|
|
$monthlyDayOfWeek.val(1);
|
|
} else if (this.reservation.IsMonday) {
|
|
$monthlyDayOfWeek.val(2);
|
|
} else if (this.reservation.IsTuesday) {
|
|
$monthlyDayOfWeek.val(4);
|
|
} else if (this.reservation.IsWednesday) {
|
|
$monthlyDayOfWeek.val(8);
|
|
} else if (this.reservation.IsThursday) {
|
|
$monthlyDayOfWeek.val(16);
|
|
} else if (this.reservation.IsFriday) {
|
|
$monthlyDayOfWeek.val(32);
|
|
} else if (this.reservation.IsSaturday) {
|
|
$monthlyDayOfWeek.val(64);
|
|
}
|
|
};
|
|
|
|
LoadFromExistingReservation.prototype._evalDate = function (strDate) {
|
|
var dateAsInt = eval(strDate.substr(6, 13));
|
|
return new Date(dateAsInt);
|
|
};
|
|
|
|
LoadFromExistingReservation.prototype._formatDate = function (objDate) {
|
|
};
|
|
|
|
LoadFromExistingReservation.prototype._setDaysChecked = function () {
|
|
|
|
$('#recurringSunday').removeAttr('checked');
|
|
$('#recurringMonday').removeAttr('checked');
|
|
$('#recurringTuesday').removeAttr('checked');
|
|
$('#recurringWednesday').removeAttr('checked');
|
|
$('#recurringThursday').removeAttr('checked');
|
|
$('#recurringFriday').removeAttr('checked');
|
|
$('#recurringSaturday').removeAttr('checked');
|
|
|
|
if (this.reservation.IsSunday) { attrOrProps($('#recurringSunday', 'checked', 'checked')); }
|
|
if (this.reservation.IsMonday) { attrOrProps($('#recurringMonday', 'checked', 'checked'));}
|
|
if (this.reservation.IsTuesday) { attrOrProps($('#recurringTuesday', 'checked', 'checked'));}
|
|
if (this.reservation.IsWednesday) { attrOrProps($('#recurringWednesday', 'checked', 'checked')); }
|
|
if (this.reservation.IsThursday) { attrOrProps($('#recurringThursday', 'checked', 'checked')); }
|
|
if (this.reservation.IsFriday) { attrOrProps($('#recurringFriday', 'checked', 'checked')); }
|
|
if (this.reservation.IsSaturday) { attrOrProps($('#recurringSaturday', 'checked', 'checked')); }
|
|
};
|
|
|
|
return LoadFromExistingReservation;
|
|
|
|
}());
|