Hi,
I have a “Select Start Date” input box where a user can select a date and it brings 2 weeks of data starting from that date. As soon as a user selects the date I am calling a function(LoadTopScheduler(Records)) where I am creating my AssessorsArray for (y_unit: AssessorsArray), Json events array(SlotsArray) and I am attaching events for my scheduler.
I have a following problems:
When I load my page teh first time and create a new event or modify an old event, “onEventSave” fires 1 time but when I change the date from “Select Start Date” input box and create a new event or modify an old event “onEventSave” fires multiple times (more than once) and I also get scheduler.myCalendar.unload is not a function error message.
function LoadTopScheduler(Records)
{
try
{
var Slots = [];
var AssessorsArray = $.extend(true, [], gAssessorsArray);
if(gCurrentLoggedInUserInfoArray[0].RoleList.indexOf('9875') > 0 || gCurrentLoggedInUserInfoArray[0].RoleList.indexOf('9970') > 0)
{
if (($('#AssessorDropDown option:selected').text() != "All"))
{
AssessorsArray = [];
for (var i = 0; i < gAssessorsArray.length; i++)
{
if(gAssessorsArray[i].key == $('#AssessorDropDown option:selected').val())
AssessorsArray.push(gAssessorsArray[i]);
}
}
}
if(Records.recordcount > 0)
{
for (var j = 1; j <= Records.recordcount; j++)
{
var SetText = '';
if(Records.getfieldbyname(j, "statusname") == 'Available')
{
var CurrentAvailableTimesArray = Records.getfieldbyname(j, "cf_1271497").split(";");
for(var i = 0; i < CurrentAvailableTimesArray.length; i++)
{
SetText += CurrentAvailableTimesArray[i] + ";";
}
SetText = 'Available;' + SetText;
SetText = SetText.replace(/;/g, '
');
}
else
{
SetText = 'Unavailable';
}
Slots[j-1] = new Object();
Slots[j-1].start_date = Records.getfieldbyname(j, "startdate").substring(0,10) + " 00:00:00";
Slots[j-1].end_date = Records.getfieldbyname(j, "enddate").substring(0,10) + " 24:00:00";
Slots[j-1].text = SetText;
Slots[j-1].Type = Records.getfieldbyname(j, "type");
Slots[j-1].Status = Records.getfieldbyname(j, "statusname");
Slots[j-1].StartDate = Records.getfieldbyname(j, "startdate").substring(0,10);
Slots[j-1].EndDate = Records.getfieldbyname(j, "enddate").substring(0,10);
Slots[j-1].UserID = Records.getfieldbyname(j, "cf_1271476");
Slots[j-1].Reason = Records.getfieldbyname(j, "cf_1271496");
Slots[j-1].ReserveType = Records.getfieldbyname(j, "cf_1271478");
Slots[j-1].ReservedFor = Records.getfieldbyname(j, "cf_1271479");
Slots[j-1].LocationType = Records.getfieldbyname(j, "cf_1271481");
Slots[j-1].AssociationCompanyID = Records.getfieldbyname(j, "cf_1271520");
Slots[j-1].AssociationCompanyName = Records.getfieldbyname(j, "cf_1271525");
Slots[j-1].AssessorNotes = Records.getfieldbyname(j, "cf_1271492");
Slots[j-1].BookingNotes = Records.getfieldbyname(j, "cf_1271517");
Slots[j-1].AvailableTimes = Records.getfieldbyname(j, "cf_1271497");
Slots[j-1].CoordinationTimes = Records.getfieldbyname(j, "cf_1271498");
Slots[j-1].EventID = Records.getfieldbyname(j, "eventid");
}
}
var JsonSlotsArray = $.toJSON(Slots);
scheduler.clearAll();
scheduler.locale.labels.section_Assessor = "Scheduler"; // This is a section in a lightbox
scheduler.config.details_on_create = true;
scheduler.config.details_on_dblclick = true;
scheduler.config.drag_move = false;
scheduler.config.show_loading = true;
scheduler.config.xml_date = "%Y-%m-%d %H:%i";
scheduler.config.start_on_monday = true;
scheduler.config.full_day = true;
scheduler.createTimelineView({
name: "TopTimeline",
x_unit: "day",
x_date: "%D, %d %M %Y ",
x_step: 1,
x_size: 14,
y_unit: AssessorsArray,
y_property:"UserID",
render:"bar"
});
scheduler.form_blocks["my_editor"]={
render:function(sns){
return "<div class='dhx_cal_ltext' style='height:650px;'> <table width='550px' cellspacing='3'> <tbody> <tr> <td class='LightBoxHeadingCell'> Location : </td> <td class='LightBoxNormalCell'> <select name='LocationDropDown' id='LocationDropDown' onchange='LocationDropDownOnChange();' style='width:150px;'> <option selected = '' value='Evaluators Office'>Evaluators Office</option> <option value='Clinic'>Clinic</option> </select> </td> <td class='LightBoxHeadingCell'> Status : </td> <td class='LightBoxNormalCell'> <select style='width:150px' name='StatusDropDown' id='StatusDropDown' disabled=disabled> <option value='25233' selected = '' >Available</option> <option value='25236'>UnAvailable</option> </select> </td> </tr> <tr id='ReasonRow' style='display:none;'> <td class='LightBoxHeadingCell'> Reason : </td> <td> <select style='width:150px' name='ReasonDropDown' id='ReasonDropDown'> <option selected = '' value=''></option> <option value='Personal Leave'>Personal Leave</option> <option value='Sick'>Sick</option> <option value='Stat Holiday'>Stat Holiday</option> <option value='Sick'>Sick</option> <option value='Training'>Training</option> <option value='Vacation'>Vacation</option> </select> </td> <td class='LightBoxHeadingCell'> </td> <td class='LightBoxHeadingCell'> </td> </tr> <tr id='ReserveRow'> <td class='LightBoxHeadingCell'> Reserve Type : </td> <td> <select style='width:150px' id='ReserveTypeDropDown' name='ReserveTypeDropDown'> <option selected = '' value=''></option> <option value='Regular'>Regular</option> <option value='All Call'>All Call</option> </select> </td> <td class='LightBoxHeadingCell'> Reserved For : </td> <td> <select style='width:150px' id='ReservedForDropDown' name='ReservedForDropDown'> <option selected = '' value=''></option> <option value='Any'>Any</option> <option value='CAT Only'>CAT Only</option> <option value='In-Person Only'>In-Person Only</option> </select> </td> </tr> <tr id='DatesRow'> <td class='LightBoxHeadingCell' id='StartDateHeadingTD'> Start Date : </td> <td id='StartDateCalendarTD'> <input type='text' id='StartDateCalendar'> </td> <td class='LightBoxHeadingCell' id='EndDateHeadingTD' style='display:none;'> End Date : </td> <td id='EndDateCalendarTD' style='display:none;'> <input type='text' id='EndDateCalendar'> </td> </tr> <tr id='AvailableTimesRow'> <td colspan='4'> <table width='500px' cellspacing='1' style='margin-top: 5px;border: 1px solid black;' id='AvailableTimesTable'> <tbody> <tr> <td colspan='2' class='LightBoxHeadingCell'> Available Times : </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='08:00 AM - 09:00 AM;'>08:00 AM - 09:00 AM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='08:30 AM - 09:30 AM;'>08:30 AM - 09:30 AM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='09:00 AM - 10:00 AM;'>09:00 AM - 10:00 AM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='09:30 AM - 10:30 AM;'>09:30 AM - 10:30 AM </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='10:00 AM - 11:00 AM;'>10:00 AM - 11:00 AM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='10:30 AM - 11:30 AM;'>10:30 AM - 11:30 AM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='11:00 AM - 12:00 PM;'>11:00 AM - 12:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='11:30 AM - 12:30 PM;'>11:30 AM - 12:30 PM </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='12:00 PM - 01:00 PM;'>12:00 PM - 01:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='12:30 PM - 01:30 PM;'>12:30 PM - 01:30 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='01:00 PM - 02:00 PM;'>01:00 PM - 02:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='01:30 PM - 02:30 PM;'>01:30 PM - 02:30 PM </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='02:00 PM - 03:00 PM;'>02:00 PM - 03:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='02:30 PM - 03:30 PM;'>02:30 PM - 03:30 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='03:00 PM - 04:00 PM;'>03:00 PM - 04:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='03:30 PM - 04:30 PM;'>03:30 PM - 04:30 PM </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='04:00 PM - 05:00 PM;'>04:00 PM - 05:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='04:30 PM - 05:30 PM;'>04:30 PM - 05:30 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='05:00 PM - 06:00 PM;'>05:00 PM - 06:00 PM </td> <td class='AvailableTimes'> </td> <td class='AvailableTimes'> </td> <td class='AvailableTimes'> </td> </tr> </tbody> </table> </td> </tr> <tr id='AssessorNotesRow'> <td valign='top' class='LightBoxHeadingCell'> Assessor Notes : </td> <td colspan='3'> <textarea name='AssessorNotes' style='border: solid 1px #CCC;width:390px;height:50px;' id='AssessorNotes'> </textarea> </td> </tr> <tr id='AssessmentsDivRow' style='display:none;'> <td colspan='4' class='LightBoxHeadingCell'> <span style='font-size:10px;'>Assessments :</span> <div id='AssessmentsGrid' style='margin-top:5px;width:500px;'> </div> </td> </tr> <tr id='BookingNotesRow'> <td valign='top' class='LightBoxHeadingCell'> Booking Notes : </td> <td td colspan='3'> <textarea name='BookingNotes' style='border: solid 1px #CCC;width:390px;height:50px;' id='BookingNotes'> </textarea> </td> </tr> </tbody> </table> </div>";
},
set_value:function(node,value,ev){
$('#StartDateCalendar').val(ev.StartDate || "");
$('#EndDateCalendar').val(ev.EndDate || "");
$("#ReasonDropDown").val(ev.Reason || "");
$("#ReserveTypeDropDown").val(ev.ReserveType || "");
$("#ReservedForDropDown").val(ev.ReservedFor || "");
$('#AssessorNotes').val(ev.AssessorNotes || "");
$('#BookingNotes').val(ev.BookingNotes || "");
$('#AvailableTimesTable input:checkbox').attr('checked','');
if(ev.AvailableTimes)
{
var CurrentArray = ev.AvailableTimes.split(";");
for(var i = 0; i < CurrentArray.length; i++)
{
$('#AvailableTimesTable input[type=checkbox]').each(function () {
if ($(this).val() == (CurrentArray[i] + ";"))
this.checked = "true";
});
}
}
},
get_value:function(node,ev){
ev.LocationType = $("#LocationDropDown").val();
ev.Reason = $("#ReasonDropDown").val();
ev.ReserveType = $("#ReserveTypeDropDown").val();
ev.ReservedFor = $("#ReservedForDropDown").val();
ev.StartDate = $('#StartDateCalendar').val();
ev.EndDate = $('#EndDateCalendar').val();
ev.AssessorNotes = $('#AssessorNotes').val();
ev.BookingNotes = $('#BookingNotes').val();
},
focus:function(node){
node.getElementsByTagName("select")[0].focus();
}
}
//===============
//Data loading
//===============
scheduler.config.lightbox.sections = [{name:"Assessor", height:130, map_to:"text", type:"my_editor"}]
scheduler.templates.lightbox_header = function(start,end,ev){
return ev.Status ;
};
scheduler.templates.tooltip_date_format = scheduler.date.date_to_str("%Y-%m-%d %h:%i %A");
scheduler.templates.tooltip_text = function(start, end, event) {
if(event.LocationType == 'Clinic')
return "<b>Location:</b> <span style='font-weight:bold;color:black;'>" + event.LocationType + "</span><br/><b>Status:</b> <span style='font-weight:bold;color:black;'>" + event.Status + "</span><br/><b>Available Times:</b> <span style='font-weight:bold;color:black;'>N/A" + "</span><br/><b>Assessor Notes:</b> <span style='font-weight:bold;color:black;'>" + event.AssessorNotes + "</span> <br/>";
else
{
if(event.LocationType == 'Evaluators Office')
return "<b>Location:</b> <span style='font-weight:bold;color:black;'>" + event.LocationType + "</span><br/><b>Status:</b> <span style='font-weight:bold;color:black;'>" + event.Status + "</span><br/><b>Available Times:</b> <br/><span style='font-weight:bold;color:black;'>" + event.AvailableTimes.replace(/;/g, '<br/>') + "</span><br/><b>Assessor Notes:</b> <span style='font-weight:bold;color:black;'>" + event.AssessorNotes + "</span> <br/>";
else
return "<b>Location:</b> <span style='font-weight:bold;color:black;'>" + event.AssociationCompanyName + "</span><br/><b>Status:</b> <span style='font-weight:bold;color:black;'>" + event.Status + "</span><br/><b>Available Times:</b> <br/><span style='font-weight:bold;color:black;'>" + event.AvailableTimes.replace(/;/g, '<br/>') + "</span><br/><b>Assessor Notes:</b> <span style='font-weight:bold;color:black;'>" + event.AssessorNotes + "</span> <br/>";
}
}
scheduler.attachEvent("onBeforeEventChanged", function(event_object, native_event, is_new, unmodified_event){
if (is_new)
{
var GetCurrentFromDate = event_object.start_date;
var GetCurrentToDate = scheduler.date.add(GetCurrentFromDate, 23, "hour");
GetCurrentToDate = scheduler.date.add(GetCurrentToDate, 59, "minute");
GetCurrentToDate.setSeconds(GetCurrentToDate.getSeconds() + 59);
var GetEvents = scheduler.getEvents(GetCurrentFromDate, GetCurrentToDate);
var GetCurrentAssesorEvents = 0;
for(var i = 0; i < GetEvents.length; i++)
{
if(GetEvents[i].UserID == event_object.UserID)
GetCurrentAssesorEvents++;
}
if(GetCurrentAssesorEvents > 1)
{
alert('There is Alreay An Event For ' + Date.parse(GetCurrentFromDate).toString('ddd, dd MMM yyyy'));
return false;
}
}
return true;
});
scheduler.attachEvent("onBeforeLightbox", function(event_id) { alert("onBeforeLightbox");
scheduler.config.buttons_right = (scheduler.getState().new_event) ? [] : ["dhx_delete_btn"];
scheduler.resetLightbox();
return true;
});
scheduler.attachEvent("onLightbox", function (event_id){ alert("onLightbox");
gCurrentEndDate = '', gCurrentAvailableTimes = '', gCurrentLocationType = '', gCurrentAssociationCompanyID = '', gCurrentAssociationCompanyName = '', gCurrentAssessorAddress = '', gCurrentAssessorCity = '', gCurrentAssessorProvince = '', gCurrentAssessorPostalCode = '', gCurrentUserUserID = '';
scheduler.myCalendar = new dhtmlXCalendarObject(['StartDateCalendar','EndDateCalendar']);
scheduler.myCalendar.hideTime();
var GetLightBoxAssessorID = scheduler.getEvent(event_id).UserID;
$("select[event_id='LocationDropDown'] > option:gt(1)").remove();
for(var i = 0; i < gAssessorCompanyAssociationssArray.length; i++)
{
if(scheduler.getEvent(event_id).UserID == gAssessorCompanyAssociationssArray[i].AssessorUserID && gAssessorCompanyAssociationssArray[i].Company != '')
$('#LocationDropDown').append(new Option(gAssessorCompanyAssociationssArray[i].Company, gAssessorCompanyAssociationssArray[i].CompanyID));
}
if(scheduler.getEvent(event_id).LocationType == 'Evaluators Office' || scheduler.getEvent(event_id).LocationType == 'Clinic')
{
$('#LocationDropDown option').each(function() {
if(scheduler.getEvent(event_id).LocationType == this.text){
$(this).attr("selected", "selected");
return true;
}});
}
else
{
for (var j = 0; j < gAssessorCompanyAssociationssArray.length; j++)
{
if(gAssessorCompanyAssociationssArray[j].CompanyID == scheduler.getEvent(event_id).AssociationCompanyID)
{
$('#LocationDropDown option').each(function() {
if(gAssessorCompanyAssociationssArray[j].Company == this.text){
$(this).attr("selected", "selected");
return true;
}});
}
}
}
AvailableTimesCheckboxesArray = document.getElementsByName("AvailableTimesCheckboxes");
for (var k = 0; k < AvailableTimesCheckboxesArray.length; ++k)
{
AvailableTimesCheckboxesArray[k].onclick = SelectAppropriateCheckBox;
}
$('#AssessmentsGrid').empty();
if(!scheduler.getState().new_event)
{
if(scheduler.getEvent(event_id).LocationType == 'Clinic')
{
$("#controls").css("height", "81px");
$('#StatusDropDown option').each(function() {
if("UnAvailable" == this.text){
$(this).attr("selected", "selected");
return true;
}});
$('#ReasonRow').show();
$('#ReserveTypeDropDown option:first-child').attr("selected", "selected");
$('#ReservedForDropDown option:first-child').attr("selected", "selected");
$('#ReserveRow').hide();
$('#StartDateHeadingTD').text("Start Date :")
$('#EndDateHeadingTD').show();
$('#EndDateCalendarTD').show();
$('#AvailableTimesRow').hide();
}
else
{
var AxsArray = [];
$('#StatusDropDown option').each(function() {
if("Available" == this.text){
$(this).attr("selected", "selected");
return true;
}});
var CurrentAxsGrid = new dhtmlXGridObject('AssessmentsGrid');
CurrentAxsGrid.setImagePath("https://www.lifemark.ca/contents/dhx/grid/imgs/"); //path to images required by grid
CurrentAxsGrid.setHeader("Ax Name,Claimant,Status,Coordination Times,Ax Address,Ax City,Ax Province,Ax Postal Code",null,["color:black;font-size:9px;vertical-align:top;font-weight:bold;", "color:black;font-size:9px;vertical-align:top;font-weight:bold;", "color:black;font-size:9px;vertical-align:top;font-weight:bold;", "color:black;font-size:9px;vertical-align:top;font-weight:bold;", "color:black;font-size:9px;vertical-align:top;font-weight:bold;", "color:black;font-size:9px;vertical-align:top;font-weight:bold;", "color:black;font-size:9px;vertical-align:top;font-weight:bold;", "color:black;font-size:9px;vertical-align:top;font-weight:bold;"]);
CurrentAxsGrid.setInitWidths("100,100,50,100,100,50,50,50");
CurrentAxsGrid.attachHeader("#select_filter,#select_filter,#select_filter, ,#text_filter,#select_filter,#select_filter,#text_filter");
CurrentAxsGrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro");
CurrentAxsGrid.setColSorting("str,str,str,str,str,str,str,str");
CurrentAxsGrid.enableMultiline(true);
CurrentAxsGrid.enableAutoHeight(true);
CurrentAxsGrid.enableResizing("false,false,false,false,false,false,false,false"); // resizing is enabled for all columns by default
CurrentAxsGrid.enableEditEvents("false,false,false,false,false,false,false,false");
CurrentAxsGrid.setSkin("dhx_skyblue");
CurrentAxsGrid.init();
var Level3RSet = level23_find(false,'',gAppID,3,'cf_1271506,cf_1271507,statusname,cf_1271510,cf_1271500,cf_1271501,cf_1271502,cf_1271503','objectid = ' + scheduler.getEvent(event_id).EventID, '', 0, 1000, '', '');
if(Level3RSet.recordcount > 0)
{
for (var l = 1; l <= Level3RSet.recordcount; l++)
{
AxsArray[l-1] = new Array();
AxsArray[l-1][0] = Level3RSet.getfieldbyname(l, "cf_1271506");
AxsArray[l-1][1] = Level3RSet.getfieldbyname(l, "cf_1271507");
AxsArray[l-1][2] = Level3RSet.getfieldbyname(l, "statusname");
AxsArray[l-1][3] = Level3RSet.getfieldbyname(l, "cf_1271510");
AxsArray[l-1][4] = Level3RSet.getfieldbyname(l, "cf_1271500");
AxsArray[l-1][5] = Level3RSet.getfieldbyname(l, "cf_1271501");
AxsArray[l-1][6] = Level3RSet.getfieldbyname(l, "cf_1271502");
AxsArray[l-1][7] = Level3RSet.getfieldbyname(l, "cf_1271503");
}
}
CurrentAxsGrid.parse(AxsArray, "jsarray");
$('#AssessmentsDivRow').show();
}
if(gCurrentLoggedInUserInfoArray[0].RoleList.indexOf('9875') > 0 || gCurrentLoggedInUserInfoArray[0].RoleList.indexOf('9970') > 0)
$('#BookingNotesRow').show();
else
$('#BookingNotesRow').hide();
}
else
{
$('#StartDateCalendar').val(Date.parse(scheduler.getEvent(event_id).start_date).toString('yyyy-MM-dd'));
$('#EndDateCalendar').val(Date.parse(scheduler.getEvent(event_id).start_date).toString('yyyy-MM-dd'));
}
});
scheduler.attachEvent("onAfterLightbox", function(){ //alert("onAfterLightbox");
scheduler.myCalendar.unload();
});
scheduler.attachEvent("onEventSave",function(id,data,is_new_event){ alert("onEventSave");
if($('#LocationDropDown option:selected').text() != 'Clinic')
{
if (($('#ReserveTypeDropDown option:selected').text() != ""))
{
if (($('#ReservedForDropDown option:selected').text() != ""))
{
if($('#StartDateCalendar').val() !='' )
{
if($('input:checkbox:checked').length > 0)
{
var GetSchedulerStartDate = scheduler.getEvent(id).start_date;
var GetCurrentFromDate = new Date(Date.parse($('#StartDateCalendar').val()));
var GetCurrentToDate = new Date(Date.parse($('#StartDateCalendar').val()));
GetCurrentToDate = scheduler.date.add(GetCurrentToDate, 23, "hour");
GetCurrentToDate = scheduler.date.add(GetCurrentToDate, 59, "minute");
GetCurrentToDate.setSeconds(GetCurrentToDate.getSeconds() + 59);
var GetEvents = scheduler.getEvents(GetCurrentFromDate, GetCurrentToDate);
var GetCurrentAssesorEvents = 0;
for(var i = 0; i < GetEvents.length; i++)
{
if(GetEvents[i].UserID == scheduler.getEvent(id).UserID)
GetCurrentAssesorEvents++;
}
if(Date.parse(GetSchedulerStartDate).compareTo(Date.parse($('#StartDateCalendar').val())) == 1)
{
if(GetCurrentAssesorEvents > 0)
{
alert('There is Alreay An Event For ' + Date.parse(GetCurrentFromDate).toString('ddd, dd MMM yyyy'));
return false;
}
}
else
{
if(GetCurrentAssesorEvents > 1)
{
alert('There is Alreay An Event For ' + Date.parse(GetCurrentFromDate).toString('ddd, dd MMM yyyy'));
return false;
}
}
return true;
}
else
alert('Please Check Available Times.');
}
else
alert('Please Enter Date.');
}
else
alert('Please Select Reserved For.');
}
else
alert('Please Select Reserve Type.');
}
else
{
if (($('#ReasonDropDown option:selected').text() != ""))
{
if($('#StartDateCalendar').val() !='' )
{
if($('#EndDateCalendar').val() !='' )
{ alert("bbbb");
var CurrentStartDateCalendar = $('#StartDateCalendar').val();
var CurrentEndDateCalendar = $('#EndDateCalendar').val();
if(Date.parse(CurrentEndDateCalendar).compareTo(Date.parse(CurrentStartDateCalendar)) > -1)
return true;
else
alert('End Date Should Be Equal To Or Greater Than Start Date.');
}
else
alert('Please Enter End Date.');
}
else
alert('Please Enter Start Date.');
}
else
alert('Please Select Reason.');
}
return false;
})
scheduler.attachEvent("onEventAdded", function(event_id, event_object) { alert("onEventAdded");
if (!event_id) return true;
gCurrentUserUserID = scheduler.getEvent(event_id).UserID;
if($('#LocationDropDown option:selected').text() != 'Clinic')
{
gCurrentEndDate = $('#StartDateCalendar').val();
$('#AvailableTimesTable input[type=checkbox]:checked').each(function (){
gCurrentAvailableTimes += $(this).val();
});
gCurrentAvailableTimes = gCurrentAvailableTimes.substring(0,gCurrentAvailableTimes.length-1);
if($('#LocationDropDown option:selected').text() == 'Evaluators Office')
{
gCurrentLocationType = $('#LocationDropDown option:selected').text();
contact_find(true,'SaveAvailability','userid,uaddress,uaddress2,ucity,ustate,Upostalcode','userid = ' + gCurrentUserUserID,'',0,1,'');
}
else
{
gCurrentLocationType = 'Association Company';
gCurrentAssociationCompanyID = $("#LocationDropDown").val();
gCurrentAssociationCompanyName = $('#LocationDropDown option:selected').text();
company_find(true,'SaveAvailability','address,address2,city,state,postalcode,companyid','companyid = ' + gCurrentAssociationCompanyID,'',0,1,'',''); }
}
else
{
gCurrentEndDate = $('#EndDateCalendar').val();
gCurrentLocationType = 'Clinic';
contact_find(true,'SaveAvailability','userid,uaddress,uaddress2,ucity,ustate,Upostalcode','userid =' + gCurrentUserUserID,'',0,1,'');
}
});
scheduler.init('Assessors_Scheduler',new Date(Date.parse($('#StartDate').val())),"TopTimeline");
scheduler.parse(JsonSlotsArray,"json");
}
catch (err)
{
alert(err.name + ": " + err.message); alert('LoadTopScheduler(Records)');
}
}